| Copyright | (C) 2015-2017 Ryan Scott |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Ryan Scott |
| Portability | Template Haskell |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Functor.Deriving
Description
Exports functions to mechanically derive Functor instances.
For more info on how deriving Functor works, see
this GHC wiki page.
Synopsis
- deriveFunctor :: Name -> Q [Dec]
- deriveFunctorOptions :: FFTOptions -> Name -> Q [Dec]
- makeFmap :: Name -> Q Exp
- makeFmapOptions :: FFTOptions -> Name -> Q Exp
- makeReplace :: Name -> Q Exp
- makeReplaceOptions :: FFTOptions -> Name -> Q Exp
- newtype FFTOptions = FFTOptions {
- fftEmptyCaseBehavior :: Bool
- defaultFFTOptions :: FFTOptions
Functor
deriveFunctor :: Name -> Q [Dec] Source #
Generates a FunctorClass instance declaration for the given data type or data
family instance.
deriveFunctorOptions :: FFTOptions -> Name -> Q [Dec] Source #
Like deriveFunctor, but takes an FFTOptions argument.
makeFmap :: Name -> Q Exp Source #
Generates a lambda expression which behaves like fmap (without requiring a
FunctorClass instance).
makeFmapOptions :: FFTOptions -> Name -> Q Exp Source #
Like makeFmap, but takes an FFTOptions argument.
makeReplace :: Name -> Q Exp Source #
Generates a lambda expression which behaves like (<$) (without requiring a
FunctorClass instance).
makeReplaceOptions :: FFTOptions -> Name -> Q Exp Source #
Like makeReplace, but takes an FFTOptions argument.
FFTOptions
newtype FFTOptions Source #
Options that further configure how the functions in Data.Functor.Deriving
should behave. (FFT stands for FunctorClassFunctorClassFunctorClass.)
Constructors
| FFTOptions | |
Fields
| |
Instances
| Read FFTOptions Source # | |
Defined in Data.Functor.Deriving.Internal Methods readsPrec :: Int -> ReadS FFTOptions readList :: ReadS [FFTOptions] readPrec :: ReadPrec FFTOptions readListPrec :: ReadPrec [FFTOptions] | |
| Show FFTOptions Source # | |
Defined in Data.Functor.Deriving.Internal Methods showsPrec :: Int -> FFTOptions -> ShowS show :: FFTOptions -> String showList :: [FFTOptions] -> ShowS | |
| Eq FFTOptions Source # | |
Defined in Data.Functor.Deriving.Internal | |
| Ord FFTOptions Source # | |
Defined in Data.Functor.Deriving.Internal Methods compare :: FFTOptions -> FFTOptions -> Ordering (<) :: FFTOptions -> FFTOptions -> Bool (<=) :: FFTOptions -> FFTOptions -> Bool (>) :: FFTOptions -> FFTOptions -> Bool (>=) :: FFTOptions -> FFTOptions -> Bool max :: FFTOptions -> FFTOptions -> FFTOptions min :: FFTOptions -> FFTOptions -> FFTOptions | |
defaultFFTOptions :: FFTOptions Source #
Conservative FFTOptions that doesn't attempt to use EmptyCase (to
prevent users from having to enable that extension at use sites.)
deriveFunctor limitations
Be aware of the following potential gotchas:
- Type variables of kind
* -> *are assumed to haveFunctorconstraints. If this is not desirable, usemakeFmap.