on master help sign in
Upgrade warning options to 8.2.1 and add more options
commit9c80d6c8be2f83bfbcb78870c7d49ae801da871a authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 13 Sep 2017, 23:23 (9 years ago) parent6f1a0b1
2 files changed+69−34
asyncly.cabal+39−8 src/Asyncly/AsyncT.hs+30−26
asyncly.cabal+39−8
@@ -35,8 +35,18 @@ library
3535 , Asyncly.AsyncT
3636
3737 default-language: Haskell2010
38− ghc-options: -Wall -fwarn-identities -fwarn-incomplete-record-updates
39− -fwarn-incomplete-uni-patterns -fwarn-tabs
38+ ghc-options: -Wall
39+ -Wcompat
40+ -Wunrecognised-warning-flags
41+ -Widentities
42+ -Wincomplete-record-updates
43+ -Wincomplete-uni-patterns
44+ -Wredundant-constraints
45+ -Wmissing-exported-signatures
46+ -Wnoncanonical-monad-instances
47+ -Wnoncanonical-monadfail-instances
48+ -Wmissed-specialisations
49+ -Wall-missed-specialisations
4050
4151 build-depends: base >= 4.8 && < 5
4252 , atomic-primops >= 0.8 && < 0.9
@@ -57,8 +67,19 @@ test-suite test
5767 type: exitcode-stdio-1.0
5868 main-is: Main.hs
5969 hs-source-dirs: test
60− ghc-options: -O0 -Wall -fwarn-identities -fwarn-incomplete-record-updates
61− -fwarn-incomplete-uni-patterns -fwarn-tabs
70+ ghc-options: -O0
71+ -Wall
72+ -Wcompat
73+ -Wunrecognised-warning-flags
74+ -Widentities
75+ -Wincomplete-record-updates
76+ -Wincomplete-uni-patterns
77+ -Wredundant-constraints
78+ -Wmissing-exported-signatures
79+ -Wnoncanonical-monad-instances
80+ -Wnoncanonical-monadfail-instances
81+ -Wmissed-specialisations
82+ -Wall-missed-specialisations
6283 build-depends:
6384 asyncly
6485 , base >= 4.8 && < 5
@@ -78,10 +99,20 @@ benchmark bench
7899 type: exitcode-stdio-1.0
79100 main-is: Main.hs
80101 hs-source-dirs: benchmark
81− ghc-options: -Wall -fwarn-identities -fwarn-incomplete-record-updates
82− -fwarn-incomplete-uni-patterns -fwarn-tabs
83− -O2 -funbox-strict-fields
84− -fno-ignore-asserts
102+ ghc-options: -O2
103+ -Wall
104+ -Wcompat
105+ -Wunrecognised-warning-flags
106+ -Widentities
107+ -Wincomplete-record-updates
108+ -Wincomplete-uni-patterns
109+ -Wredundant-constraints
110+ -Wmissing-exported-signatures
111+ -Wnoncanonical-monad-instances
112+ -Wnoncanonical-monadfail-instances
113+ -Wmissed-specialisations
114+ -Wall-missed-specialisations
115+ -fno-ignore-asserts
85116 build-depends:
86117 asyncly
87118 , atomic-primops >= 0.8 && < 0.9
src/Asyncly/AsyncT.hs+30−26
@@ -120,7 +120,7 @@ newtype AsyncT m a =
120120type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m)
121121
122122------------------------------------------------------------------------------
123−-- Monad
123+-- Monoid
124124------------------------------------------------------------------------------
125125
126126-- | Appends the results of two AsyncT computations in order.
@@ -151,6 +151,32 @@ infixr 5 <=>
151151(<=>) :: AsyncT m a -> AsyncT m a -> AsyncT m a
152152(<=>) = interleave
153153
154+------------------------------------------------------------------------------
155+-- Functor
156+------------------------------------------------------------------------------
157+
158+instance Monad m => Functor (AsyncT m) where
159+ fmap = liftM
160+
161+------------------------------------------------------------------------------
162+-- Applicative
163+------------------------------------------------------------------------------
164+
165+-- Note: We cannot have the applicative instance run the two actions in
166+-- parallel. This is because the first action can always return empty and in
167+-- case it returns empty we should not be starting the second action. Therefore
168+-- we can only start the second action after getting a result from the first.
169+-- For running applicative actions in parallel we can use the async package and
170+-- lift the result into AsyncT.
171+
172+instance Monad m => Applicative (AsyncT m) where
173+ pure a = AsyncT $ \ctx _ yld -> yld a ctx Nothing
174+ (<*>) = ap
175+
176+------------------------------------------------------------------------------
177+-- Monad
178+------------------------------------------------------------------------------
179+
154180-- We do not use bind for parallelism. That is, we do not start each iteration
155181-- of the list in parallel. That will introduce too much uncontrolled
156182-- parallelism. Instead we control parallelism using <|>, it is used for
@@ -184,7 +210,7 @@ bindWith k m f = go m
184210 in g Nothing stp yield
185211
186212instance Monad m => Monad (AsyncT m) where
187− return a = AsyncT $ \ctx _ yld -> yld a ctx Nothing
213+ return = pure
188214
189215 AsyncT m >>= f = AsyncT $ \_ stp yld ->
190216 let run x = (runAsyncT x) Nothing stp yld
@@ -204,28 +230,6 @@ instance Monad m => Monad (AsyncT m) where
204230(>|>) :: MonadAsync m => AsyncT m a -> (a -> AsyncT m b) -> AsyncT m b
205231(>|>) = bindWith (<|>)
206232
207−------------------------------------------------------------------------------
208−-- Functor
209−------------------------------------------------------------------------------
210−
211−instance Monad m => Functor (AsyncT m) where
212− fmap = liftM
213−
214−------------------------------------------------------------------------------
215−-- Applicative
216−------------------------------------------------------------------------------
217−
218−-- Note: We cannot have the applicative instance run the two actions in
219−-- parallel. This is because the first action can always return empty and in
220−-- case it returns empty we should not be starting the second action. Therefore
221−-- we can only start the second action after getting a result from the first.
222−-- For running applicative actions in parallel we can use the async package and
223−-- lift the result into AsyncT.
224−
225−instance Monad m => Applicative (AsyncT m) where
226− pure = return
227− (<*>) = ap
228−
229233------------------------------------------------------------------------------
230234-- Alternative
231235------------------------------------------------------------------------------
@@ -478,10 +482,10 @@ instance MonadAsync m => Alternative (AsyncT m) where
478482-- | Just like '<>' except that it can execute the action on the right in
479483-- parallel ahead of time. Returns the results in serial order like '<>' from
480484-- left to right.
481−parAhead :: MonadAsync m => AsyncT m a -> AsyncT m a -> AsyncT m a
485+parAhead :: AsyncT m a -> AsyncT m a -> AsyncT m a
482486parAhead = undefined
483487
484−(<>|) :: MonadAsync m => AsyncT m a -> AsyncT m a -> AsyncT m a
488+(<>|) :: AsyncT m a -> AsyncT m a -> AsyncT m a
485489(<>|) = parAhead
486490
487491-- | Left biased parallel execution. Actions may run in parallel but not