Safe Haskell | None |
---|
Data
instances for HListFlat
and Record
which pretend
to be flat data structures. The Data
instance for HList
gives a nested
structure.
NOTE: these instances do not work with ghc-7.8 because of http://ghc.haskell.org/trac/ghc/ticket/8486
HList
The data instance for
a :: HList '[Int, Double, b]
Looks like the same instance for
type T b = (Int, (Double, (b, ())))
HListFlat
The Data instance for
a :: Data b => HListFlat '[Int,Double,b]
will look like the Data instance for:
data A b = A Int Double b
Record
For Record
similar ideas apply. An
a :: Record '[ LVPair "x" Int, LVPair "y" Double ]
should behave like a:
data A = A { x :: Int, y :: Double } deriving (Data)
Many unsafecoerces are necessary here because the Data class includes type
parameters c
that cannot be used in the class context for the instance.
Perhaps there is another way.
- type DataHListFlatCxt g a = (HBuild' `[]` g, Typeable (HListFlat a), TypeablePolyK a, HFoldl (GfoldlK C) (C g) a (C (HList a)), HFoldr (GunfoldK C) (C g) (HReplicateR (HLength a) ()) (C (HList a)), HReplicate (HLength a) ())
- type DataRecordCxt a = (Data (HListFlat (RecordValuesR a)), TypeablePolyK a, TypeRepsList (Record a), RecordValues a, RecordLabelsStr a)
- class TypeRepsList a
- class RecordLabelsStr xs where
- recordLabelsStr :: Record xs -> [String]
- data GfoldlK c where
- data GunfoldK c where
- newtype HListFlat a = HListFlat (HList a)
exports for type signatures/ haddock usage
type DataHListFlatCxt g a = (HBuild' `[]` g, Typeable (HListFlat a), TypeablePolyK a, HFoldl (GfoldlK C) (C g) a (C (HList a)), HFoldr (GunfoldK C) (C g) (HReplicateR (HLength a) ()) (C (HList a)), HReplicate (HLength a) ())Source
type DataRecordCxt a = (Data (HListFlat (RecordValuesR a)), TypeablePolyK a, TypeRepsList (Record a), RecordValues a, RecordLabelsStr a)Source
class TypeRepsList a Source
TypeRepsList HNil' | |
(TypeRepsList (Prime xs), ConvHList xs) => TypeRepsList (Record xs) | |
(TypeRepsList xs, Typeable x) => TypeRepsList (HCons' x xs) |
less likely to be used
class RecordLabelsStr xs whereSource
recordLabelsStr :: Record xs -> [String]Source
RecordLabelsStr ([] *) | |
(RecordLabelsStr xs, ShowLabel k x) => RecordLabelsStr (: * (Tagged k x t) xs) |
wraps up the first argument to gfoldl