morley-0.3.0.1: Developer tools for the Michelson Language

Safe HaskellNone
LanguageHaskell2010

Michelson.Typed.Haskell

Description

Haskell-Michelson conversions.

Synopsis

Documentation

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 #

IsComparable k => GetOpHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

Associated Types

type GetOpKeyHs (BigMap k v) :: Type Source #

type GetOpValHs (BigMap k v) :: Type Source #

IsComparable k => UpdOpHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

Associated Types

type UpdOpKeyHs (BigMap k v) :: Type Source #

type UpdOpParamsHs (BigMap k v) :: Type Source #

IsComparable k => MemOpHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

Associated Types

type MemOpKeyHs (BigMap k v) :: Type Source #

type ToT (BigMap k v) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

type ToT (BigMap k v) = TBigMap (ToCT k) (ToT v)
type GetOpKeyHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

type GetOpKeyHs (BigMap k v) = k
type GetOpValHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

type GetOpValHs (BigMap k v) = v
type UpdOpKeyHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

type UpdOpKeyHs (BigMap k v) = k
type UpdOpParamsHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

type UpdOpParamsHs (BigMap k v) = Maybe v
type MemOpKeyHs (BigMap k v) Source # 
Instance details

Defined in Lorentz.Polymorphic

type MemOpKeyHs (BigMap k v) = k

newtype ContractAddr (cp :: Type) Source #

Since Contract name is used to designate contract code, lets call analogy of TContract type as follows.

Constructors

ContractAddr 
Instances
IsoValue (ContractAddr cp) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (ContractAddr cp) :: T Source #

type ToT (ContractAddr cp) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

type ToT (ContractAddr cp) = TContract (ToT cp)

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

A useful property which holds for all CT types.

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 

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 

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 

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

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT Address :: 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 (ContractAddr cp) Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToT (ContractAddr cp) :: T Source #

