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

Commit dbb13e3

Browse files
committed
Use 0.9.1 features
Relax `BooleanAlgebra` constrain to `HeytingAlgebra`. Use single quote instead of `P`.
1 parent c938d15 commit dbb13e3

15 files changed

Lines changed: 75 additions & 85 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ E.g. the `Left` side of an `Either`, or the `Nothing` side of a `Maybe`.
5050

5151
For almost all of the types provided there are simple versions and more general versions. Using `Lens` as the example.
5252

53-
`LensP s a` is the simple type when you don't need to change the type of your structure.
53+
`Lens' s a` is the simple type when you don't need to change the type of your structure.
5454

5555
`Lens s t a b` is the type when you may want to change the type of your structure.
5656

@@ -59,7 +59,7 @@ For example:
5959
```purescript
6060
data Foo = Bar String Number Boolean
6161
62-
fooNum :: LensP Foo Number
62+
fooNum :: Lens' Foo Number
6363
fooNum = lens (\(Bar _ n _) -> n) (\(Bar s _ b) n -> Bar s n b)
6464
```
6565

@@ -79,10 +79,10 @@ So, what are the type synonyms? Some examples are:
7979

8080
```purescript
8181
type Lens s t a b = forall f. (Functor f) => (a -> f b) -> s -> f t
82-
type LensP s a = Lens s s a a
82+
type Lens' s a = Lens s s a a
8383
8484
type Prism s t a b = forall f p. (Applicative f, Choice p) => p a (f b) -> p s (f t)
85-
type PrismP s a = Prism s s a a
85+
type Prism' s a = Prism s s a a
8686
```
8787

8888
These might seem scary, especially `Prism`, but if you squint at them properly, they look very familiar.
@@ -116,11 +116,11 @@ If you can define a lens for `Foo`, you can do just that
116116
```purescript
117117
module Foo where
118118
119-
import Optic.Core ((*~), LensP())
119+
import Optic.Core ((*~), Lens'())
120120
121121
data Foo = Foo Number
122122
123-
_Foo :: LensP Foo Number -- forall f. (Functor f) => (Number -> f Number) -> Foo -> f Foo
123+
_Foo :: Lens' Foo Number -- forall f. (Functor f) => (Number -> f Number) -> Foo -> f Foo
124124
_Foo f (Foo n) = Foo <$> f n
125125
126126
doubleFoo :: Foo -> Foo

docs/Optic/Core.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ prism :: forall f p s t a b. (Applicative f, Choice p) => (b -> t) -> (s -> Eith
8787
#### `only`
8888

8989
``` purescript
90-
only :: forall a. Eq a => a -> PrismP a Unit
90+
only :: forall a. Eq a => a -> Prism' a Unit
9191
```
9292

9393
#### `nearly`
9494

9595
``` purescript
96-
nearly :: forall a. a -> (a -> Boolean) -> PrismP a Unit
96+
nearly :: forall a. a -> (a -> Boolean) -> Prism' a Unit
9797
```
9898

9999
#### `matching`
@@ -143,7 +143,7 @@ setJust :: forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
143143
#### `set'`
144144

145145
``` purescript
146-
set' :: forall s a. ASetterP s a -> a -> s -> s
146+
set' :: forall s a. ASetter' s a -> a -> s -> s
147147
```
148148

149149
#### `set`
@@ -161,7 +161,7 @@ over :: forall p s t a b. Profunctor p => Setting p s t a b -> p a b -> s -> t
161161
#### `or`
162162

163163
``` purescript
164-
or :: forall s t a. BooleanAlgebra a => ASetter s t a a -> a -> s -> t
164+
or :: forall s t a. HeytingAlgebra a => ASetter s t a a -> a -> s -> t
165165
```
166166

167167
#### `mul`
@@ -203,7 +203,7 @@ argument :: forall p r a b. Profunctor p => Setter (p b r) (p a r) a b
203203
#### `and`
204204

205205
``` purescript
206-
and :: forall s t a. BooleanAlgebra a => ASetter s t a a -> a -> s -> t
206+
and :: forall s t a. HeytingAlgebra a => ASetter s t a a -> a -> s -> t
207207
```
208208

209209
#### `add`
@@ -274,10 +274,10 @@ infixr 4 over as %~
274274

275275
### Re-exported from Optic.Types:
276276

277-
#### `SettingP`
277+
#### `Setting'`
278278

279279
``` purescript
280-
type SettingP p s a = Setting p s s a a
280+
type Setting' p s a = Setting p s s a a
281281
```
282282

283283
#### `Setting`
@@ -286,10 +286,10 @@ type SettingP p s a = Setting p s s a a
286286
type Setting p s t a b = p a (Identity b) -> s -> Identity t
287287
```
288288

289-
#### `SetterP`
289+
#### `Setter'`
290290

291291
``` purescript
292-
type SetterP s a = Setter s s a a
292+
type Setter' s a = Setter s s a a
293293
```
294294

295295
#### `Setter`
@@ -298,10 +298,10 @@ type SetterP s a = Setter s s a a
298298
type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t
299299
```
300300

301-
#### `PrismP`
301+
#### `Prism'`
302302

