-
-
Notifications
You must be signed in to change notification settings - Fork 414
Closed
Labels
Description
Another weird one from @masaeedu:
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DataKinds #-}
import Prelude hiding (id, (.))
import Control.Category
import Data.List.NonEmpty
data Index f as
where
Head :: f a -> Index f (a ':| as)
Next :: Index f (a ':| as) -> Index f (x ':| a ': as)
newtype Flip p a b = Flip { runFlip :: p b a }
data Smoosh p as bs
where
Terminal :: Smoosh p as '[]
Projection :: Index (Flip p b) (a ':| as) -> Smoosh p (a ': as) bs -> Smoosh p (a ': as) (b ': bs)
heteroCompose
:: Category p
=> Index (Flip p c) (b ':| bs)
-> Smoosh p (a ': as) (b ': bs)
-> Index (Flip p c) (a ':| as)
heteroCompose = _Wingman produces this:
heteroCompose (Head fl) _ = Head fl
heteroCompose (Next in') _ = Next in'which doesn't type-check. The real solution should be
heteroCompose = \case
Head (Flip pbc) -> \(Projection (Head (Flip pab)) _) -> Head $ Flip $ pbc . pab
Next v -> \(Projection _ r) -> heteroCompose v r