morley-1.0.0: Developer tools for the Michelson Language

Safe HaskellNone
LanguageHaskell2010

Michelson.Typed.Haskell.Value

Contents

Description

Conversions between haskell types/values and Michelson ones.

Synopsis

Value conversions

class IsoCValue a where Source #

Isomorphism between Michelson primitive values and plain Haskell types.

Associated Types

type ToCT a :: CT Source #

Type function that converts a regular Haskell type into a comparable type (which has kind CT).

Methods

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 # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Bool :: CT Source #

IsoCValue Integer Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Integer :: CT Source #

IsoCValue Natural Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Natural :: CT Source #

IsoCValue ByteString Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT ByteString :: CT Source #

(DoNotUseTextError :: Constraint) => IsoCValue Text Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Text :: CT Source #

IsoCValue MText Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT MText :: CT Source #

IsoCValue KeyHash Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT KeyHash :: CT Source #

IsoCValue Timestamp Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Timestamp :: CT Source #

IsoCValue Mutez Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Mutez :: CT Source #

IsoCValue Address Source #

This instance erases reference to contract entrypoint! If this is an issue, use EpAddress instead.

Applications which use addresses just as participants identifiers should not experience problems with using plain Address.

Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Address :: CT Source #

IsoCValue EpAddress Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT EpAddress :: CT 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.

Minimal complete definition

Nothing

Associated Types

type ToT a :: T Source #

Type function that converts a regular Haskell type into a T type.

Methods

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
IsoValue Bool Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Bool :: T Source #

IsoValue Integer Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Integer :: T Source #

IsoValue Natural Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Natural :: T Source #

IsoValue () Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT () :: T Source #

Methods

toVal :: () -> Value (ToT ()) Source #

fromVal :: Value (ToT ()) -> () Source #

IsoValue ByteString Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT ByteString :: T Source #

(DoNotUseTextError :: Constraint) => IsoValue Text Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Text :: T Source #

IsoValue MText Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT MText :: T Source #

IsoValue KeyHash Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT KeyHash :: T Source #

IsoValue Signature Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Signature :: T Source #

IsoValue PublicKey Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT PublicKey :: T Source #

IsoValue ChainId Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT ChainId :: T Source #

IsoValue Timestamp Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Timestamp :: T Source #

IsoValue Mutez Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Mutez :: T Source #

IsoValue Address Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Address :: T Source #

IsoValue EpAddress Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT EpAddress :: T Source #

IsoValue Operation Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Operation :: T Source #

IsoValue MyCompoundType Source # 
Instance details

Defined in Michelson.Typed.Haskell.Instr.Sum

Associated Types

type ToT MyCompoundType :: T Source #

IsoValue a => IsoValue [a] Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT [a] :: T Source #

Methods

toVal :: [a] -> Value (ToT [a]) Source #

fromVal :: Value (ToT [a]) -> [a] Source #

IsoValue a => IsoValue (Maybe a) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (Maybe a) :: T Source #

Methods

toVal :: Maybe a -> Value (ToT (Maybe a)) Source #

fromVal :: Value (ToT (Maybe a)) -> Maybe a Source #

IsoValue a => IsoValue (Identity a) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (Identity a) :: T Source #

(Ord c, IsoCValue c) => IsoValue (Set c) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (Set c) :: T Source #

Methods

toVal :: Set c -> Value (ToT (Set c)) Source #

fromVal :: Value (ToT (Set c)) -> Set c Source #

IsoValue (ContractRef arg) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (ContractRef arg) :: T Source #

(IsoValue l, IsoValue r) => IsoValue (Either l r) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (Either l r) :: T Source #

Methods

toVal :: Either l r -> Value (ToT (Either l r)) Source #

fromVal :: Value (ToT (Either l r)) -> Either l r Source #

(IsoValue a, IsoValue b) => IsoValue (a, b) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (a, b) :: T Source #

Methods

toVal :: (a, b) -> Value (ToT (a, b)) Source #

fromVal :: Value (ToT (a, b)) -> (a, b) Source #