303303
``` purescript
304-
type PrismP s a = Prism s s a a
304+
type Prism' s a = Prism s s a a
305305
```
306306

307307
#### `Prism`
@@ -310,10 +310,10 @@ type PrismP s a = Prism s s a a
310310
type Prism s t a b = forall f p. (Applicative f, Choice p) => p a (f b) -> p s (f t)
311311
```
312312

313-
#### `OpticalP`
313+
#### `Optical'`
314314

315315
``` purescript
316-
type OpticalP p q f s a = Optical p q f s s a a
316+
type Optical' p q f s a = Optical p q f s s a a
317317
```
318318

319319
#### `Optical`
@@ -322,10 +322,10 @@ type OpticalP p q f s a = Optical p q f s s a a
322322
type Optical p q f s t a b = p a (f b) -> q s (f t)
323323
```
324324

325-
#### `LensP`
325+
#### `Lens'`
326326

327327
``` purescript
328-
type LensP s a = Lens s s a a
328+
type Lens' s a = Lens s s a a
329329
```
330330

331331
#### `Lens`
@@ -352,10 +352,10 @@ type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f
352352
type Accessing p m s a = p a (Const m a) -> s -> Const m s
353353
```
354354

355-
#### `ASetterP`
355+
#### `ASetter'`
356356

357357
``` purescript
358-
type ASetterP s a = ASetter s s a a
358+
type ASetter' s a = ASetter s s a a
359359
```
360360

361361
#### `ASetter`
@@ -364,10 +364,10 @@ type ASetterP s a = ASetter s s a a
364364
type ASetter s t a b = (a -> Identity b) -> s -> Identity t
365365
```
366366

367-
#### `APrismP`
367+
#### `APrism'`
368368

369369
``` purescript
370-
type APrismP s a = APrism s s a a
370+
type APrism' s a = APrism s s a a
371371
```
372372

373373
#### `APrism`

docs/Optic/Internal/Prism.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Profunctor (Market a b)
1414
Choice (Market a b)
1515
```
1616

17-
#### `MarketP`
17+
#### `Market'`
1818

1919
``` purescript
20-
type MarketP a = Market a a
20+
type Market' a = Market a a
2121
```
2222

2323

docs/Optic/Laws/Lens.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ Valid `Lens`es should satisfy three laws.
55
#### `validLens`
66

77
``` purescript
8-
validLens :: forall s a. (Eq a, Eq s) => LensP s a -> s -> a -> a -> a -> Boolean
8+
validLens :: forall s a. (Eq a, Eq s) => Lens' s a -> s -> a -> a -> a -> Boolean
99
```
1010

1111
A valid `Lens` satisfies all three of the following laws.
1212

1313
#### `getSet`
1414

1515
``` purescript
16-
getSet :: forall s a. Eq s => LensP s a -> s -> Boolean
16+
getSet :: forall s a. Eq s => Lens' s a -> s -> Boolean
1717
```
1818

1919
If you get a value out, and then set it immediately back,
@@ -22,7 +22,7 @@ nothing should change.
2222
#### `setGet`
2323

2424
``` purescript
25-
setGet :: forall s a. Eq a => LensP s a -> s -> a -> Boolean
25+
setGet :: forall s a. Eq a => Lens' s a -> s -> a -> Boolean
2626
```
2727

2828
If you set a value, and them get it immediately out,

docs/Optic/Prism.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ matching :: forall s t a b. APrism s t a b -> s -> Either t a
2727
#### `nearly`
2828

2929
``` purescript
30-
nearly :: forall a. a -> (a -> Boolean) -> PrismP a Unit
30+
nearly :: forall a. a -> (a -> Boolean) -> Prism' a Unit
3131
```
3232

3333
#### `only`
3434

3535
``` purescript
36-
only :: forall a. Eq a => a -> PrismP a Unit
36+
only :: forall a. Eq a => a -> Prism' a Unit
3737
```
3838

3939
#### `prism`

docs/Optic/Setter.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ set :: forall s t a b. ASetter s t a b -> b -> s -> t
9393
#### `set'`
9494

9595
``` purescript
96-
set' :: forall s a. ASetterP s a -> a -> s -> s
96+
set' :: forall s a. ASetter' s a -> a -> s -> s
9797
```
9898

9999
#### `sets`
@@ -129,13 +129,13 @@ div :: forall s t a. EuclideanRing a => ASetter s t a a -> a -> s -> t
129129
#### `or`
130130

131131
``` purescript
132-
or :: forall s t a. BooleanAlgebra a => ASetter s t a a -> a -> s -> t
132+
or :: forall s t a. HeytingAlgebra a => ASetter s t a a -> a -> s -> t
133133
```
134134

135135
#### `and`
136136

137137
``` purescript
138-
and :: forall s t a. BooleanAlgebra a => ASetter s t a a -> a -> s -> t
138+
and :: forall s t a. HeytingAlgebra a => ASetter s t a a -> a -> s -> t
139139
```
140140

141141
#### `concat`

