Safe Haskell | None |
---|---|
Language | Haskell2010 |
Product type Michelson layout optimized for non-dupable fields case.
Synopsis
- deriveSemiDupableGeneric :: String -> Int -> DecsQ
Documentation
deriveSemiDupableGeneric :: String -> Int -> DecsQ Source #
Produce Generic
instance for a datatype containing non-dupable and
plain dupable elements so that operations on this datatype
(like getField
) remain optimal in average.
Derivation strategies available for customGeneric
suffer from a problem:
getField
is non-optimal as long as during its recursive descend it
operates with a non-dupable pairs subtree. deriveSemiDupableGeneric
tries to keep all dupable elements in the left subtree of the root
(speeding up getField
on them), and all non-dupable elements in the right
subtree.
Prerequisites for calling this function:
- All the fields of dupable types must locate before all the fields of non-dupable types.
- You have to supply the expected number of non-dupable fields as an argument. We expect this number, not the number of dupable fields, since non-dupable elements are rare and so are supposed to be updated less often.
Unfortunatelly, there seems to be no decent way to see whether a type is dupable or not at TH time, so we have to accept some information explicitly. To ensure that this information is up to date, each time calling this function we encourage the user to also add a test using utilities from Lorentz.Test.DupableScan module.