| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Michelson.Typed.Haskell.ValidateDescription
Synopsis
- type FieldDescriptions = [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
- type FieldDescriptionsV = Demote FieldDescriptions
- type family FieldDescriptionsValid (descr :: FieldDescriptions) (typ :: Type) :: Constraint where ...
Documentation
type FieldDescriptions = [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))] Source #
Description of constructors and fields of some datatype.
This type is just two nested maps represented as associative lists. It is supposed to be interpreted like this:
[(Constructor name, (Maybe constructor description, [(Field name, Field description)]))]
Example with a concrete data type:
data Foo
= Foo
{ fFoo :: Int
}
| Bar
{ fBar :: Text
}
deriving (Generic)
type FooDescriptions =
'[ '( "Foo", '( 'Just "foo constructor",
, '[ '("fFoo", "some number")
])
)
, '( "Bar", '( 'Nothing,
, '[ '("fBar", "some string")
])
)
]type FieldDescriptionsV = Demote FieldDescriptions Source #
Value-level counterpart to FieldDescriptions.
type family FieldDescriptionsValid (descr :: FieldDescriptions) (typ :: Type) :: Constraint where ... Source #
This type family checks that field descriptions mention only existing constructors and fields.
When descr is empty this family does nothing, to avoid breaking for built-in, non-ADT types.
When descr is not empty, this family will demand Generic instance for typ and fail with a
TypeError if there none.