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