QG 5      !"#$%&'()*+, - . / 0 1 2 3 4  Safe-Inferred Strict Pair The shape of a 5  A reified 6. Strict 7  Reversed '[]'  89:;<=>?@      89:;<=>?@ TrustworthyPartially apply a $ to some initial input on the left. Apply a  to a container full of input: $run ["hello","world"] $ L id (++) [] "helloworld"run [1,2,3] $ L id (+) 06Apply a  to a single element of input Lift a  into a A. 'This acts like a generalized notion of " costrength",  when applied to a , causing it to return the 7 left-most value that fails to match the Prism, or the ) result of accumulating rewrapped in the A if  everything matches. 9run [Left 1, Left 2, Left 3] $ beneath _Left $ R id (+) 0Left 6;run [Left 1, Right 2, Right 3] $ beneath _Left $ R id (+) 0Right 2  , beneath :: Prism s t a b -> p a b -> p s t , beneath :: Iso s t a b -> p a b -> p s t BCDBCD TrustworthyA Moore Machine IConstruct a Moore machine from a state valuation and transition function E efficient , leaky   FGHIJKLMNOEP   FGHIJKLMNOEP Trustworthy!A strict left fold / strict Moore machine #PConstruct a strict Moore machine from a state valuation and transition function Q efficient , leaky  RS!"#TUVWXYZ[\]Q^!"#!"#RS!"#TUVWXYZ[\]Q^ Trustworthy$A Mealy Machine _`a$%bcdefghijklmno$%$%_a`$%bcdefghijklmno Trustworthy&A strict Mealy Machine pqr&'stuvwxyz{|}~&'&'prq&'stuvwxyz{|}~ Trustworthy(A 5, caught in amber. a.k.a. a monoidal reducer  efficient  , efficient  ()()() () Trustworthy*A semigroup reducer *+*+*+*+  Trustworthy, right folds / a reversed Moore machine leaky  , efficient  ,-,-,- ,-  Trustworthy.A reversed Mealy machine ././././  non-portable experimentalEdward Kmett <ekmett@gmail.com> Safe-Inferred 114 is a folding homomorphism to a strict left folding    xs (1 ) "a  xs    xs (1 ) "a 1 ( xs )   l xs (1 ) "a 1 ( l xs )   (1 ) xs "a 1 (  xs)   l (1 ) xs "a 1 ( l  xs)  left' (1 ) "a 1 (left' )  right' (1 ) "a 1 (right' )  dimap l r (1 ) "a 1 (dimap l r )  extract (1 ) "a extract   pure a "a 1 (pure a)  1  <*> 1  "a 1 ( <*> )   a "a 1 ( a)  1   1 . k "a 1 (  k)   p (1 ) "a 1 ( p )   a (1 ) "a 1 ( a ) 331 is a folding homomorphism to a monoidal folding    xs (3 ) "a  xs    xs (3 ) "a 3 ( xs )   l xs (3 ) "a 3 ( l xs )   (3 ) xs "a 3 (  xs)   l (3 ) xs "a 3 ( l  xs)  left' (3 ) "a 3 (left' )  right' (3 ) "a 3 (right' )  dimap l r (3 ) "a 3 (dimap l r )  extract (3 ) "a extract   pure a "a 3 (pure a)  3  <*> 3  "a 3 ( <*> )   a "a 3 ( a)  3   3 . k "a 3 (  k)   p (3 ) "a 3 ( p )   a (3 ) "a 3 ( a ) 44. is a folding homomorphism to a right folding    xs (4 ) "a  xs    xs (4 ) "a 4 ( xs )   l xs (4 ) "a 4 ( l xs )   (4 ) xs "a 4 (  xs)   l (4 ) xs "a 4 ( l  xs)  left' (4 ) "a 4 (left' )  right' (4 ) "a 4 (right' )  dimap l r (4 ) "a 4 (dimap l r )  extract (4 ) "a extract   pure a "a 4 (pure a)  4  <*> 4  "a 4 ( <*> )   a "a 4 ( a)  4   4 . k "a 4 (  k)   p (4 ) "a 4 ( p )   a (4 ) "a 4 ( a ) BWe can convert from a lazy left folding to a strict left folding. %We can convert a lazy fold to itself FWe can convert from a strict left folding to a right or monoidal fold DWe can convert from a lazy left folding to a right or monoidal fold 9We can convert from a monoidal fold to a lazy right fold 9We can convert from a lazy right fold to a monoidal fold 01234#!"$%&'()*+,-./01234#$%&'*+./!"(),-23401 01234    !"#$%&'(()**+,,--..// 0 0 1 1 2 3 4 5 67897:;7<=>?@ABCDEFGHIJKLMNOPQRSTUVWXXYZ[\]^_`abcdefghijklmnopqrstdefguvwxyz{|}~g    g 77   folds-0.3Data.Fold.InternalData.Fold.Class Data.Fold.L Data.Fold.L' Data.Fold.L1 Data.Fold.L1' Data.Fold.M Data.Fold.M1 Data.Fold.R Data.Fold.R1 Data.FoldPair'TreeTwoOneZeroNrunNMaybe'Just'Nothing'SnocListNilSnocmaybe'FoldingprefixprefixOfpostfix postfixOfrunrunOf filteringScanprefix1postfix1run1 interspersingbeneathLunfoldLL'unfoldL'L1L1'MM1RR1AsL'asL'AsRMasMasRbase Data.FoldablefoldMap Data.MonoidMonoid Data.MaybeMaybe $fMonoidPair'$fTraversableTree$fFoldableTree $fFunctorTree $fMonoidN$fFoldableMaybe'$fTraversableSnocList$fFoldableSnocList$fFunctorSnocList lens-3.9.0.3Control.Lens.TypePrism $fFoldableOne $fFoldingL$fComonadApplyL$fApplyL $fExtendL$fMonadL$fBindL$fApplicativeL $fComonadL $fFunctorL $fChoiceL $fProfunctorL$fScanL $fFoldingL'Pair$fComonadApplyL' $fApplyL' $fExtendL' $fMonadL'$fBindL'$fApplicativeL' $fComonadL' $fFunctorL' $fChoiceL'$fProfunctorL'$fScanL' SnocList1FirstSnoc1walk$fArrowChoiceL1 $fChoiceL1 $fStrongL1$fProfunctorL1 $fArrowL1 $fCategoryL1$fSemigroupoidL1 $fMonadL1$fApplicativeL1 $fApplyL1 $fPointedL1 $fFunctorL1$fScanL1$fArrowChoiceL1' $fChoiceL1' $fStrongL1'$fProfunctorL1' $fArrowL1' $fCategoryL1'$fSemigroupoidL1' $fMonadL1'$fApplicativeL1' $fApplyL1' $fPointedL1' $fFunctorL1' $fScanL1' $fFoldingM$fComonadApplyM$fApplyM $fExtendM$fMonadM$fBindM$fApplicativeM $fComonadM $fFunctorM $fChoiceM $fProfunctorM$fScanMTree1Tip1Bin1$fArrowChoiceM1 $fChoiceM1 $fStrongM1$fProfunctorM1 $fArrowM1 $fCategoryM1$fSemigroupoidM1 $fMonadM1$fApplicativeM1 $fApplyM1 $fPointedM1 $fFunctorM1$fScanM1 $fFoldingR$fComonadApplyR$fApplyR $fExtendR$fApplicativeR$fMonadR$fBindR $fComonadR $fFunctorR $fChoiceR $fProfunctorR$fScanRList1LastCons1$fArrowChoiceR1 $fChoiceR1 $fStrongR1$fProfunctorR1 $fArrowR1 $fCategoryR1$fSemigroupoidR1 $fMonadR1$fApplicativeR1 $fApplyR1 $fPointedR1 $fFunctorR1$fScanR1GHC.Basereturn>>=$fAsL'L$fAsL'L'$fAsRML'$fAsRML$fAsRMM$fAsRMRBox