Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 with promoted string (Symbol) labels because of https://ghc.haskell.org/trac/ghc/ticket/9111
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.
Synopsis
- type DataHListFlatCxt na g a = (g ~ FoldRArrow a (HList a), HBuild' '[] g, Typeable (HListFlat a), TypeablePolyK a, HFoldl (GfoldlK C) (C g) a (C (HList a)), HFoldr (GunfoldK C) (C g) (HReplicateR na ()) (C (HList a)), HLengthEq a na, HReplicate na ())
- type DataRecordCxt a = (Data (HListFlat (RecordValuesR a)), TypeablePolyK a, TypeRepsList (Record a), RecordValues a, RecordLabelsStr a)
- class TypeRepsList a where
- typeRepsList :: a -> [TypeRep]
- class RecordLabelsStr (xs :: [*]) where
- recordLabelsStr :: Record xs -> [String]
- data GfoldlK c where
- data GunfoldK c where
- newtype HListFlat a = HListFlat (HList a)
- type TypeablePolyK (a :: k) = Typeable a
exports for type signatures/ haddock usage
type DataHListFlatCxt na g a = (g ~ FoldRArrow a (HList a), HBuild' '[] g, Typeable (HListFlat a), TypeablePolyK a, HFoldl (GfoldlK C) (C g) a (C (HList a)), HFoldr (GunfoldK C) (C g) (HReplicateR na ()) (C (HList a)), HLengthEq a na, HReplicate na ()) Source #
type DataRecordCxt a = (Data (HListFlat (RecordValuesR a)), TypeablePolyK a, TypeRepsList (Record a), RecordValues a, RecordLabelsStr a) Source #
class TypeRepsList a where Source #
typeRepsList :: a -> [TypeRep] Source #
Instances
(TypeRepsList (HList xs), Typeable x) => TypeRepsList (HList (x ': xs)) Source # | |
Defined in Data.HList.Data typeRepsList :: HList (x ': xs) -> [TypeRep] Source # | |
TypeRepsList (HList ('[] :: [Type])) Source # | |
Defined in Data.HList.Data typeRepsList :: HList '[] -> [TypeRep] Source # | |
TypeRepsList (HList xs) => TypeRepsList (Record xs) Source # | |
Defined in Data.HList.Data typeRepsList :: Record xs -> [TypeRep] Source # |
less likely to be used
class RecordLabelsStr (xs :: [*]) where Source #
recordLabelsStr :: Record xs -> [String] Source #
Instances
RecordLabelsStr ('[] :: [Type]) Source # | |
Defined in Data.HList.Data recordLabelsStr :: Record '[] -> [String] Source # | |
(RecordLabelsStr xs, ShowLabel x) => RecordLabelsStr (Tagged x t ': xs) Source # | |
Defined in Data.HList.Data |
wraps up the first argument to gfoldl
this data type only exists to have Data instance
Instances
DataHListFlatCxt na g a => Data (HListFlat a) Source # | |
Defined in Data.HList.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HListFlat a -> c (HListFlat a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HListFlat a) # toConstr :: HListFlat a -> Constr # dataTypeOf :: HListFlat a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HListFlat a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HListFlat a)) # gmapT :: (forall b. Data b => b -> b) -> HListFlat a -> HListFlat a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HListFlat a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HListFlat a -> r # gmapQ :: (forall d. Data d => d -> u) -> HListFlat a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HListFlat a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HListFlat a -> m (HListFlat a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HListFlat a -> m (HListFlat a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HListFlat a -> m (HListFlat a) # |
type TypeablePolyK (a :: k) = Typeable a Source #
Orphan instances
(Data x, Data (HList xs), TypeablePolyK (x ': xs), Typeable (HList (x ': xs))) => Data (HList (x ': xs)) Source # | |
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HList (x ': xs) -> c (HList (x ': xs)) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HList (x ': xs)) # toConstr :: HList (x ': xs) -> Constr # dataTypeOf :: HList (x ': xs) -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HList (x ': xs))) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HList (x ': xs))) # gmapT :: (forall b. Data b => b -> b) -> HList (x ': xs) -> HList (x ': xs) # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HList (x ': xs) -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HList (x ': xs) -> r # gmapQ :: (forall d. Data d => d -> u) -> HList (x ': xs) -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HList (x ': xs) -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HList (x ': xs) -> m (HList (x ': xs)) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HList (x ': xs) -> m (HList (x ': xs)) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HList (x ': xs) -> m (HList (x ': xs)) # | |
Typeable (HList ('[] :: [Type])) => Data (HList ('[] :: [Type])) Source # | |
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HList '[] -> c (HList '[]) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HList '[]) # toConstr :: HList '[] -> Constr # dataTypeOf :: HList '[] -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HList '[])) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HList '[])) # gmapT :: (forall b. Data b => b -> b) -> HList '[] -> HList '[] # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HList '[] -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HList '[] -> r # gmapQ :: (forall d. Data d => d -> u) -> HList '[] -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HList '[] -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HList '[] -> m (HList '[]) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HList '[] -> m (HList '[]) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HList '[] -> m (HList '[]) # | |
DataRecordCxt a => Data (Record a) Source # | |
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Record a -> c (Record a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Record a) # toConstr :: Record a -> Constr # dataTypeOf :: Record a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Record a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Record a)) # gmapT :: (forall b. Data b => b -> b) -> Record a -> Record a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Record a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Record a -> r # gmapQ :: (forall d. Data d => d -> u) -> Record a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Record a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Record a -> m (Record a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Record a -> m (Record a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Record a -> m (Record a) # | |
(TypeablePolyK xs, Typeable (HList xs), Data (HList xs)) => Data (TIP xs) Source # | |
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TIP xs -> c (TIP xs) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TIP xs) # toConstr :: TIP xs -> Constr # dataTypeOf :: TIP xs -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TIP xs)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TIP xs)) # gmapT :: (forall b. Data b => b -> b) -> TIP xs -> TIP xs # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TIP xs -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TIP xs -> r # gmapQ :: (forall d. Data d => d -> u) -> TIP xs -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TIP xs -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TIP xs -> m (TIP xs) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TIP xs -> m (TIP xs) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TIP xs -> m (TIP xs) # | |
(TypeablePolyK xs, Typeable (Variant xs), Data (Variant xs)) => Data (TIC xs) Source # | |
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TIC xs -> c (TIC xs) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TIC xs) # toConstr :: TIC xs -> Constr # dataTypeOf :: TIC xs -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TIC xs)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TIC xs)) # gmapT :: (forall b. Data b => b -> b) -> TIC xs -> TIC xs # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TIC xs -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TIC xs -> r # gmapQ :: (forall d. Data d => d -> u) -> TIC xs -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TIC xs -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TIC xs -> m (TIC xs) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TIC xs -> m (TIC xs) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TIC xs -> m (TIC xs) # |