Skip to content

Commit 54138b0

Browse files
authored
Merge pull request #90 from purescript-contrib/compiler/0.12
Compiler/0.12
2 parents 2d10428 + b8627f3 commit 54138b0

20 files changed

+106
-93
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 6
4+
node_js: stable
5+
env:
6+
- PATH=$HOME/purescript:$PATH
57
install:
6-
- npm install bower -g
8+
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
9+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
11+
- chmod a+x $HOME/purescript
12+
- npm install -g bower
713
- npm install
8-
- bower install --production
914
script:
15+
- bower install --production
1016
- npm run -s build
1117
- bower install
12-
- npm -s test
18+
- npm run -s test
1319
after_success:
1420
- >-
1521
test $TRAVIS_TAG &&

bower.json

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,28 @@
1212
"url": "git://github.com/purescript-contrib/purescript-profunctor-lenses.git"
1313
},
1414
"dependencies": {
15-
"purescript-const": "^3.0.0",
16-
"purescript-functors": "^2.0.0",
17-
"purescript-foldable-traversable": "^3.4.0",
18-
"purescript-identity": "^3.0.0",
19-
"purescript-profunctor": "^3.0.0",
20-
"purescript-sets": "^3.0.0",
21-
"purescript-unsafe-coerce": "^3.0.0",
22-
"purescript-transformers": "^3.0.0",
23-
"purescript-record": "^0.2.0"
15+
"purescript-arrays": "^5.0.0",
16+
"purescript-bifunctors": "^4.0.0",
17+
"purescript-const": "^4.0.0",
18+
"purescript-control": "^4.0.0",
19+
"purescript-distributive": "^4.0.0",
20+
"purescript-either": "^4.0.0",
21+
"purescript-foldable-traversable": "^4.0.0",
22+
"purescript-foreign-object": "^1.0.0",
23+
"purescript-functors": "^3.0.0",
24+
"purescript-identity": "^4.0.0",
25+
"purescript-lists": "^5.0.0",
26+
"purescript-maybe": "^4.0.0",
27+
"purescript-newtype": "^3.0.0",
28+
"purescript-ordered-collections": "^1.0.0",
29+
"purescript-partial": "^2.0.0",
30+
"purescript-prelude": "^4.0.0",
31+
"purescript-profunctor": "^4.0.0",
32+
"purescript-record": "^1.0.0",
33+
"purescript-transformers": "^4.0.0",
34+
"purescript-tuples": "^5.0.0"
2435
},
2536
"devDependencies": {
26-
"purescript-console": "^3.0.0"
37+
"purescript-console": "^4.0.0"
2738
}
2839
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^11.0.0",
10-
"purescript-psa": "^0.5.0",
11-
"purescript": "^0.11.1",
12-
"rimraf": "^2.5.4"
9+
"pulp": "^12.2.0",
10+
"purescript-psa": "^0.6.0",
11+
"rimraf": "^2.6.2"
1312
}
1413
}

src/Data/Lens/At.purs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ module Data.Lens.At
77
import Prelude
88

