Skip to content

Commit 5bc1c96

Browse files
committed
Updates for PureScript 0.9
1 parent 69e53f5 commit 5bc1c96

39 files changed

+331
-266
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/.*
2+
!/.gitignore
3+
!/.travis.yml
14
/bower_components/
25
/node_modules/
36
/output/
4-
/.psci*
5-
/src/.webpack.js

.travis.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
2-
sudo: required
32
dist: trusty
4-
node_js: 5
3+
sudo: required
4+
node_js: 6
55
env:
66
- PATH=$HOME/purescript:$PATH
77
install:
@@ -11,15 +11,13 @@ install:
1111
- chmod a+x $HOME/purescript
1212
- npm install -g bower
1313
- npm install
14-
- bower install
1514
script:
16-
- npm run build
15+
- bower install --production
16+
- npm run -s build
17+
- bower install
18+
- npm -s test
1719
after_success:
1820
- >-
1921
test $TRAVIS_TAG &&
20-
psc-publish > .pursuit.json &&
21-
curl -X POST http://pursuit.purescript.org/packages \
22-
-d @.pursuit.json \
23-
-H 'Accept: application/json' \
24-
-H "Authorization: token ${GITHUB_TOKEN}"
25-
22+
echo $GITHUB_TOKEN | pulp login &&
23+
echo y | pulp publish --no-push

bower.json

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@
1111
"type": "git",
1212
"url": "git://github.com/purescript-contrib/purescript-profunctor-lenses.git"
1313
},
14-
"devDependencies": {
15-
"purescript-console": "^0.1.0"
16-
},
1714
"dependencies": {
18-
"purescript-const": "~0.5.0",
19-
"purescript-coproducts": "~0.4.0",
20-
"purescript-functors": "~0.1.0",
21-
"purescript-identity": "~0.4.0",
22-
"purescript-lists": "~0.7.0",
23-
"purescript-maps": "~0.5.2",
24-
"purescript-profunctor": "~0.3.0",
25-
"purescript-sets": "~0.5.1",
26-
"purescript-unsafe-coerce": "~0.1.0",
27-
"purescript-transformers": "~0.8.1",
28-
"purescript-functor-compose": "~0.0.1"
15+
"purescript-const": "^v1.0.0-rc.1",
16+
"purescript-functor-coproducts": "^v1.0.0-rc.1",
17+
"purescript-functor-products": "^v1.0.0-rc.1",
18+
"purescript-identity": "^v1.0.0-rc.1",
19+
"purescript-profunctor": "^v1.0.0-rc.1",
20+
"purescript-sets": "^v1.0.0-rc.1",
21+
"purescript-unsafe-coerce": "^v1.0.0-rc.1",
22+
"purescript-transformers": "^v1.0.0-rc.1"
23+
},
24+
"devDependencies": {
25+
"purescript-console": "^1.0.0-rc.1"
2926
}
3027
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"private": true,
33
"scripts": {
4-
"postinstall": "bower install",
54
"clean": "rimraf output && rimraf .pulp-cache",
6-
"build": "pulp test"
5+
"build": "pulp build --censor-lib --strict",
6+
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^8.1.1",
9+
"pulp": "^8.2.0",
10+
"purescript-psa": "^0.3.8",
1011
"rimraf": "^2.5.0"
1112
}
1213
}

src/Data/Lens.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ module Data.Lens
2222
, module Data.Lens.Common
2323
) where
2424

