Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit c56d09b

Browse files
committed
Update for PureScript 0.11
1 parent 409e4d8 commit c56d09b

File tree

17 files changed

+67
-103
lines changed

17 files changed

+67
-103
lines changed

.eslintrc.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 5
4+
},
5+
"extends": "eslint:recommended",
6+
"env": {
7+
"commonjs": true
8+
},
9+
"rules": {
10+
"strict": [2, "global"],
11+
"block-scoped-var": 2,
12+
"consistent-return": 2,
13+
"eqeqeq": [2, "smart"],
14+
"guard-for-in": 2,
15+
"no-caller": 2,
16+
"no-extend-native": 2,
17+
"no-loop-func": 2,
18+
"no-new": 2,
19+
"no-param-reassign": 2,
20+
"no-return-assign": 2,
21+
"no-unused-expressions": 2,
22+
"no-use-before-define": 2,
23+
"radix": [2, "always"],
24+
"indent": [2, 2],
25+
"quotes": [2, "double"],
26+
"semi": [2, "always"]
27+
}
28+
}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/.*
22
!/.gitignore
3-
!/.jscsrc
4-
!/.jshintrc
3+
!/.eslintrc.json
54
!/.travis.yml
65
/bower_components/
76
/node_modules/

.jscsrc

Lines changed: 0 additions & 17 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 20 deletions
This file was deleted.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 6
4+
node_js: stable
55
env:
66
- PATH=$HOME/purescript:$PATH
77
install:

bower.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"package.json"
2222
],
2323
"dependencies": {
24-
"purescript-arrays": "^3.0.0",
25-
"purescript-functions": "^2.0.0",
26-
"purescript-lists": "^3.0.0",
27-
"purescript-st": "^2.0.0"
24+
"purescript-arrays": "^4.0.0",
25+
"purescript-functions": "^3.0.0",
26+
"purescript-lists": "^4.0.0",
27+
"purescript-st": "^3.0.0"
2828
},
2929
"devDependencies": {
30-
"purescript-quickcheck": "^3.0.0"
30+
"purescript-quickcheck": "^4.0.0"
3131
}
3232
}

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
"private": true,
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
5-
"build": "jshint src && jscs src && psa \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" --censor-lib --strict",
6-
"test": "psc \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" \"test/**/*.purs\" && psc-bundle \"output/**/*.js\" --module Test.Main --main Test.Main | node"
5+
"build": "eslint src && pulp build -- --censor-lib --strict",
6+
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"jscs": "^2.8.0",
10-
"jshint": "^2.9.1",
11-
"pulp": "^8.2.0",
12-
"purescript-psa": "^0.3.8",
13-
"rimraf": "^2.5.0"
9+
"eslint": "^3.17.1",
10+
"pulp": "^10.0.4",
11+
"purescript-psa": "^0.5.0-rc.1",
12+
"rimraf": "^2.6.1"
1413
}
1514
}

src/Data/Map.purs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module Data.Map
1818
, findMax
1919
, fromFoldable
2020
, fromFoldableWith
21-
, toList
2221
, toUnfoldable
2322
, toAscUnfoldable
2423
, delete
@@ -98,7 +97,7 @@ instance traversableMap :: Traversable (Map k) where
9897
sequence = traverse id
9998

10099
-- | Render a `Map` as a `String`
101-
showTree :: forall k v. (Show k, Show v) => Map k v -> String
100+
showTree :: forall k v. Show k => Show v => Map k v -> String
102101
showTree Leaf = "Leaf"
103102
showTree (Two left k v right) =
104103
"Two (" <> showTree left <>
@@ -164,7 +163,7 @@ lookup = unsafePartial \k tree ->
164163

165164

166165
-- | Lookup a value for the specified key, or the greatest one less than it
167-
lookupLE :: forall k v. (Ord k) => k -> Map k v -> Maybe { key :: k, value :: v }
166+
lookupLE :: forall k v. Ord k => k -> Map k v -> Maybe { key :: k, value :: v }
168167
lookupLE _ Leaf = Nothing
169168
lookupLE k (Two left k1 v1 right) = case compare k k1 of
170169
EQ -> Just { key: k1, value: v1 }
@@ -176,7 +175,7 @@ lookupLE k (Three left k1 v1 mid k2 v2 right) = case compare k k2 of
176175
LT -> lookupLE k $ Two left k1 v1 mid
177176

