Skip to content

Commit df1a66c

Browse files
authored
Merge pull request #102 from purescript/compiler/0.12
Update for PureScript 0.12
2 parents 12fdaf1 + 0054657 commit df1a66c

File tree

15 files changed

+174
-137
lines changed

15 files changed

+174
-137
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/bower_components/
66
/node_modules/
77
/output/
8+
package-lock.json

LICENSE

Lines changed: 22 additions & 16 deletions
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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "purescript-foldable-traversable",
33
"homepage": "https://github.com/purescript/purescript-foldable-traversable",
44
"description": "Classes for foldable and traversable data structures",
5-
"license": "MIT",
5+
"license": "BSD-3-Clause",
66
"repository": {
77
"type": "git",
88
"url": "git://github.com/purescript/purescript-foldable-traversable.git"
@@ -17,14 +17,18 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-bifunctors": "^3.0.0",
21-
"purescript-maybe": "^3.0.0",
22-
"purescript-orders": "^3.0.0"
20+
"purescript-bifunctors": "^4.0.0",
21+
"purescript-control": "^4.0.0",
22+
"purescript-maybe": "^4.0.0",
23+
"purescript-newtype": "^3.0.0",
24+
"purescript-orders": "^4.0.0",
25+
"purescript-prelude": "^4.0.0"
2326
},
2427
"devDependencies": {
25-
"purescript-assert": "^3.0.0",
26-
"purescript-console": "^3.0.0",
27-
"purescript-integers": "^3.0.0",
28-
"purescript-math": "^2.0.0"
28+
"purescript-assert": "^4.0.0",
29+
"purescript-console": "^4.0.0",
30+
"purescript-integers": "^4.0.0",
31+
"purescript-math": "^2.1.1",
32+
"purescript-unsafe-coerce": "^4.0.0"
2933
}
3034
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"eslint": "^3.17.1",
10-
"pulp": "^11.0.0",
11-
"purescript-psa": "^0.5.1",
12-
"rimraf": "^2.6.1"
9+
"eslint": "^4.19.1",
10+
"pulp": "^12.2.0",
11+
"purescript-psa": "^0.6.0",
12+
"rimraf": "^2.6.2"
1313
}
1414
}

src/Data/Bifoldable.purs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module Data.Bifoldable where
33
import Prelude
44

55
import Control.Apply (applySecond)
6-
7-
import Data.Monoid (class Monoid, mempty)
86
import Data.Monoid.Conj (Conj(..))
97
import Data.Monoid.Disj (Disj(..))
108
import Data.Monoid.Dual (Dual(..))
@@ -127,7 +125,7 @@ bifoldMapDefaultL f g = bifoldl (\m a -> m <> f a) (\m b -> m <> g b) mempty
127125

128126
-- | Fold a data structure, accumulating values in a monoidal type.
129127
bifold :: forall t m. Bifoldable t => Monoid m => t m m -> m
130-
bifold = bifoldMap id id
128+
bifold = bifoldMap identity identity
131129

132130
-- | Traverse a data structure, accumulating effects using an `Applicative` functor,
133131
-- | ignoring the final result.
@@ -160,7 +158,7 @@ bisequence_
160158
=> Applicative f
161159
=> t (f a) (f b)
162160
-> f Unit
163-
bisequence_ = bitraverse_ id id
161+
bisequence_ = bitraverse_ identity identity
164162

165163
-- | Test whether a predicate holds at any position in a data structure.
166164
biany

src/Data/Bitraversable.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bisequenceDefault
9292
=> Applicative f
9393
=> t (f a) (f b)
9494
-> f (t a b)
95-
bisequenceDefault = bitraverse id id
95+
bisequenceDefault = bitraverse identity identity
9696

9797
-- | Traverse a data structure, accumulating effects and results using an `Applicative` functor.
9898
bifor

src/Data/Foldable.purs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ module Data.Foldable
3434
import Prelude
3535

3636
import Control.Plus (class Plus, alt, empty)
37-
3837
import Data.Maybe (Maybe(..))
3938
import Data.Maybe.First (First(..))
4039
import Data.Maybe.Last (Last(..))
41-
import Data.Monoid (class Monoid, mempty)
4240
import Data.Monoid.Additive (Additive(..))
4341
import Data.Monoid.Conj (Conj(..))
4442
import Data.Monoid.Disj (Disj(..))
@@ -173,7 +171,7 @@ instance foldableMultiplicative :: Foldable Multiplicative where
173171

174172
-- | Fold a data structure, accumulating values in some `Monoid`.
175173
fold :: forall f m. Foldable f => Monoid m => f m -> m
176-
fold = foldMap id
174+
fold = foldMap identity
177175

178176
-- | Similar to 'foldl', but the result is encapsulated in a monad.
179177
-- |
@@ -230,7 +228,7 @@ for_ = flip traverse_
230228
-- | sequence_ [ trace "Hello, ", trace " world!" ]
231229
-- | ```
232230
sequence_ :: forall a f m. Applicative m => Foldable f => f (m a) -> m Unit
233-
sequence_ = traverse_ id
231+
sequence_ = traverse_ identity
234232

235233
-- | Combines a collection of elements using the `Alt` operation.
236234
oneOf :: forall f g a. Foldable f => Plus g => f (g a) -> g a
@@ -287,19 +285,19 @@ surroundMap d t f = unwrap (foldMap joined f) d
287285
-- | = "*1*2*3*"
288286
-- | ```
289287
surround :: forall f m. Foldable f => Semigroup m => m -> f m -> m
290-
surround d = surroundMap d id
288+
surround d = surroundMap d identity
291289

