putlenses-0.1.3: Put-based lens library

Copyright(C) 2013 Hugo Pacheco
LicenseBSD-style (see the file LICENSE)
MaintainerHugo Pacheco <hpacheco@nii.ac.jp>
Safe HaskellNone



Template Haskell procedures to generate default putlenses for record types and default putlens constructors and destructores for Generic instances.



makePutlensFields :: Name -> Q [Dec] Source

Generates field putlenses for record types For a record data T a = T { t1 :: String, t2 :: a } $( makePutlensFields ''T ) it generates two putlenses t1Put :: Monad m => PutlensM m e (T a) String t2Put :: Monad m => PutlensM e (T a) a

makePutlensConstructors :: Name -> Q [Dec] Source

Generates constructor and destructor putlenses for data types that are Generic instances For an algebraic data type data List a = Nil | Cons a [a] deriving Generic $( makePutlensConstructors ''List ) it generates two constructors nilPut :: MonadPlus m => PutlensM m e (List a) () nilPut = innPut .< injlPut consPut :: Monad m => PutlensM m e (List a) (a,List a) consPut = innPut .< injrPut and two destructors unnilPut :: Monad m => PutlensM m e () (List a) unnilPut = uninjlPut .< outPut unconsPut :: Monad m => PutlensM m e (a,List a) (List a) unconsPut = uninjrPut .< outPut