178177
-- | Lookup a value for the greatest key less than the specified key
179-
lookupLT :: forall k v. (Ord k) => k -> Map k v -> Maybe { key :: k, value :: v }
178+
lookupLT :: forall k v. Ord k => k -> Map k v -> Maybe { key :: k, value :: v }
180179
lookupLT _ Leaf = Nothing
181180
lookupLT k (Two left k1 v1 right) = case compare k k1 of
182181
EQ -> findMax left
@@ -188,7 +187,7 @@ lookupLT k (Three left k1 v1 mid k2 v2 right) = case compare k k2 of
188187
LT -> lookupLT k $ Two left k1 v1 mid
189188

190189
-- | Lookup a value for the specified key, or the least one greater than it
191-
lookupGE :: forall k v. (Ord k) => k -> Map k v -> Maybe { key :: k, value :: v }
190+
lookupGE :: forall k v. Ord k => k -> Map k v -> Maybe { key :: k, value :: v }
192191
lookupGE _ Leaf = Nothing
193192
lookupGE k (Two left k1 v1 right) = case compare k k1 of
194193
EQ -> Just { key: k1, value: v1 }
@@ -200,7 +199,7 @@ lookupGE k (Three left k1 v1 mid k2 v2 right) = case compare k k1 of
200199
GT -> lookupGE k $ Two mid k2 v2 right
201200

202201
-- | Lookup a value for the least key greater than the specified key
203-
lookupGT :: forall k v. (Ord k) => k -> Map k v -> Maybe { key :: k, value :: v }
202+
lookupGT :: forall k v. Ord k => k -> Map k v -> Maybe { key :: k, value :: v }
204203
lookupGT _ Leaf = Nothing
205204
lookupGT k (Two left k1 v1 right) = case compare k k1 of
206205
EQ -> findMin right
@@ -371,21 +370,16 @@ update f k m = alter (maybe Nothing f) k m
371370

372371
-- | Convert any foldable collection of key/value pairs to a map.
373372
-- | On key collision, later values take precedence over earlier ones.
374-
fromFoldable :: forall f k v. (Ord k, Foldable f) => f (Tuple k v) -> Map k v
373+
fromFoldable :: forall f k v. Ord k => Foldable f => f (Tuple k v) -> Map k v
375374
fromFoldable = foldl (\m (Tuple k v) -> insert k v m) empty
376375