292290
-- | The conjunction of all the values in a data structure. When specialized
293291
-- | to `Boolean`, this function will test whether all of the values in a data
294292
-- | structure are `true`.
295293
and :: forall a f. Foldable f => HeytingAlgebra a => f a -> a
296-
and = all id
294+
and = all identity
297295

298296
-- | The disjunction of all the values in a data structure. When specialized
299297
-- | to `Boolean`, this function will test whether any of the values in a data
300298
-- | structure is `true`.
301299
or :: forall a f. Foldable f => HeytingAlgebra a => f a -> a
302-
or = any id
300+
or = any identity
303301

304302
-- | `all f` is the same as `and <<< map f`; map a function over the structure,
305303
-- | and then get the conjunction of the results.

src/Data/FoldableWithIndex.purs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Data.FunctorWithIndex (mapWithIndex)
2323
import Data.Maybe (Maybe(..))
2424
import Data.Maybe.First (First)
2525
import Data.Maybe.Last (Last)
26-
import Data.Monoid (class Monoid, mempty)
2726
import Data.Monoid.Additive (Additive)
2827
import Data.Monoid.Conj (Conj(..))
2928
import Data.Monoid.Disj (Disj(..))
@@ -32,15 +31,15 @@ import Data.Monoid.Endo (Endo(..))
3231
import Data.Monoid.Multiplicative (Multiplicative)
3332
import Data.Newtype (unwrap)
3433

35-
-- | A `Foldable` with an additional index.
34+
-- | A `Foldable` with an additional index.
3635
-- | A `FoldableWithIndex` instance must be compatible with its `Foldable`
3736
-- | instance
3837
-- | ```purescript
3938
-- | foldr f = foldrWithIndex (const f)
4039
-- | foldl f = foldlWithIndex (const f)
4140
-- | foldMap f = foldMapWithIndex (const f)
4241
-- | ```
43-
-- |
42+
-- |
4443
-- | Default implementations are provided by the following functions:
4544
-- |
4645
-- | - `foldrWithIndexDefault`
@@ -156,9 +155,9 @@ instance foldableWithIndexMultiplicative :: FoldableWithIndex Unit Multiplicativ
156155
foldMapWithIndex f = foldMap $ f unit
157156

158157

159-
-- | Similar to 'foldlWithIndex', but the result is encapsulated in a monad.
158+
-- | Similar to 'foldlWithIndex', but the result is encapsulated in a monad.
160159
-- |
161-
-- | Note: this function is not generally stack-safe, e.g., for monads which
160+
-- | Note: this function is not generally stack-safe, e.g., for monads which
162161
-- | build up thunks a la `Eff`.
163162
foldWithIndexM
164163
:: forall i f m a b
@@ -269,11 +268,16 @@ findWithIndex
269268
. FoldableWithIndex i f
270269
=> (i -> a -> Boolean)
271270
-> f a
272-
-> Maybe a
271+
-> Maybe { index :: i, value :: a }
273272
findWithIndex p = foldlWithIndex go Nothing
274273
where
275-
go i Nothing x | p i x = Just x
276-
go i r _ = r
274+
go
275+
:: i
276+
-> Maybe { index :: i, value :: a }
277+
-> a
278+
-> Maybe { index :: i, value :: a }
279+
go i Nothing x | p i x = Just { index: i, value: x }
280+
go _ r _ = r
277281

278282
-- | A default implementation of `foldr` using `foldrWithIndex`
279283
foldrDefault

src/Data/FunctorWithIndex.purs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import Data.Monoid.Disj (Disj)
1313
import Data.Monoid.Dual (Dual)
1414
import Data.Monoid.Multiplicative (Multiplicative)
1515

16-
17-
-- | A `Functor` with an additional index.
16+
-- | A `Functor` with an additional index.
1817
-- | Instances must satisfy a modified form of the `Functor` laws
1918
-- | ```purescript
20-
-- | mapWithIndex (\_ a -> a) = id
19+
-- | mapWithIndex (\_ a -> a) = identity
2120
-- | mapWithIndex f . mapWithIndex g = mapWithIndex (\i -> f i <<< g i)
2221
-- | ```
2322
-- | and be compatible with the `Functor` instance

src/Data/Semigroup/Foldable.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Foldable t <= Foldable1 t where
3939

4040
-- | A default implementation of `fold1` using `foldMap1`.
4141
fold1Default :: forall t m. Foldable1 t => Semigroup m => t m -> m
42-
fold1Default = foldMap1 id
42+
fold1Default = foldMap1 identity
4343

4444
-- | A default implementation of `foldMap1` using `fold1`.
4545
foldMap1Default :: forall t m a. Foldable1 t => Functor t => Semigroup m => (a -> m) -> t a -> m
@@ -76,7 +76,7 @@ for1_ = flip traverse1_
7676
-- | Perform all of the effects in some data structure in the order
7777
-- | given by the `Foldable1` instance, ignoring the final result.
7878
sequence1_ :: forall t f a. Foldable1 t => Apply f => t (f a) -> f Unit
79-
sequence1_ = traverse1_ id
79+
sequence1_ = traverse1_ identity
8080

8181
maximum :: forall f a. Ord a => Foldable1 f => f a -> a
8282
maximum = ala Max foldMap1
@@ -96,7 +96,7 @@ instance semigroupJoinWith :: Semigroup a => Semigroup (JoinWith a) where
9696
-- | Fold a data structure using a `Semigroup` instance,
9797
-- | combining adjacent elements using the specified separator.
9898
intercalate :: forall f m. Foldable1 f => Semigroup m => m -> f m -> m
99-
intercalate = flip intercalateMap id
99+
intercalate = flip intercalateMap identity
100100

101101
-- | Fold a data structure, accumulating values in some `Semigroup`,
102102
-- | combining adjacent elements using the specified separator.

0 commit comments

Comments
 (0)