&      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~#Convert endomorphism in to a value.(c) 2015, Peter TrakoBSD3peter.trsko@gmail.com experimentalNoImplicitPreludeSafe9;DR1Type class provides functionality for converting  b and  ( b) in to some type a. Type b6, on which endomorphism operates, is implied by type aO, but generally aren't the same type. In other words it is dual type class to .+Convert endomorphism in to a value of type a. Provided default implementation:  =    8In a lot of cases it is necessary to evaluate result of  . Example:IfromEndoWith ((`runState` def) :: State Int () -> ((), Int)) (Endo (+10))((), 10)Following property holds:   =   See also  .Same as , but deals with  wrapped inside a . 8In a lot of cases it is necessary to evaluate result of  . Example:PfromEndoWith ((`runState` def) :: State Int () -> ((), Int)) (Dual (Endo (+10)))((), 10)Following property holds:    =   See also . Same as  , but deals with   wrapped inside a .  Variant of 0 that takes type restriction on the result type a as an argument.  Variant of 1 that takes type restriction on the result type a as an argument.  Modify state.  ( f) =  f  Modify state.  ( f) =  f  Modify state.  ( f) =  f  Modify state.  ( f) =  f .Retrieve environment modified by endomorphism.  ( f) =  f      sApplyEndo provides easier endomorphism evaluation in cases when there is an "obvious" default value.(c) 2015-2016, Peter TrakoBSD3peter.trsko@gmail.com experimentalCPP, DeriveFoldable, DeriveFunctor, DeriveDataTypeable, DeriveGeneric, DeriveTraversable, FlexibleInstances, NoImplicitPrelude, TypeFamiliesNone 023459;DIRSame as , but strictness is implied.Type tag identifying usage of  operation in  instance of .Type tag identifying usage of  operation in  instance of .Type tag identifying usage of  from .Type tag identifying usage of  from .There are cases when it is "obvious" what is the default value, which should be modified by the endomorphism. This type is a result of such endomorphism application and it uses phantom type tP as distinguishing property, which decides what is the correct "default value".2Apply endomorphism using provided "default" value. Similar as , but expects  to be wrapped by a .Constrained version of . Usage example: applyMempty . fromEndo :: ( f,  a) =>  a -> f a Same as , but  functor is specialized to  functor and evaluated. Examples:?fromEndoWith applyMempty_ $ foldEndo (+1) [(*10), (+42)] :: Int421CfromEndoWith applyMempty_ $ dualFoldEndo (+1) [(*10), (+42)] :: Int52! Evaluates  in a R by joining it with the monad it contains. It can be also viewed as a variant of  defined as: ! = ( ) "Constrained version of . Usage example: applyDef . fromEndo :: ( f,  a) =>  a -> f a #Same as ", but  functor is specialized to  functor and evaluated. Examples:<fromEndoWith applyDef_ $ foldEndo (+1) [(*10), (+42)] :: Int421@fromEndoWith applyDef_ $ dualFoldEndo (+1) [(*10), (+42)] :: Int52$ Evaluates  in a R by joining it with the monad it contains. It can be also viewed as a variant of " defined as: $ = ( ") % Evaluates  in terms of  operation.This (->) r is a valid 0 instance, therefore, this is a valid use case:7(applyReader . fromEndo $ foldEndo (*10) (+1)) 0 :: Int10& Evaluates  in terms of B operation and then evaluates the resalt using provided function.This (->) r is a valid 0 instance, therefore, this is a valid use case:=applyReaderWith ($ 0) . fromEndo $ foldEndo (*10) (+1) :: Int10' Evaluates  in a R by joining it with the monad it contains. It can be also viewed as a variant of % defined as: ' = ( %) ( Evaluates  in terms of  operation.) Evaluates  in a R by joining it with the monad it contains. It can be also viewed as a variant of ( defined as: ) = ( () * Evaluates  in terms of  operation.+ Evaluates  in a R by joining it with the monad it contains. It can be also viewed as a variant of * defined as: + = ( *) , Evaluates  in terms of  operation:  ( f) =  . / $ \s -> let s' = f s in s' `seq` (s', s') - Evaluates  in terms of  operation:  e =  .   \s -> let s' =  e s in (s', s') . Evaluates  in terms of  operation:  =  .  .   !"#$%&'()*+,-./012 !"#$%&'()*+ !"#$%&'()*+ !"#$%&'()*+,-./012)Conversion of values in to endomorphisms.(c) 2014-2016, Peter TrakoBSD3peter.trsko@gmail.com experimentaliCPP, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, NoImplicitPrelude, TypeFamiliesNone 023459;DIR B Wrapper for 5 types. Used to provide instances that work for all  types without the need for OverlappingInstances language extension.EaClass 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 E ( a) where type F ( a) = a G _ =  -- = Endo  H _ =  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 E a => E ( a) where type F ( a) = F a G  =  -- = Endo  G ( e) = G e -- Definition of H is analogous.  Instance for MaybeB lets us conditionally inject endomorphism in to a folding chain.  instance E a => E ( a) where type F ( a) = F a G ( e) = G e H ( e) = H e $Above instance allows us to discard Z wrapper, which is commonly used in data types that are parametrized by functor or monad.F7Extract type on which endomorphism operates, e.g. for ( a) it would be a.GConvert value encoding (a -> a) in to . Default implementation: G =  . H HDual to G. Default implementation: H =  . G IUse  (possibly result of 0) and use it to create value of different type. Examples: I   :: (Monad m, E e, w ~ F e) => e ->    ( w) m () I (  . ) :: (Monad m, E e, s ~ F e) => e ->   s m ()  See also J.JDual to I , which uses H instead of G.TFold in reverese order.YHas same semantics as ) and it is actually defined in terms of E instance for .Z<Constructs identity endomorphism for specified phantom type.BCDEFGHIEmbedding function.JEmbedding function.KLMNOPQRSTUVWXYZ[\]^ BCDEFGHIJ EFGHBCDIJBCDEFGHIJKLMNOPQRSTUVWXYZ[\]^9Generic folding for various endomorphism representations.(c) 2014-2016, Peter TrakoBSD3peter.trsko@gmail.com experimentalCPP, DeriveDataTypeable, DeriveGeneric, FlexibleInstances, NoImplicitPrelude, RankNTypes, TypeOperators, TypeFamiliesNone 9;DOQRT kXType alias that restricts type of endomorphism folding result, and it looks similar to ->!. Example of creating version of q with specific result: foldToEndoString :: l args => args k  String foldToEndoString = q 6foldToEndoString ("foo" <>) ("bar" <>) `appEndo` "baz" "foobarbaz"Following type signatures for o are equivalent: l args => args k  String (l args, n args ~  String) => args lClass of arguments for q and its dual r functions.)Note that results are instances of this (l;) class and endomorphism representations are instances of E type class.m8Extracts type of a value that is modified by the result.nYResult type of the whole endomorphism folding. It can be used to restrict the result of q and p . Example: -- Type restricted version of qA that forces the result of the -- whole folding machinery to be " Int". myFoldEndo :: (n args ~  Int, l( args) => args -> args myFoldEndo = q qDFold 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) $ 16rSame as q+, but folds endomorphisms in reverse order.'Following are the same examples as for q4 function. Please, note the differences in results.4Order in which endomorphisms are folded is reversed:2dualFoldEndo (Endo (1:)) [(2:), (3:)] `appEndo` [][3,2,1]For numbers it would look like:1dualFoldEndo (Endo (+1)) [(+2), (*3)] `appEndo` 112Above can be seen as:(*3) . (+2) . (+1) $ 112sVariant 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).tVariant of function () ::  f => (a -> b) -> a -> b from  Data.Functor module, but with fixity as s function.4This instance can be used in cases when there is no l instance for a specific  functor. Example:  $ q <*>  parseSomething <*>  parseSomethingElse =Allows endomorphism folding for endomorphisms wrapped inside  monad. Examples: q7 <*> ((<>) <$> getLine) <*> ((<>) <$> getLine) :: (l r, m 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|  "" t qm 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 l instances if first argument is E(. This instance is actually what makes q and r variadic-like.klmnopqrstuvwxyz{|}~BCDEFGHIJklnmopqrstqrlmnopEFGHBCDkstIJklmnopqrstuvwxyz{|}~s1t1Utilities for Endo data type.(c) 2013-2015, Peter TrakoBSD3peter.trsko@gmail.com experimentalNoImplicitPreludeSafeIType synonym for endomorphsm; it can be used to simplify type signatures.Transform function wrapped in . Variation of  for functions with arity two.Apply  to function wrapped in . It's a short hand for  .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.   !"#$%&'()*+,-./01233456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ #endo-0.3.0.0-FDoQmRwl62o5XNvfgqOehrData.Monoid.EndoData.Monoid.Endo.FromEndoData.Monoid.Endo.ApplyData.Monoid.Endo.AnEndoData.Monoid.Endo.FoldAnEndoData.Endo.FoldfoldEndoControl.Monad.Trans.Writer.LazytellWriterTControl.Monad.Trans.State.Lazymodify Data.MonoidappEndoStateT Data.Function$& Data.Functor<$>Control.Monad.Trans.Identity runIdentityTControl.Monad.EndorunEndobaseEndoFromEndoEndoOperatedOnfromEndo fromDualEndo fromEndoWith fromEndoWithFfromDualEndoWithfromDualEndoWithF fromEndoTofromDualEndoTo$fFromEndoStateT$fFromEndoStateT0$fFromEndoRWST$fFromEndoRWST0$fFromEndoReaderT$fFromEndoDual$fFromEndoEndo$fFromEndo(->)Modify'ModifyReaderDefMempty ApplyEndo applyEndoapplyapplyF applyMempty applyMempty_joinApplyMemptyapplyDef applyDef_ joinApplyDef applyReaderapplyReaderWithjoinApplyReader applyModifyjoinApplyModify applyModify'joinApplyModify'$fFromEndoApplyEndo$fFromEndoApplyEndo0$fFromEndoApplyEndo1$fFromEndoApplyEndo2$fFromEndoApplyEndo3$fShow1ApplyEndo$fRead1ApplyEndo$fApplicativeApplyEndo$fFoldableApplyEndo$fFunctorApplyEndo$fGenericApplyEndo$fGeneric1ApplyEndo$fMonadApplyEndo$fTraversableApplyEndo$fDataApplyEndo$fEq1ApplyEndo$fOrd1ApplyEndo$fGenericMempty $fGenericDef$fGenericReader$fGenericModify$fGenericModify'WrappedFoldable WrapFoldable getFoldableEndoOperatesOnanEndo aDualEndo embedEndoWithembedDualEndoWith$fAnEndo(,,,,,,,,,)$fAnEndo(,,,,,,,,)$fAnEndo(,,,,,,,)$fAnEndo(,,,,,,)$fAnEndo(,,,,,)$fAnEndo(,,,,) $fAnEndo(,,,) $fAnEndo(,,) $fAnEndo(,)$fAnEndoReverse $fAnEndo[]$fAnEndoWrappedFoldable$fShow1WrappedFoldable$fRead1WrappedFoldable$fAnEndoOption $fAnEndoProxy $fAnEndoMaybe$fAnEndoIdentity $fAnEndo(->) $fAnEndoEndo$fApplicativeWrappedFoldable$fFoldableWrappedFoldable$fFunctorWrappedFoldable$fGenericWrappedFoldable$fGeneric1WrappedFoldable$fMonadWrappedFoldable$fReadWrappedFoldable$fShowWrappedFoldable$fTraversableWrappedFoldable$fDataWrappedFoldable$fEq1WrappedFoldable$fOrd1WrappedFoldable:-> FoldEndoArgsResultOperatesOnResult foldEndoArgsdualFoldEndoArgs dualFoldEndo&$<&$>$fFoldEndoArgsWriterT$fFoldEndoArgsWriterT0$fFoldEndoArgsStateT$fFoldEndoArgsStateT0$fFoldEndoArgsRWST$fFoldEndoArgsRWST0$fFoldEndoArgsReaderT$fFoldEndoArgsMaybeT$fFoldEndoArgsListT$fFoldEndoArgsExceptT$fFoldEndoArgsIdentityT$fFoldEndoArgsProduct$fFoldEndoArgsCompose$fFoldEndoArgsMaybe$fFoldEndoArgsIO$fFoldEndoArgsIdentity$fFoldEndoArgsEither$fFoldEndoArgsConst$fFoldEndoArgsEndo$fFoldEndoArgs(->)EmapEndomapEndo2liftEndoendoDualGHC.Base.getDualidFunctortransformers-0.5.2.0 Control.Monad.Trans.State.StrictControl.Monad.Trans.RWS.StrictControl.Monad.Trans.RWS.LazyControl.Monad.Trans.Readerasks mtl-2.2.1-6qsR1PHUy5lL47Hpoa4jCMControl.Monad.State.ClassstateControl.Monad.Reader.Class1data-default-class-0.1.2.0-FYQpjIylblBDctdkHAFeXAData.Default.ClassdefDefaultmemptyMonoid ApplicativeData.Functor.IdentityIdentityMonad>>= MonadReader Data.FoldableFoldable Data.ProxyProxyMaybeNothingJust IdentityTghc-prim GHC.TypesIOfmap