377376
-- | Convert any foldable collection of key/value pairs to a map.
378377
-- | On key collision, the values are configurably combined.
379-
fromFoldableWith :: forall f k v. (Ord k, Foldable f) => (v -> v -> v) -> f (Tuple k v) -> Map k v
378+
fromFoldableWith :: forall f k v. Ord k => Foldable f => (v -> v -> v) -> f (Tuple k v) -> Map k v
380379
fromFoldableWith f = foldl (\m (Tuple k v) -> alter (combine v) k m) empty where
381380
combine v (Just v') = Just $ f v v'
382381
combine v Nothing = Just v
383382

384-
-- | Convert a map to a list of key/value pairs.
385-
-- | DEPRECATED: use toUnfoldable or toAscUnfoldable instead.
386-
toList :: forall k v. Map k v -> List (Tuple k v)
387-
toList = toAscUnfoldable
388-
389383
-- | Convert a map to an unfoldable structure of key/value pairs
390384
toUnfoldable :: forall f k v. Unfoldable f => Map k v -> f (Tuple k v)
391385
toUnfoldable m = unfoldr go (m : Nil) where
@@ -427,7 +421,7 @@ values (Three left _ v1 mid _ v2 right) = values left <> pure v1 <> values mid <
427421
-- | Compute the union of two maps, using the specified function
428422
-- | to combine values for duplicate keys.
429423
unionWith :: forall k v. Ord k => (v -> v -> v) -> Map k v -> Map k v -> Map k v
430-
unionWith f m1 m2 = foldl go m2 (toList m1)
424+
unionWith f m1 m2 = foldl go m2 (toUnfoldable m1 :: List (Tuple k v))
431425
where
432426
go m (Tuple k v) = alter (Just <<< maybe v (f v)) k m
433427

@@ -437,7 +431,7 @@ union :: forall k v. Ord k => Map k v -> Map k v -> Map k v
437431
union = unionWith const
438432

439433
-- | Compute the union of a collection of maps
440-
unions :: forall k v f. (Ord k, Foldable f) => f (Map k v) -> Map k v
434+
unions :: forall k v f. Ord k => Foldable f => f (Map k v) -> Map k v
441435
unions = foldl union empty
442436

443437
-- | Calculate the number of key/value pairs in a map

src/Data/StrMap.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/* global exports */
21
"use strict";
32

4-
// module Data.StrMap
5-
63
exports._copyEff = function (m) {
74
return function () {
85
var r = {};
@@ -21,7 +18,6 @@ exports.runST = function (f) {
2118
return f;
2219
};
2320

24-
// jshint maxparams: 2
2521
exports._fmapStrMap = function (m0, f) {
2622
var m = {};
2723
for (var k in m0) {
@@ -32,7 +28,6 @@ exports._fmapStrMap = function (m0, f) {
3228
return m;
3329
};
3430

35-
// jshint maxparams: 2
3631
exports._mapWithKey = function (m0, f) {
3732
var m = {};
3833
for (var k in m0) {
@@ -43,7 +38,6 @@ exports._mapWithKey = function (m0, f) {
4338
return m;
4439
};
4540

46-
// jshint maxparams: 1
4741
exports._foldM = function (bind) {
4842
return function (f) {
4943
return function (mz) {
@@ -65,20 +59,19 @@ exports._foldM = function (bind) {
6559
};
6660
};
6761

68-
// jshint maxparams: 4
6962
exports._foldSCStrMap = function (m, z, f, fromMaybe) {
63+
var acc = z;
7064
for (var k in m) {
7165
if (hasOwnProperty.call(m, k)) {
72-
var maybeR = f(z)(k)(m[k]);
66+
var maybeR = f(acc)(k)(m[k]);
7367
var r = fromMaybe(null)(maybeR);
74-
if (r === null) return z;
75-
else z = r;
68+
if (r === null) return acc;
69+
else acc = r;
7670
}
7771
}
78-
return z;
72+
return acc;
7973
};
8074

81-
// jshint maxparams: 1
8275
exports.all = function (f) {
8376
return function (m) {
8477
for (var k in m) {
@@ -98,18 +91,15 @@ exports.size = function (m) {
9891
return s;
9992
};
10093

101-
// jshint maxparams: 4
10294
exports._lookup = function (no, yes, k, m) {
10395
return k in m ? yes(m[k]) : no;
10496
};
10597

106-
// jshint maxparams: 2
10798
exports._unsafeDeleteStrMap = function (m, k) {
10899
delete m[k];
109100
return m;
110101
};
111102

112-
// jshint maxparams: 4
113103
exports._lookupST = function (no, yes, k, m) {
114104
return function () {
115105
return k in m ? yes(m[k]) : no;

src/Data/StrMap.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import Data.Tuple (Tuple(..), uncurry)
5454
import Data.Unfoldable (class Unfoldable)
5555

5656
-- | `StrMap a` represents a map from `String`s to values of type `a`.
57-
foreign import data StrMap :: * -> *
57+
foreign import data StrMap :: Type -> Type
5858

5959
foreign import _copyEff :: forall a b h r. a -> Eff (st :: ST.ST h | r) b
6060

@@ -94,13 +94,13 @@ fold = _foldM ((#))
9494

9595
-- | Fold the keys and values of a map, accumulating values using
9696
-- | some `Monoid`.
97-
foldMap :: forall a m. (Monoid m) => (String -> a -> m) -> StrMap a -> m
97+
foldMap :: forall a m. Monoid m => (String -> a -> m) -> StrMap a -> m
9898
foldMap f = fold (\acc k v -> acc <> f k v) mempty
9999

100100
-- | Fold the keys and values of a map, accumulating values and effects in
101101
-- | some `Monad`.
102-
foldM :: forall a m z. (Monad m) => (z -> String -> a -> m z) -> z -> StrMap a -> m z
103-
foldM f z = _foldM (>>=) f (pure z)
102+
foldM :: forall a m z. Monad m => (z -> String -> a -> m z) -> z -> StrMap a -> m z
103+
foldM f z = _foldM bind f (pure z)
104104

105105
instance foldableStrMap :: Foldable StrMap where
106106
foldl f = fold (\z _ -> f z)
@@ -136,7 +136,7 @@ instance showStrMap :: (Show a) => Show (StrMap a) where
136136
foreign import empty :: forall a. StrMap a
137137

138138
-- | Test whether one map contains all of the keys and values contained in another map
139-
isSubmap :: forall a. (Eq a) => StrMap a -> StrMap a -> Boolean
139+
isSubmap :: forall a. Eq a => StrMap a -> StrMap a -> Boolean
140140
isSubmap m1 m2 = all f m1 where
141141
f k v = runFn4 _lookup false ((==) v) k m2
142142

0 commit comments

Comments
 (0)