docs/Optic/Types.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ type Accessing p m s a = p a (Const m a) -> s -> Const m s
1212
type APrism s t a b = Market a b a (Identity b) -> Market a b s (Identity t)
1313
```
1414

15-
#### `APrismP`
15+
#### `APrism'`
1616

1717
``` purescript
18-
type APrismP s a = APrism s s a a
18+
type APrism' s a = APrism s s a a
1919
```
2020

2121
#### `ASetter`
@@ -24,10 +24,10 @@ type APrismP s a = APrism s s a a
2424
type ASetter s t a b = (a -> Identity b) -> s -> Identity t
2525
```
2626

27-
#### `ASetterP`
27+
#### `ASetter'`
2828

2929
``` purescript
30-
type ASetterP s a = ASetter s s a a
30+
type ASetter' s a = ASetter s s a a
3131
```
3232

3333
#### `Getting`
@@ -48,10 +48,10 @@ type Getter s a = forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f
4848
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
4949
```
5050

51-
#### `LensP`
51+
#### `Lens'`
5252

5353
``` purescript
54-
type LensP s a = Lens s s a a
54+
type Lens' s a = Lens s s a a
5555
```
5656

5757
#### `Optical`
@@ -60,10 +60,10 @@ type LensP s a = Lens s s a a
6060
type Optical p q f s t a b = p a (f b) -> q s (f t)
6161
```
6262

63-
#### `OpticalP`
63+
#### `Optical'`
6464

6565
``` purescript
66-
type OpticalP p q f s a = Optical p q f s s a a
66+
type Optical' p q f s a = Optical p q f s s a a
6767
```
6868

6969
#### `Prism`
@@ -72,10 +72,10 @@ type OpticalP p q f s a = Optical p q f s s a a
7272
type Prism s t a b = forall f p. (Applicative f, Choice p) => p a (f b) -> p s (f t)
7373
```
7474

75-
#### `PrismP`
75+
#### `Prism'`
7676

7777
``` purescript
78-
type PrismP s a = Prism s s a a
78+
type Prism' s a = Prism s s a a
7979
```
8080

8181
#### `Setter`
@@ -84,10 +84,10 @@ type PrismP s a = Prism s s a a
8484
type Setter s t a b = forall f. Settable f => (a -> f b) -> s -> f t
8585
```
8686

87-
#### `SetterP`
87+
#### `Setter'`
8888

8989
``` purescript
90-
type SetterP s a = Setter s s a a
90+
type Setter' s a = Setter s s a a
9191
```
9292

9393
#### `Setting`
@@ -96,10 +96,10 @@ type SetterP s a = Setter s s a a
9696
type Setting p s t a b = p a (Identity b) -> s -> Identity t
9797
```
9898

99-
#### `SettingP`
99+
#### `Setting'`
100100

101101
``` purescript
102-
type SettingP p s a = Setting p s s a a
102+
type Setting' p s a = Setting p s s a a
103103
```
104104

105105

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"scripts": {
2020
"clean": "rimraf output && rimraf .pulp-cache",
21+
"docs": "pulp docs",
2122
"build": "pulp build --censor-lib --strict",
2223
"test": "pulp test"
2324
},

src/Optic/Core.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Optic.Core
1212
import Optic.Lens (flip', lens, (??))
1313
import Optic.Prism (clonePrism, is, isn't, matching, nearly, only, prism, prism', withPrism)
1414
import Optic.Setter (add, and, argument, concat, contramapped, div, mapped, mul, or, over, set, set', setJust, sets, sub, (%~), (&&~), (*~), (+~), (-~), (.~), (/~), (<>~), (?~), (||~))
15-
import Optic.Types (APrism, APrismP, ASetter, ASetterP, Accessing, Getter, Getting, Lens, LensP, Optical, OpticalP, Prism, PrismP, Setter, SetterP, Setting, SettingP)
15+
import Optic.Types (APrism, APrism', ASetter, ASetter', Accessing, Getter, Getting, Lens, Lens', Optical, Optical', Prism, Prism', Setter, Setter', Setting, Setting')
1616

1717

1818
import Prelude (class Semigroupoid, (<<<))

src/Optic/Getter.purs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module Optic.Getter
66
) where
77

88
import Data.Const (getConst, Const(..))
9-
import Data.Functor.Contravariant ((>$<), class Contravariant)
10-
import Data.Profunctor (dimap, class Profunctor)
9+
import Data.Functor.Contravariant (class Contravariant, coerce)
10+
import Data.Profunctor (class Profunctor, dimap)
1111

1212
import Optic.Types (Getting())
1313

14-
import Prelude (class Functor, (<$>), flip)
14+
import Prelude (class Functor, flip)
1515

1616
infixl 8 weiv as ^.
1717

@@ -23,12 +23,3 @@ module Optic.Getter
2323

2424
weiv :: forall s a. s -> Getting a s a -> a
2525
weiv = flip view
26-
27-
newtype Void = Void Void
28-
29-
coerce :: forall f a b. (Contravariant f, Functor f) => f a -> f b
30-
coerce a = absurd <$> (absurd >$< a)
31-
32-
absurd :: forall a. Void -> a
33-
absurd a = spin a
34-
where spin (Void b) = spin b

0 commit comments

Comments
 (0)