Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Created July 10, 2018 01:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lysxia/147a593d32bf7d8d468b61b882c1b9ba to your computer and use it in GitHub Desktop.
Save Lysxia/147a593d32bf7d8d468b61b882c1b9ba to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
-- https://blog.poisson.chat/posts/2018-07-09-type-gadt.html
module UnMTL where
import Control.Monad.Trans.Reader
import Control.Monad.Trans.State
import Control.Monad.Trans.Except
import Data.Functor.Identity
import Data.Kind
type family UnMTL (a :: Type) :: Type
type instance UnMTL (ReaderT r m a) = r -> UnMTL (m a)
type instance UnMTL (StateT s m a) = s -> UnMTL (m (a, s))
type instance UnMTL (ExceptT e m a) = UnMTL (m (Either e a))
type instance UnMTL (Identity a) = a
type instance UnMTL (IO a) = IO a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment