on master help sign in
Enable -XKitchenSink by default
3019f46Vladislav Zavialov
ether-flatten/ether-flatten.cabal+49−21
@@ -17,28 +17,56 @@ extra-source-files: CHANGELOG.md
17
17
18source-repository head
18source-repository head
19
19
20− type: git
20+ type: git
21− location: git@github.com:int-index/ether.git
21+ location: git@github.com:int-index/ether.git
22
22
23
23
24library
24library
25
25
26+ exposed-modules:
26− exposed-modules: Control.Monad.Ether.Reader.Flatten
27+ Control.Monad.Ether.Reader.Flatten
27− , Control.Monad.Ether.State.Flatten
28+ Control.Monad.Ether.State.Flatten
29+
28− build-depends: base >=4.9 && <4.11
30+ build-depends:
31+ base >=4.9 && <4.11,
29− , ether >=0.5 && <0.6
32+ ether >=0.5 && <0.6,
30− , mtl >=2.2.1
33+ mtl >=2.2.1,
31− , transformers >=0.4.2
34+ transformers >=0.4.2,
32− , transformers-lift >=0.1.0.1
35+ transformers-lift >=0.1.0.1,
33− , ghc-prim >=0.3
36+ ghc-prim >=0.3,
34− , lens >=4.14
37+ lens >=4.14,
35− , deepseq >= 1.4
38+ deepseq >= 1.4
36−
39+
37− default-language: Haskell2010
40+ default-language:
41+ Haskell2010
42+
38− default-extensions: PolyKinds
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
39− ScopedTypeVariables
56+ ScopedTypeVariables
40− FunctionalDependencies
57+ RankNTypes
58+ TemplateHaskell
59+ TupleSections
41− TypeApplications
60+ TypeApplications
42−
61+ TypeFamilies
62+ TypeInType
63+ TypeOperators
64+ TypeSynonymInstances
65+ UndecidableInstances
66+ UndecidableSuperClasses
67+
43− hs-source-dirs: src
68+ hs-source-dirs:
69+ src
70+
44− ghc-options: -Wall -O2
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−
13module Control.Monad.Ether.Reader.Flatten
1module Control.Monad.Ether.Reader.Flatten
14 ( runReader
2 ( runReader
15 , runReaderT
3 , 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−
12module Control.Monad.Ether.State.Flatten
1module Control.Monad.Ether.State.Flatten
13 ( runState
2 ( runState
14 , runStateT
3 , runStateT
ether-suite/bench/Bench.hs−8
@@ -1,13 +1,5 @@
1{-# OPTIONS -fno-warn-partial-type-signatures #-}
1{-# OPTIONS -fno-warn-partial-type-signatures #-}
2
2
3−{-# LANGUAGE TypeApplications #-}
4−{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE FunctionalDependencies #-}
6−{-# LANGUAGE FlexibleContexts #-}
7−{-# LANGUAGE DataKinds #-}
8−{-# LANGUAGE TypeOperators #-}
9−{-# LANGUAGE PartialTypeSignatures #-}
10−
11module Main (main) where
3module Main (main) where
12
4
13import Criterion.Main
5import Criterion.Main
ether-suite/ether-suite.cabal+115−54
@@ -9,63 +9,124 @@ library
9
9
10test-suite regression
10test-suite regression
11
11
12− build-depends: base >=4.9 && <4.11
12+ build-depends:
13+ base >=4.9 && <4.11,
13− , transformers >=0.4.2
14+ transformers >=0.4.2,
14− , mtl >=2.2.1
15+ mtl >=2.2.1,
15− , tasty >=0.10
16+ tasty >=0.10,
16− , tasty-quickcheck >=0.8
17+ tasty-quickcheck >=0.8,
17− , QuickCheck >=2.8
18+ QuickCheck >=2.8,
18− , ghc-prim >=0.3
19+ ghc-prim >=0.3,
19− , lens >=4.14
20+ lens >=4.14,
20− , ether
21+ ether,
21− , ether-zoom
22+ ether-zoom
22−
23+
24+ main-is:
23− main-is: Regression.hs
25+ Regression.hs
26+
24− other-modules: Regression.T1
27+ other-modules:
28+ Regression.T1
25− Regression.T2
29+ Regression.T2
26− Regression.T3
30+ Regression.T3
27− Regression.T4
31+ Regression.T4
28− Regression.T5
32+ Regression.T5
29− Regression.T6
33+ Regression.T6
30− Regression.T7
34+ Regression.T7
31− Regression.T8
35+ Regression.T8
32− Regression.T9
36+ Regression.T9
33− Regression.T10
37+ Regression.T10
34− Regression.T11
38+ Regression.T11
35− Regression.T12
39+ Regression.T12
36−
40+
41+ type:
37− type: exitcode-stdio-1.0
42+ exitcode-stdio-1.0
43+
38− hs-source-dirs: test
44+ hs-source-dirs:
45+ test
46+
39− default-language: Haskell2010
47+ default-language:
48+ Haskell2010
49+
40− default-extensions: ConstraintKinds
50+ default-extensions:
51+ AllowAmbiguousTypes
52+ ConstraintKinds
41− DataKinds
53+ DataKinds
54+ DeriveGeneric
42− EmptyDataDecls
55+ EmptyDataDecls
43− FlexibleContexts
56+ FlexibleContexts
57+ FlexibleInstances
58+ FunctionalDependencies
59+ GADTs
44− GeneralizedNewtypeDeriving
60+ GeneralizedNewtypeDeriving
45− LambdaCase
61+ PartialTypeSignatures
46− PolyKinds
62+ PolyKinds
47− ScopedTypeVariables
63+ ScopedTypeVariables
64+ RankNTypes
65+ TemplateHaskell
66+ TupleSections
48− TypeApplications
67+ TypeApplications
49− TypeFamilies
68+ TypeFamilies
69+ TypeInType
50− TypeOperators
70+ TypeOperators
71+ TypeSynonymInstances
72+ UndecidableInstances
73+ UndecidableSuperClasses
74+
75+ ghc-options:
51− ghc-options: -Wall -fno-warn-missing-signatures
76+ -Wall -fno-warn-missing-signatures
52
77
53
78
54benchmark bench
79benchmark bench
55
80
56− build-depends: base >=4.9 && <4.11
81+ build-depends:
82+ base >=4.9 && <4.11,
57− , mtl >=2.2.1
83+ mtl >=2.2.1,
58− , transformers >=0.4.2
84+ transformers >=0.4.2,
59− , criterion >=1.1
85+ criterion >=1.1,
60− , deepseq >=1.4
86+ deepseq >=1.4,
61− , lens >=4.14
87+ lens >=4.14,
62− , ether
88+ ether,
63− , ether-flatten
89+ ether-flatten
64
90
91+ main-is:
65− main-is: Bench.hs
92+ Bench.hs
66
93
94+ type:
67− type: exitcode-stdio-1.0
95+ exitcode-stdio-1.0
96+
68− hs-source-dirs: bench
97+ hs-source-dirs:
98+ bench
99+
69− default-language: Haskell2010
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+
70− ghc-options: -Wall -O2
128+ ghc-options:
129+ -Wall -O2
130+
71− ghc-prof-options: -fprof-auto
131+ ghc-prof-options:
132+ -fprof-auto
ether-zoom/ether-zoom.cabal+42−17
@@ -17,24 +17,49 @@ extra-source-files: CHANGELOG.md
17
17
18source-repository head
18source-repository head
19
19
20− type: git
20+ type: git
21− location: git@github.com:int-index/ether.git
21+ location: git@github.com:int-index/ether.git
22
22
23
23
24library
24library
25
25
26+ exposed-modules:
26− exposed-modules: Control.Monad.Ether.State.Zoom
27+ Control.Monad.Ether.State.Zoom
28+
27− build-depends: base >=4.9 && <4.11
29+ build-depends:
30+ base >=4.9 && <4.11,
28− , ether >=0.5 && <0.6
31+ ether >=0.5 && <0.6,
29− , transformers >=0.5
32+ transformers >=0.5,
30− , lens >=4.14
33+ lens >=4.14,
31− , reflection >=2.1
34+ reflection >=2.1
32−
35+
33− default-language: Haskell2010
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
34− default-extensions: PolyKinds
48+ PolyKinds
35− ScopedTypeVariables
49+ ScopedTypeVariables
36− FunctionalDependencies
50+ RankNTypes
51+ TemplateHaskell
52+ TupleSections
37− TypeApplications
53+ TypeApplications
38−
54+ TypeFamilies
55+ TypeInType
56+ TypeOperators
57+ TypeSynonymInstances
58+ UndecidableInstances
59+ UndecidableSuperClasses
60+
39− hs-source-dirs: src
61+ hs-source-dirs:
62+ src
63+
40− ghc-options: -Wall -O2
64+ ghc-options:
65+ -Wall -O2
ether-zoom/src/Control/Monad/Ether/State/Zoom.hs+2−9
@@ -1,19 +1,12 @@
1{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
1{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
2
2
3−{-# LANGUAGE DataKinds #-}
4−{-# LANGUAGE RankNTypes #-}
5−{-# LANGUAGE TypeSynonymInstances #-}
6−{-# LANGUAGE FlexibleInstances #-}
7−{-# LANGUAGE FlexibleContexts #-}
8−{-# LANGUAGE UndecidableInstances #-}
9−{-# LANGUAGE TypeFamilies #-}
10−
11module Control.Monad.Ether.State.Zoom
3module Control.Monad.Ether.State.Zoom
12 ( TAG_ZOOM
4 ( TAG_ZOOM
13 , TagZoomT
5 , TagZoomT
14 , tagZoom
6 , tagZoom
15 ) where
7 ) where
16
8
9+import Data.Kind as K
17import Control.Lens
10import Control.Lens
18import Data.Reflection
11import Data.Reflection
19import Control.Monad.Trans.Ether.Handler
12import Control.Monad.Trans.Ether.Handler
@@ -25,7 +18,7 @@ import Data.Coerce
25-- | Encode type-level information for 'tagZoom'.
18-- | Encode type-level information for 'tagZoom'.
26data TAG_ZOOM t z
19data TAG_ZOOM t z
27
20
28−type TagZoomT t (z :: *) = Handler (TAG_ZOOM t z) IdentityT
21+type TagZoomT t (z :: K.Type) = Handler (TAG_ZOOM t z) IdentityT
29
22
30-- | Zoom into a part of a state using a lens.
23-- | Zoom into a part of a state using a lens.
31tagZoom
24tagZoom
ether/ether.cabal+73−54
@@ -20,65 +20,84 @@ extra-source-files: CHANGELOG.md
20
20
21source-repository head
21source-repository head
22
22
23− type: git
23+ type: git
24− location: git@github.com:int-index/ether.git
24+ location: git@github.com:int-index/ether.git
25
25
26
26
27library
27library
28
28
29+ exposed-modules:
29− exposed-modules: Control.Ether.Abbr
30+ Control.Ether.Abbr
30− Control.Ether.Implicit.Abbr
31+ Control.Ether.Implicit.Abbr
31− Control.Ether.Optic
32+ Control.Ether.Optic
32− Control.Monad.Trans.Ether.Handler
33+ Control.Monad.Trans.Ether.Handler
33− Control.Monad.Ether
34+ Control.Monad.Ether
34− Control.Monad.Ether.Handle
35+ Control.Monad.Ether.Handle
35− Control.Monad.Ether.TagAttach
36+ Control.Monad.Ether.TagAttach
36− Control.Monad.Ether.TagReplace
37+ Control.Monad.Ether.TagReplace
37− Control.Monad.Ether.Reader
38+ Control.Monad.Ether.Reader
38− Control.Monad.Ether.Reader.Class
39+ Control.Monad.Ether.Reader.Class
39− Control.Monad.Ether.Writer
40+ Control.Monad.Ether.Writer
40− Control.Monad.Ether.Writer.Class
41+ Control.Monad.Ether.Writer.Class
41− Control.Monad.Ether.State
42+ Control.Monad.Ether.State
42− Control.Monad.Ether.State.Class
43+ Control.Monad.Ether.State.Class
43− Control.Monad.Ether.State.Lazy
44+ Control.Monad.Ether.State.Lazy
44− Control.Monad.Ether.State.Strict
45+ Control.Monad.Ether.State.Strict
45− Control.Monad.Ether.Except
46+ Control.Monad.Ether.Except
46− Control.Monad.Ether.Except.Class
47+ Control.Monad.Ether.Except.Class
47− Control.Monad.Ether.Implicit
48+ Control.Monad.Ether.Implicit
48− Control.Monad.Ether.Implicit.Reader
49+ Control.Monad.Ether.Implicit.Reader
49− Control.Monad.Ether.Implicit.Writer
50+ Control.Monad.Ether.Implicit.Writer
50− Control.Monad.Ether.Implicit.State
51+ Control.Monad.Ether.Implicit.State
51− Control.Monad.Ether.Implicit.State.Lazy
52+ Control.Monad.Ether.Implicit.State.Lazy
52− Control.Monad.Ether.Implicit.State.Strict
53+ Control.Monad.Ether.Implicit.State.Strict
53− Control.Monad.Ether.Implicit.Except
54+ Control.Monad.Ether.Implicit.Except
54
55
56+ other-modules:
55− other-modules: Control.Monad.Ether.State.Common
57+ Control.Monad.Ether.State.Common
56
58
57− build-depends: base >=4.9 && <4.11
59+ build-depends:
60+ base >=4.9 && <4.11,
58− , transformers >=0.4.2
61+ transformers >=0.4.2,
59− , transformers-lift >=0.1.0.1
62+ transformers-lift >=0.1.0.1,
60− , mtl >=2.2.1
63+ mtl >=2.2.1,
61− , mmorph >=1.0.4
64+ mmorph >=1.0.4,
62− , monad-control >=1.0.0.4
65+ monad-control >=1.0.0.4,
63− , transformers-base >=0.4.4
66+ transformers-base >=0.4.4,
64− , exceptions >=0.8
67+ exceptions >=0.8,
65− , template-haskell >=2.11
68+ template-haskell >=2.11,
66− , tagged >=0.8.5
69+ tagged >=0.8.5
67
70
68− default-language: Haskell2010
71+ default-language:
69− default-extensions: PolyKinds
72+ Haskell2010
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
82
73
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+
83− hs-source-dirs: src
99+ hs-source-dirs:
100+ src
101+
84− ghc-options: -Wall -O2
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−
7-- | Abbreviations for constraints.
1-- | Abbreviations for constraints.
8
2
9module Control.Ether.Abbr
3module Control.Ether.Abbr
@@ -15,33 +9,34 @@ module Control.Ether.Abbr
15 , ReifyAbbr
9 , ReifyAbbr
16 ) where
10 ) where
17
11
12+import Data.Kind as K
18import GHC.Exts (Constraint)
13import GHC.Exts (Constraint)
19
14
20import Control.Monad.Ether
15import Control.Monad.Ether
21
16
22-- | Turns an abbreviation into an actual constraint.
17-- | 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
24
19
25-- | Denotes 'MonadReader'. The mnemonic is that you read values of type @r@
20-- | Denotes 'MonadReader'. The mnemonic is that you read values of type @r@
26-- from the reader environment tagged by @tag@, thus the arrows points
21-- from the reader environment tagged by @tag@, thus the arrows points
27-- from @tag@ to @r@.
22-- from @tag@ to @r@.
28data tag --> r
23data tag --> r
29−type instance ReifyAbbr (tag --> r) m = MonadReader tag r m
24+type instance ReifyAbbr (tag --> r) = MonadReader tag r
30
25
31-- | Denotes 'MonadWriter'. The mnemonic is that you write values of type @w@
26-- | Denotes 'MonadWriter'. The mnemonic is that you write values of type @w@
32-- to the writer accumulator tagged by @tag@, thus the arrows points
27-- to the writer accumulator tagged by @tag@, thus the arrows points
33-- from @w@ to @tag@.
28-- from @w@ to @tag@.
34data tag <-- w
29data tag <-- w
35−type instance ReifyAbbr (tag <-- w) m = MonadWriter tag w m
30+type instance ReifyAbbr (tag <-- w) = MonadWriter tag w
36
31
37-- | Denotes 'MonadState'. The mnemonic is that you can both read from and
32-- | Denotes 'MonadState'. The mnemonic is that you can both read from and
38-- write into the state, thus the arrow points in both directions.
33-- write into the state, thus the arrow points in both directions.
39data tag <-> s
34data tag <-> s
40−type instance ReifyAbbr (tag <-> s) m = MonadState tag s m
35+type instance ReifyAbbr (tag <-> s) = MonadState tag s
41
36
42-- | Denotes 'MonadExcept'.
37-- | Denotes 'MonadExcept'.
43data tag -!- e
38data tag -!- e
44−type instance ReifyAbbr (tag -!- e) m = MonadExcept tag e m
39+type instance ReifyAbbr (tag -!- e) = MonadExcept tag e
45
40
46-- | Reify a list of constraint abbreviations.
41-- | Reify a list of constraint abbreviations.
47--
42--
@@ -55,6 +50,12 @@ type instance ReifyAbbr (tag -!- e) m = MonadExcept tag e m
55-- > , MonadExcept Quux e m
50-- > , MonadExcept Quux e m
56-- > ) => m a
51-- > ) => m a
57
52
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+
58−type family Ether (abbrs :: [*]) m :: Constraint where
59+type family Ether (abbrs :: [K.Type]) :: (K.Type -> K.Type) -> Constraint where
59− Ether '[] m = ()
60+ Ether '[] = U
60− Ether (abbr ': abbrs) m = (ReifyAbbr abbr m, Ether abbrs m)
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−
3-- | See "Control.Ether.Abbr".
1-- | See "Control.Ether.Abbr".
4
2
5module Control.Ether.Implicit.Abbr (R, W, S, E) where
3module Control.Ether.Implicit.Abbr (R, W, S, E) where
@@ -9,17 +7,17 @@ import Control.Monad.Ether.Implicit
9
7
10-- | Denotes 'MonadReader'.
8-- | Denotes 'MonadReader'.
11data R r
9data R r
12−type instance ReifyAbbr (R r) m = MonadReader r m
10+type instance ReifyAbbr (R r) = MonadReader r
13
11
14-- | Denotes 'MonadWriter'.
12-- | Denotes 'MonadWriter'.
15data W w
13data W w
16−type instance ReifyAbbr (W w) m = MonadWriter w m
14+type instance ReifyAbbr (W w) = MonadWriter w
17
15
18-- | Denotes 'MonadState'.
16-- | Denotes 'MonadState'.
19data S s
17data S s
20−type instance ReifyAbbr (S s) m = MonadState s m
18+type instance ReifyAbbr (S s) = MonadState s
21
19
22-- | Denotes 'MonadExcept'.
20-- | Denotes 'MonadExcept'.
23data E e
21data E e
24−type instance ReifyAbbr (E e) m = MonadExcept e m
22+type instance ReifyAbbr (E e) = MonadExcept e
25
23
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−
14module Control.Ether.Optic
1module Control.Ether.Optic
15 ( Tagged(..)
2 ( Tagged(..)
16 , Tags
3 , 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−
7-- | See "Control.Monad.Except".
1-- | See "Control.Monad.Except".
8
2
9module Control.Monad.Ether.Except
3module 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−
6-- | See "Control.Monad.Except".
1-- | See "Control.Monad.Except".
7
2
8module Control.Monad.Ether.Except.Class
3module 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−
9module Control.Monad.Ether.Handle
1module Control.Monad.Ether.Handle
10 ( Handle(..)
2 ( Handle(..)
11 , HandleSuper
3 , HandleSuper
@@ -13,26 +5,31 @@ module Control.Monad.Ether.Handle
13 , TAGGED
5 , TAGGED
14 ) where
6 ) where
15
7
8+import Data.Kind as K
16import GHC.Exts (Constraint)
9import GHC.Exts (Constraint)
17
10
18data TAGGED e t
11data TAGGED e t
19
12
13+type K_Monad = K.Type -> K.Type
14+
15+type K_Trans = K_Monad -> K_Monad
16+
20type family
17type family
21 HandleSuper
18 HandleSuper
22 (eff :: keff)
19 (eff :: keff)
23 (p :: kp)
20 (p :: kp)
24− (trans :: (* -> *) -> * -> *)
21+ (trans :: K_Trans)
25 :: Constraint
22 :: Constraint
26
23
27type family
24type family
28 HandleConstraint
25 HandleConstraint
29 (eff :: keff)
26 (eff :: keff)
30 (p :: kp)
27 (p :: kp)
31− (trans :: (* -> *) -> * -> *) (m :: * -> *)
28+ (trans :: K_Trans) (m :: K_Monad)
32 :: Constraint
29 :: Constraint
33
30
34class
31class
35 HandleSuper eff p trans =>
32 HandleSuper eff p trans =>
36− Handle eff p (trans :: (* -> *) -> * -> *) | eff trans -> p
33+ Handle eff p (trans :: K_Trans) | eff trans -> p
37 where
34 where
38 handling :: Monad m => (HandleConstraint eff p trans m => r) -> r
35 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−
3-- | See "Control.Monad.Ether.Except".
1-- | See "Control.Monad.Ether.Except".
4
2
5module Control.Monad.Ether.Implicit.Except
3module Control.Monad.Ether.Implicit.Except
ether/src/Control/Monad/Ether/Implicit/Reader.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
3-- | See "Control.Monad.Ether.Reader".
1-- | See "Control.Monad.Ether.Reader".
4
2
5module Control.Monad.Ether.Implicit.Reader
3module Control.Monad.Ether.Implicit.Reader
ether/src/Control/Monad/Ether/Implicit/State/Lazy.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
3-- | See "Control.Monad.Ether.State.Lazy".
1-- | See "Control.Monad.Ether.State.Lazy".
4
2
5module Control.Monad.Ether.Implicit.State.Lazy
3module Control.Monad.Ether.Implicit.State.Lazy
ether/src/Control/Monad/Ether/Implicit/State/Strict.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
3-- | See "Control.Monad.Ether.State.Strict".
1-- | See "Control.Monad.Ether.State.Strict".
4
2
5module Control.Monad.Ether.Implicit.State.Strict
3module Control.Monad.Ether.Implicit.State.Strict
ether/src/Control/Monad/Ether/Implicit/Writer.hs−2
@@ -1,5 +1,3 @@
1−{-# LANGUAGE ConstraintKinds #-}
2−
3-- | See "Control.Monad.Ether.Writer".
1-- | See "Control.Monad.Ether.Writer".
4
2
5module Control.Monad.Ether.Implicit.Writer
3module 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−
8-- | See "Control.Monad.Reader".
1-- | See "Control.Monad.Reader".
9
2
10module Control.Monad.Ether.Reader
3module 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−
8-- | See "Control.Monad.Reader.Class".
1-- | See "Control.Monad.Reader.Class".
9
2
10module Control.Monad.Ether.Reader.Class
3module Control.Monad.Ether.Reader.Class
11 ( MonadReader(..)
4 ( MonadReader(..)
12 ) where
5 ) where
13
6
7+import Data.Kind as K
14import Control.Monad.Trans.Ether.Handler
8import Control.Monad.Trans.Ether.Handler
15import qualified Control.Monad.Trans.Lift.Local as Lift
9import qualified Control.Monad.Trans.Lift.Local as Lift
16import Data.Coerce
10import Data.Coerce
@@ -45,13 +39,20 @@ instance {-# OVERLAPPABLE #-}
45 , MonadReader tag r m
39 , MonadReader tag r m
46 ) => MonadReader tag r (t m)
40 ) => MonadReader tag r (t m)
47 where
41 where
42+
48 ask = Lift.lift (ask @tag)
43 ask = Lift.lift (ask @tag)
44+ {-# INLINE ask #-}
45+
49 local = Lift.liftLocal (ask @tag) (local @tag)
46 local = Lift.liftLocal (ask @tag) (local @tag)
47+ {-# INLINE local #-}
48+
49+ reader = Lift.lift . reader @tag
50+ {-# INLINE reader #-}
50
51
51instance {-# OVERLAPPABLE #-}
52instance {-# OVERLAPPABLE #-}
52 ( Monad (trans m)
53 ( Monad (trans m)
53 , MonadReader tag r (Handler dps trans m)
54 , 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))
55 where
56 where
56
57
57 ask =
58 ask =
@@ -67,3 +68,10 @@ instance {-# OVERLAPPABLE #-}
67 Lift.Local r (Handler (dp ': dps) trans m) a)
68 Lift.Local r (Handler (dp ': dps) trans m) a)
68 (local @tag)
69 (local @tag)
69 {-# INLINE local #-}
70 {-# 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−
8-- | See "Control.Monad.State.Class".
1-- | See "Control.Monad.State.Class".
9
2
10module Control.Monad.Ether.State.Class
3module Control.Monad.Ether.State.Class
11 ( MonadState(..)
4 ( MonadState(..)
12 ) where
5 ) where
13
6
7+import Data.Kind as K
14import Control.Monad.Trans.Ether.Handler
8import Control.Monad.Trans.Ether.Handler
15import qualified Control.Monad.Trans as Lift
9import qualified Control.Monad.Trans as Lift
16import Data.Coerce
10import Data.Coerce
@@ -42,14 +36,20 @@ instance {-# OVERLAPPABLE #-}
42 , MonadState tag s m
36 , MonadState tag s m
43 ) => MonadState tag s (t m)
37 ) => MonadState tag s (t m)
44 where
38 where
39+
45 get = Lift.lift (get @tag)
40 get = Lift.lift (get @tag)
41+ {-# INLINE get #-}
42+
46 put = Lift.lift . put @tag
43 put = Lift.lift . put @tag
44+ {-# INLINE put #-}
45+
47 state = Lift.lift . state @tag
46 state = Lift.lift . state @tag
47+ {-# INLINE state #-}
48
48
49instance {-# OVERLAPPABLE #-}
49instance {-# OVERLAPPABLE #-}
50 ( Monad (trans m)
50 ( Monad (trans m)
51 , MonadState tag s (Handler dps trans m)
51 , 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))
53 where
53 where
54
54
55 get =
55 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−
8module Control.Monad.Ether.State.Common
1module Control.Monad.Ether.State.Common
9 ( MonadState
2 ( MonadState
10 , get
3 , 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−
6-- | See "Control.Monad.State.Lazy".
1-- | See "Control.Monad.State.Lazy".
7
2
8module Control.Monad.Ether.State.Lazy
3module 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−
6-- | See "Control.Monad.State.Strict".
1-- | See "Control.Monad.State.Strict".
7
2
8module Control.Monad.Ether.State.Strict
3module 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−
8module Control.Monad.Ether.TagAttach
1module Control.Monad.Ether.TagAttach
9 ( TAG_ATTACH
2 ( TAG_ATTACH
10 , TagAttachT
3 , 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−
8module Control.Monad.Ether.TagReplace
1module Control.Monad.Ether.TagReplace
9 ( TAG_REPLACE
2 ( TAG_REPLACE
10 , TagReplaceT
3 , 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−
7-- | See "Control.Monad.Writer".
1-- | See "Control.Monad.Writer".
8
2
9module Control.Monad.Ether.Writer
3module 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−
6-- | See "Control.Monad.Writer.Class".
1-- | See "Control.Monad.Writer.Class".
7
2
8module Control.Monad.Ether.Writer.Class
3module Control.Monad.Ether.Writer.Class
@@ -19,9 +14,7 @@ class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where
19
14
20 -- | Embed a simple writer action.
15 -- | Embed a simple writer action.
21 writer :: (a, w) -> m a
16 writer :: (a, w) -> m a
22− writer ~(a, w) = do
23− tell @tag w
17+ writer ~(a, w) = a <$ tell @tag w
24− return a
25
18
26 -- | Append a value to the accumulator within the monad.
19 -- | Append a value to the accumulator within the monad.
27 tell :: w -> m ()
20 tell :: w -> m ()
@@ -33,7 +26,7 @@ class (Monoid w, Monad m) => MonadWriter tag w m | m tag -> w where
33
26
34 -- | Execute an action which returns a value and a function,
27 -- | Execute an action which returns a value and a function,
35 -- and return the value, applying the function to the accumulator.
28 -- 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
37
30
38instance {-# OVERLAPPABLE #-}
31instance {-# OVERLAPPABLE #-}
39 ( Lift.LiftListen t
32 ( Lift.LiftListen t
@@ -42,7 +35,15 @@ instance {-# OVERLAPPABLE #-}
42 , MonadWriter tag w m
35 , MonadWriter tag w m
43 , Monoid w
36 , Monoid w
44 ) => MonadWriter tag w (t m) where
37 ) => MonadWriter tag w (t m) where
38+
45 writer = Lift.lift . writer @tag
39 writer = Lift.lift . writer @tag
40+ {-# INLINE writer #-}
41+
46 tell = Lift.lift . tell @tag
42 tell = Lift.lift . tell @tag
43+ {-# INLINE tell #-}
44+
47 listen = Lift.liftListen (listen @tag)
45 listen = Lift.liftListen (listen @tag)
46+ {-# INLINE listen #-}
47+
48 pass = Lift.liftPass (pass @tag)
48 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−
10module Control.Monad.Trans.Ether.Handler
1module Control.Monad.Trans.Ether.Handler
11 ( Handler(..)
2 ( Handler(..)
12 ) where
3 ) where