Safe Haskell | None |
---|---|
Language | Haskell2010 |
Conversions between haskell types/values and Michelson ones.
Synopsis
- class IsoCValue a where
- class IsoValue a where
- class GIsoValue (x :: Type -> Type) where
- type GValueType x :: T
- type family ToTs (ts :: [Type]) :: [T] where ...
- type family ToT' (t :: k) :: T where ...
- type family ToTs' (t :: [k]) :: [T] where ...
- type IsComparable c = ToT c ~ Tc (ToCT c)
- newtype ContractAddr (cp :: Type) = ContractAddr {}
- newtype BigMap k v = BigMap {}
Documentation
class IsoCValue a where Source #
Isomorphism between Michelson primitive values and plain Haskell types.
Type function that converts a regular Haskell type into a comparable type
(which has kind CT
).
toCVal :: a -> CValue (ToCT a) Source #
Converts a single Haskell value into CVal
representation.
fromCVal :: CValue (ToCT a) -> a Source #
Converts a CVal
value into a single Haskell value.
Instances
IsoCValue Bool Source # | |
IsoCValue Integer Source # | |
IsoCValue Natural Source # | |
IsoCValue ByteString Source # | |
Defined in Michelson.Typed.Haskell.Value type ToCT ByteString :: CT Source # toCVal :: ByteString -> CValue (ToCT ByteString) Source # fromCVal :: CValue (ToCT ByteString) -> ByteString Source # | |
(DoNotUseTextError :: Constraint) => IsoCValue Text Source # | |
IsoCValue MText Source # | |
IsoCValue Timestamp Source # | |
IsoCValue Mutez Source # | |
IsoCValue KeyHash Source # | |
IsoCValue Address Source # | |
class IsoValue a where Source #
Isomorphism between Michelson values and plain Haskell types.
Default implementation of this typeclass converts ADTs to Michelson "pair"s and "or"s.
Nothing
toVal :: a -> Value (ToT a) Source #
Converts a Haskell structure into Value
representation.
toVal :: (Generic a, GIsoValue (Rep a), ToT a ~ GValueType (Rep a)) => a -> Value (ToT a) Source #
Converts a Haskell structure into Value
representation.
fromVal :: Value (ToT a) -> a Source #
Converts a Value
into Haskell type.
fromVal :: (Generic a, GIsoValue (Rep a), ToT a ~ GValueType (Rep a)) => Value (ToT a) -> a Source #
Converts a Value
into Haskell type.
Instances
class GIsoValue (x :: Type -> Type) Source #
Implements ADT conversion to Michelson value.
Thanks to Generic, Michelson representation will be a balanced tree; this reduces average access time in general case.
A drawback of such approach is that, in theory, in new GHC version generified representation may change; however, chances are small and I (martoon) believe that contract versions will change much faster anyway.
gToValue, gFromValue
type GValueType x :: T Source #
Instances
type family ToTs (ts :: [Type]) :: [T] where ... Source #
Type function to convert a Haskell stack type to T
-based one.
type family ToT' (t :: k) :: T where ... Source #
Overloaded version of ToT
to work on Haskell and T
types.
type family ToTs' (t :: [k]) :: [T] where ... Source #
Overloaded version of ToTs
to work on Haskell and T
stacks.
newtype ContractAddr (cp :: Type) Source #
Since Contract
name is used to designate contract code, lets call
analogy of TContract
type as follows.
Instances
IsoValue (ContractAddr cp) Source # | |
Defined in Michelson.Typed.Haskell.Value type ToT (ContractAddr cp) :: T Source # toVal :: ContractAddr cp -> Value (ToT (ContractAddr cp)) Source # fromVal :: Value (ToT (ContractAddr cp)) -> ContractAddr cp Source # | |
type ToT (ContractAddr cp) Source # | |
Defined in Michelson.Typed.Haskell.Value |