úÎS¬Oï     9Generic folding for various endomorphism representations.(c) 2014-2015, Peter TrakoBSD3peter.trsko@gmail.com experimentaliCPP, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, NoImplicitPrelude, TypeFamilies Safe-Inferred +024=K Wrapper for  instances.This allows using  and  for any  instance without the need for OverlappingInstances language extension.aClass that represents various endomorphism representation. In other words anything that encodes a -> a can be instance of this class.BHere are some important instances with not so obvious definitions.  instance  ( a) where type  ( a) = a  _ =  -- = Endo    _ =  It got quite common to use “ data type as an explicit way to pass types around. Above instance allows you to restrict type of result of endomorphism folding, to some extent.  instance  a =>  (Maybe a) where type  (Maybe a) =  a  Nothing =  -- = Endo   (Just e) =  e -- Definition of   is analogous.  Instance for MaybeB lets us conditionally inject endomorphism in to a folding chain.7Extract type on which endomorphism operates, e.g. for  a it would be a.Convert value encoding a -> a in to . Default implementation:  =  .   Dual to . Default implementation:   =   .  Class of arguments for  and its dual  functions.)Note that results are instances of this ( ;) class and endomorphism representations are instances of  type class. 8Extracts type of a value that is modified by the result. YResult type of the whole endomorphism folding. It can be used to restrict the result of  and  . Example: -- Type restricted version of A that forces the result of the -- whole folding machinery to be " Int". myFoldEndo :: (  args ~  Int,  ( args) => args -> args myFoldEndo =  DFold all variously represented endomorphisms in to one endomorphism.5Order in which endomorphisms are folded is preserved:.foldEndo (Endo (1:)) [(2:), (3:)] `appEndo` [][1,2,3]For numbers it would look like:-foldEndo (Endo (+1)) [(+2), (*3)] `appEndo` 16Above can be seen as:(+1) . (+2) . (*3) $ 16Same as +, but folds endomorphisms in reverse order.'Following are the same examples as for 4 function. Please, note the differences in results.4Order in which endomorphisms are folded is reversed:2dualFoldEndo (Endo (1:)) [(2:), (3:)] `appEndo` [][2,3,1]For numbers it would look like:1dualFoldEndo (Endo (+1)) [(+2), (*3)] `appEndo` 112Above can be seen as:(*3) . (+2) . (+1) $ 112Variant of function () :: (a -> b) -> a -> b, from  Data.Function module, but with fixity as () :: a -> (a -> b) -> b function from  Data.Function3 module (available in base since version 4.8.0.0).Variant of function () :: ! f => (a -> b) -> a -> b from  Data.Functor module, but with fixity as  function.Use  (possibly result of 0) and use it to create value of different type. Examples:    :: (Monad m,  e, w ~  e) => e ->   ( w) m ()    :: (Monad m,  e, s ~  e) => e ->    s m ()  See also .Dual to  , which uses   instead of ."Fold in reverese order.#<Constructs identity endomorphism for specified phantom type.$4This instance can be used in cases when there is no   instance for a specific % functor. Example:  $  <*> & parseSomething <*> & parseSomethingElse '=Allows endomorphism folding for endomorphisms wrapped inside ( monad. Examples: : <*> ((++) <$> getLine) <*> ((++) <$> getLine) :: :: (  r,   r ~ String) => IO r In the next example, prefix ghci> indicates GHCi prompt, ghci| is GHCi continuation prompt, <<< indicates user input and >>> GHCi output. Also, :{ and :}D is GHCi's way of starting and ending multiline mode, respectively. ghci> :{ ghci|  ""  m ghci| <*> ((++) <$> getLine) ghci| <*> ((++) <$> getLine) ghci| :} <<< alpha <<< bet >>> "alphabet" )6This basically discards result of folding, in example:0foldEndo ('n':) ('o':) :: Const () (Endo String)Const ()*Recurse along   instances if first argument is (. This instance is actually what makes  and  variadic-like.5 Embedding function.Embedding function.+,-./0123"45#6789:;<=>?@A$BCD'EF)G*   ,  +,-./0123"45#6789:;<=>?@A$BCD'EF)G*Utilities for Endo data type.(c) 2013-2015, Peter TrakoBSD3peter.trsko@gmail.com experimentalNoImplicitPrelude Safe-InferredIType synonym for endomorphsm; it can be used to simplify type signatures.Transform function wrapped in . Variation of  for functions with arity two.Apply H to function wrapped in . It's a short hand for  H.Flipped version of . Lens for . In terms of lens package it would have type:  :: Lens ( a) ( b) ( a) ( b) For details see  'http://hackage.haskell.org/package/lens lens package.  I !"#$%&'()*+,-./01234526789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`2ab endo-0.2.0.1Data.Monoid.EndoData.Monoid.Endo.Fold Data.Function$& Data.Functor<$>Control.Monad.Trans.Writer.LazytellWriterTControl.Monad.Trans.State.LazymodifyStateTControl.Monad.Trans.Identity runIdentityTControl.Monad.EndorunEndobase Data.MonoidappEndoEndoWrappedFoldable WrapFoldable getFoldableAnEndoEndoOperatesOnanEndo aDualEndo FoldEndoArgsResultOperatesOnResult foldEndoArgsdualFoldEndoArgsfoldEndo dualFoldEndo&$<&$> embedEndoWithembedDualEndoWithEmapEndomapEndo2liftEndoendo Data.FoldableFoldable Data.ProxyProxymemptyGHC.BaseidgetDualDualFunctor$fAnEndoReverse $fAnEndoProxy$fFoldEndoArgsIdentityTControl.Applicative Applicativetransformers-0.3.0.0 IdentityT$fFoldEndoArgsIOghc-prim GHC.TypesIO$fFoldEndoArgsConst$fFoldEndoArgs(->)$fAnEndo(,,,,,,,,,)$fAnEndo(,,,,,,,,)$fAnEndo(,,,,,,,)$fAnEndo(,,,,,,)$fAnEndo(,,,,,)$fAnEndo(,,,,) $fAnEndo(,,,) $fAnEndo(,,) $fAnEndo(,) $fAnEndo[]$fAnEndoWrappedFoldable $fAnEndoMaybe $fAnEndo(->) $fAnEndoEndo$fFoldEndoArgsWriterT$fFoldEndoArgsWriterT0$fFoldEndoArgsStateT$fFoldEndoArgsStateT0$fFoldEndoArgsRWST$fFoldEndoArgsRWST0$fFoldEndoArgsReaderT$fFoldEndoArgsMaybeT$fFoldEndoArgsListT$fFoldEndoArgsProduct$fFoldEndoArgsCompose$fFoldEndoArgsMaybe$fFoldEndoArgsIdentity$fFoldEndoArgsEither$fFoldEndoArgsEndofmap