IsoValue r => IsoValue (VoidResult r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type ToT (VoidResult r) :: T Source #

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

Defined in Lorentz.Store

Associated Types

type ToT (Store a) :: T Source #

Methods

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

fromVal :: Value (ToT (Store a)) -> Store a 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 (Lambda inp out) Source # 
Instance details

Defined in Lorentz.Base

Associated Types

type ToT (Lambda inp out) :: T Source #

Methods

toVal :: Lambda inp out -> Value (ToT (Lambda inp out)) Source #

fromVal :: Value (ToT (Lambda inp out)) -> Lambda inp out Source #

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

Defined in Lorentz.Macro

Associated Types

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

Methods

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

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

IsoValue a => IsoValue (View a r) Source # 
Instance details

Defined in Lorentz.Macro

Associated Types

type ToT (View a r) :: T Source #

Methods

toVal :: View a r -> Value (ToT (View a r)) Source #

fromVal :: Value (ToT (View a r)) -> View a r Source #

(IsoValue storeTemplate, IsoValue other) => IsoValue (StorageSkeleton storeTemplate other) Source # 
Instance details

Defined in Lorentz.Store

Associated Types

type ToT (StorageSkeleton storeTemplate other) :: T Source #

Methods

toVal :: StorageSkeleton storeTemplate other -> Value (ToT (StorageSkeleton storeTemplate other)) Source #

fromVal :: Value (ToT (StorageSkeleton storeTemplate other)) -> StorageSkeleton storeTemplate other 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 v => IsoValue (k2 |-> v) Source # 
Instance details

Defined in Lorentz.Store

Associated Types

type ToT (k2 |-> v) :: T Source #

Methods

toVal :: (k2 |-> v) -> Value (ToT (k2 |-> v)) Source #

fromVal :: Value (ToT (k2 |-> v)) -> k2 |-> v 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 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 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 KeyHash Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT KeyHash :: CT Source #

IsoCValue Address Source # 
Instance details

Defined in Michelson.Typed.Haskell.Value

Associated Types

type ToCT Address :: CT Source #

type InstrConstructC dt = (IsoValue dt, Generic dt, GInstrConstruct (Rep dt), GValueType (Rep dt) ~ ToT dt) Source #

Constraint for instrConstruct.

type ConstructorFieldTypes dt = GFieldTypes (Rep dt) Source #

Types of all fields in a datatype.

newtype FieldConstructor (st :: [k]) (field :: Type) Source #

Way to construct one of the fields in a complex datatype.

Constructors

FieldConstructor (Instr (ToTs' st) (ToT field ': ToTs' st)) 

type InstrSetFieldC dt name = (IsoValue dt, Generic dt, GInstrSetField name (Rep dt) (LnrBranch (GetNamed name dt)) (LnrFieldType (GetNamed name dt)), GValueType (Rep dt) ~ ToT dt) Source #

Constraint for instrSetField.

type InstrGetFieldC dt name = (IsoValue dt, Generic dt, GInstrGet name (Rep dt) (LnrBranch (GetNamed name dt)) (LnrFieldType (GetNamed name dt)), GValueType (Rep dt) ~ ToT dt) Source #

Constraint for instrGetField.

type GetFieldType dt name = LnrFieldType (GetNamed name dt) Source #

Get type of field by datatype it is contained in and field name.

instrGetField :: forall dt name st. InstrGetFieldC dt name => Label name -> Instr (ToT dt ': st) (ToT (GetFieldType dt name) ': st) Source #

Make an instruction which accesses given field of the given datatype.

instrSetField :: forall dt name st. InstrSetFieldC dt name => Label name -> Instr (ToT (GetFieldType dt name) ': (ToT dt ': st)) (ToT dt ': st) Source #

For given complex type dt and its field fieldTy update the field value.

instrConstruct :: forall dt st. InstrConstructC dt => Rec (FieldConstructor st) (ConstructorFieldTypes dt) -> Instr st (ToT dt ': st) Source #

For given complex type dt and its field fieldTy update the field value.

type InstrUnwrapC dt name = (IsoValue dt, Generic dt, GInstrUnwrap (Rep dt) (LnrBranch (GetNamed name dt)) (CtorOnlyField name dt), GValueType (Rep dt) ~ ToT dt) Source #

type CaseClauses a = GCaseClauses (Rep a) Source #

List of CaseClauseParams required to pattern match on the given type.

data CaseClause (inp :: [T]) (out :: [T]) (param :: CaseClauseParam) where Source #

Type information about single case clause.

Constructors

CaseClause :: Instr (AppendCtorField x inp) out -> CaseClause inp out (CaseClauseParam ctor x) 

data CaseClauseParam Source #

In what different case branches differ - related constructor name and input stack type which the branch starts with.

type InstrCaseC dt inp out = (IsoValue dt, GInstrCase (Rep dt), GValueType (Rep dt) ~ ToT dt) Source #

type InstrWrapC dt name = (IsoValue dt, Generic dt, GInstrWrap (Rep dt) (LnrBranch (GetNamed name dt)) (LnrFieldType (GetNamed name dt)), GValueType (Rep dt) ~ ToT dt) Source #

type CtorOnlyField name dt = RequireOneField name (GetCtorField dt name) Source #

Expect referred constructor to have only one field (otherwise compile error is raised) and extract its type.

type CtorHasOnlyField ctor dt f = GetCtorField dt ctor ~ OneField f Source #

Expect referred constructor to have only one field (in form of constraint) and extract its type.

type GetCtorField dt ctor = LnrFieldType (GetNamed ctor dt) Source #

Get type of constructor fields (one or zero) referred by given datatype and name.

type AppendCtorFieldAxiom (cf :: CtorField) (st :: [Type]) = ToTs (AppendCtorField cf st) ~ AppendCtorField cf (ToTs st) Source #

To use AppendCtorField not only here for T-based stacks, but also later in Lorentz with Type-based stacks we need the following property.

type family AppendCtorField (cf :: CtorField) (l :: [k]) :: [k] where ... Source #

Push field to stack, if any.

Equations

AppendCtorField (OneField t) (l :: [T]) = ToT t ': l 
AppendCtorField (OneField t) (l :: [Type]) = t ': l 
AppendCtorField NoFields (l :: [T]) = l 
AppendCtorField NoFields (l :: [Type]) = l 

type family ExtractCtorField (cf :: CtorField) where ... Source #

Get something as field of the given constructor.

data CtorField Source #

We support only two scenarious - constructor with one field and without fields. Nonetheless, it's not that sad since for sum types we can't even assign names to fields if there are many (the style guide prohibits partial records).

Constructors

OneField Type 
NoFields 

instrWrap :: forall dt name st. InstrWrapC dt name => Label name -> Instr (AppendCtorField (GetCtorField dt name) st) (ToT dt ': st) Source #

Wrap given element into a constructor with the given name.

Mentioned constructor must have only one field.

Since labels interpretable by OverloadedLabels extension cannot start with capital latter, prepend constructor name with letter "c" (see examples below).

hsWrap :: forall dt name. InstrWrapC dt name => Label name -> ExtractCtorField (GetCtorField dt name) -> dt Source #

Wrap a haskell value into a constructor with the given name.

This is symmetric to instrWrap.

instrCase :: forall dt out inp. InstrCaseC dt inp out => Rec (CaseClause inp out) (CaseClauses dt) -> Instr (ToT dt ': inp) out Source #

Pattern-match on the given datatype.

(//->) :: Label ("c" `AppendSymbol` ctor) -> Instr (AppendCtorField x inp) out -> CaseClause inp out (CaseClauseParam ctor x) infixr 8 Source #

Lift an instruction to case clause.

You should write out constructor name corresponding to the clause explicitly. Prefix constructor name with "c" letter, otherwise your label will not be recognized by Haskell parser. Passing constructor name can be circumvented but doing so is not recomended as mentioning contructor name improves readability and allows avoiding some mistakes.

instrUnwrapUnsafe :: forall dt name st. InstrUnwrapC dt name => Label name -> Instr (ToT dt ': st) (ToT (CtorOnlyField name dt) ': st) Source #

Unwrap a constructor with the given name.

Rules which apply to instrWrap function work here as well. Although, unlike instrWrap, this function does not work for nullary constructors.

hsUnwrap :: forall dt name. InstrUnwrapC dt name => Label name -> dt -> Maybe (CtorOnlyField name dt) Source #

Try to unwrap a constructor with the given name.