Skip to content

Instantly share code, notes, and snippets.

@chrisdone-artificial
Created October 7, 2025 14:04
Show Gist options
  • Save chrisdone-artificial/2a0b5b46d89abea939a136e1aec25f2c to your computer and use it in GitHub Desktop.
Save chrisdone-artificial/2a0b5b46d89abea939a136e1aec25f2c to your computer and use it in GitHub Desktop.
T1 wrapper
newtype T1 t a = T1 { unT1 :: forall e. t e a }
deriving instance (forall e. Functor (t e)) => Functor (T1 t)
instance (forall e. Applicative (Either e)) => Applicative (T1 Either) where
pure x = T1 (pure x)
(<*>) f x = T1 (unT1 f <*> unT1 x)
instance (forall e. Monad (Either e)) => Monad (T1 Either) where
(>>=) m f = T1 (unT1 m >>= unT1 . f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment