3
3
-- |
4
4
-- | ```purescript
5
5
-- | data Fill -- think of a paint program filling a shape
6
- -- | = Solid Color
7
- -- | ...
6
+ -- | = NoFill
7
+ -- | | Solid Color
8
+ -- | | ...
8
9
-- | ```
9
10
-- |
10
- -- | A prism that focuses on `Solid` fills would be written like this:
11
+ -- | A prism that focuses on `Solid` fills could be written like this:
11
12
-- |
12
13
-- | ```purescript
13
14
-- | solidFocus :: Prism' Fill Color
31
32
-- | review solidFocus Color.white == Solid Color.white
32
33
-- | ```
33
34
-- |
34
- -- | For more information, see `PrismsForSumTypes` in the
35
+ -- | For more information, see `PrismsForSumTypes.purs ` in the
35
36
-- | `examples/src` directory.
36
37
37
38
module Data.Lens.Prism
38
39
( prism , prism'
39
40
, only , nearly
40
41
, review
41
- , is , isn't
42
- , clonePrism , withPrism , matching
42
+ , is , isn't , matching
43
+ , clonePrism , withPrism
43
44
, module ExportTypes
44
45
) where
45
46
@@ -60,20 +61,20 @@ import Data.Newtype (under)
60
61
-- | produces an `Either`:
61
62
-- |
62
63
-- | ```purescript
63
- -- | solidFocus' :: Prism' Fill Color
64
- -- | solidFocus' = prism Solid case _ of
64
+ -- | solidFocus :: Prism' Fill Color
65
+ -- | solidFocus = prism Solid case _ of
65
66
-- | Solid color -> Right color
66
67
-- | anotherCase -> Left anotherCase
67
68
-- | ```
68
69
prism :: forall s t a b . (b -> t ) -> (s -> Either t a ) -> Prism s t a b
69
70
prism to fro pab = dimap fro (either id id) (right (rmap to pab))
70
71
71
72
-- | Create a `Prism` from a constructor and a "focus" function that
72
- -- | produces an `Maybe`:
73
+ -- | produces a `Maybe`:
73
74
-- |
74
75
-- | ```purescript
75
- -- | solidFocus' :: Prism' Fill Color
76
- -- | solidFocus' = prism' Solid case _ of
76
+ -- | solidFocus :: Prism' Fill Color
77
+ -- | solidFocus = prism' Solid case _ of
77
78
-- | Solid color -> Just color
78
79
-- | _ -> Nothing
79
80
-- | ```
@@ -123,7 +124,6 @@ only x = nearly x (_ == x)
123
124
-- | Create the "whole" corresponding to a specific "part":
124
125
-- |
125
126
-- | ```purescript
126
- -- | -- solidFocus is a `Prism Fill Color`
127
127
-- | review solidFocus Color.white == Solid Color.white
128
128
-- | ```
129
129
review :: forall s t a b . Review s t a b -> b -> t
@@ -139,10 +139,10 @@ withPrism l f = case l (Market id Right) of
139
139
matching :: forall s t a b . APrism s t a b -> s -> Either t a
140
140
matching l = withPrism l \_ f -> f
141
141
142
- -- | Would `preview prism` produce a `Just`?
142
+ -- | Ask if `preview prism` would produce a `Just`.
143
143
is :: forall s t a b r . HeytingAlgebra r => APrism s t a b -> s -> r
144
144
is l = either (const ff) (const tt) <<< matching l
145
145
146
- -- | Would `preview prism` produce a `Nothing`?
146
+ -- | Ask if `preview prism` would produce a `Nothing`.
147
147
isn't :: forall s t a b r . HeytingAlgebra r => APrism s t a b -> s -> r
148
148
isn't l = not <<< is l
0 commit comments