Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ‘Compose f g a b’ (= Biff f g Identity a b) #60

Open
Icelandjack opened this issue May 20, 2017 · 2 comments
Open

Add ‘Compose f g a b’ (= Biff f g Identity a b) #60

Icelandjack opened this issue May 20, 2017 · 2 comments

Comments

@Icelandjack
Copy link
Contributor

Icelandjack commented May 20, 2017

Add Compose f g a b (= Biff f g dentity a b) from Edward's monad homomorphisms

type COMPOSE f g = Biff f g Identity

newtype Compose f g a b = COMPOSE { runCOMPOSE :: COMPOSE f g a b }
  deriving (Functor, Foldable, Traversable, Bifunctor, Bifoldable, Biapplicative)
@Icelandjack
Copy link
Contributor Author

Icelandjack commented May 20, 2017

Also Bitraversable

pattern Compose :: Bifunctor f => f (g a) b -> Compose f g a b
pattern Compose{runCompose} <- (second runIdentity . runBiff . runCOMPOSE -> runCompose)
  where Compose              = COMPOSE . Biff . second Identity

instance (Bitraversable f, Traversable g) => Bitraversable (Compose f g) where
  bitraverse :: Applicative f => (a -> f a') -> (b -> f b') -> ((Tensor f g) a b -> f ((Tensor f g) a' b'))
  bitraverse f g = fmap Tensor . bitraverse (traverse f) g . runTensor

@Icelandjack
Copy link
Contributor Author

Icelandjack commented May 20, 2017

With issue #12369 this becomes an instance of Compose

data family Compose (k -> xx) -> (k' -> k) -> (k' -> xx)

newtype instance Compose f g a     = Compose  (f (g a))
newtype instance Compose f g a b   = Compose2 (f (g a) b)
newtype instance Compose f g a b c = Compose3 (f (g a) b c)

@Icelandjack Icelandjack changed the title Add ‘Tensor s t m a’ (= Biff s t Identity m a) Add ‘Compose f g a b’ (= Biff f g Identity a b) May 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant