Skip to content

Commit 6a64dd6

Browse files
authored
Merge pull request #109 from purescript/compiler/0.12
Updates for 0.12
2 parents cea6d90 + d8c028d commit 6a64dd6

24 files changed

+135
-138
lines changed

LICENSE

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
The MIT License (MIT)
1+
Copyright 2018 PureScript
22

3-
Copyright (c) 2014 PureScript
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
45

5-
Permission is hereby granted, free of charge, to any person obtaining a copy of
6-
this software and associated documentation files (the "Software"), to deal in
7-
the Software without restriction, including without limitation the rights to
8-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9-
the Software, and to permit persons to whom the Software is furnished to do so,
10-
subject to the following conditions:
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
118

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation and/or
11+
other materials provided with the distribution.
1412

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
3. Neither the name of the copyright holder nor the names of its contributors
14+
may be used to endorse or promote products derived from this software without
15+
specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bower.json

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"name": "purescript-transformers",
33
"homepage": "https://github.com/purescript/purescript-transformers",
4-
"description": "PureScript monad and comonad transformers library",
54
"authors": [
65
"Gary Burgess <[email protected]>",
76
"Hardy Jones <[email protected]>",
87
"Eric Thul <[email protected]>",
98
"Phil Freeman <[email protected]>",
109
"Brian McKenna <[email protected]>"
1110
],
12-
"license": "MIT",
11+
"license": "BSD-3-Clause",
1312
"repository": {
1413
"type": "git",
1514
"url": "git://github.com/purescript/purescript-transformers.git"
@@ -24,12 +23,22 @@
2423
"package.json"
2524
],
2625
"dependencies": {
27-
"purescript-arrays": "^4.0.0",
28-
"purescript-lazy": "^3.0.0",
29-
"purescript-distributive": "^3.0.0",
30-
"purescript-tuples": "^4.0.0"
26+
"purescript-control": "^4.0.0",
27+
"purescript-distributive": "^4.0.0",
28+
"purescript-effect": "^2.0.0",
29+
"purescript-either": "^4.0.0",
30+
"purescript-foldable-traversable": "^4.0.0",
31+
"purescript-identity": "^4.0.0",
32+
"purescript-lazy": "^4.0.0",
33+
"purescript-maybe": "^4.0.0",
34+
"purescript-newtype": "^3.0.0",
35+
"purescript-prelude": "^4.0.0",
36+
"purescript-tailrec": "^4.0.0",
37+
"purescript-tuples": "^5.0.0",
38+
"purescript-unfoldable": "^4.0.0"
3139
},
3240
"devDependencies": {
33-
"purescript-console": "^3.0.0"
41+
"purescript-arrays": "^5.0.0",
42+
"purescript-console": "^4.0.0"
3443
}
3544
}

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^11.0.0",
10-
"purescript-psa": "^0.5.1",
11-
"rimraf": "^2.6.1"
9+
"pulp": "^12.2.0",
10+
"purescript-psa": "^0.6.0",
11+
"rimraf": "^2.6.2"
1212
}
1313
}

src/Control/Comonad/Store/Class.purs

-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import Control.Comonad.Store.Trans (StoreT(..))
1010
import Control.Comonad.Traced.Trans (TracedT)
1111
import Control.Comonad.Trans.Class (lower)
1212
import Control.Extend (duplicate)
13-
1413
import Data.Tuple (Tuple(..))
15-
import Data.Monoid (class Monoid)
1614

1715
-- | The `ComonadStore` type class represents those monads which support local position information via
1816
-- | `pos` and `peek`.

src/Control/Comonad/Traced/Class.purs

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import Prelude
66

77
import Control.Comonad (class Comonad, extract)
88
import Control.Comonad.Traced.Trans (TracedT(..))
9-
10-
import Data.Monoid (class Monoid)
119
import Data.Tuple (Tuple(..))
1210

1311
-- | The `ComonadTraced` type class represents those monads which support relative (monoidal)

src/Control/Comonad/Traced/Trans.purs

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import Prelude
77
import Control.Comonad (class Comonad, extract)
88
import Control.Comonad.Trans.Class (class ComonadTrans)
99
import Control.Extend (class Extend, (<<=))
10-
11-
import Data.Monoid (class Monoid, mempty)
1210
import Data.Newtype (class Newtype)
1311

1412
-- | The cowriter comonad transformer.

src/Control/Monad/Cont/Trans.purs

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ module Control.Monad.Cont.Trans
99
import Prelude
1010

1111
import Control.Monad.Cont.Class (class MonadCont, callCC)
12-
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1312
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader, ask, local)
1413
import Control.Monad.State.Class (class MonadState, state)
1514
import Control.Monad.Trans.Class (class MonadTrans, lift)
16-
1715
import Data.Newtype (class Newtype)
16+
import Effect.Class (class MonadEffect, liftEffect)
1817

1918
-- | The CPS monad transformer.
2019
-- |
@@ -55,8 +54,8 @@ instance monadContT :: Monad m => Monad (ContT r m)
5554
instance monadTransContT :: MonadTrans (ContT r) where
5655
lift m = ContT (\k -> m >>= k)
5756

58-
instance monadEffContT :: MonadEff eff m => MonadEff eff (ContT r m) where
59-
liftEff = lift <<< liftEff
57+
instance monadEffectContT :: MonadEffect m => MonadEffect (ContT r m) where
58+
liftEffect = lift <<< liftEffect
6059

6160
instance monadAskContT :: MonadAsk r1 m => MonadAsk r1 (ContT r m) where
6261
ask = lift ask

src/Control/Monad/Except/Trans.purs

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Prelude
1111
import Control.Alt (class Alt)
1212
import Control.Alternative (class Alternative)
1313
import Control.Monad.Cont.Class (class MonadCont, callCC)
14-
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1514
import Control.Monad.Error.Class (class MonadThrow, class MonadError, throwError, catchError)
1615
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader, ask, local)
1716
import Control.Monad.Rec.Class (class MonadRec, tailRecM, Step(..))
@@ -21,11 +20,10 @@ import Control.Monad.Writer.Class (class MonadWriter, class MonadTell, pass, lis
2120
import Control.MonadPlus (class MonadPlus)
2221
import Control.MonadZero (class MonadZero)
2322
import Control.Plus (class Plus)
24-
2523
import Data.Either (Either(..), either)
26-
import Data.Monoid (class Monoid, mempty)
2724
import Data.Newtype (class Newtype)
2825
import Data.Tuple (Tuple(..))
26+
import Effect.Class (class MonadEffect, liftEffect)
2927

3028
-- | A monad transformer which adds exceptions to other monads, in the same way
3129
-- | as `Except`. As before, `e` is the type of exceptions, and `a` is the type
@@ -103,8 +101,8 @@ instance monadTransExceptT :: MonadTrans (ExceptT e) where
103101
a <- m
104102
pure $ Right a
105103

106-
instance monadEffExceptT :: MonadEff eff m => MonadEff eff (ExceptT e m) where
107-
liftEff = lift <<< liftEff
104+
instance monadEffectExceptT :: MonadEffect m => MonadEffect (ExceptT e m) where
105+
liftEffect = lift <<< liftEffect
108106

109107
instance monadContExceptT :: MonadCont m => MonadCont (ExceptT e m) where
110108
callCC f = ExceptT $ callCC \c ->
@@ -136,5 +134,5 @@ instance monadWriterExceptT :: MonadWriter w m => MonadWriter w (ExceptT e m) wh
136134
pass = mapExceptT \m -> pass do
137135
a <- m
138136
pure case a of
139-
Left e -> Tuple (Left e) id
137+
Left e -> Tuple (Left e) identity
140138
Right (Tuple r f) -> Tuple (Right r) f

src/Control/Monad/List/Trans.purs

+18-10
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ import Prelude
4040

4141
import Control.Alt (class Alt)
4242
import Control.Alternative (class Alternative)
43-
import Control.Monad.Eff.Class (class MonadEff, liftEff)
43+
import Control.Monad.Rec.Class as MR
4444
import Control.Monad.Trans.Class (class MonadTrans, lift)
4545
import Control.MonadPlus (class MonadPlus)
46-
import Control.Monad.Rec.Class as MR
4746
import Control.MonadZero (class MonadZero)
4847
import Control.Plus (class Plus)
49-
5048
import Data.Lazy (Lazy, defer, force)
5149
import Data.Maybe (Maybe(..), fromMaybe)
52-
import Data.Monoid (class Monoid)
5350
import Data.Newtype (class Newtype)
5451
import Data.Tuple (Tuple(..), fst, snd)
5552
import Data.Unfoldable (class Unfoldable)
53+
import Data.Unfoldable1 (class Unfoldable1)
54+
import Effect.Class (class MonadEffect, liftEffect)
5655

5756
-- | The list monad transformer.
5857
-- |
@@ -139,7 +138,7 @@ iterate f a = unfold g a
139138

140139
-- | Generate an infinite list by repeating a value.
141140
repeat :: forall f a. Monad f => a -> ListT f a
142-
repeat = iterate id
141+
repeat = iterate identity
143142

144143
-- | Take a number of elements from the front of a list.
145144
take :: forall f a. Applicative f => Int -> ListT f a -> ListT f a
@@ -187,7 +186,7 @@ mapMaybe f = stepMap g where
187186

188187
-- | Remove elements from a list which do not contain a value.
189188
catMaybes :: forall f a. Functor f => ListT f (Maybe a) -> ListT f a
190-
catMaybes = mapMaybe id
189+
catMaybes = mapMaybe identity
191190

192191
-- | Perform the first step of a computation in the `ListT` monad.
193192
uncons :: forall f a. Monad f => ListT f a -> f (Maybe (Tuple a (ListT f a)))
@@ -284,8 +283,17 @@ instance functorListT :: Functor f => Functor (ListT f) where
284283

285284
instance unfoldableListT :: Monad f => Unfoldable (ListT f) where
286285
unfoldr f b = go (f b)
287-
where go Nothing = nil
288-
go (Just (Tuple x y)) = cons (pure x) (defer \_ -> (go (f y)))
286+
where
287+
go = case _ of
288+
Nothing -> nil
289+
Just (Tuple x y) -> cons (pure x) (defer \_ -> (go (f y)))
290+
291+
instance unfoldable1ListT :: Monad f => Unfoldable1 (ListT f) where
292+
unfoldr1 f b = go (f b)
293+
where
294+
go = case _ of
295+
Tuple x Nothing -> singleton x
296+
Tuple x (Just y) -> cons (pure x) (defer \_ -> (go (f y)))
289297

290298
instance applyListT :: Monad f => Apply (ListT f) where
291299
apply = ap
@@ -318,5 +326,5 @@ instance monadZeroListT :: Monad f => MonadZero (ListT f)
318326

319327
instance monadPlusListT :: Monad f => MonadPlus (ListT f)
320328

321-
instance monadEffListT :: MonadEff eff m => MonadEff eff (ListT m) where
322-
liftEff = lift <<< liftEff
329+
instance monadEffectListT :: MonadEffect m => MonadEffect (ListT m) where
330+
liftEffect = lift <<< liftEffect

src/Control/Monad/Maybe/Trans.purs

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Prelude
1010
import Control.Alt (class Alt)
1111
import Control.Alternative (class Alternative)
1212
import Control.Monad.Cont.Class (class MonadCont, callCC)
13-
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1413
import Control.Monad.Error.Class (class MonadThrow, class MonadError, catchError, throwError)
1514
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader, ask, local)
1615
import Control.Monad.Rec.Class (class MonadRec, tailRecM, Step(..))
@@ -20,10 +19,10 @@ import Control.Monad.Writer.Class (class MonadWriter, class MonadTell, pass, lis
2019
import Control.MonadPlus (class MonadPlus)
2120
import Control.MonadZero (class MonadZero)
2221
import Control.Plus (class Plus)
23-
2422
import Data.Maybe (Maybe(..))
2523
import Data.Newtype (class Newtype)
2624
import Data.Tuple (Tuple(..))
25+
import Effect.Class (class MonadEffect, liftEffect)
2726

2827
-- | The `MaybeT` monad transformer.
2928
-- |
@@ -87,8 +86,8 @@ instance monadRecMaybeT :: MonadRec m => MonadRec (MaybeT m) where
8786
Just (Loop a1) -> Loop a1
8887
Just (Done b) -> Done (Just b)
8988

90-
instance monadEffMaybe :: MonadEff eff m => MonadEff eff (MaybeT m) where
91-
liftEff = lift <<< liftEff
89+
instance monadEffectMaybe :: MonadEffect m => MonadEffect (MaybeT m) where
90+
liftEffect = lift <<< liftEffect
9291

9392
instance monadContMaybeT :: MonadCont m => MonadCont (MaybeT m) where
9493
callCC f =
@@ -120,5 +119,5 @@ instance monadWriterMaybeT :: MonadWriter w m => MonadWriter w (MaybeT m) where
120119
pass = mapMaybeT \m -> pass do
121120
a <- m
122121
pure case a of
123-
Nothing -> Tuple Nothing id
122+
Nothing -> Tuple Nothing identity
124123
Just (Tuple v f) -> Tuple (Just v) f

src/Control/Monad/RWS/Trans.purs

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ import Prelude
1111
import Control.Alt (class Alt, (<|>))
1212
import Control.Alternative (class Alternative)
1313
import Control.Lazy (class Lazy)
14-
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1514
import Control.Monad.Error.Class (class MonadThrow, class MonadError, throwError, catchError)
1615
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader)
1716
import Control.Monad.Rec.Class (class MonadRec, tailRecM, Step(..))
1817
import Control.Monad.State.Class (class MonadState)
1918
import Control.Monad.Trans.Class (class MonadTrans, lift)
2019
import Control.Monad.Writer.Class (class MonadWriter, class MonadTell)
2120
import Control.Plus (class Plus, empty)
22-
23-
import Data.Monoid (class Monoid, mempty)
2421
import Data.Newtype (class Newtype)
2522
import Data.Tuple (Tuple(..), uncurry)
23+
import Effect.Class (class MonadEffect, liftEffect)
2624

