deriving-compat-0.6.7: Backports of GHC deriving extensions
Copyright(C) 2015-2017 Ryan Scott
LicenseBSD-style (see the file LICENSE)
MaintainerRyan Scott
PortabilityTemplate Haskell
Safe HaskellNone
LanguageHaskell2010

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

Functor

deriveFunctor :: Name -> Q [Dec] Source #

Generates a Functor 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 Functor 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 Functor 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 FunctorFoldableTraversable.)

Constructors

FFTOptions 

Fields

  • fftEmptyCaseBehavior :: Bool

    If True, derived instances for empty data types (i.e., ones with no data constructors) will use the EmptyCase language extension. If False, derived instances will simply use seq instead. (This has no effect on GHCs before 7.8, since EmptyCase is only available in 7.8 or later.)

Instances

Instances details
Read FFTOptions Source # 
Instance details

Defined in Data.Functor.Deriving.Internal

Methods

readsPrec :: Int -> ReadS FFTOptions

readList :: ReadS [FFTOptions]

readPrec :: ReadPrec FFTOptions

readListPrec :: ReadPrec [FFTOptions]

Show FFTOptions Source # 
Instance details

Defined in Data.Functor.Deriving.Internal

Methods

showsPrec :: Int -> FFTOptions -> ShowS

show :: FFTOptions -> String

showList :: [FFTOptions] -> ShowS

Eq FFTOptions Source # 
Instance details

Defined in Data.Functor.Deriving.Internal

Methods

(==) :: FFTOptions -> FFTOptions -> Bool

(/=) :: FFTOptions -> FFTOptions -> Bool

Ord FFTOptions Source # 
Instance details

Defined in Data.Functor.Deriving.Internal

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 have Functor constraints. If this is not desirable, use makeFmap.