99
import Data.Identity (Identity(..))
10+
import Data.Lens (Lens', lens)
11+
import Data.Lens.Index (class Index)
1012
import Data.Map as M
1113
import Data.Maybe (Maybe(..), maybe)
12-
import Data.Set as S
13-
import Data.StrMap as SM
1414
import Data.Newtype (unwrap)
15-
16-
import Data.Lens (Lens', lens)
17-
import Data.Lens.Index (class Index)
15+
import Data.Set as S
16+
import Foreign.Object as FO
1817

1918
-- | `At` is a type class whose instances let you add
2019
-- | new elements or delete old ones from "container-like" types:
@@ -40,7 +39,7 @@ instance atIdentity :: At (Identity a) Unit a where
4039
at _ = lens (Just <<< unwrap) (flip maybe Identity)
4140

4241
instance atMaybe :: At (Maybe a) Unit a where
43-
at _ = lens id \_ -> id
42+
at _ = lens identity \_ -> identity
4443

4544
instance atSet :: Ord v => At (S.Set v) v Unit where
4645
at x = lens get (flip update)
@@ -57,7 +56,7 @@ instance atMap :: Ord k => At (M.Map k v) k v where
5756
lens (M.lookup k) \m ->
5857
maybe (M.delete k m) \v -> M.insert k v m
5958

60-
instance atStrMap :: At (SM.StrMap v) String v where
59+
instance atForeignObject :: At (FO.Object v) String v where
6160
at k =
62-
lens (SM.lookup k) \m ->
63-
maybe (SM.delete k m) \ v -> SM.insert k v m
61+
lens (FO.lookup k) \m ->
62+
maybe (FO.delete k m) \ v -> FO.insert k v m

src/Data/Lens/Fold.purs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ import Prelude
1616
import Data.Either (Either(..), either)
1717
import Data.Foldable (class Foldable, foldMap)
1818
import Data.HeytingAlgebra (tt, ff)
19-
import Data.Lens.Internal.Forget (Forget (..))
19+
import Data.Lens.Internal.Forget (Forget(..))
2020
import Data.Lens.Types (Fold, Fold') as ExportTypes
2121
import Data.Lens.Types (IndexedFold, Fold, Optic', Indexed(..))
2222
import Data.List (List(..), (:))
2323
import Data.Maybe (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(..))
@@ -47,18 +46,18 @@ infixl 8 previewOn as ^?
4746

4847
-- | Folds all foci of a `Fold` to one. Note that this is the same as `view`.
4948
foldOf :: forall s t a b. Fold a s t a b -> s -> a
50-
foldOf p = foldMapOf p id
49+
foldOf p = foldMapOf p identity
5150

5251
-- | Maps and then folds all foci of a `Fold`.
5352
foldMapOf :: forall s t a b r. Fold r s t a b -> (a -> r) -> s -> r
5453
foldMapOf = under Forget
5554

5655
-- | Right fold over a `Fold`.
57-
foldrOf :: forall s t a b r. Fold (Endo r) s t a b -> (a -> r -> r) -> r -> s -> r
56+
foldrOf :: forall s t a b r. Fold (Endo (->) r) s t a b -> (a -> r -> r) -> r -> s -> r
5857
foldrOf p f r = flip unwrap r <<< foldMapOf p (Endo <<< f)
5958

6059
-- | Left fold over a `Fold`.
61-
foldlOf :: forall s t a b r. Fold (Dual (Endo r)) s t a b -> (r -> a -> r) -> r -> s -> r
60+
foldlOf :: forall s t a b r. Fold (Dual (Endo (->) r)) s t a b -> (r -> a -> r) -> r -> s -> r
6261
foldlOf p f r = flip unwrap r <<< unwrap <<< foldMapOf p (Dual <<< Endo <<< flip f)
6362

6463
-- | Whether all foci of a `Fold` satisfy a predicate.
@@ -71,11 +70,11 @@ anyOf p f = unwrap <<< foldMapOf p (Disj <<< f)
7170

7271
-- | The conjunction of all foci of a `Fold`.
7372
andOf :: forall s t a b. HeytingAlgebra a => Fold (Conj a) s t a b -> s -> a
74-
andOf p = allOf p id
73+
andOf p = allOf p identity
7574

7675
-- | The disjunction of all foci of a `Fold`.
7776
orOf :: forall s t a b. HeytingAlgebra a => Fold (Disj a) s t a b -> s -> a
78-
orOf p = anyOf p id
77+
orOf p = anyOf p identity
7978

8079
-- | Whether a `Fold` contains a given element.
8180
elemOf :: forall s t a b. Eq a => Fold (Disj Boolean) s t a b -> a -> s -> Boolean
@@ -106,25 +105,25 @@ lastOf :: forall s t a b. Fold (Last a) s t a b -> s -> Maybe a
106105
lastOf p = unwrap <<< foldMapOf p (Last <<< Just)
107106

108107
-- | The maximum of all foci of a `Fold`, if there is any.
109-
maximumOf :: forall s t a b. Ord a => Fold (Endo (Maybe a)) s t a b -> s -> Maybe a
108+
maximumOf :: forall s t a b. Ord a => Fold (Endo (->) (Maybe a)) s t a b -> s -> Maybe a
110109
maximumOf p = foldrOf p (\a -> Just <<< maybe a (max a)) Nothing where
111110
max a b = if a > b then a else b
112111

113112
-- | The minimum of all foci of a `Fold`, if there is any.
114-
minimumOf :: forall s t a b. Ord a => Fold (Endo (Maybe a)) s t a b -> s -> Maybe a
113+
minimumOf :: forall s t a b. Ord a => Fold (Endo (->) (Maybe a)) s t a b -> s -> Maybe a
115114
minimumOf p = foldrOf p (\a -> Just <<< maybe a (min a)) Nothing where
116115
min a b = if a < b then a else b
117116

118117
-- | Find the first focus of a `Fold` that satisfies a predicate, if there is any.
119-
findOf :: forall s t a b. Fold (Endo (Maybe a)) s t a b -> (a -> Boolean) -> s -> Maybe a
118+
findOf :: forall s t a b. Fold (Endo (->) (Maybe a)) s t a b -> (a -> Boolean) -> s -> Maybe a
120119
findOf p f = foldrOf p (\a -> maybe (if f a then Just a else Nothing) Just) Nothing
121120

122121
-- | Sequence the foci of a `Fold`, pulling out an `Applicative`, and ignore
123122
-- | the result. If you need the result, see `sequenceOf` for `Traversal`s.
124123
sequenceOf_
125124
:: forall f s t a b
126125
. Applicative f
127-
=> Fold (Endo (f Unit)) s t (f a) b
126+
=> Fold (Endo (->) (f Unit)) s t (f a) b
128127
-> s
129128
-> f Unit
130129
sequenceOf_ p = flip unwrap (pure unit) <<< foldMapOf p \f -> Endo (f *> _)
@@ -133,18 +132,18 @@ sequenceOf_ p = flip unwrap (pure unit) <<< foldMapOf p \f -> Endo (f *> _)
133132
traverseOf_
134133
:: forall f s t a b r
135134
. Applicative f
136-
=> Fold (Endo (f Unit)) s t a b
135+
=> Fold (Endo (->) (f Unit)) s t a b
137136
-> (a -> f r)
138137
-> s
139138
-> f Unit
140139
traverseOf_ p f = foldrOf p (\a fu -> void (f a) *> fu) (pure unit)
141140

142141
-- | Collects the foci of a `Fold` into a list.
143-
toListOf :: forall s t a b. Fold (Endo (List a)) s t a b -> s -> List a
142+
toListOf :: forall s t a b. Fold (Endo (->) (List a)) s t a b -> s -> List a
144143
toListOf p = foldrOf p (:) Nil
145144

146145
-- | Synonym for `toListOf`, reversed.
147-
toListOfOn :: forall s t a b. s -> Fold (Endo (List a)) s t a b -> List a
146+
toListOfOn :: forall s t a b. s -> Fold (Endo (->) (List a)) s t a b -> List a
148147
toListOfOn s p = toListOf p s
149148

150149
infixl 8 toListOfOn as ^..
@@ -163,7 +162,7 @@ filtered f =
163162
right >>>
164163
dimap
165164
(\x -> if f x then Right x else Left x)
166-
(either id id)
165+
(either identity identity)
167166

168167
-- | Replicates the elements of a fold.
169168
replicated :: forall a b t r. Monoid r => Int -> Fold r a b a t
@@ -198,7 +197,7 @@ ifoldMapOf p f = unwrap $ p $ Indexed $ Forget (uncurry f)
198197
-- | Right fold over an `IndexedFold`.
199198
ifoldrOf
200199
:: forall i s t a b r
201-
. IndexedFold (Endo r) i s t a b
200+
. IndexedFold (Endo (->) r) i s t a b
202201
-> (i -> a -> r -> r)
203202
-> r
204203
-> s
@@ -208,7 +207,7 @@ ifoldrOf p f r = flip unwrap r <<< ifoldMapOf p (\i -> Endo <<< f i)
208207
-- | Left fold over an `IndexedFold`.
209208
ifoldlOf
210209
:: forall i s t a b r
211-
. IndexedFold (Dual (Endo r)) i s t a b
210+
. IndexedFold (Dual (Endo (->) r)) i s t a b
212211
-> (i -> r -> a -> r)
213212
-> r
214213
-> s
@@ -242,7 +241,7 @@ ianyOf p f = unwrap <<< ifoldMapOf p (\i -> Disj <<< f i)
242241
-- | there is any.
243242
ifindOf
244243
:: forall i s t a b
245-
. IndexedFold (Endo (Maybe a)) i s t a b
244+
. IndexedFold (Endo (->) (Maybe a)) i s t a b
246245
-> (i -> a -> Boolean)
247246
-> s
248247
-> Maybe a
@@ -255,15 +254,15 @@ ifindOf p f =
255254
-- | Collects the foci of an `IndexedFold` into a list.
256255
itoListOf
257256
:: forall i s t a b
258-
. IndexedFold (Endo (List (Tuple i a))) i s t a b
257+
. IndexedFold (Endo (->) (List (Tuple i a))) i s t a b
259258
-> s
260259
-> List (Tuple i a)
261260
itoListOf p = ifoldrOf p (\i x xs -> Tuple i x : xs) Nil
262261

263262
-- | Traverse the foci of an `IndexedFold`, discarding the results.
264263
itraverseOf_
265264
:: forall i f s t a b r. (Applicative f)
266-
=> IndexedFold (Endo (f Unit)) i s t a b
265+
=> IndexedFold (Endo (->) (f Unit)) i s t a b
267266
-> (i -> a -> f r)
268267
-> s
269268
-> f Unit
@@ -272,7 +271,7 @@ itraverseOf_ p f = ifoldrOf p (\i a fu -> void (f i a) *> fu) (pure unit)
272271
-- | Flipped version of `itraverseOf_`.
273272
iforOf_
274273
:: forall i f s t a b r. (Applicative f)
275-
=> IndexedFold (Endo (f Unit)) i s t a b
274+
=> IndexedFold (Endo (->) (f Unit)) i s t a b
276275
-> s
277276
-> (i -> a -> f r)
278277
-> f Unit

src/Data/Lens/Getter.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ infixl 8 viewOn as ^.
1818

1919
-- | View the focus of a `Getter`.
2020
view :: forall s t a b. Getter s t a b -> s -> a
21-
view l = unwrap (l (Forget id))
21+
view l = unwrap (l (Forget identity))
2222

2323
-- | View the focus of a `Getter` and its index.
2424
iview :: forall i s t a b. IndexedFold (Tuple i a) i s t a b -> s -> Tuple i a
25-
iview l = unwrap (l (Indexed $ Forget id))
25+
iview l = unwrap (l (Indexed $ Forget identity))
2626

2727
-- | Synonym for `view`, flipped.
2828
viewOn :: forall s t a b. s -> Getter s t a b -> a
@@ -34,7 +34,7 @@ to f p = Forget (unwrap p <<< f)
3434

3535
-- | Combine two getters.
3636
takeBoth :: forall s t a b c d. Getter s t a b -> Getter s t c d -> Getter s t (Tuple a c) (Tuple b d)
37-
takeBoth l r a = cmps (l (Forget id)) (r (Forget id))
37+
takeBoth l r a = cmps (l (Forget identity)) (r (Forget identity))
3838
where
3939
cmps :: Forget a s t -> Forget c s t -> Forget (Tuple a c) s t
4040
cmps (Forget f) (Forget g) = Forget (f &&& g)

src/Data/Lens/Grate.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Data.Lens.Grate
1313
) where
1414

1515
import Prelude
16+
1617
import Data.Distributive (class Distributive, cotraverse)
1718
import Data.Lens.Internal.Grating (Grating(..))
1819
import Data.Lens.Internal.Zipping (Zipping(..))
@@ -27,13 +28,13 @@ grate :: forall s t a b. (((s -> a) -> b) -> t) -> Grate s t a b
2728
grate f pab = dimap (#) f (closed pab)
2829

2930
withGrate :: forall s t a b. AGrate s t a b -> ((s -> a) -> b) -> t
30-
withGrate g = unwrap (g (Grating \f -> f id))
31+
withGrate g = unwrap (g (Grating \f -> f identity))
3132

3233
cloneGrate :: forall s t a b. AGrate s t a b -> Grate s t a b
3334
cloneGrate g = grate (withGrate g)
3435

3536
cotraversed :: forall f a b. Distributive f => Grate (f a) (f b) a b
36-
cotraversed = grate \f -> cotraverse f id
37+
cotraversed = grate \f -> cotraverse f identity
3738

3839
zipWithOf :: forall s t a b. Optic Zipping s t a b -> (a -> a -> b) -> s -> s -> t
3940
zipWithOf g f = unwrap (g (Zipping f))

src/Data/Lens/Index.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Data.Lens.Types (Traversal')
1212
import Data.Map as M
1313
import Data.Maybe (Maybe, maybe, fromMaybe)
1414
import Data.Set as S
15-
import Data.StrMap as SM
15+
import Foreign.Object as FO
1616
import Data.Traversable (traverse)
1717

1818
-- | `Index` is a type class whose instances are optics used when:
@@ -80,10 +80,10 @@ instance indexMap :: Ord k => Index (M.Map k v) k v where
8080
(pure m)
8181
(coalg >>> map \v -> M.insert k v m)
8282

83-
instance indexStrMap :: Index (SM.StrMap v) String v where
83+
instance indexForeignObject :: Index (FO.Object v) String v where
8484
ix k =
8585
wander \coalg m ->
86-
SM.lookup k m #
86+
FO.lookup k m #
8787
maybe
8888
(pure m)
89-
(coalg >>> map \v -> SM.insert k v m)
89+
(coalg >>> map \v -> FO.insert k v m)

src/Data/Lens/Indexed.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Data.Lens.Iso.Newtype (_Newtype)
99
import Data.Lens.Setter ((%~))
1010
import Data.Lens.Types (wander, Optic, IndexedOptic, Indexed(..), Traversal, IndexedTraversal)
1111
import Data.Newtype (unwrap)
12-
import Data.Profunctor (class Profunctor, dimap, lmap)
12+
import Data.Profunctor (class Profunctor, dimap, lcmap)
1313
import Data.Profunctor.Star (Star(..))
1414
import Data.Profunctor.Strong (first)
1515
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
@@ -21,19 +21,19 @@ unIndex
2121
. Profunctor p
2222
=> IndexedOptic p i s t a b
2323
-> Optic p s t a b
24-
unIndex l = l <<< Indexed <<< dimap snd id
24+
unIndex l = l <<< Indexed <<< dimap snd identity
2525

2626
asIndex
2727
:: forall p i s t a b
2828
. Profunctor p
2929
=> IndexedOptic p i s t a b
3030
-> Optic p s t i b
31-
asIndex l = l <<< Indexed <<< dimap fst id
31+
asIndex l = l <<< Indexed <<< dimap fst identity
3232

3333
-- | Remap the index.
3434
reindexed :: forall p i j r a b . Profunctor p =>
3535
(i -> j) -> (Indexed p i a b -> r) -> Indexed p j a b -> r
36-
reindexed ij = (_ <<< _Newtype %~ lmap (first ij))
36+
reindexed ij = (_ <<< _Newtype %~ lcmap (first ij))
3737

3838
-- | Converts a `lens`-like indexed traversal to an `IndexedTraversal`.
3939
iwander

src/Data/Lens/Internal/Focusing.purs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Data.Lens.Internal.Focusing where
33

44
import Prelude
55

6-
import Data.Monoid (class Monoid)
76
import Data.Tuple (Tuple)
87
import Data.Newtype (class Newtype)
98

0 commit comments

Comments
 (0)