! {      !"#$%&'()*+,-./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.comSafe-.HUVsquaresType level list append BSD-style (see the file LICENSE)sjoerd@w3future.comSafe &'.=>?@HUVsquaresFunctions 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.squaresJCalculate 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.comSafe &'.=>?HSUVX squaresONatural 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.squaresGCalculate 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.comSafe &'-.>HSUVXcy'squares+Values as a functor from the unit category.)squares4The boring profunctor from and to the unit category.+squares E1--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/squaresBCombine two profunctors from Hask to a profunctor from Hask x Hask1squares FH-f--H | v | p--@--q H = Hask, H = Hask x Hask | v | H-g--H2squaresTo make composing squares associative, this library uses squares with lists of functors and profunctors, which are composed together. tFList '[] 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.GTo 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 {!aWe 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 {Hping 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 '+-----+ | | | /-<f | v | +--f--+The profunctor } f( can be bent down to become the functor f again.Bsquares '+-----+ | | f>-\ | | v | +--f--+The profunctor | f( can be bent down to become the functor f again.Csquares S+-----+ f>-\ | fromLeft | v | === f<-/ | toLeft +-----+B and @$ can be composed vertically to bend | f back to } f.Dsquares U+-----+ | /-<f fromRight | v | === | \->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</ v | toLeft ||| funId | | | === g<--/ | toLeft +-----+Gsquares a+-----+ | /--<f fromRight | | | === | v /<g funId ||| fromRight +-f-g-+Hsquares _+-----+ g>--\ | fromLeft | | | === f>\ | | fromLeft ||| funId +-f-g-+Isquares +f-f-f+ +--f--+ spiderLemma n = |v v v| f> v <f fromLeft ||| funId ||| fromRight | \|/ | | \|/ | === p--@--q ==> p--@--q n | /|\ | | /|\ | === |v v v| g< v >g toLeft ||| funId ||| toRight +g-g-g+ +--g--+eThe 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.;squares<squares=squares>squaresIsquaresJsquares$'()*+,-./0123456789:;<=>?@ABCDEFGHIJ$6789:3452;<=>?@ABCDEFGHIJ1/0,-.+)*'(=6>5 BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.rKsquares '+--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: c+--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--+ Dtraverse = (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.comSafe. Osquares '+-a"_-+ | v | p--@--p | v | +-a"_-+Psquares '+-a"_-+ | v | p--@--p | v | +-a"_-+Qsquares '+-a!_-+ | v | p--@--p | v | +-a!_-+Rsquares '+--f--+ | v | p--@--p | v | +--f--+Ssquares , +-----+ | | (!)-@ | | | +-----+Tsquares (+-----+ | | | @-(!) | | +-----+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 x+-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.comSafe.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 /-<f .<-@ | f \-<g +-----+ 5toComposeCostar = fromRight2 === toCompose === toLeftYZ[\]^_`YZ[\]^_` BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.asquares '+-k!_-+ | v | | @ | | v | +--f--+bsquares '+--f--+ | v | | @ | | v | +-k!_-+abab  BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.csquares '+-----+ | | f<-@->g | | +-----+ +leftAdjunct = unit === (toLeft ||| toRight)dsquares '+-----+ | | g>-@-<f | | +-----+ 2rightAdjunct = (fromLeft ||| fromRight) === counitesquares '+-----+ | | | /@\ | | v v | +-f-g-+ )unit = fromRight ||| leftAdj ||| fromLeftfsquares '+-g-f-+ | v v | | \@/ | | | +-----+ ,counit = toRight ||| rightAdjoint ||| toLeftcdefcdef  BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.fgsquares '+--t--+ | v | f<-@-<f | v | +--t--+ Hcotraverse = (funId ||| fromRight) === distribute === (toLeft ||| funId)hsquares 1+---t-f-+ | v v | | /-@-/ | | v v | +-f-t---+ 0distribute = fromRight ||| cotraverse ||| toLeftghgh  BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.~isquares '+-----+ | | | R | | v | +--m--+jsquares '+--m--+ | v | m>-B | | v | +--m--+B`(>>=)` as a square (or to be precise its flipped version `(=<<)`)Left identity law: k+-----+ | R | +-----+ | v | | | m>-B | === m>-\ | | v | | v | +--m--+ +--m--+Right identity law: k+---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 `(M.>=>)` %(>=>) = fromLeft === bind === toRightijklijkl  BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.msquares '+--w--+ | v | | X | | | +-----+nsquares '+--w--+ | v | w<-E | | v | +--w--+ as a squareRight identity law: k+--w--+ | v | +--w--+ w<-E | | v | | v | === w<-/ | | X | | | +-----+ +-----+Left identity law: k+---w-+ | v | +--w--+ | /-E | | | | | v | | === | v | | X v | | | | +---w-+ +--w--+Associativity law: +--w--+ +---w-+ | v | | v | w<-E | | /-E | | v | === w<E | | w<-E | | | | | | v | w</ v | +--w--+ +---w-+osquares '+---w-+ | v | | /-@ | | v v | +-w-w-+  duplicate = fromRight ||| extendpsquares '+-----+ | /-<w w<-@ | w<-/ | +-----+Cokleisli composition `(W.<=<)` '(<=<) = fromRight === extend === toLeftmnopmnop  BSD-style (see the file LICENSE)sjoerd@w3future.comSafe&'.qsquares '+-----+ | | | @--a | | +-----+rsquares '+-----+ a--\ | | @--a a--/ | +-----+ssquares '+-_"d-+ | v | a--@--a | v | +-_"d-+tsquares 'H-"--H | v | a-@--a | v | H-"--Husquares '+-_"d-+ | v | a--@--a | v | +-_"d-+vsquares 'H-"--H | v | a-@--a | v | H-"--Hqrstuvqrstuv BSD-style (see the file LICENSE)sjoerd@w3future.comSafe.wsquares '+--t--+ | v | !m-@-!m | ? | +--?--+ as a square. Note that because Y ignores its output parameter, this square can have any list of functors as output type.xsquaresx is w specialized to .ysquaresy is w specialized to .zsquares '+--t--+ | v | f>-@->f | | +-----+z is a mapping version of , or a generalization of .wxyzwxyz !"#$%&'()*+,-./01234567899::;<<=>>?@A@BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno p q r s t u v w x y z { | } ~  \ ] {$squares-0.1.1-AMmPSiBmROzCNdBteVP7cYData.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.Foldable.Square 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 duplicate<=<arr>>>***+++foldMapanyallafoldMapbaseGHC.Basefmap(profunctors-5.5.2-KC2L325It2EIdUumqsPs2KData.Profunctor.TypesStarCostar'bifunctors-5.5.7-K3znhqcGXpP3BVPnO58c1JData.Bifunctor.BiffBiff$comonad-5.0.6-JfcN6iPhxp7Eeulcp61Z8tControl.Comonad Data.FoldableForgetasum concatMap