Skip to content

Instantly share code, notes, and snippets.

@dmwit
Created March 7, 2019 14:47
Show Gist options
  • Save dmwit/4cceddecaf139b1428c0199378f044b3 to your computer and use it in GitHub Desktop.
Save dmwit/4cceddecaf139b1428c0199378f044b3 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeFamilies #-}
class Foo a where
type I a t
foo :: I a t -> t -> a
instance Foo () where
type I () t = ()
foo _ _ = ()
instance Foo b => Foo (a, b) where
type I (a, b) t = (t -> a, I b t)
foo (f, gs) t = (f t, foo gs t)
-- > foo ((+1), ((+2), ((+3), ()))) 0 :: (Int, (Int, (Int, ())))
-- (1,(2,(3,())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment