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 ToT' (t :: k) :: T where ...
- data SomeIsoValue where
- SomeIsoValue :: (Typeable a, IsoValue a) => a -> SomeIsoValue
- newtype AnyIsoValue = AnyIsoValue (forall a. IsoValue a => a)
- type IsComparable c = ToT c ~ Tc (ToCT c)
- type GenericIsoValue t = (IsoValue t, Generic t, ToT t ~ GValueType (Rep t))
- type EntryPointCall param arg = EntryPointCallT (ToT param) (ToT arg)
- type SomeEntryPointCall arg = SomeEntryPointCallT (ToT arg)
- data ContractRef (arg :: Type) = ContractRef {
- crAddress :: Address
- crEntryPoint :: SomeEntryPointCall arg
- coerceContractRef :: ToT a ~ ToT b => ContractRef a -> ContractRef b
- contractRefToAddr :: ContractRef cp -> EpAddress
- newtype BigMap k v = BigMap {}
- type family ToTs (ts :: [Type]) :: [T] where ...
- type family ToTs' (t :: [k]) :: [T] where ...
- class IsoValuesStack (ts :: [Type]) where
- totsKnownLemma :: forall s. KnownList s :- KnownList (ToTs s)
- totsAppendLemma :: forall a b. KnownList a => Dict (ToTs (a ++ b) ~ (ToTs a ++ ToTs b))
Value conversions
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 KeyHash Source # | |
IsoCValue Timestamp Source # | |
IsoCValue Mutez Source # | |
IsoCValue Address Source # | This instance erases reference to contract entrypoint!
If this is an issue, use Applications which use addresses just as participants identifiers
should not experience problems with using plain |
IsoCValue EpAddress 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 ToT' (t :: k) :: T where ... Source #
Overloaded version of ToT
to work on Haskell and T
types.
data SomeIsoValue where Source #
Hides some Haskell value put in line with Michelson Value
.
SomeIsoValue :: (Typeable a, IsoValue a) => a -> SomeIsoValue |
newtype AnyIsoValue Source #
Any Haskell value which can be converted to Michelson Value
.
AnyIsoValue (forall a. IsoValue a => a) |
type GenericIsoValue t = (IsoValue t, Generic t, ToT t ~ GValueType (Rep t)) Source #
Whether Michelson representation of the type is derived via Generics.
Missing Haskell analogies to Michelson values
type EntryPointCall param arg = EntryPointCallT (ToT param) (ToT arg) Source #
type SomeEntryPointCall arg = SomeEntryPointCallT (ToT arg) Source #
data ContractRef (arg :: Type) Source #
Since Contract
name is used to designate contract code, lets call
analogy of TContract
type as follows.
Note that type argument always designates an argument of entrypoint.
If a contract has explicit default entrypoint (and no root entrypoint),
ContractRef
referring to it can never have the entire parameter as its
type argument.
Instances
coerceContractRef :: ToT a ~ ToT b => ContractRef a -> ContractRef b Source #
Replace type argument of ContractAddr
with isomorphic one.
contractRefToAddr :: ContractRef cp -> EpAddress Source #
Instances
(Eq k, Eq v) => Eq (BigMap k v) Source # | |
(Show k, Show v) => Show (BigMap k v) Source # | |
Ord k => Semigroup (BigMap k v) Source # | |
Ord k => Monoid (BigMap k v) Source # | |
Default (BigMap k v) Source # | |
Defined in Michelson.Typed.Haskell.Value | |
(Ord k, IsoCValue k, IsoValue v) => IsoValue (BigMap k v) Source # | |
(PolyCTypeHasDocC (k ': ([] :: [Type])), PolyTypeHasDocC (v ': ([] :: [Type])), Ord k) => TypeHasDoc (BigMap k v) Source # | |
Defined in Michelson.Typed.Haskell.Doc typeDocName :: Proxy (BigMap k v) -> Text Source # typeDocMdDescription :: Markdown Source # typeDocMdReference :: Proxy (BigMap k v) -> WithinParens -> Markdown Source # typeDocDependencies :: Proxy (BigMap k v) -> [SomeTypeWithDoc] Source # typeDocHaskellRep :: TypeDocHaskellRep (BigMap k v) Source # typeDocMichelsonRep :: TypeDocMichelsonRep (BigMap k v) Source # | |
type ToT (BigMap k v) Source # | |
Stack conversion
type family ToTs (ts :: [Type]) :: [T] where ... Source #
Type function to convert a Haskell stack type to T
-based one.
type family ToTs' (t :: [k]) :: [T] where ... Source #
Overloaded version of ToTs
to work on Haskell and T
stacks.
class IsoValuesStack (ts :: [Type]) where Source #
Isomorphism between Michelson stack and its Haskell reflection.
toValStack :: Rec Identity ts -> Rec Value (ToTs ts) Source #
fromValStack :: Rec Value (ToTs ts) -> Rec Identity ts Source #
Instances
IsoValuesStack ([] :: [Type]) Source # | |
(IsoValue t, IsoValuesStack st) => IsoValuesStack (t ': st) Source # | |