on master help sign in
Enable -XKitchenSink by default
commit3019f460526602f4c09c869c97bdce0db3092904 authorVladislav Zavialov <vlad.z.4096@gmail.com> dateSun 23 Apr 2017, 23:41 (9 years ago) parent0b0b8bb
30 files changed+342−329
ether-flatten/ether-flatten.cabal+49−21 ether-flatten/src/Control/Monad/Ether/Reader/Flatten.hs−12 ether-flatten/src/Control/Monad/Ether/State/Flatten.hs−11 ether-suite/bench/Bench.hs−8 ether-suite/ether-suite.cabal+115−54 ether-zoom/ether-zoom.cabal+42−17 ether-zoom/src/Control/Monad/Ether/State/Zoom.hs+2−9 ether/ether.cabal+73−54 ether/src/Control/Ether/Abbr.hs+15−14 ether/src/Control/Ether/Implicit/Abbr.hs+4−6 ether/src/Control/Ether/Optic.hs−13 ether/src/Control/Monad/Ether/Except.hs−6 ether/src/Control/Monad/Ether/Except/Class.hs−5 ether/src/Control/Monad/Ether/Handle.hs+8−11 ether/src/Control/Monad/Ether/Implicit/Except.hs−2 ether/src/Control/Monad/Ether/Implicit/Reader.hs−2 ether/src/Control/Monad/Ether/Implicit/State/Lazy.hs−2 ether/src/Control/Monad/Ether/Implicit/State/Strict.hs−2 ether/src/Control/Monad/Ether/Implicit/Writer.hs−2 ether/src/Control/Monad/Ether/Reader.hs−7 ether/src/Control/Monad/Ether/Reader/Class.hs+16−8 ether/src/Control/Monad/Ether/State/Class.hs+8−8 ether/src/Control/Monad/Ether/State/Common.hs−7 ether/src/Control/Monad/Ether/State/Lazy.hs−5 ether/src/Control/Monad/Ether/State/Strict.hs−5 ether/src/Control/Monad/Ether/TagAttach.hs−7 ether/src/Control/Monad/Ether/TagReplace.hs−7 ether/src/Control/Monad/Ether/Writer.hs−6 ether/src/Control/Monad/Ether/Writer/Class.hs+10−9 ether/src/Control/Monad/Trans/Ether/Handler.hs−9
ether-flatten/ether-flatten.cabal+49−21
@@ -17,28 +17,56 @@ extra-source-files: CHANGELOG.md
1717
1818source-repository head
1919
20− type: git
21− location: git@github.com:int-index/ether.git
20+ type: git
21+ location: git@github.com:int-index/ether.git
2222
2323
2424library
2525
26− exposed-modules: Control.Monad.Ether.Reader.Flatten
27− , Control.Monad.Ether.State.Flatten
28− build-depends: base >=4.9 && <4.11
29− , ether >=0.5 && <0.6
30− , mtl >=2.2.1
31− , transformers >=0.4.2
32− , transformers-lift >=0.1.0.1
33− , ghc-prim >=0.3
34− , lens >=4.14
35− , deepseq >= 1.4
36−
37− default-language: Haskell2010
38− default-extensions: PolyKinds
39− ScopedTypeVariables
40− FunctionalDependencies
41− TypeApplications
42−
43− hs-source-dirs: src
44− ghc-options: -Wall -O2
26+ exposed-modules:
27+ Control.Monad.Ether.Reader.Flatten
28+ Control.Monad.Ether.State.Flatten
29+
30+ build-depends:
31+ base >=4.9 && <4.11,
32+ ether >=0.5 && <0.6,
33+ mtl >=2.2.1,
34+ transformers >=0.4.2,
35+ transformers-lift >=0.1.0.1,
36+ ghc-prim >=0.3,
37+ lens >=4.14,
38+ deepseq >= 1.4
39+
40+ default-language:
41+ Haskell2010
42+
43+ default-extensions:
44+ AllowAmbiguousTypes
45+ ConstraintKinds
46+ DataKinds
47+ DeriveGeneric
48+ EmptyDataDecls
49+ FlexibleContexts
50+ FlexibleInstances
51+ FunctionalDependencies
52+ GADTs
53+ GeneralizedNewtypeDeriving
54+ PartialTypeSignatures
55+ PolyKinds
56+ ScopedTypeVariables
57+ RankNTypes
58+ TemplateHaskell
59+ TupleSections
60+ TypeApplications
61+ TypeFamilies
62+ TypeInType
63+ TypeOperators
64+ TypeSynonymInstances
65+ UndecidableInstances
66+ UndecidableSuperClasses
67+
68+ hs-source-dirs:
69+ src
70+
71+ ghc-options:
72+ -Wall -O2
ether-flatten/src/Control/Monad/Ether/Reader/Flatten.hs−12
@@ -1,15 +1,3 @@
1−{-# LANGUAGE RankNTypes #-}
2−{-# LANGUAGE TypeSynonymInstances #-}
3−{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE UndecidableInstances #-}
6−{-# LANGUAGE FlexibleInstances #-}
7−{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE TypeFamilies #-}
9−{-# LANGUAGE AllowAmbiguousTypes #-}
10−{-# LANGUAGE TypeInType #-}
11−{-# LANGUAGE ConstraintKinds #-}
12−
131module Control.Monad.Ether.Reader.Flatten
142 ( runReader
153 , runReaderT
ether-flatten/src/Control/Monad/Ether/State/Flatten.hs−11
@@ -1,14 +1,3 @@
1−{-# LANGUAGE RankNTypes #-}
2−{-# LANGUAGE TypeSynonymInstances #-}
3−{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE UndecidableInstances #-}
6−{-# LANGUAGE FlexibleInstances #-}
7−{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE TypeFamilies #-}
9−{-# LANGUAGE AllowAmbiguousTypes #-}
10−{-# LANGUAGE TypeInType #-}
11−
121module Control.Monad.Ether.State.Flatten
132 ( runState
143 , runStateT
ether-suite/bench/Bench.hs−8
@@ -1,13 +1,5 @@
11{-# OPTIONS -fno-warn-partial-type-signatures #-}
22
3−{-# LANGUAGE TypeApplications #-}
4−{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE FunctionalDependencies #-}
6−{-# LANGUAGE FlexibleContexts #-}
7−{-# LANGUAGE DataKinds #-}
8−{-# LANGUAGE TypeOperators #-}
9−{-# LANGUAGE PartialTypeSignatures #-}
10−
113module Main (main) where
124
135import Criterion.Main
ether-suite/ether-suite.cabal+115−54
@@ -9,63 +9,124 @@ library
99
1010test-suite regression
1111
12− build-depends: base >=4.9 && <4.11
13− , transformers >=0.4.2
14− , mtl >=2.2.1
15− , tasty >=0.10
16− , tasty-quickcheck >=0.8
17− , QuickCheck >=2.8
18− , ghc-prim >=0.3
19− , lens >=4.14
20− , ether
21− , ether-zoom
22−
23− main-is: Regression.hs
24− other-modules: Regression.T1
25− Regression.T2
26− Regression.T3
27− Regression.T4
28− Regression.T5
29− Regression.T6
30− Regression.T7
31− Regression.T8
32− Regression.T9
33− Regression.T10
34− Regression.T11
35− Regression.T12
36−
37− type: exitcode-stdio-1.0
38− hs-source-dirs: test
39− default-language: Haskell2010
40− default-extensions: ConstraintKinds
41− DataKinds
42− EmptyDataDecls
43− FlexibleContexts
44− GeneralizedNewtypeDeriving
45− LambdaCase
46− PolyKinds
47− ScopedTypeVariables
48− TypeApplications
49− TypeFamilies
50− TypeOperators
51− ghc-options: -Wall -fno-warn-missing-signatures
12+ build-depends:
13+ base >=4.9 && <4.11,
14+ transformers >=0.4.2,
15+ mtl >=2.2.1,
16+ tasty >=0.10,
17+ tasty-quickcheck >=0.8,
18+ QuickCheck >=2.8,
19+ ghc-prim >=0.3,
20+ lens >=4.14,
21+ ether,
22+ ether-zoom
23+
24+ main-is:
25+ Regression.hs
26+
27+ other-modules:
28+ Regression.T1
29+ Regression.T2
30+ Regression.T3
31+ Regression.T4
32+ Regression.T5
33+ Regression.T6
34+ Regression.T7
35+ Regression.T8
36+ Regression.T9
37+ Regression.T10
38+ Regression.T11
39+ Regression.T12
40+
41+ type:
42+ exitcode-stdio-1.0
43+
44+ hs-source-dirs:
45+ test
46+
47+ default-language:
48+ Haskell2010
49+
50+ default-extensions:
51+ AllowAmbiguousTypes
52+ ConstraintKinds
53+ DataKinds
54+ DeriveGeneric
55+ EmptyDataDecls
56+ FlexibleContexts
57+ FlexibleInstances
58+ FunctionalDependencies
59+ GADTs
60+ GeneralizedNewtypeDeriving
61+ PartialTypeSignatures
62+ PolyKinds
63+ ScopedTypeVariables
64+ RankNTypes
65+ TemplateHaskell
66+ TupleSections
67+ TypeApplications
68+ TypeFamilies
69+ TypeInType
70+ TypeOperators
71+ TypeSynonymInstances
72+ UndecidableInstances
73+ UndecidableSuperClasses
74+
75+ ghc-options:
76+ -Wall -fno-warn-missing-signatures
5277
5378
5479benchmark bench
5580
56− build-depends: base >=4.9 && <4.11
57− , mtl >=2.2.1
58− , transformers >=0.4.2
59− , criterion >=1.1
60− , deepseq >=1.4
61− , lens >=4.14
62− , ether
63− , ether-flatten
81+ build-depends:
82+ base >=4.9 && <4.11,
83+ mtl >=2.2.1,
84+ transformers >=0.4.2,
85+ criterion >=1.1,
86+ deepseq >=1.4,
87+ lens >=4.14,
88+ ether,
89+ ether-flatten
6490
65− main-is: Bench.hs
91+ main-is:
92+ Bench.hs
6693
67− type: exitcode-stdio-1.0
68− hs-source-dirs: bench
69− default-language: Haskell2010
70− ghc-options: -Wall -O2
71− ghc-prof-options: -fprof-auto
94+ type:
95+ exitcode-stdio-1.0
96+
97+ hs-source-dirs:
98+ bench
99+
100+ default-language:
101+ Haskell2010
102+
103+ default-extensions:
104+ AllowAmbiguousTypes
105+ ConstraintKinds
106+ DataKinds
107+ DeriveGeneric
108+ EmptyDataDecls
109+ FlexibleContexts
110+ FlexibleInstances
111+ FunctionalDependencies
112+ GADTs
113+ GeneralizedNewtypeDeriving
114+ PartialTypeSignatures
115+ PolyKinds
116+ ScopedTypeVariables
117+ RankNTypes
118+ TemplateHaskell
119+ TupleSections
120+ TypeApplications
121+ TypeFamilies
122+ TypeInType
123+ TypeOperators
124+ TypeSynonymInstances
125+ UndecidableInstances
126+ UndecidableSuperClasses
127+
128+ ghc-options:
129+ -Wall -O2
130+
131+ ghc-prof-options:
132+ -fprof-auto
ether-zoom/ether-zoom.cabal+42−17
@@ -17,24 +17,49 @@ extra-source-files: CHANGELOG.md
1717
1818source-repository head
1919
20− type: git
21− location: git@github.com:int-index/ether.git
20+ type: git
21+ location: git@github.com:int-index/ether.git
2222
2323
2424library
2525
26− exposed-modules: Control.Monad.Ether.State.Zoom
27− build-depends: base >=4.9 && <4.11
28− , ether >=0.5 && <0.6
29− , transformers >=0.5
30− , lens >=4.14
31− , reflection >=2.1
32−
33− default-language: Haskell2010
34− default-extensions: PolyKinds
35− ScopedTypeVariables
36− FunctionalDependencies
37− TypeApplications
38−
39− hs-source-dirs: src
40− ghc-options: -Wall -O2
26+ exposed-modules:
27+ Control.Monad.Ether.State.Zoom
28+
29+ build-depends:
30+ base >=4.9 && <4.11,
31+ ether >=0.5 && <0.6,
32+ transformers >=0.5,
33+ lens >=4.14,
34+ reflection >=2.1
35+
36+ default-extensions:
37+ AllowAmbiguousTypes
38+ ConstraintKinds
39+ DataKinds
40+ DeriveGeneric
41+ EmptyDataDecls
42+ FlexibleContexts
43+ FlexibleInstances
44+ FunctionalDependencies
45+ GADTs
46+ GeneralizedNewtypeDeriving
47+ PartialTypeSignatures
48+ PolyKinds
49+ ScopedTypeVariables
50+ RankNTypes
51+ TemplateHaskell
52+ TupleSections
53+ TypeApplications
54+ TypeFamilies
55+ TypeInType
56+ TypeOperators
57+ TypeSynonymInstances
58+ UndecidableInstances
59+ UndecidableSuperClasses
60+
61+ hs-source-dirs:
62+ src
63+
64+ ghc-options:
65+ -Wall -O2
ether-zoom/src/Control/Monad/Ether/State/Zoom.hs+2−9
@@ -1,19 +1,12 @@
11{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
22
3−{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE RankNTypes #-}
5−{-# LANGUAGE TypeSynonymInstances #-}
6−{-# LANGUAGE FlexibleInstances #-}
7−{-# LANGUAGE FlexibleContexts #-}
8−{-# LANGUAGE UndecidableInstances #-}
9−{-# LANGUAGE TypeFamilies #-}
10−
113module Control.Monad.Ether.State.Zoom
124 ( TAG_ZOOM
135 , TagZoomT
146 , tagZoom
157 ) where
168
9+import Data.Kind as K
1710import Control.Lens
1811import Data.Reflection
1912import Control.Monad.Trans.Ether.Handler
@@ -25,7 +18,7 @@ import Data.Coerce
2518-- | Encode type-level information for 'tagZoom'.
2619data TAG_ZOOM t z
2720
28−type TagZoomT t (z :: *) = Handler (TAG_ZOOM t z) IdentityT
21+type TagZoomT t (z :: K.Type) = Handler (TAG_ZOOM t z) IdentityT
2922
3023-- | Zoom into a part of a state using a lens.
3124tagZoom
ether/ether.cabal+73−54
@@ -20,65 +20,84 @@ extra-source-files: CHANGELOG.md
2020
2121source-repository head
2222
23− type: git
24− location: git@github.com:int-index/ether.git
23+ type: git
24+ location: git@github.com:int-index/ether.git
2525
2626
2727library
2828
29− exposed-modules: Control.Ether.Abbr
30− Control.Ether.Implicit.Abbr
31− Control.Ether.Optic
32− Control.Monad.Trans.Ether.Handler
33− Control.Monad.Ether
34− Control.Monad.Ether.Handle
35− Control.Monad.Ether.TagAttach
36− Control.Monad.Ether.TagReplace
37− Control.Monad.Ether.Reader
38− Control.Monad.Ether.Reader.Class
39− Control.Monad.Ether.Writer
40− Control.Monad.Ether.Writer.Class
41− Control.Monad.Ether.State
42− Control.Monad.Ether.State.Class
43− Control.Monad.Ether.State.Lazy
44− Control.Monad.Ether.State.Strict
45− Control.Monad.Ether.Except
46− Control.Monad.Ether.Except.Class
47− Control.Monad.Ether.Implicit
48− Control.Monad.Ether.Implicit.Reader
49− Control.Monad.Ether.Implicit.Writer
50− Control.Monad.Ether.Implicit.State
51− Control.Monad.Ether.Implicit.State.Lazy
52− Control.Monad.Ether.Implicit.State.Strict
53− Control.Monad.Ether.Implicit.Except
29+ exposed-modules:
30+ Control.Ether.Abbr
31+ Control.Ether.Implicit.Abbr
32+ Control.Ether.Optic
33+ Control.Monad.Trans.Ether.Handler
34+ Control.Monad.Ether
35+ Control.Monad.Ether.Handle
36+ Control.Monad.Ether.TagAttach
37+ Control.Monad.Ether.TagReplace
38+ Control.Monad.Ether.Reader
39+ Control.Monad.Ether.Reader.Class
40+ Control.Monad.Ether.Writer
41+ Control.Monad.Ether.Writer.Class
42+ Control.Monad.Ether.State
43+ Control.Monad.Ether.State.Class
44+ Control.Monad.Ether.State.Lazy
45+ Control.Monad.Ether.State.Strict
46+ Control.Monad.Ether.Except
47+ Control.Monad.Ether.Except.Class
48+ Control.Monad.Ether.Implicit
49+ Control.Monad.Ether.Implicit.Reader
50+ Control.Monad.Ether.Implicit.Writer
51+ Control.Monad.Ether.Implicit.State
52+ Control.Monad.Ether.Implicit.State.Lazy
53+ Control.Monad.Ether.Implicit.State.Strict
54+ Control.Monad.Ether.Implicit.Except
5455
55− other-modules: Control.Monad.Ether.State.Common
56+ other-modules:
57+ Control.Monad.Ether.State.Common
5658
57− build-depends: base >=4.9 && <4.11
58− , transformers >=0.4.2
59− , transformers-lift >=0.1.0.1
60− , mtl >=2.2.1
61− , mmorph >=1.0.4
62− , monad-control >=1.0.0.4
63− , transformers-base >=0.4.4
64− , exceptions >=0.8
65− , template-haskell >=2.11
66− , tagged >=0.8.5
59+ build-depends:
60+ base >=4.9 && <4.11,
61+ transformers >=0.4.2,
62+ transformers-lift >=0.1.0.1,
63+ mtl >=2.2.1,
64+ mmorph >=1.0.4,
65+ monad-control >=1.0.0.4,
66+ transformers-base >=0.4.4,
67+ exceptions >=0.8,
68+ template-haskell >=2.11,
69+ tagged >=0.8.5
6770
68− default-language: Haskell2010
69− default-extensions: PolyKinds
70− ScopedTypeVariables
71− FunctionalDependencies
72− TypeApplications
73− other-extensions: ConstraintKinds
74− DataKinds
75− DefaultSignatures
76− DeriveGeneric
77− FlexibleInstances
78− GeneralizedNewtypeDeriving
79− TypeFamilies
80− TypeOperators
81− UndecidableInstances
71+ default-language:
72+ Haskell2010
8273
83− hs-source-dirs: src
84− ghc-options: -Wall -O2
74+ default-extensions:
75+ AllowAmbiguousTypes
76+ ConstraintKinds
77+ DataKinds
78+ DeriveGeneric
79+ EmptyDataDecls
80+ FlexibleContexts
81+ FlexibleInstances
82+ FunctionalDependencies
83+ GADTs
84+ GeneralizedNewtypeDeriving
85+ PartialTypeSignatures
86+ PolyKinds
87+ ScopedTypeVariables
88+ RankNTypes
89+ TemplateHaskell
90+ TupleSections
91+ TypeApplications
92+ TypeFamilies
93+ TypeInType
94+ TypeOperators
95+ TypeSynonymInstances
96+ UndecidableInstances
97+ UndecidableSuperClasses
98+
99+ hs-source-dirs:
100+ src
101+
102+ ghc-options:
103+ -Wall -O2
ether/src/Control/Ether/Abbr.hs+15−14
@@ -1,9 +1,3 @@
1−{-# LANGUAGE EmptyDataDecls #-}
2−{-# LANGUAGE TypeOperators #-}
3−{-# LANGUAGE ConstraintKinds #-}
4−{-# LANGUAGE DataKinds #-}
5−{-# LANGUAGE TypeFamilies #-}
6−
71-- | Abbreviations for constraints.
82
93module Control.Ether.Abbr
@@ -15,33 +9,34 @@ module Control.Ether.Abbr
159 , ReifyAbbr
1610 ) where
1711
12+import Data.Kind as K
1813import GHC.Exts (Constraint)
1914
2015import Control.Monad.Ether
2116
2217-- | Turns an abbreviation into an actual constraint.
23−type family ReifyAbbr (abbr :: *) (m :: * -> *) :: Constraint
18+type family ReifyAbbr (abbr :: k) :: (K.Type -> K.Type) -> Constraint
2419
2520-- | Denotes 'MonadReader'. The mnemonic is that you read values of type @r@
2621-- from the reader environment tagged by @tag@, thus the arrows points
2722-- from @tag@ to @r@.
2823data tag --> r
29−type instance ReifyAbbr (tag --> r) m = MonadReader tag r m
24+type instance ReifyAbbr (tag --> r) = MonadReader tag r
3025
3126-- | Denotes 'MonadWriter'. The mnemonic is that you write values of type @w@
3227-- to the writer accumulator tagged by @tag@, thus the arrows points
3328-- from @w@ to @tag@.
3429data tag <-- w
35−type instance ReifyAbbr (tag <-- w) m = MonadWriter tag w m
30+type instance ReifyAbbr (tag <-- w) = MonadWriter tag w
3631
3732-- | Denotes 'MonadState'. The mnemonic is that you can both read from and
3833-- write into the state, thus the arrow points in both directions.
3934data tag <-> s
40−type instance ReifyAbbr (tag <-> s) m = MonadState tag s m
35+type instance ReifyAbbr (tag <-> s) = MonadState tag s
4136
4237-- | Denotes 'MonadExcept'.
4338data tag -!- e
44−type instance ReifyAbbr (tag -!- e) m = MonadExcept tag e m
39+type instance ReifyAbbr (tag -!- e) = MonadExcept tag e
4540
4641-- | Reify a list of constraint abbreviations.
4742--
@@ -55,6 +50,12 @@ type instance ReifyAbbr (tag -!- e) m = MonadExcept tag e m
5550-- > , MonadExcept Quux e m
5651-- > ) => m a
5752
58−type family Ether (abbrs :: [*]) m :: Constraint where
59− Ether '[] m = ()
60− Ether (abbr ': abbrs) m = (ReifyAbbr abbr m, Ether abbrs m)
53+class U a
54+instance U a
55+
56+class (c a, d a) => (c &&& d) a
57+instance (c a, d a) => (c &&& d) a
58+
59+type family Ether (abbrs :: [K.Type]) :: (K.Type -> K.Type) -> Constraint where
60+ Ether '[] = U
61+ Ether (abbr ': abbrs) = ReifyAbbr abbr &&& Ether abbrs
ether/src/Control/Ether/Implicit/Abbr.hs+4−6
@@ -1,5 +1,3 @@
1−{-# LANGUAGE TypeFamilies #-}
2−
31-- | See "Control.Ether.Abbr".
42
53module Control.Ether.Implicit.Abbr (R, W, S, E) where
@@ -9,17 +7,17 @@ import Control.Monad.Ether.Implicit
97
108-- | Denotes 'MonadReader'.
119data R r
12−type instance ReifyAbbr (R r) m = MonadReader r m
10+type instance ReifyAbbr (R r) = MonadReader r
1311
1412-- | Denotes 'MonadWriter'.
1513data W w
16−type instance ReifyAbbr (W w) m = MonadWriter w m
14+type instance ReifyAbbr (W w) = MonadWriter w
1715
1816-- | Denotes 'MonadState'.
1917data S s
20−type instance ReifyAbbr (S s) m = MonadState s m
18+type instance ReifyAbbr (S s) = MonadState s
2119
2220-- | Denotes 'MonadExcept'.
2321data E e
24−type instance ReifyAbbr (E e) m = MonadExcept e m
22+type instance ReifyAbbr (E e) = MonadExcept e
2523
ether/src/Control/Ether/Optic.hs−13
@@ -1,16 +1,3 @@
1−{-# LANGUAGE RankNTypes #-}
2−{-# LANGUAGE AllowAmbiguousTypes #-}
3−{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE TupleSections #-}
5−{-# LANGUAGE TemplateHaskell #-}
6−{-# LANGUAGE DataKinds #-}
7−{-# LANGUAGE FlexibleContexts #-}
8−{-# LANGUAGE UndecidableInstances #-}
9−{-# LANGUAGE TypeOperators #-}
10−{-# LANGUAGE GADTs #-}
11−{-# LANGUAGE TypeInType #-}
12−{-# LANGUAGE TypeFamilies #-}
13−
141module Control.Ether.Optic
152 ( Tagged(..)
163 , Tags
ether/src/Control/Monad/Ether/Except.hs−6
@@ -1,9 +1,3 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE UndecidableInstances #-}
4−{-# LANGUAGE TypeFamilies #-}
5−{-# LANGUAGE AllowAmbiguousTypes #-}
6−
71-- | See "Control.Monad.Except".
82
93module Control.Monad.Ether.Except
ether/src/Control/Monad/Ether/Except/Class.hs−5
@@ -1,8 +1,3 @@
1−{-# LANGUAGE FlexibleInstances #-}
2−{-# LANGUAGE UndecidableInstances #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE AllowAmbiguousTypes #-}
5−
61-- | See "Control.Monad.Except".
72
83module Control.Monad.Ether.Except.Class
ether/src/Control/Monad/Ether/Handle.hs+8−11
@@ -1,11 +1,3 @@
1−{-# LANGUAGE RankNTypes #-}
2−{-# LANGUAGE ConstraintKinds #-}
3−{-# LANGUAGE AllowAmbiguousTypes #-}
4−{-# LANGUAGE TypeFamilies #-}
5−{-# LANGUAGE PolyKinds #-}
6−{-# LANGUAGE UndecidableInstances #-}
7−{-# LANGUAGE UndecidableSuperClasses #-}
8−
91module Control.Monad.Ether.Handle
102 ( Handle(..)
113 , HandleSuper
@@ -13,26 +5,31 @@ module Control.Monad.Ether.Handle
135 , TAGGED
146 ) where
157
8+import Data.Kind as K
169import GHC.Exts (Constraint)
1710
1811data TAGGED e t
1912
13+type K_Monad = K.Type -> K.Type
14+
15+type K_Trans = K_Monad -> K_Monad
16+
2017type family
2118 HandleSuper
2219 (eff :: keff)
2320 (p :: kp)
24− (trans :: (* -> *) -> * -> *)
21+ (trans :: K_Trans)
2522 :: Constraint
2623
2724type family
2825 HandleConstraint
2926 (eff :: keff)
3027 (p :: kp)
31− (trans :: (* -> *) -> * -> *) (m :: * -> *)
28+ (trans :: K_Trans) (m :: K_Monad)
3229 :: Constraint
3330
3431class
3532 HandleSuper eff p trans =>
36− Handle eff p (trans :: (* -> *) -> * -> *) | eff trans -> p
33+ Handle eff p (trans :: K_Trans) | eff trans -> p
3734 where
3835 handling :: Monad m => (HandleConstraint eff p trans m => r) -> r
ether/src/Control/Monad/Ether/Implicit/Except.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
31-- | See "Control.Monad.Ether.Except".
42
53module Control.Monad.Ether.Implicit.Except
ether/src/Control/Monad/Ether/Implicit/Reader.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
31-- | See "Control.Monad.Ether.Reader".
42
53module Control.Monad.Ether.Implicit.Reader
ether/src/Control/Monad/Ether/Implicit/State/Lazy.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
31-- | See "Control.Monad.Ether.State.Lazy".
42
53module Control.Monad.Ether.Implicit.State.Lazy
ether/src/Control/Monad/Ether/Implicit/State/Strict.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
31-- | See "Control.Monad.Ether.State.Strict".
42
53module Control.Monad.Ether.Implicit.State.Strict
ether/src/Control/Monad/Ether/Implicit/Writer.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
31-- | See "Control.Monad.Ether.Writer".
42
53module Control.Monad.Ether.Implicit.Writer
ether/src/Control/Monad/Ether/Reader.hs−7
@@ -1,10 +1,3 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE UndecidableInstances #-}
4−{-# LANGUAGE TypeFamilies #-}
5−{-# LANGUAGE AllowAmbiguousTypes #-}
6−{-# LANGUAGE TypeOperators #-}
7−
81-- | See "Control.Monad.Reader".
92
103module Control.Monad.Ether.Reader
ether/src/Control/Monad/Ether/Reader/Class.hs+16−8
@@ -1,16 +1,10 @@
1−{-# LANGUAGE FlexibleInstances #-}
2−{-# LANGUAGE UndecidableInstances #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE DataKinds #-}
6−{-# LANGUAGE AllowAmbiguousTypes #-}
7−
81-- | See "Control.Monad.Reader.Class".
92
103module Control.Monad.Ether.Reader.Class
114 ( MonadReader(..)
125 ) where
136
7+import Data.Kind as K
148import Control.Monad.Trans.Ether.Handler
159import qualified Control.Monad.Trans.Lift.Local as Lift
1610import Data.Coerce
@@ -45,13 +39,20 @@ instance {-# OVERLAPPABLE #-}
4539 , MonadReader tag r m
4640 ) => MonadReader tag r (t m)
4741 where
42+
4843 ask = Lift.lift (ask @tag)
44+ {-# INLINE ask #-}
45+
4946 local = Lift.liftLocal (ask @tag) (local @tag)
47+ {-# INLINE local #-}
48+
49+ reader = Lift.lift . reader @tag
50+ {-# INLINE reader #-}
5051
5152instance {-# OVERLAPPABLE #-}
5253 ( Monad (trans m)
5354 , MonadReader tag r (Handler dps trans m)
54− ) => MonadReader tag r (Handler (dp ': dps) trans (m :: * -> *))
55+ ) => MonadReader tag r (Handler (dp ': dps) trans (m :: K.Type -> K.Type))
5556 where
5657
5758 ask =
@@ -67,3 +68,10 @@ instance {-# OVERLAPPABLE #-}
6768 Lift.Local r (Handler (dp ': dps) trans m) a)
6869 (local @tag)
6970 {-# INLINE local #-}
71+
72+ reader =
73+ (coerce :: forall a .
74+ ((r -> a) -> Handler dps trans m a) ->
75+ ((r -> a) -> Handler (dp ': dps) trans m a))
76+ (reader @tag)
77+ {-# INLINE reader #-}
ether/src/Control/Monad/Ether/State/Class.hs+8−8
@@ -1,16 +1,10 @@
1−{-# LANGUAGE FlexibleInstances #-}
2−{-# LANGUAGE UndecidableInstances #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE TypeOperators #-}
5−{-# LANGUAGE DataKinds #-}
6−{-# LANGUAGE AllowAmbiguousTypes #-}
7−
81-- | See "Control.Monad.State.Class".
92
103module Control.Monad.Ether.State.Class
114 ( MonadState(..)
125 ) where
136
7+import Data.Kind as K
148import Control.Monad.Trans.Ether.Handler
159import qualified Control.Monad.Trans as Lift
1610import Data.Coerce
@@ -42,14 +36,20 @@ instance {-# OVERLAPPABLE #-}
4236 , MonadState tag s m
4337 ) => MonadState tag s (t m)
4438 where
39+
4540 get = Lift.lift (get @tag)
41+ {-# INLINE get #-}
42+
4643 put = Lift.lift . put @tag
44+ {-# INLINE put #-}
45+
4746 state = Lift.lift . state @tag
47+ {-# INLINE state #-}
4848
4949instance {-# OVERLAPPABLE #-}
5050 ( Monad (trans m)
5151 , MonadState tag s (Handler dps trans m)
52− ) => MonadState tag s (Handler (dp ': dps) trans (m :: * -> *))
52+ ) => MonadState tag s (Handler (dp ': dps) trans (m :: K.Type -> K.Type))
5353 where
5454
5555 get =
ether/src/Control/Monad/Ether/State/Common.hs−7
@@ -1,10 +1,3 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE AllowAmbiguousTypes #-}
3−{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE UndecidableInstances #-}
5−{-# LANGUAGE TypeFamilies #-}
6−{-# LANGUAGE TypeOperators #-}
7−
81module Control.Monad.Ether.State.Common
92 ( MonadState
103 , get
ether/src/Control/Monad/Ether/State/Lazy.hs−5
@@ -1,8 +1,3 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE UndecidableInstances #-}
4−{-# LANGUAGE TypeFamilies #-}
5−
61-- | See "Control.Monad.State.Lazy".
72
83module Control.Monad.Ether.State.Lazy
ether/src/Control/Monad/Ether/State/Strict.hs−5
@@ -1,8 +1,3 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE UndecidableInstances #-}
4−{-# LANGUAGE TypeFamilies #-}
5−
61-- | See "Control.Monad.State.Strict".
72
83module Control.Monad.Ether.State.Strict
ether/src/Control/Monad/Ether/TagAttach.hs−7
@@ -1,10 +1,3 @@
1−{-# LANGUAGE DeriveGeneric #-}
2−{-# LANGUAGE TypeFamilies #-}
3−{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE UndecidableInstances #-}
5−{-# LANGUAGE DataKinds #-}
6−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7−
81module Control.Monad.Ether.TagAttach
92 ( TAG_ATTACH
103 , TagAttachT
ether/src/Control/Monad/Ether/TagReplace.hs−7
@@ -1,10 +1,3 @@
1−{-# LANGUAGE DeriveGeneric #-}
2−{-# LANGUAGE TypeFamilies #-}
3−{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE UndecidableInstances #-}
5−{-# LANGUAGE DataKinds #-}
6−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7−
81module Control.Monad.Ether.TagReplace
92 ( TAG_REPLACE
103 , TagReplaceT
ether/src/Control/Monad/Ether/Writer.hs−6
@@ -1,9 +1,3 @@
1−{-# LANGUAGE DataKinds #-}
2−{-# LANGUAGE FlexibleInstances #-}
3−{-# LANGUAGE UndecidableInstances #-}
4−{-# LANGUAGE TypeFamilies #-}
5−{-# LANGUAGE AllowAmbiguousTypes #-}
6−
71-- | See "Control.Monad.Writer".
82
93module Control.Monad.Ether.Writer
ether/src/Control/Monad/Ether/Writer/Class.hs+10−9
@@ -1,8 +1,3 @@
1−{-# LANGUAGE FlexibleInstances #-}
2−{-# LANGUAGE UndecidableInstances #-}
3−{-# LANGUAGE TypeFamilies #-}
4−{-# LANGUAGE AllowAmbiguousTypes #-}
5−
61-- | See "Control.Monad.Writer.Class".
72
83module Control.Monad.Ether.Writer.Class
@@ -19,9 +14,7 @@ class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where
1914
2015 -- | Embed a simple writer action.
2116 writer :: (a, w) -> m a
22− writer ~(a, w) = do
23− tell @tag w
24− return a
17+ writer ~(a, w) = a <$ tell @tag w
2518
2619 -- | Append a value to the accumulator within the monad.
2720 tell :: w -> m ()
@@ -33,7 +26,7 @@ class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where
3326
3427 -- | Execute an action which returns a value and a function,
3528 -- and return the value, applying the function to the accumulator.
36− pass :: m (a, w -> w) -> m a
29+ pass :: m (a, w -> w) -> m a
3730
3831instance {-# OVERLAPPABLE #-}
3932 ( Lift.LiftListen t
@@ -42,7 +35,15 @@ instance {-# OVERLAPPABLE #-}
4235 , MonadWriter tag w m
4336 , Monoid w
4437 ) => MonadWriter tag w (t m) where
38+
4539 writer = Lift.lift . writer @tag
40+ {-# INLINE writer #-}
41+
4642 tell = Lift.lift . tell @tag
43+ {-# INLINE tell #-}
44+
4745 listen = Lift.liftListen (listen @tag)
46+ {-# INLINE listen #-}
47+
4848 pass = Lift.liftPass (pass @tag)
49+ {-# INLINE pass #-}
ether/src/Control/Monad/Trans/Ether/Handler.hs−9
@@ -1,12 +1,3 @@
1−{-# LANGUAGE DeriveGeneric #-}
2−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3−{-# LANGUAGE FlexibleInstances #-}
4−{-# LANGUAGE UndecidableInstances #-}
5−{-# LANGUAGE ConstraintKinds #-}
6−{-# LANGUAGE RankNTypes #-}
7−{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE TypeFamilies #-}
9−
101module Control.Monad.Trans.Ether.Handler
112 ( Handler(..)
123 ) where