Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | None |
- makePrisms :: Name -> DecsQ
- makeClassyPrisms :: Name -> DecsQ
- makeDecPrisms :: Bool -> Dec -> DecsQ
Documentation
Generate a Prism
for each constructor of a data type.
Isos generated when possible.
Reviews are created for constructors with existentially
quantified constructors and GADTs.
e.g.
data FooBarBaz a = Foo Int | Bar a | Baz Int Char makePrisms ''FooBarBaz
will create
_Foo :: Prism' (FooBarBaz a) Int _Bar :: Prism (FooBarBaz a) (FooBarBaz b) a b _Baz :: Prism' (FooBarBaz a) (Int, Char)
Generate a Prism
for each constructor of a data type
and combine them into a single class. No Isos are created.
Reviews are created for constructors with existentially
quantified constructors and GADTs.
e.g.
data FooBarBaz a = Foo Int | Bar a | Baz Int Char makeClassyPrisms ''FooBarBaz
will create
class AsFooBarBaz s a | s -> a where
_FooBarBaz :: Prism' s (FooBarBaz a)
_Foo :: Prism' s Int
_Bar :: Prism' s a
_Baz :: Prism' s (Int,Char)
_Foo = _FooBarBaz . _Foo
_Bar = _FooBarBaz . _Bar
_Baz = _FooBarBaz . _Baz
instance AsFooBarBaz (FooBarBaz a) a
| Generate an As class of prisms. Names are selected by prefixing the constructor
name with an underscore. Constructors with multiple fields will
construct Prisms to tuples of those fields.