ekmett / bifunctors

Haskell 98 bifunctors, bifoldables and bitraversables
Other
57 stars 42 forks source link

(Bi?)Compose #57

Closed Icelandjack closed 7 years ago

Icelandjack commented 7 years ago

Section 3 of Constructing Applicative Functors describes defining ZipList as a fixed point of the composition of Maybe ∘ ×. If we have a composition of a functor and a bifunctor

newtype (f · g) a b = C (f (g a b))

we can define ZipList as Fix (Maybe · (,))

type ZipList = Fix (Maybe · (,))

pattern Nil :: ZipList a
pattern Nil = In (C Nothing)

infixr 5 :::
pattern (:::) :: a -> ZipList a -> ZipList a
pattern a:::as = In (C (Just (as, a)))
RyanGlScott commented 7 years ago

Isn't this what Tannen gives you?

newtype Tannen f p a b = Tannen { runTannen :: f (p a b) }
type (·) = Tannen
Icelandjack commented 7 years ago

Not surprised this exists already but the name is not very descriptive

Icelandjack commented 7 years ago

I'll use this instead and close the ticket :) thanks