Îõ³h&=.:)„      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc d e f g h i j k l m n o p q r s t u v wxyz{|}~€‚ƒ BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred01ÌÙÚ©squaresType level list append BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred )*1ÁÂÃÄÌÙÚ²squaresFunctions for working with s.squaresCombine 2 nested  s into one .squares Split one  into 2 nested s.squares Convert a  to its simplified form.squares Create a  from its simplified form.squaresÊCalculate the simplified type of the composition of a list of profunctors.squares!N-ary composition of profunctors.      BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred )*1ÁÂÃÌ×ÙÚÜasquaresÏNatural transformations between two functors. (Why is this still not in base??)squaresFunctions for working with s.squaresCombine 2 nested  s into one .squares Split one  into 2 nested s.squares Convert an  to its simplified form.squares Create an  from its simplified form.squaresÇCalculate the simplified type of the composition of a list of functors.squaresN-ary composition of functors. 0FList '[] a ~ a FList '[f, g, h] a ~ h (g (f a))   BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred )*01ÂÌ×ÙÚÜø«'squares+Values as a functor from the unit category.)squares4The boring profunctor from and to the unit category.+squares Å1--a--H | v | U--@--q 1 = Hask^0 = (), H = Hask | v | 1--b--H,squares Uncurry the kind of a bifunctor. 3type UncurryF :: (a -> b -> Type) -> (a, b) -> Type/squaresÂCombine two profunctors from Hask to a profunctor from Hask x Hask1squares ÆH²-f--H | v | p--@--q H = Hask, H² = Hask x Hask | v | H²-g--H2squares†To make composing squares associative, this library uses squares with lists of functors and profunctors, which are composed together. ôFList '[] a ~ a FList '[f, g, h] a ~ h (g (f a)) PList '[] a b ~ a -> b PList '[p, q, r] a b ~ (p a x, q x y, r y b)3squares '+--f--+ | v | p--@--q | v | +--g--+ "forall a b. p a b -> q (f a) (g b)’The complete definition of a square is a combination of natural transformations between functors and natural transformations between profunctors.ÇTo make type inferencing easier the above type is wrapped by a newtype.6squares '+-----+ | | | | | | +-----+  forall a b. (a -> b) -> (a -> b)0The empty square is the identity transformation.7squares '+-----+ | | p-----p | | +-----+ forall a b. p a b -> p a b*Profunctors are drawn as horizontal lines. Note that 6 is 7 for the profunctor (->). We don't draw a line for (->)7 because it is the identity for profunctor composition.8squares '+--f--+ | | | | v | | | | +--f--+ $forall a b. (a -> b) -> (f a -> f b)ßFunctors are drawn with vertical lines with arrow heads. You will recognize the above type as „!áWe don't draw lines for the identity functor, because it is the identity for functor composition.9squares '+--f--+ | | | | @ | | | | +--g--+ $forall a b. (a -> b) -> (f a -> g b)/Non-identity transformations are drawn with an @Ý in the middle. Natural transformations between haskell functors are usualy given the type forall a. f a -> g a. The type above you get when „Èping before or after. (It doesn't matter which, because of naturality!):squares '+-----+ | | p--@--q | | +-----+ forall a b. p a b -> q a b,Natural transformations between profunctors.;squares1A helper function to add the wrappers needed for  and .<squares4A helper function to remove the wrappers needed for  and .=squares ¸+--f--+ +--h--+ +--f--h--+ | v | | v | | v v | p--@--q ||| q--@--r ==> p--@--@--r | v | | v | | v v | +--g--+ +--i--+ +--g--i--+#Horizontal composition of squares. 7 is the identity of =Ä. This is regular function composition of the underlying functions.>squares ê+--f--+ | v | p--@--q +--f--+ | v | | v | +--g--+ p--@--q === ==> | v | +--g--+ r--@--s | v | | v | r--@--s +--h--+ | v | +--h--+!Vertical composition of squares. 8 is the identity of >.?squares '+--f--+ | v | | \->f | | +-----+ A functor f3 can be bent to the right to become the profunctor … f.@squares '+--f--+ | v | f<-/ | | | +-----+ A functor f2 can be bent to the left to become the profunctor † f.Asquares '+-----+ | | | /--\ | | v | +--f--+The profunctor … f( can be bent down to become the functor f again.Csquares Ó+-----+ f>-\ | fromLeft | v | === f<-/ | toLeft +-----+B and @$ can be composed vertically to bend … f back to † f.Dsquares Õ+-----+ | /-f toRight +-----+A and ?$ can be composed vertically to bend † f to … f.Esquares Ý+-f-g-+ | v \>g funId ||| toRight | | | === | \-->f toRight +-----+Fsquares Û+-f-g-+ f--\ | fromLeft | | | === f>\ | | fromLeft ||| funId +-f-g-+Isquares …+f-f-f+ +--f--+ spiderLemma n = |v v v| f> v p--@--q n | /|\ | | /|\ | === |v v v| g< v >g toLeft ||| funId ||| toRight +g-g-g+ +--g--+åThe spider lemma is an example how bending wires can also be seen as sliding functors around corners.Jsquares ÜspiderLemma' n = (toRight === proId === fromRight) ||| n ||| (toLeft === proId === fromLeft)(The spider lemma in the other direction.$'()*+,.-/0123546789:;<=>?@ABCDEFGHIJ$6789:3542;<=>?@ABCDEFGHIJ1/0,.-+)*'(=6>5 BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred1Ksquares '+--t--+ | v | f>-T->f | v | +--t--+K as a square.Naturality law: +-----t--+ +--t-----+ | v | | v | f>-@->T->g === f>-T->@->g | v | | v | +-----t--+ +--t-----+ Identity law: ã+--t--+ +--t--+ | v | | | | | T | === | v | | v | | | | +--t--+ +--t--+Composition law: ‹+--t--+ +--t--+ | v | | v | f>-T->f f>\|/>f | v | === | T | g>-T->g g>/|\>g | v | | v | +--t--+ +--t--+ Ätraverse = (fromLeft ||| funId) === sequence === (funId ||| toRight)Lsquares 1+-f-t---+ | v v | | \-@-\ | | v v | +---t-f-+ ,sequence = toRight ||| traverse ||| fromLeftMsquares 7mapAccumL :: ((s, a) -> (s, b)) -> (s, t a) -> (s, t b)Nsquares 7mapAccumR :: ((s, a) -> (s, b)) -> (s, t a) -> (s, t b)KLMNKLMN BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred1#ä Osquares '+-a—E_-+ | v | p--@--p | v | +-a—E_-+Psquares '+-a•E_-+ | v | p--@--p | v | +-a•E_-+Qsquares '+-a’C_-+ | v | p--@--p | v | +-a’C_-+Rsquares '+--f--+ | v | p--@--p | v | +--f--+Ssquares , +-----+ | | (’C)-@ | | | +-----+Tsquares (+-----+ | | | @-(’C) | | +-----+Usquares , +-----+ | /-p q.p-@ | | \-q +-----+Vsquares - +-----+ p-\ | | @-q.p q-/ | +-----+Wsquares Ý+--f--+ +--f--+ | v | | B--@--q Biff q f g is the "universal filler for the niche": q | v | | +--g--+ +--g--+Xsquares ø+-h-f-+ | v v | +--h--+ | \ / | | v | p--@--q -> p--@--B | / \ | | v | | v v | +--k--+ +-k-g-+"This is the universal property of ‡. OPQRSTUVWX OPQRSTUVWX BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred1&óYsquares , +--I--+ | v | | @ | | | +-----+Zsquares '+-----+ | | | @ | | v | +--I--+[squares , +-g.f-+ | v | | /@\ | | v v | +-f-g-+\squares '+-----+ f /->f .>-@ | g \->g +-----+ 7fromComposeStar = fromLeft === fromCompose === toRight2]squares '+-----+ f<-\ g | @-<. g<-/ f +-----+ 9fromComposeCostar = fromRight === fromCompose === toLeft2^squares , +-f-g-+ | v v | | \@/ | | v | +-g.f-+_squares '+-----+ f>-\ f | @->. g>-/ g +-----+ 3toComposeStar = fromLeft2 === toCompose === toRight`squares '+-----+ g /-g | | +-----+ +leftAdjunct = unit === (toLeft ||| toRight)dsquares '+-----+ | | g>-@--B | | v | +--m--+ˆ3 as a square (or to be precise its flipped version ‰)Left identity law: ë+-----+ | R | +-----+ | v | | | m>-B | === m>-\ | | v | | v | +--m--+ +--m--+Right identity law: ë+---m-+ | R v | +--m--+ | v | | | | | | \-B | === | v | | v | | | | +---m-+ +--m--+Associativity law: ‹+--m--+ +---m-+ | v | m>\ v | m>-B | | v | | | v | === m>B | | m>-B | | \-B | | v | | v | +--m--+ +---m-+ksquares '+-m-m-+ | v v | | \-@ | | v | +---m-+ join = toRight ||| bindlsquares '+-----+ m>-\ | m>-@ | | \->m +-----+Kleisli composition Š %(>=>) = fromLeft === bind === toRightijklijkl  BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred12msquares '+--w--+ | v | | X | | | +-----+nsquares '+--w--+ | v | w<-E | | v | +--w--+‹ as a squareRight identity law: ë+--w--+ | v | +--w--+ w<-E | | v | | v | === w<-/ | | X | | | +-----+ +-----+Left identity law: ë+---w-+ | v | +--w--+ | /-E | | | | | v | | === | v | | X v | | | | +---w-+ +--w--+Associativity law: ‹+--w--+ +---w-+ | v | | v | w<-E | | /-E | | v | === w h--@ | h-/| | | v | | v | +--g--+ +--g--+4Any square like the one on the left factors through |. } gives the remaining square.~squares '+--R--+ | v | j--@ | | v | +--g--+squares ó+--f--+ | v | +--f--+ h-\| | | v | | @ | ==> h--@ | j-/| | | v | | v | +--R--+ +--g--+4Any square like the one on the left factors through ~.  gives the remaining square. wyxz{|}~ z{|}wyx~ BSD-style (see the file LICENSE)sjoerd@w3future.com Safe-Inferred1:€squares '+--t--+ | v | !m-@-!m | ? | +--?--+Œ as a square. Note that because Ù ignores its output parameter, this square can have any list of functors as output type.squares is € specialized to .‚squares‚ is € specialized to .ƒsquares '+--t--+ | v | f>-@->f | | +-----+ƒ is a mapping version of Ž, or a generalization of .€‚ƒ€‚ƒ !"#$%&'()*+,-./0123456789:;<<==>??@AABCDCEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr s t u v w x y z { | } ~   €  _ ‚ ` ƒ„„…††‡ˆ‰Š‹ŒŽ‘’“”’“•–—˜™š›|œ~ž‹’“Ÿž ž¡¢"squares-0.2-2oA0JDF6MuqBj7o2nq9kSvData.Type.List Data.Profunctor.Composition.ListData.Functor.Compose.List Data.SquareData.Traversable.SquareData.Profunctor.SquareData.Functor.SquareData.Functor.Rep.SquareData.Functor.Adjunction.SquareData.Distributive.SquareControl.Monad.SquareControl.Comonad.SquareControl.Arrow.SquareData.Functor.Kan.SquareData.Foldable.SquareW<=< Data.MonoidAnyAll++IsPListpappend punappendtoPlainP fromPlainPPlainPPListHomPPCompunHomunP$fProfunctorPList$fProfunctorPList0$fProfunctorPList1 $fIsPList: $fIsPList:0 $fIsPList[]~>IsFListfappend funappendtoPlainF fromPlainFPlainFFListIdFFCompunIdunFunFComp$fFunctorFList$fFunctorFList0$fFunctorFList1 $fIsFList: $fIsFList:0 $fIsFList[]ValueFUnitSquare01UncurryFcurryF:**:Square21SquareSquareNTunSquare emptySquareproIdfunIdfunNatproNatmkSquare runSquare|||===toRighttoLeft fromRightfromLeftuLeftuRighttoRight2toLeft2 fromRight2 fromLeft2 spiderLemma spiderLemma'traversesequence mapAccumL mapAccumRsecondrightclosedmapfromHomtoHomfromProcompose toProcomposefromBifftoBiff fromIdentity toIdentity fromComposefromComposeStarfromComposeCostar toCompose toComposeStartoComposeCostartabulateindex leftAdjunct rightAdjunctunitcounit cotraverse distributereturnbindjoin>=>extractextend duplicatearr>>>***+++RanrunRanLan lanSquare lanFactor ranSquare ranFactorfoldMapanyallafoldMapbaseGHC.Basefmap(profunctors-5.6.2-4ODtuOgqw2dHLNfZGgKnhDData.Profunctor.TypesStarCostar'bifunctors-5.6.1-42auZdaVIr46uhebkv4FdqData.Bifunctor.BiffBiff>>==<< Control.Monad$comonad-5.0.8-1zfoK1lQeVy2YK4KZkoAKGControl.Comonad Data.FoldableForgetasum concatMap