hexresearch / hschain-utxo

UTXO-based contracts for hschain
0 stars 0 forks source link

Gen instances #219

Closed anton-k closed 3 years ago

anton-k commented 3 years ago

Implements generic instnaces for Eq, Ord, Show, Serialise for all types that do not contain arrows including custom user data-types.

Also number of bug-fixes.

Changes format for Args. It was collection of vectors for primitive types but now we can store anything and decode it to the right type with type annotation:

getArgs :: (Int, Bytes)

getArgs :: [Text]

Note that although we store a ByteString we can not store plain haskell ByteStrings as they are. We should convert them to proper format that our evaluator can decode.

For it we can use helper functions:

toArgs :: IsTerm a => a -> Args

fromArgs :: IsTerm a => Args -> a

 serialiseTerm :: IsTerm a => a -> ByteString
 deserialiseTerm :: IsTerm a => ByteString -> a

Instnaces for IsTerm are predefined for many useful types.