@@ -6,11 +6,15 @@
6{-# LANGUAGE UndecidableInstances #-}
6{-# LANGUAGE UndecidableInstances #-}
7module Control.Ether.Core
7module Control.Ether.Core
8 ( EtherTagless
8 ( EtherTagless
10 , EtherTags
9 , EtherTags
12+import Data.Proxy (Proxy)
13−import Data.Functor.Identity
13+import Data.Functor.Identity (Identity)
14+import Data.Monoid (First, Last)
15+import qualified Control.Monad.ST.Strict as Strict (ST)
16+import qualified Control.Monad.ST.Lazy as Lazy (ST)
14import GHC.Exts (Constraint)
18import GHC.Exts (Constraint)
16import qualified Control.Monad.Trans.Cont as Trans
20import qualified Control.Monad.Trans.Cont as Trans
@@ -36,41 +40,28 @@ type family ELEM (x :: k) (as :: [k]) :: Bool where
36type family EtherTagless (tag :: *) (m :: * -> *) :: Constraint where
40type family EtherTagless (tag :: *) (m :: * -> *) :: Constraint where
37 EtherTagless tag m = ELEM tag (EtherTags m) ~ 'False
41 EtherTagless tag m = ELEM tag (EtherTags m) ~ 'False
39−class Monad m => MonadEther m where
40− type family EtherTags m :: [*]
43+type family EtherTags (m :: * -> *) :: [*]
42−instance MonadEther IO where
45+type instance EtherTags IO = '[]
43− type EtherTags IO = '[]
46+type instance EtherTags Identity = '[]
44−
47+type instance EtherTags [] = '[]
45−instance MonadEther Identity where
46− type EtherTags Identity = '[]
48+type instance EtherTags Maybe = '[]
47−
49+type instance EtherTags Last = '[]
48−instance Monad m => MonadEther (Trans.ContT r m) where
50+type instance EtherTags First = '[]
49− type EtherTags (Trans.ContT r m) = EtherTags m
51+type instance EtherTags ((->) r) = '[]
50−
52+type instance EtherTags STM = '[]
51−instance Monad m => MonadEther (Trans.ExceptT e m) where
52− type EtherTags (Trans.ExceptT e m) = EtherTags m
53+type instance EtherTags (Either e) = '[]
53−
54+type instance EtherTags Proxy = '[]
54−instance Monad m => MonadEther (Trans.IdentityT m) where
55+type instance EtherTags (Strict.ST s) = '[]
55− type EtherTags (Trans.IdentityT m) = EtherTags m
56+type instance EtherTags (Lazy.ST s) = '[]
57−instance Monad m => MonadEther (Trans.ListT m) where
58− type EtherTags (Trans.ListT m) = EtherTags m
58+type instance EtherTags (Trans.ContT r m) = EtherTags m
59−
59+type instance EtherTags (Trans.ExceptT e m) = EtherTags m
60−instance Monad m => MonadEther (Trans.MaybeT m) where
61− type EtherTags (Trans.MaybeT m) = EtherTags m
60+type instance EtherTags (Trans.IdentityT m) = EtherTags m
62−
61+type instance EtherTags (Trans.ListT m) = EtherTags m
63−instance Monad m => MonadEther (Trans.ReaderT r m) where
64− type EtherTags (Trans.ReaderT r m) = EtherTags m
62+type instance EtherTags (Trans.MaybeT m) = EtherTags m
65−
63+type instance EtherTags (Trans.ReaderT r m) = EtherTags m
66−instance Monad m => MonadEther (Trans.Lazy.StateT s m) where
67− type EtherTags (Trans.Lazy.StateT s m) = EtherTags m
64+type instance EtherTags (Trans.Lazy.StateT s m) = EtherTags m
69−instance Monad m => MonadEther (Trans.Strict.StateT s m) where
70− type EtherTags (Trans.Strict.StateT s m) = EtherTags m
65+type instance EtherTags (Trans.Strict.StateT s m) = EtherTags m
72−instance (Monoid w, Monad m) => MonadEther (Trans.Lazy.WriterT w m) where
73− type EtherTags (Trans.Lazy.WriterT w m) = EtherTags m
66+type instance EtherTags (Trans.Lazy.WriterT w m) = EtherTags m
75−instance (Monoid w, Monad m) => MonadEther (Trans.Strict.WriterT w m) where
76− type EtherTags (Trans.Strict.WriterT w m) = EtherTags m
67+type instance EtherTags (Trans.Strict.WriterT w m) = EtherTags m