on master help sign in
Ambiguous wrappers instead of TH (#21)
commit8d8e5ffbbc2c4f6f925b5a6bd4b1a0102b79e117 authorIndex Int <vlad.z.4096@gmail.com> dateSat 30 Apr 2016, 17:51 (10 years ago) parentc6e803c
17 files changed+419−74
ether.cabal+8−1 src/Control/Ether/TH.hs−19 src/Control/Monad/Ether.hs−1 src/Control/Monad/Ether/Ambiguous.hs+13 src/Control/Monad/Ether/Ambiguous/Except.hs+55 src/Control/Monad/Ether/Ambiguous/Reader.hs+54 src/Control/Monad/Ether/Ambiguous/State.hs+8 src/Control/Monad/Ether/Ambiguous/State/Lazy.hs+79 src/Control/Monad/Ether/Ambiguous/State/Strict.hs+79 src/Control/Monad/Ether/Ambiguous/Writer.hs+74 src/Control/Monad/Trans/Ether/Dispatch.hs+4−8 test/Regression/T1.hs+8−8 test/Regression/T3.hs+12−12 test/Regression/T4.hs+4−4 test/Regression/T7.hs+4−4 test/Regression/T8.hs+9−9 test/Regression/T9.hs+8−8
ether.cabal+8−1
@@ -28,7 +28,6 @@ library
2828
2929 exposed-modules: Control.Ether.Abbr
3030 Control.Ether.Implicit.Abbr
31− Control.Ether.TH
3231 Control.Monad.Trans.Ether.Reader
3332 Control.Monad.Trans.Ether.Writer
3433 Control.Monad.Trans.Ether.State
@@ -55,6 +54,13 @@ library
5554 Control.Monad.Ether.Implicit.State.Lazy
5655 Control.Monad.Ether.Implicit.State.Strict
5756 Control.Monad.Ether.Implicit.Except
57+ Control.Monad.Ether.Ambiguous
58+ Control.Monad.Ether.Ambiguous.Reader
59+ Control.Monad.Ether.Ambiguous.Writer
60+ Control.Monad.Ether.Ambiguous.State
61+ Control.Monad.Ether.Ambiguous.State.Lazy
62+ Control.Monad.Ether.Ambiguous.State.Strict
63+ Control.Monad.Ether.Ambiguous.Except
5864
5965 build-depends: base >=4.7 && <4.10
6066 , transformers >=0.4.2
@@ -122,6 +128,7 @@ test-suite regression
122128 PolyKinds
123129 ScopedTypeVariables
124130 TemplateHaskell
131+ TypeApplications
125132 TypeFamilies
126133 TypeOperators
127134 QuasiQuotes
src/Control/Ether/TH.hsdeleted−19
@@ -1,19 +0,0 @@
1−{-# LANGUAGE TemplateHaskell #-}
2−{-# LANGUAGE MagicHash #-}
3−
4−-- | Template Haskell utilities.
5−
6−module Control.Ether.TH (tag) where
7−
8−import qualified Language.Haskell.TH as TH
9−import qualified Language.Haskell.TH.Quote as TH
10−
11−import GHC.Prim (Proxy#, proxy#)
12−
13−tag :: TH.QuasiQuoter
14−tag = TH.QuasiQuoter proxyExpQ undefined undefined undefined
15− where
16− proxyExpQ :: String -> TH.ExpQ
17− proxyExpQ nameStr =
18− let ty = TH.conT (TH.mkName nameStr)
19− in [e| proxy# :: Proxy# $ty |]
src/Control/Monad/Ether.hs−1
@@ -11,4 +11,3 @@ import Control.Monad.Ether.Writer as X
1111import Control.Monad.Ether.State as X
1212import Control.Monad.Ether.Except as X
1313import Control.Monad.Trans.Ether.Dispatch as X
14−import Control.Ether.TH as X (tag)
src/Control/Monad/Ether/Ambiguous.hsnew file+13
@@ -0,0 +1,13 @@
1+
2+-- | This module provides convenience exports of all
3+-- ambiguously tagged monad classes from Ether.
4+
5+module Control.Monad.Ether.Ambiguous (module X) where
6+
7+import Control.Monad as X
8+import Control.Monad.Fix as X
9+import Control.Monad.Ether.Ambiguous.Reader as X
10+import Control.Monad.Ether.Ambiguous.Writer as X
11+import Control.Monad.Ether.Ambiguous.State as X
12+import Control.Monad.Ether.Ambiguous.Except as X
13+import Control.Monad.Trans.Ether.Dispatch as X
src/Control/Monad/Ether/Ambiguous/Except.hsnew file+55
@@ -0,0 +1,55 @@
1+{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
4+
5+-- | See "Control.Monad.Ether.Except".
6+
7+module Control.Monad.Ether.Ambiguous.Except
8+ (
9+ -- * MonadExcept class
10+ MonadExcept
11+ , throw
12+ , catch
13+ -- * The Except monad
14+ , Except
15+ , runExcept
16+ -- * The ExceptT monad transformer
17+ , ExceptT
18+ , exceptT
19+ , runExceptT
20+ -- * Handle functions
21+ , handle
22+ , handleT
23+ ) where
24+
25+import GHC.Prim (Proxy#, proxy#)
26+import Control.Monad.Ether.Except (MonadExcept, ExceptT, Except)
27+import qualified Control.Monad.Ether.Except as Explicit
28+
29+-- | See 'Control.Monad.Ether.Except.throw'.
30+throw :: forall tag e m a . MonadExcept tag e m => e -> m a
31+throw = Explicit.throw (proxy# :: Proxy# tag)
32+
33+-- | See 'Control.Monad.Ether.Except.catch'.
34+catch :: forall tag e m a . MonadExcept tag e m => m a -> (e -> m a) -> m a
35+catch = Explicit.catch (proxy# :: Proxy# tag)
36+
37+-- | See 'Control.Monad.Ether.Except.runExcept'.
38+runExcept :: forall tag e a . Except tag e a -> Either e a
39+runExcept = Explicit.runExcept proxy#
40+
41+-- | See 'Control.Monad.Ether.Except.exceptT'.
42+exceptT :: forall tag e m a . m (Either e a) -> ExceptT tag e m a
43+exceptT = Explicit.exceptT proxy#
44+
45+-- | See 'Control.Monad.Ether.Except.runExceptT'.
46+runExceptT :: forall tag e m a . ExceptT tag e m a -> m (Either e a)
47+runExceptT = Explicit.runExceptT proxy#
48+
49+-- | See 'Control.Monad.Ether.Except.handle'.
50+handle :: forall tag e a . (e -> a) -> Except tag e a -> a
51+handle = Explicit.handle proxy#
52+
53+-- | See 'Control.Monad.Ether.Except.handleT'.
54+handleT :: forall tag e m a . Functor m => (e -> a) -> ExceptT tag e m a -> m a
55+handleT = Explicit.handleT proxy#
src/Control/Monad/Ether/Ambiguous/Reader.hsnew file+54
@@ -0,0 +1,54 @@
1+{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
4+
5+-- | See "Control.Monad.Ether.Reader".
6+
7+module Control.Monad.Ether.Ambiguous.Reader
8+ (
9+ -- * MonadReader class
10+ MonadReader
11+ , local
12+ , ask
13+ , reader
14+ , asks
15+ -- * The Reader monad
16+ , Reader
17+ , runReader
18+ -- * The ReaderT monad transformer
19+ , ReaderT
20+ , readerT
21+ , runReaderT
22+ ) where
23+
24+import GHC.Prim (Proxy#, proxy#)
25+import Control.Monad.Ether.Reader (MonadReader, ReaderT, Reader)
26+import qualified Control.Monad.Ether.Reader as Explicit
27+
28+-- | See 'Control.Monad.Ether.Reader.readerT'.
29+readerT :: forall tag r m a . (r -> m a) -> ReaderT tag r m a
30+readerT = Explicit.readerT proxy#
31+
32+-- | See 'Control.Monad.Ether.Reader.runReaderT'.
33+runReaderT :: forall tag r m a . ReaderT tag r m a -> r -> m a
34+runReaderT = Explicit.runReaderT proxy#
35+
36+-- | See 'Control.Monad.Ether.Reader.runReader'.
37+runReader :: forall tag r a . Reader tag r a -> r -> a
38+runReader = Explicit.runReader proxy#
39+
40+-- | See 'Control.Monad.Ether.Reader.local'.
41+local :: forall tag r m a . MonadReader tag r m => (r -> r) -> m a -> m a
42+local = Explicit.local (proxy# :: Proxy# tag)
43+
44+-- | See 'Control.Monad.Ether.Reader.ask'.
45+ask :: forall tag r m . MonadReader tag r m => m r
46+ask = Explicit.ask (proxy# :: Proxy# tag)
47+
48+-- | See 'Control.Monad.Ether.Reader.reader'.
49+reader :: forall tag r m a . MonadReader tag r m => (r -> a) -> m a
50+reader = Explicit.reader (proxy# :: Proxy# tag)
51+
52+-- | See 'Control.Monad.Ether.Reader.asks'.
53+asks :: forall tag r m a . MonadReader tag r m => (r -> a) -> m a
54+asks = Explicit.asks (proxy# :: Proxy# tag)
src/Control/Monad/Ether/Ambiguous/State.hsnew file+8
@@ -0,0 +1,8 @@
1+
2+-- | See "Control.Monad.Ether.State".
3+
4+module Control.Monad.Ether.Ambiguous.State
5+ ( module Control.Monad.Ether.Ambiguous.State.Lazy
6+ ) where
7+
8+import Control.Monad.Ether.Ambiguous.State.Lazy
src/Control/Monad/Ether/Ambiguous/State/Lazy.hsnew file+79
@@ -0,0 +1,79 @@
1+{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
4+
5+-- | See "Control.Monad.Ether.State.Lazy".
6+
7+module Control.Monad.Ether.Ambiguous.State.Lazy
8+ (
9+ -- * MonadState class
10+ MonadState
11+ , get
12+ , put
13+ , state
14+ , modify
15+ , gets
16+ -- * The State monad
17+ , State
18+ , runState
19+ , evalState
20+ , execState
21+ -- * The StateT monad transformer
22+ , StateT
23+ , stateT
24+ , runStateT
25+ , evalStateT
26+ , execStateT
27+ ) where
28+
29+import GHC.Prim (Proxy#, proxy#)
30+import Control.Monad.Ether.State.Lazy (MonadState, StateT, State)
31+import qualified Control.Monad.Ether.State.Lazy as Explicit
32+
33+-- | See 'Control.Monad.Ether.State.Lazy.stateT'.
34+stateT :: forall tag s m a . (s -> m (a, s)) -> StateT tag s m a
35+stateT = Explicit.stateT proxy#
36+
37+-- | See 'Control.Monad.Ether.State.Lazy.runStateT'.
38+runStateT :: forall tag s m a . StateT tag s m a -> s -> m (a, s)
39+runStateT = Explicit.runStateT proxy#
40+
41+-- | See 'Control.Monad.Ether.State.Lazy.runState'.
42+runState :: forall tag s a . State tag s a -> s -> (a, s)
43+runState = Explicit.runState proxy#
44+
45+-- | See 'Control.Monad.Ether.State.Lazy.evalStateT'.
46+evalStateT :: forall tag s m a . Monad m => StateT tag s m a -> s -> m a
47+evalStateT = Explicit.evalStateT proxy#
48+
49+-- | See 'Control.Monad.Ether.State.Lazy.evalState'.
50+evalState :: forall tag s a . State tag s a -> s -> a
51+evalState = Explicit.evalState proxy#
52+
53+-- | See 'Control.Monad.Ether.State.Lazy.execStateT'.
54+execStateT :: forall tag s m a . Monad m => StateT tag s m a -> s -> m s
55+execStateT = Explicit.execStateT proxy#
56+
57+-- | See 'Control.Monad.Ether.State.Lazy.execState'.
58+execState :: forall tag s a . State tag s a -> s -> s
59+execState = Explicit.execState proxy#
60+
61+-- | See 'Control.Monad.Ether.State.Lazy.get'.
62+get :: forall tag s m . MonadState tag s m => m s
63+get = Explicit.get (proxy# :: Proxy# tag)
64+
65+-- | See 'Control.Monad.Ether.State.Lazy.gets'.
66+gets :: forall tag s m a . MonadState tag s m => (s -> a) -> m a
67+gets = Explicit.gets (proxy# :: Proxy# tag)
68+
69+-- | See 'Control.Monad.Ether.State.Lazy.put'.
70+put :: forall tag s m . MonadState tag s m => s -> m ()
71+put = Explicit.put (proxy# :: Proxy# tag)
72+
73+-- | See 'Control.Monad.Ether.State.Lazy.state'.
74+state :: forall tag s m a . MonadState tag s m => (s -> (a, s)) -> m a
75+state = Explicit.state (proxy# :: Proxy# tag)
76+
77+-- | See 'Control.Monad.Ether.State.Lazy.modify'.
78+modify :: forall tag s m . MonadState tag s m => (s -> s) -> m ()
79+modify = Explicit.modify (proxy# :: Proxy# tag)
src/Control/Monad/Ether/Ambiguous/State/Strict.hsnew file+79
@@ -0,0 +1,79 @@
1+{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
4+
5+-- | See "Control.Monad.Ether.State.Strict".
6+
7+module Control.Monad.Ether.Ambiguous.State.Strict
8+ (
9+ -- * MonadState class
10+ MonadState
11+ , get
12+ , put
13+ , state
14+ , modify
15+ , gets
16+ -- * The State monad
17+ , State
18+ , runState
19+ , evalState
20+ , execState
21+ -- * The StateT monad transformer
22+ , StateT
23+ , stateT
24+ , runStateT
25+ , evalStateT
26+ , execStateT
27+ ) where
28+
29+import GHC.Prim (Proxy#, proxy#)
30+import Control.Monad.Ether.State.Strict (MonadState, StateT, State)
31+import qualified Control.Monad.Ether.State.Strict as Explicit
32+
33+-- | See 'Control.Monad.Ether.State.Strict.stateT'.
34+stateT :: forall tag s m a . (s -> m (a, s)) -> StateT tag s m a
35+stateT = Explicit.stateT proxy#
36+
37+-- | See 'Control.Monad.Ether.State.Strict.runStateT'.
38+runStateT :: forall tag s m a . StateT tag s m a -> s -> m (a, s)
39+runStateT = Explicit.runStateT proxy#
40+
41+-- | See 'Control.Monad.Ether.State.Strict.runState'.
42+runState :: forall tag s a . State tag s a -> s -> (a, s)
43+runState = Explicit.runState proxy#
44+
45+-- | See 'Control.Monad.Ether.State.Strict.evalStateT'.
46+evalStateT :: forall tag s m a . Monad m => StateT tag s m a -> s -> m a
47+evalStateT = Explicit.evalStateT proxy#
48+
49+-- | See 'Control.Monad.Ether.State.Strict.evalState'.
50+evalState :: forall tag s a . State tag s a -> s -> a
51+evalState = Explicit.evalState proxy#
52+
53+-- | See 'Control.Monad.Ether.State.Strict.execStateT'.
54+execStateT :: forall tag s m a . Monad m => StateT tag s m a -> s -> m s
55+execStateT = Explicit.execStateT proxy#
56+
57+-- | See 'Control.Monad.Ether.State.Strict.execState'.
58+execState :: forall tag s a . State tag s a -> s -> s
59+execState = Explicit.execState proxy#
60+
61+-- | See 'Control.Monad.Ether.State.Strict.get'.
62+get :: forall tag s m . MonadState tag s m => m s
63+get = Explicit.get (proxy# :: Proxy# tag)
64+
65+-- | See 'Control.Monad.Ether.State.Strict.gets'.
66+gets :: forall tag s m a . MonadState tag s m => (s -> a) -> m a
67+gets = Explicit.gets (proxy# :: Proxy# tag)
68+
69+-- | See 'Control.Monad.Ether.State.Strict.put'.
70+put :: forall tag s m . MonadState tag s m => s -> m ()
71+put = Explicit.put (proxy# :: Proxy# tag)
72+
73+-- | See 'Control.Monad.Ether.State.Strict.state'.
74+state :: forall tag s m a . MonadState tag s m => (s -> (a, s)) -> m a
75+state = Explicit.state (proxy# :: Proxy# tag)
76+
77+-- | See 'Control.Monad.Ether.State.Strict.modify'.
78+modify :: forall tag s m . MonadState tag s m => (s -> s) -> m ()
79+modify = Explicit.modify (proxy# :: Proxy# tag)
src/Control/Monad/Ether/Ambiguous/Writer.hsnew file+74
@@ -0,0 +1,74 @@
1+{-# LANGUAGE AllowAmbiguousTypes #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
3+{-# LANGUAGE MagicHash #-}
4+
5+-- | See "Control.Monad.Ether.Writer".
6+
7+module Control.Monad.Ether.Ambiguous.Writer
8+ (
9+ -- * MonadWriter class
10+ MonadWriter
11+ , writer
12+ , tell
13+ , listen
14+ , pass
15+ , listens
16+ , censor
17+ -- * The Writer monad
18+ , Writer
19+ , runWriter
20+ , execWriter
21+ -- * The WriterT monad transformer
22+ , WriterT
23+ , writerT
24+ , runWriterT
25+ , execWriterT
26+ ) where
27+
28+import GHC.Prim (Proxy#, proxy#)
29+import Control.Monad.Ether.Writer (MonadWriter, WriterT, Writer)
30+import qualified Control.Monad.Ether.Writer as Explicit
31+
32+-- | See 'Control.Monad.Ether.Writer.writer'.
33+writer :: forall tag w m a . MonadWriter tag w m => (a, w) -> m a
34+writer = Explicit.writer (proxy# :: Proxy# tag)
35+
36+-- | See 'Control.Monad.Ether.Writer.tell'.
37+tell :: forall tag w m . MonadWriter tag w m => w -> m ()
38+tell = Explicit.tell (proxy# :: Proxy# tag)
39+
40+-- | See 'Control.Monad.Ether.Writer.listen'.
41+listen :: forall tag w m a . MonadWriter tag w m => m a -> m (a, w)
42+listen = Explicit.listen (proxy# :: Proxy# tag)
43+
44+-- | See 'Control.Monad.Ether.Writer.pass'.
45+pass :: forall tag w m a . MonadWriter tag w m => m (a, w -> w) -> m a
46+pass = Explicit.pass (proxy# :: Proxy# tag)
47+
48+-- | See 'Control.Monad.Ether.Writer.listens'.
49+listens :: forall tag w m a b . MonadWriter tag w m => (w -> b) -> m a -> m (a, b)
50+listens = Explicit.listens (proxy# :: Proxy# tag)
51+
52+-- | See 'Control.Monad.Ether.Writer.censor'.
53+censor :: forall tag w m a . MonadWriter tag w m => (w -> w) -> m a -> m a
54+censor = Explicit.censor (proxy# :: Proxy# tag)
55+
56+-- | See 'Control.Monad.Ether.Writer.runWriter'.
57+runWriter :: forall tag w a . Writer tag w a -> (a, w)
58+runWriter = Explicit.runWriter proxy#
59+
60+-- | See 'Control.Monad.Ether.Writer.execWriter'.
61+execWriter :: forall tag w a . Writer tag w a -> w
62+execWriter = Explicit.execWriter proxy#
63+
64+-- | See 'Control.Monad.Ether.Writer.writerT'.
65+writerT :: forall tag w m a . m (a, w) -> WriterT tag w m a
66+writerT = Explicit.writerT proxy#
67+
68+-- | See 'Control.Monad.Ether.Writer.runWriterT'.
69+runWriterT :: forall tag w m a . WriterT tag w m a -> m (a, w)
70+runWriterT = Explicit.runWriterT proxy#
71+
72+-- | See 'Control.Monad.Ether.Writer.execWriterT'.
73+execWriterT :: forall tag w m a . Monad m => WriterT tag w m a -> m w
74+execWriterT = Explicit.execWriterT proxy#
src/Control/Monad/Trans/Ether/Dispatch.hs+4−8
@@ -144,16 +144,12 @@ instance Lift.LiftCallCC (DispatchT dp) where
144144 liftCallCC' = Lift.defaultLiftCallCC' pack unpack
145145
146146-- | Attach a tag to untagged transformers.
147−tagAttach :: Proxy# t -> DispatchTagAttachT t m a -> m a
148−tagAttach _ = coerce
147+tagAttach :: forall tag m a . DispatchTagAttachT tag m a -> m a
148+tagAttach = coerce
149149
150150-- | Replace a tag with another tag.
151−tagReplace
152− :: Proxy# tOld
153− -> Proxy# tNew
154− -> DispatchTagReplaceT tOld tNew m a
155− -> m a
156−tagReplace _ _ = coerce
151+tagReplace :: forall tOld tNew m a . DispatchTagReplaceT tOld tNew m a -> m a
152+tagReplace = coerce
157153
158154
159155-- TagAttach instances
test/Regression/T1.hs+8−8
@@ -1,6 +1,6 @@
11module Regression.T1 (test1) where
22
3−import Control.Monad.Ether
3+import Control.Monad.Ether.Ambiguous
44import Control.Ether.Abbr
55
66import Test.Tasty
@@ -13,17 +13,17 @@ testEther
1313 :: Ether '[Tag1 --> String, Tag2 --> String] m
1414 => m ((String, String), (String, String))
1515testEther = do
16− s1 <- ask [tag|Tag1|]
17− s2 <- ask [tag|Tag2|]
16+ s1 <- ask @Tag1
17+ s2 <- ask @Tag2
1818 let s1s2 = (s1, s2)
19− s1s2' <- local [tag|Tag2|] (map succ) $ do
20− s1' <- ask [tag|Tag1|]
21− s2' <- ask [tag|Tag2|]
19+ s1s2' <- local @Tag2 (map succ) $ do
20+ s1' <- ask @Tag1
21+ s2' <- ask @Tag2
2222 return (s1', s2')
2323 return (s1s2, s1s2')
2424
25−runner1 s1 s2 = flip (runReader [tag|Tag1|]) s1 . flip (runReaderT [tag|Tag2|]) s2
26−runner2 s1 s2 = flip (runReader [tag|Tag2|]) s2 . flip (runReaderT [tag|Tag1|]) s1
25+runner1 s1 s2 = flip (runReader @Tag1) s1 . flip (runReaderT @Tag2) s2
26+runner2 s1 s2 = flip (runReader @Tag2) s2 . flip (runReaderT @Tag1) s1
2727
2828test1 :: TestTree
2929test1 = testGroup "T1: Reader local environment"
test/Regression/T3.hs+12−12
@@ -1,7 +1,7 @@
11module Regression.T3 (test3) where
22
33import Control.Ether.Abbr
4−import Control.Monad.Ether
4+import Control.Monad.Ether.Ambiguous
55
66import qualified Control.Monad.Reader as T
77import qualified Control.Monad.State as T
@@ -22,21 +22,21 @@ testMTL = do
2222testEther
2323 :: Ether '[STag --> Int, STag <-> Int, RTag --> Int] m
2424 => m (Int, Int, Int)
25−testEther = local [tag|RTag|] (*2) $ do
26− a_mul_b <- tagAttach [tag|STag|] testMTL
27− a_add_b <- get [tag|STag|]
28− modify [tag|STag|] negate
29− c <- ask [tag|RTag|]
25+testEther = local @RTag (*2) $ do
26+ a_mul_b <- tagAttach @STag testMTL
27+ a_add_b <- get @STag
28+ modify @STag negate
29+ c <- ask @RTag
3030 return (a_mul_b, a_add_b, c)
3131
3232runner1 s r
33− = flip (runReader [tag|RTag|]) (negate r)
34− . flip (runReaderT [tag|STag|]) r
35− . flip (runStateT [tag|STag|]) s
33+ = flip (runReader @RTag) (negate r)
34+ . flip (runReaderT @STag) r
35+ . flip (runStateT @STag) s
3636runner2 s r
37− = flip (runReader [tag|RTag|]) (negate r)
38− . flip (runStateT [tag|STag|]) s
39− . flip (runReaderT [tag|STag|]) r
37+ = flip (runReader @RTag) (negate r)
38+ . flip (runStateT @STag) s
39+ . flip (runReaderT @STag) r
4040
4141test3 :: TestTree
4242test3 = testGroup "T3: Tag attachement"
test/Regression/T4.hs+4−4
@@ -1,7 +1,7 @@
11module Regression.T4 (test4) where
22
33import Control.Ether.Abbr
4−import Control.Monad.Ether
4+import Control.Monad.Ether.Ambiguous
55
66import Test.Tasty
77import Test.Tasty.QuickCheck
@@ -9,11 +9,11 @@ import Test.Tasty.QuickCheck
99data RTag
1010
1111testEther :: Ether '[RTag --> Int] m => m Int
12−testEther = ask [tag|RTag|]
12+testEther = ask @RTag
1313
1414runner r
15− = flip (runReader [tag|RTag|]) (r' :: Int)
16− . flip (runReaderT [tag|RTag|]) (r :: Int)
15+ = flip (runReader @RTag) (r' :: Int)
16+ . flip (runReaderT @RTag) (r :: Int)
1717 where
1818 r' = negate r
1919
test/Regression/T7.hs+4−4
@@ -3,7 +3,7 @@ module Regression.T7 (test7) where
33import Data.Monoid
44import Control.Monad
55
6−import Control.Monad.Ether
6+import Control.Monad.Ether.Ambiguous
77import qualified Control.Monad.Writer as T
88
99import Test.Tasty
@@ -19,16 +19,16 @@ testEther
1919testEther xs = do
2020 forM_ xs $ \x -> do
2121 T.tell (Sum x)
22− tell [tag|WTag|] (Sum 1)
22+ tell @WTag (Sum 1)
2323
2424runner1 :: Num a => [a] -> (a, a)
2525runner1 xs =
26− let (s, c) = T.runWriter . execWriterT [tag|WTag|] $ testEther xs
26+ let (s, c) = T.runWriter . execWriterT @WTag $ testEther xs
2727 in (getSum s, getSum c)
2828
2929runner2 :: Num a => [a] -> (a, a)
3030runner2 xs =
31− let (c, s) = runWriter [tag|WTag|] . T.execWriterT $ testEther xs
31+ let (c, s) = runWriter @WTag . T.execWriterT $ testEther xs
3232 in (getSum s, getSum c)
3333
3434triangular :: Integral a => a -> a
test/Regression/T8.hs+9−9
@@ -1,7 +1,7 @@
11module Regression.T8 (test8) where
22
33import Control.Ether.Abbr
4−import Control.Monad.Ether
4+import Control.Monad.Ether.Ambiguous
55
66import qualified Control.Monad.State as T
77
@@ -21,22 +21,22 @@ testEther
2121 :: Ether '[Foo <-> Int, Bar <-> Bool] m
2222 => m String
2323testEther = do
24− tagAttach [tag|Foo|] testMTL1
25− tagAttach [tag|Bar|] testMTL2
26− a <- gets [tag|Foo|] show
27− b <- gets [tag|Bar|] show
24+ tagAttach @Foo testMTL1
25+ tagAttach @Bar testMTL2
26+ a <- gets @Foo show
27+ b <- gets @Bar show
2828 return (a ++ b)
2929
3030model :: Int -> Bool -> String
3131model a b = show (negate a) ++ show (not b)
3232
3333runner1 a b
34− = flip (evalState [tag|Foo|]) a
35− . flip (evalStateT [tag|Bar|]) b
34+ = flip (evalState @Foo) a
35+ . flip (evalStateT @Bar) b
3636
3737runner2 a b
38− = flip (evalState [tag|Bar|]) b
39− . flip (evalStateT [tag|Foo|]) a
38+ = flip (evalState @Bar) b
39+ . flip (evalStateT @Foo) a
4040
4141test8 :: TestTree
4242test8 = testGroup "T8: Multiple tag attachements"
test/Regression/T9.hs+8−8
@@ -1,7 +1,7 @@
11module Regression.T9 (test9) where
22
33import Control.Ether.Abbr
4−import Control.Monad.Ether
4+import Control.Monad.Ether.Ambiguous
55
66import Test.Tasty
77import Test.Tasty.QuickCheck
@@ -11,11 +11,11 @@ data Bar
1111
1212testEther1 :: Ether '[Foo <-> Int] m => m String
1313testEther1 = do
14− modify [tag|Foo|] negate
15− gets [tag|Foo|] show
14+ modify @Foo negate
15+ gets @Foo show
1616
1717testEther2 :: Ether '[Bar <-> Int] m => m String
18−testEther2 = tagReplace [tag|Foo|] [tag|Bar|] testEther1
18+testEther2 = tagReplace @Foo @Bar testEther1
1919
2020testEther
2121 :: Ether '[Foo <-> Int, Bar <-> Int] m
@@ -29,12 +29,12 @@ model :: Int -> Int -> String
2929model a b = show (negate a) ++ show (negate b)
3030
3131runner1 a b
32− = flip (evalState [tag|Foo|]) a
33− . flip (evalStateT [tag|Bar|]) b
32+ = flip (evalState @Foo) a
33+ . flip (evalStateT @Bar) b
3434
3535runner2 a b
36− = flip (evalState [tag|Bar|]) b
37− . flip (evalStateT [tag|Foo|]) a
36+ = flip (evalState @Bar) b
37+ . flip (evalStateT @Foo) a
3838
3939test9 :: TestTree
4040test9 = testGroup "T9: Tag replacement"