Generates a Foldable instance declaration for the given data type or data family instance.
Modulederiving-compat-0.6.8Haskell2010
Data.Foldable.Deriving
Exports functions to mechanically derive Foldable instances in a way that mimics
how the -XDeriveFoldable extension works since GHC 8.0.
These changes make it possible to derive Foldable instances for data types with
existential constraints, e.g.,
data WrappedSet a where
WrapSet :: Ord a => a -> WrappedSet a
deriving instance Foldable WrappedSet -- On GHC 8.0 on later
$(deriveFoldable ''WrappedSet) -- On GHC 7.10 and earlier
In addition, derived Foldable instances from this module do not generate
superfluous mempty expressions in its implementation of foldMap. One can
verify this by compiling a module that uses deriveFoldable with the
-ddump-splices GHC flag.
For more info on these changes, see this GHC wiki page.
- 1 type
- 13 values
- Packagederiving-compat-0.6.8
- Exports14
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceDeriving.hs
Foldable
12 declarationsLike deriveFoldable, but takes an FFTOptions argument.
Like makeFoldMap, but takes an FFTOptions argument.
Like makeFoldr, but takes an FFTOptions argument.
Generates a lambda expression which behaves like fold (without requiring a
Foldable instance).
Like makeFold, but takes an FFTOptions argument.
Like makeFoldl, but takes an FFTOptions argument.
Like makeNull, but takes an FFTOptions argument.
FFTOptions
2 declarationsOptions that further configure how the functions in Data.Functor.Deriving
should behave. (FFT stands for FunctorFoldableTraversable.)
Constructors
Instances4Eq, Ord, Read, Show
Eq FFTOptionsDefined in deriving-compat-0.6.8 · Data.Functor.Deriving.InternalOrd FFTOptionsDefined in deriving-compat-0.6.8 · Data.Functor.Deriving.InternalRead FFTOptionsDefined in deriving-compat-0.6.8 · Data.Functor.Deriving.InternalShow FFTOptionsDefined in deriving-compat-0.6.8 · Data.Functor.Deriving.Internal
Conservative FFTOptions that doesn't attempt to use EmptyCase (to
prevent users from having to enable that extension at use sites.)
deriveFoldable limitations
0 declarationsBe aware of the following potential gotchas:
If you are using the
-XGADTsor-XExistentialQuantificationextensions, an existential constraint cannot mention the last type variable. For example,data Illegal a = forall a. Show a => Illegal acannot have a derived Functor instance.Type variables of kind
* -> *are assumed to have Foldable constraints. If this is not desirable, use makeFoldr or makeFoldMap.