25-
import Data.Lens.Iso
26-
import Data.Lens.Lens
27-
import Data.Lens.Prism
28-
import Data.Lens.Traversal
25+
import Data.Lens.Iso (AnIso, AnIsoP, Iso, IsoP, Optic, Exchange(..), Re(..), au, auf, cloneIso, curried, flipped, iso, re, runRe, uncurried, under, withIso)
26+
import Data.Lens.Lens (ALens, ALensP, Lens, LensP, cloneLens, lens, lens', withLens)
27+
import Data.Lens.Prism (APrism, APrismP, Prism, PrismP, Review, ReviewP, clonePrism, is, isn't, matching, nearly, only, prism, prism', review, withPrism)
28+
import Data.Lens.Traversal (Traversal, TraversalP, element, elementsOf, failover, itraverseOf, sequenceOf, traverseOf, traversed)
2929
import Data.Lens.Types
30-
import Data.Lens.Setter
31-
import Data.Lens.Getter
32-
import Data.Lens.Fold
33-
import Data.Lens.Common
30+
import Data.Lens.Setter (IndexedSetter, Setter, SetterP, Indexed(..), addModifying, addOver, appendModifying, appendOver, assign, assignJust, conjModifying, conjOver, disjModifying, disjOver, divModifying, divOver, iover, modifying, mulModifying, mulOver, over, set, setJust, subModifying, subOver, (%=), (%~), (&&=), (&&~), (*=), (*~), (++=), (++~), (+=), (+~), (-=), (-~), (.=), (.~), (//=), (//~), (<>=), (<>~), (?=), (?~), (||=), (||~))
31+
import Data.Lens.Getter (Fold, Getter, IndexedFold, IndexedGetter, Optic, Indexed(..), iuse, iview, to, use, view, viewOn, (^.))
32+
import Data.Lens.Fold (Fold, FoldP, allOf, andOf, anyOf, elemOf, filtered, findOf, firstOf, foldMapOf, foldOf, folded, foldlOf, foldrOf, has, hasn't, iallOf, ianyOf, ifoldMapOf, ifoldlOf, ifoldrOf, itoListOf, itraverseOf_, lastOf, lengthOf, maximumOf, minimumOf, notElemOf, orOf, preview, previewOn, productOf, replicated, sequenceOf_, sumOf, toListOf, toListOfOn, unfolded, (^..), (^?))
33+
import Data.Lens.Common (_1, _2, _Just, _Left, _Nothing, _Right, first, left, right, second, united)

src/Data/Lens/At.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Data.Maybe (Maybe(..), maybe)
1111
import Data.Set as S
1212
import Data.StrMap as SM
1313

14-
import Data.Lens (LensP(), lens)
14+
import Data.Lens (LensP, lens)
1515
import Data.Lens.Index (class Index)
1616

1717
class (Index m a b) <= At m a b where

src/Data/Lens/Common.purs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
-- | This module defines common lenses and prisms.
2-
32
module Data.Lens.Common
43
( module Data.Lens.Lens.Tuple
54
, module Data.Lens.Lens.Unit
6-
, module Data.Lens.Lens.Void
75
, module Data.Lens.Prism.Either
86
, module Data.Lens.Prism.Maybe
97
) where
108

11-
import Data.Lens.Lens.Tuple
12-
import Data.Lens.Lens.Unit
13-
import Data.Lens.Lens.Void
14-
import Data.Lens.Prism.Either
15-
import Data.Lens.Prism.Maybe
9+
import Data.Lens.Lens.Tuple (_1, _2, first, second)
10+
import Data.Lens.Lens.Unit (united)
11+
import Data.Lens.Prism.Either (_Left, _Right, left, right)
12+
import Data.Lens.Prism.Maybe (_Just, _Nothing)

src/Data/Lens/Fold.purs

Lines changed: 97 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
-- | This module defines functions for working with folds.
2-
32
module Data.Lens.Fold
43
( (^?), previewOn
54
, (^..), toListOfOn
@@ -13,10 +12,12 @@ module Data.Lens.Fold
1312

1413
import Prelude
1514

16-
import Control.Apply ((*>))
17-
1815
import Data.Either (Either(..), either)
1916
import Data.Foldable (class Foldable, foldMap)
17+
import Data.HeytingAlgebra (tt, ff)
18+
import Data.Lens.Internal.Forget (Forget (..), runForget)
19+
import Data.Lens.Types (Fold, FoldP) as ExportTypes
20+
import Data.Lens.Types (IndexedFold, Fold, OpticP, Indexed(..))
2021
import Data.List (List(..), (:))
2122
import Data.Maybe (Maybe(..), maybe)
2223
import Data.Maybe.First (First(..), runFirst)
@@ -32,15 +33,6 @@ import Data.Profunctor (dimap)
3233
import Data.Profunctor.Choice (class Choice, right)
3334
import Data.Tuple (Tuple(..), uncurry)
3435

35-
import Data.Lens.Internal.Void (coerce)
36-
import Data.Lens.Internal.Forget (Forget (..), runForget)
37-
import Data.Lens.Types (Fold(), FoldP()) as ExportTypes
38-
import Data.Lens.Types (Optic(), OpticP(), Fold())
39-
import Data.Lens.Types (IndexedOptic(), IndexedFold(), Indexed(..))
40-
41-
infixl 8 previewOn as ^?
42-
infixl 8 toListOfOn as ^..
43-
4436
-- | Previews the first value of a fold, if there is any.
4537
preview :: forall s t a b. Fold (First a) s t a b -> s -> Maybe a
4638
preview p = runFirst <<< foldMapOf p (First <<< Just)
@@ -49,6 +41,8 @@ preview p = runFirst <<< foldMapOf p (First <<< Just)
4941
previewOn :: forall s t a b. s -> Fold (First a) s t a b -> Maybe a
5042
previewOn s p = preview p s
5143

44+
infixl 8 previewOn as ^?
45+
5246
-- | Folds all foci of a `Fold` to one. Note that this is the same as `view`.
5347
foldOf :: forall s t a b. Fold a s t a b -> s -> a
5448
foldOf p = runForget (p (Forget id))
@@ -125,11 +119,22 @@ findOf p f = foldrOf p (\a -> maybe (if f a then Just a else Nothing) Just) Noth
125119

126120
-- | Sequence the foci of a `Fold`, pulling out an `Applicative`, and ignore
127121
-- | the result. If you need the result, see `sequenceOf` for `Traversal`s.
128-
sequenceOf_ :: forall f s t a b. (Applicative f) => Fold (Endo (f Unit)) s t (f a) b -> s -> f Unit
122+
sequenceOf_
123+
:: forall f s t a b
124+
. Applicative f
125+
=> Fold (Endo (f Unit)) s t (f a) b
126+
-> s
127+
-> f Unit
129128
sequenceOf_ p = flip runEndo (pure unit) <<< foldMapOf p \f -> Endo (f *> _)
130129

131130
-- | Traverse the foci of a `Fold`, discarding the results.
132-
traverseOf_ :: forall f s t a b r. (Applicative f) => Fold (Endo (f Unit)) s t a b -> (a -> f r) -> s -> f Unit
131+
traverseOf_
132+
:: forall f s t a b r
133+
. Applicative f
134+
=> Fold (Endo (f Unit)) s t a b
135+
-> (a -> f r)
136+
-> s
137+
-> f Unit
133138
traverseOf_ p f = foldrOf p (\a fu -> void (f a) *> fu) (pure unit)
134139

135140
-- | Collects the foci of a `Fold` into a list.
@@ -140,17 +145,23 @@ toListOf p = foldrOf p (:) Nil
140145
toListOfOn :: forall s t a b. s -> Fold (Endo (List a)) s t a b -> List a
141146
toListOfOn s p = toListOf p s
142147

148+
infixl 8 toListOfOn as ^..
149+
143150
-- | Determines whether a `Fold` has at least one focus.
144-
has :: forall s t a b r. (BooleanAlgebra r) => Fold (Disj r) s t a b -> s -> r
145-
has p = runDisj <<< foldMapOf p (const (Disj top))
151+
has :: forall s t a b r. HeytingAlgebra r => Fold (Disj r) s t a b -> s -> r
152+
has p = runDisj <<< foldMapOf p (const (Disj tt))
146153

147154
-- | Determines whether a `Fold` does not have a focus.
148-
hasn't :: forall s t a b r. (BooleanAlgebra r) => Fold (Conj r) s t a b -> s -> r
149-
hasn't p = runConj <<< foldMapOf p (const (Conj bottom))
155+
hasn't :: forall s t a b r. HeytingAlgebra r => Fold (Conj r) s t a b -> s -> r
156+
hasn't p = runConj <<< foldMapOf p (const (Conj ff))
150157

151158
-- | Filters on a predicate.
152159
filtered :: forall p a. (Choice p) => (a -> Boolean) -> OpticP p a a
153-
filtered f = dimap (\x -> if f x then Right x else Left x) (either id id) <<< right
160+
filtered f =
161+
right >>>
162+
dimap
163+
(\x -> if f x then Right x else Left x)
164+
(either id id)
154165

155166
-- | Replicates the elements of a fold.
156167
replicated :: forall a b t r. (Monoid r) => Int -> Fold r a b a t
@@ -163,40 +174,94 @@ folded :: forall g a b t r. (Monoid r, Foldable g) => Fold r (g a) b a t
163174
folded = Forget <<< foldMap <<< runForget
164175

165176
-- | Builds a `Fold` using an unfold.
166-
unfolded :: forall r s t a b. (Monoid r) => (s -> Maybe (Tuple a s)) -> Fold r s t a b
167-
unfolded f p = Forget go where
177+
unfolded
178+
:: forall r s t a b
179+
. Monoid r
180+
=> (s -> Maybe (Tuple a s))
181+
-> Fold r s t a b
182+
unfolded f p = Forget go
183+
where
168184
go = maybe mempty (\(Tuple a sn) -> runForget p a <> go sn) <<< f
169185

170186
-- | Fold map over an `IndexedFold`.
171-
ifoldMapOf :: forall r i s t a b. IndexedFold r i s t a b -> (i -> a -> r) -> s -> r
187+
ifoldMapOf
188+
:: forall r i s t a b
189+
. IndexedFold r i s t a b
190+
-> (i -> a -> r)
191+
-> s
192+
-> r
172193
ifoldMapOf p f = runForget $ p $ Indexed $ Forget (uncurry f)
173194

174195
-- | Right fold over an `IndexedFold`.
175-
ifoldrOf :: forall i s t a b r. IndexedFold (Endo r) i s t a b -> (i -> a -> r -> r) -> r -> s -> r
196+
ifoldrOf
197+
:: forall i s t a b r
198+
. IndexedFold (Endo r) i s t a b
199+
-> (i -> a -> r -> r)
200+
-> r
201+
-> s
202+
-> r
176203
ifoldrOf p f r = flip runEndo r <<< ifoldMapOf p (\i -> Endo <<< f i)
177204

178205
-- | Left fold over an `IndexedFold`.
179-
ifoldlOf :: forall i s t a b r. IndexedFold (Dual (Endo r)) i s t a b -> (i -> r -> a -> r) -> r -> s -> r
180-
ifoldlOf p f r = flip runEndo r <<< runDual <<< ifoldMapOf p (\i -> Dual <<< Endo <<< flip (f i))
206+
ifoldlOf
207+
:: forall i s t a b r
208+
. IndexedFold (Dual (Endo r)) i s t a b
209+
-> (i -> r -> a -> r)
210+
-> r
211+
-> s
212+
-> r
213+
ifoldlOf p f r =
214+
flip runEndo r
215+
<<< runDual
216+
<<< ifoldMapOf p (\i -> Dual <<< Endo <<< flip (f i))
181217

182218
-- | Whether all foci of an `IndexedFold` satisfy a predicate.
183-
iallOf :: forall i s t a b r. (BooleanAlgebra r) => IndexedFold (Conj r) i s t a b -> (i -> a -> r) -> s -> r
219+
iallOf
220+
:: forall i s t a b r
221+
. HeytingAlgebra r
222+
=> IndexedFold (Conj r) i s t a b
223+
-> (i -> a -> r)
224+
-> s
225+
-> r
184226
iallOf p f = runConj <<< ifoldMapOf p (\i -> Conj <<< f i)
185227

186228
-- | Whether any focus of an `IndexedFold` satisfies a predicate.
187-
ianyOf :: forall i s t a b r. (BooleanAlgebra r) => IndexedFold (Disj r) i s t a b -> (i -> a -> r) -> s -> r
229+
ianyOf
230+
:: forall i s t a b r
231+
. HeytingAlgebra r
232+
=> IndexedFold (Disj r) i s t a b
233+
-> (i -> a -> r)
234+
-> s
235+
-> r
188236
ianyOf p f = runDisj <<< ifoldMapOf p (\i -> Disj <<< f i)
189237

190-
-- | Find the first focus of an `IndexedFold` that satisfies a predicate, if there is any.
191-
ifindOf :: forall i s t a b. IndexedFold (Endo (Maybe a)) i s t a b -> (i -> a -> Boolean) -> s -> Maybe a
192-
ifindOf p f = ifoldrOf p (\i a -> maybe (if f i a then Just a else Nothing) Just) Nothing
238+
-- | Find the first focus of an `IndexedFold` that satisfies a predicate, if
239+
-- | there is any.
240+
ifindOf
241+
:: forall i s t a b
242+
. IndexedFold (Endo (Maybe a)) i s t a b
243+
-> (i -> a -> Boolean)
244+
-> s
245+
-> Maybe a
246+
ifindOf p f =
247+
ifoldrOf
248+
p
249+
(\i a -> maybe (if f i a then Just a else Nothing) Just)
250+
Nothing
193251

194252
-- | Collects the foci of an `IndexedFold` into a list.
195-
itoListOf :: forall i s t a b. IndexedFold (Endo (List (Tuple i a))) i s t a b -> s -> List (Tuple i a)
253+
itoListOf
254+
:: forall i s t a b
255+
. IndexedFold (Endo (List (Tuple i a))) i s t a b
256+
-> s
257+
-> List (Tuple i a)
196258
itoListOf p = ifoldrOf p (\i x xs -> Tuple i x : xs) Nil
197259

198260
-- | Traverse the foci of an `IndexedFold`, discarding the results.
199261
itraverseOf_
200262
:: forall i f s t a b r. (Applicative f)
201-
=> IndexedFold (Endo (f Unit)) i s t a b -> (i -> a -> f r) -> s -> f Unit
263+
=> IndexedFold (Endo (f Unit)) i s t a b
264+
-> (i -> a -> f r)
265+
-> s
266+
-> f Unit
202267
itraverseOf_ p f = ifoldrOf p (\i a fu -> void (f i a) *> fu) (pure unit)

src/Data/Lens/Getter.purs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
-- | This module defines functions for working with getters.
2-
32
module Data.Lens.Getter
43
( (^.), viewOn
54
, view, to, use, iview, iuse
65
, module Data.Lens.Types
76
) where
87

9-
import Prelude (id, (<<<), ($))
8+
import Prelude
109

11-
import Data.Const (Const(..), getConst)
12-
import Data.Functor.Contravariant (class Contravariant, cmap)
13-
import Data.Profunctor (class Profunctor, lmap)
14-
import Data.Profunctor.Star (Star(..), runStar)
15-
import Data.Tuple (Tuple (..))
1610
import Control.Monad.State.Class (class MonadState, gets)
1711

18-
import Data.Lens.Internal.Forget (Forget (..), runForget)
19-
import Data.Lens.Types (Getter(), Fold(), Optic())
20-
import Data.Lens.Types (IndexedGetter(), Indexed (..))
21-
import Data.Lens.Types (IndexedFold())
12+
import Data.Lens.Internal.Forget (Forget(..), runForget)
13+
import Data.Lens.Types (Getter, Fold, Optic, IndexedGetter, Indexed(..), IndexedFold)
14+
import Data.Tuple (Tuple)
2215

2316
infixl 8 viewOn as ^.
2417

src/Data/Lens/Index.purs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ module Data.Lens.Index
55

66
import Prelude
77

8-
import Data.Identity (Identity())
8+
import Data.Array as A
9+
import Data.Identity (Identity)
10+
import Data.Lens.Internal.Wander (wander)
11+
import Data.Lens.Types (TraversalP)
912
import Data.Map as M
10-
import Data.Maybe (Maybe(), maybe, fromMaybe)
13+
import Data.Maybe (Maybe, maybe, fromMaybe)
1114
import Data.Set as S
1215
import Data.StrMap as SM
13-
import Data.Array as A
14-
1516
import Data.Traversable (traverse)
16-
import Data.Lens.Internal.Wander (wander)
17-
import Data.Lens.Types (TraversalP())
1817

1918
class Index m a b where
2019
ix :: a -> TraversalP m b

0 commit comments

Comments
 (0)