(Ord k, IsoCValue k, IsoValue v) => IsoValue (Map k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (Map k v) :: T Source #

Methods

toVal :: Map k v -> Value (ToT (Map k v)) Source #

fromVal :: Value (ToT (Map k v)) -> Map k v Source #

(Ord k, IsoCValue k, IsoValue v) => IsoValue (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (BigMap k v) :: T Source #

Methods

toVal :: BigMap k v -> Value (ToT (BigMap k v)) Source #

fromVal :: Value (ToT (BigMap k v)) -> BigMap k v Source #

(IsoValue a, IsoValue b, IsoValue c) => IsoValue (a, b, c) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (a, b, c) :: T Source #

Methods

toVal :: (a, b, c) -> Value (ToT (a, b, c)) Source #

fromVal :: Value (ToT (a, b, c)) -> (a, b, c) Source #

IsoValue a => IsoValue (NamedF Maybe a name) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (NamedF Maybe a name) :: T Source #

Methods

toVal :: NamedF Maybe a name -> Value (ToT (NamedF Maybe a name)) Source #

fromVal :: Value (ToT (NamedF Maybe a name)) -> NamedF Maybe a name Source #

IsoValue a => IsoValue (NamedF Identity a name) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (NamedF Identity a name) :: T Source #

Methods

toVal :: NamedF Identity a name -> Value (ToT (NamedF Identity a name)) Source #

fromVal :: Value (ToT (NamedF Identity a name)) -> NamedF Identity a name Source #

(IsoValue a, IsoValue b, IsoValue c, IsoValue d) => IsoValue (a, b, c, d) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (a, b, c, d) :: T Source #

Methods

toVal :: (a, b, c, d) -> Value (ToT (a, b, c, d)) Source #

fromVal :: Value (ToT (a, b, c, d)) -> (a, b, c, d) Source #

(IsoValue a, IsoValue b, IsoValue c, IsoValue d, IsoValue e) => IsoValue (a, b, c, d, e) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (a, b, c, d, e) :: T Source #

Methods

toVal :: (a, b, c, d, e) -> Value (ToT (a, b, c, d, e)) Source #

fromVal :: Value (ToT (a, b, c, d, e)) -> (a, b, c, d, e) Source #

(IsoValue a, IsoValue b, IsoValue c, IsoValue d, IsoValue e, IsoValue f) => IsoValue (a, b, c, d, e, f) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (a, b, c, d, e, f) :: T Source #

Methods

toVal :: (a, b, c, d, e, f) -> Value (ToT (a, b, c, d, e, f)) Source #

fromVal :: Value (ToT (a, b, c, d, e, f)) -> (a, b, c, d, e, f) Source #

(IsoValue a, IsoValue b, IsoValue c, IsoValue d, IsoValue e, IsoValue f, IsoValue g) => IsoValue (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (a, b, c, d, e, f, g) :: T Source #

Methods

toVal :: (a, b, c, d, e, f, g) -> Value (ToT (a, b, c, d, e, f, g)) Source #

fromVal :: Value (ToT (a, b, c, d, e, f, g)) -> (a, b, c, d, e, f, g) Source #

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.

Minimal complete definition

gToValue, gFromValue

Associated Types

type GValueType x :: T Source #

Instances
GIsoValue (U1 :: Type -> Type) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type GValueType U1 :: T Source #

IsoValue a => GIsoValue (Rec0 a) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type GValueType (Rec0 a) :: T Source #

Methods

gToValue :: Rec0 a p -> Value (GValueType (Rec0 a))

gFromValue :: Value (GValueType (Rec0 a)) -> Rec0 a p

(GIsoValue x, GIsoValue y) => GIsoValue (x :+: y) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type GValueType (x :+: y) :: T Source #

Methods

gToValue :: (x :+: y) p -> Value (GValueType (x :+: y))

gFromValue :: Value (GValueType (x :+: y)) -> (x :+: y) p

(GIsoValue x, GIsoValue y) => GIsoValue (x :*: y) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type GValueType (x :*: y) :: T Source #

Methods

gToValue :: (x :*: y) p -> Value (GValueType (x :*: y))

gFromValue :: Value (GValueType (x :*: y)) -> (x :*: y) p

GIsoValue x => GIsoValue (M1 t i x) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type GValueType (M1 t i x) :: T Source #

Methods

gToValue :: M1 t i x p -> Value (GValueType (M1 t i x))

gFromValue :: Value (GValueType (M1 t i x)) -> M1 t i x p

type family ToT' (t :: k) :: T where ... Source #

Overloaded version of ToT to work on Haskell and T types.

Equations

ToT' (t :: T) = t 
ToT' (t :: Type) = ToT t 

data SomeIsoValue where Source #

Hides some Haskell value put in line with Michelson Value.

Constructors

SomeIsoValue :: (Typeable a, IsoValue a) => a -> SomeIsoValue 

newtype AnyIsoValue Source #

Any Haskell value which can be converted to Michelson Value.

Constructors

AnyIsoValue (forall a. IsoValue a => a) 

type IsComparable c = ToT c ~ Tc (ToCT c) Source #

A useful property which holds for all CT types.

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 #

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
Eq (ContractRef arg) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

(==) :: ContractRef arg -> ContractRef arg -> Bool #

(/=) :: ContractRef arg -> ContractRef arg -> Bool #

Show (ContractRef arg) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

showsPrec :: Int -> ContractRef arg -> ShowS #

show :: ContractRef arg -> String #

showList :: [ContractRef arg] -> ShowS #

Buildable (ContractRef arg) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

build :: ContractRef arg -> Builder #

IsoValue (ContractRef arg) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (ContractRef arg) :: T Source #

PolyTypeHasDocC (cp ': ([] :: [Type])) => TypeHasDoc (ContractRef cp) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Doc

type ToT (ContractRef arg) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

type ToT (ContractRef arg) = TContract (ToT arg)

coerceContractRef :: ToT a ~ ToT b => ContractRef a -> ContractRef b Source #

Replace type argument of ContractAddr with isomorphic one.

newtype BigMap k v Source #

Constructors

BigMap 

Fields

Instances
(Eq k, Eq v) => Eq (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

(==) :: BigMap k v -> BigMap k v -> Bool #

(/=) :: BigMap k v -> BigMap k v -> Bool #

(Show k, Show v) => Show (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

showsPrec :: Int -> BigMap k v -> ShowS #

show :: BigMap k v -> String #

showList :: [BigMap k v] -> ShowS #

Ord k => Semigroup (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

(<>) :: BigMap k v -> BigMap k v -> BigMap k v #

sconcat :: NonEmpty (BigMap k v) -> BigMap k v #

stimes :: Integral b => b -> BigMap k v -> BigMap k v #

Ord k => Monoid (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

mempty :: BigMap k v #

mappend :: BigMap k v -> BigMap k v -> BigMap k v #

mconcat :: [BigMap k v] -> BigMap k v #

Default (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

def :: BigMap k v #

(Ord k, IsoCValue k, IsoValue v) => IsoValue (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (BigMap k v) :: T Source #

Methods

toVal :: BigMap k v -> Value (ToT (BigMap k v)) Source #

fromVal :: Value (ToT (BigMap k v)) -> BigMap k v Source #

(PolyCTypeHasDocC (k ': ([] :: [Type])), PolyTypeHasDocC (v ': ([] :: [Type])), Ord k) => TypeHasDoc (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Doc

type ToT (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

type ToT (BigMap k v) = TBigMap (ToCT k) (ToT v)

Stack conversion

type family ToTs (ts :: [Type]) :: [T] where ... Source #

Type function to convert a Haskell stack type to T-based one.

Equations

ToTs '[] = '[] 
ToTs (x ': xs) = ToT x ': ToTs xs 

type family ToTs' (t :: [k]) :: [T] where ... Source #

Overloaded version of ToTs to work on Haskell and T stacks.

Equations

ToTs' (t :: [T]) = t 
ToTs' (a :: [Type]) = ToTs a 

class IsoValuesStack (ts :: [Type]) where Source #

Isomorphism between Michelson stack and its Haskell reflection.

Instances
IsoValuesStack ([] :: [Type]) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

(IsoValue t, IsoValuesStack st) => IsoValuesStack (t ': st) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Methods

toValStack :: Rec Identity (t ': st) -> Rec Value (ToTs (t ': st)) Source #

fromValStack :: Rec Value (ToTs (t ': st)) -> Rec Identity (t ': st) Source #

totsAppendLemma :: forall a b. KnownList a => Dict (ToTs (a ++ b) ~ (ToTs a ++ ToTs b)) Source #