2725
data RWSResult state result writer = RWSResult state result writer
2826

@@ -85,8 +83,8 @@ instance monadTransRWST :: Monoid w => MonadTrans (RWST r w s) where
8583
instance lazyRWST :: Lazy (RWST r w s m a) where
8684
defer f = RWST \r s -> case f unit of RWST f' -> f' r s
8785

88-
instance monadEffRWS :: (Monoid w, MonadEff eff m) => MonadEff eff (RWST r w s m) where
89-
liftEff = lift <<< liftEff
86+
instance monadEffectRWS :: (Monoid w, MonadEffect m) => MonadEffect (RWST r w s m) where
87+
liftEffect = lift <<< liftEffect
9088

9189
instance monadAskRWST :: (Monad m, Monoid w) => MonadAsk r (RWST r w s m) where
9290
ask = RWST \r s -> pure $ RWSResult s r mempty

src/Control/Monad/Reader/Class.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Monad m <= MonadAsk r m | m -> r where
1717
ask :: m r
1818

1919
instance monadAskFun :: MonadAsk r ((->) r) where
20-
ask = id
20+
ask = identity
2121

2222
-- | Projects a value from the global context in a `MonadAsk`.
2323
asks :: forall r m a. MonadAsk r m => (r -> a) -> m a

src/Control/Monad/Reader/Trans.purs

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Control.Alt (class Alt, (<|>))
1212
import Control.Alternative (class Alternative)
1313
import Control.Apply (lift2)
1414
import Control.Monad.Cont.Class (class MonadCont, callCC)
15-
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1615
import Control.Monad.Error.Class (class MonadThrow, class MonadError, catchError, throwError)
1716
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader, ask, asks, local)
1817
import Control.Monad.Rec.Class (class MonadRec, tailRecM)
@@ -22,10 +21,9 @@ import Control.Monad.Writer.Class (class MonadWriter, class MonadTell, pass, lis
2221
import Control.MonadPlus (class MonadPlus)
2322
import Control.MonadZero (class MonadZero)
2423
import Control.Plus (class Plus, empty)
25-
2624
import Data.Distributive (class Distributive, distribute, collect)
27-
import Data.Monoid (class Monoid, mempty)
2825
import Data.Newtype (class Newtype)
26+
import Effect.Class (class MonadEffect, liftEffect)
2927

3028
-- | The reader monad transformer.
3129
-- |
@@ -85,8 +83,8 @@ instance monadPlusReaderT :: MonadPlus m => MonadPlus (ReaderT r m)
8583
instance monadTransReaderT :: MonadTrans (ReaderT r) where
8684
lift = ReaderT <<< const
8785

88-
instance monadEffReader :: MonadEff eff m => MonadEff eff (ReaderT r m) where
89-
liftEff = lift <<< liftEff
86+
instance monadEffectReader :: MonadEffect m => MonadEffect (ReaderT r m) where
87+
liftEffect = lift <<< liftEffect
9088

9189
instance monadContReaderT :: MonadCont m => MonadCont (ReaderT r m) where
9290
callCC f = ReaderT \r -> callCC \c ->

src/Control/Monad/State/Class.purs

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ gets f = state \s -> Tuple (f s) s
3636
put :: forall m s. MonadState s m => s -> m Unit
3737
put s = state \_ -> Tuple unit s
3838

39-
-- | Modify the state by applying a function to the current state.
40-
modify :: forall s m. MonadState s m => (s -> s) -> m Unit
41-
modify f = state \s -> Tuple unit (f s)
39+
-- | Modify the state by applying a function to the current state. The returned
40+
-- | value is the new state value.
41+
modify :: forall s m. MonadState s m => (s -> s) -> m s
42+
modify f = state \s -> let s' = f s in Tuple s' s'

0 commit comments

Comments
 (0)