Safe Haskell | None |
---|---|
Language | Haskell2010 |
A fold on the shape of the constructors of a DataD or NewtypeD record.
- type Field = (Name, Con, Either Int Name)
- data FieldType
- fieldType :: FieldType -> Type
- constructorName :: Con -> Name
- constructorFields :: Name -> Con -> [Field]
- constructorFieldTypes :: Con -> [FieldType]
- constructorPat :: Con -> PatQ
- fPos :: FieldType -> Either Int Name
- fName :: FieldType -> Either Int Name
- fType :: FieldType -> Type
- foldShape :: Monad m => ([(Con, [FieldType])] -> m r) -> (Con -> [FieldType] -> m r) -> ([Con] -> m r) -> (Con -> FieldType -> m r) -> [Con] -> m r
Field name and position
constructorName :: Con -> Name Source #
constructorFieldTypes :: Con -> [FieldType] Source #
constructorPat :: Con -> PatQ Source #
Build a pattern that will match only values with the given constructor.
Decl shape
foldShape :: Monad m => ([(Con, [FieldType])] -> m r) -> (Con -> [FieldType] -> m r) -> ([Con] -> m r) -> (Con -> FieldType -> m r) -> [Con] -> m r Source #
Given the list of constructors from a Dec, dispatch on the different levels of complexity of the type they represent - a wrapper is a single arity one constructor, an enum is several arity zero constructors, and so on.