33-- |
44-- | ```purescript
55-- | data Fill -- think of a paint program filling a shape
6- -- | = Solid Color
7- -- | ...
6+ -- | = NoFill
7+ -- | | Solid Color
8+ -- | | ...
89-- | ```
910-- |
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:
1112-- |
1213-- | ```purescript
1314-- | solidFocus :: Prism' Fill Color
3132-- | review solidFocus Color.white == Solid Color.white
3233-- | ```
3334-- |
34- -- | For more information, see `PrismsForSumTypes` in the
35+ -- | For more information, see `PrismsForSumTypes.purs ` in the
3536-- | `examples/src` directory.
3637
3738module Data.Lens.Prism
3839 ( prism , prism'
3940 , only , nearly
4041 , review
41- , is , isn't
42- , clonePrism , withPrism , matching
42+ , is , isn't , matching
43+ , clonePrism , withPrism
4344 , module ExportTypes
4445 ) where
4546
@@ -60,20 +61,20 @@ import Data.Newtype (under)
6061-- | produces an `Either`:
6162-- |
6263-- | ```purescript
63- -- | solidFocus' :: Prism' Fill Color
64- -- | solidFocus' = prism Solid case _ of
64+ -- | solidFocus :: Prism' Fill Color
65+ -- | solidFocus = prism Solid case _ of
6566-- | Solid color -> Right color
6667-- | anotherCase -> Left anotherCase
6768-- | ```
6869prism :: forall s t a b . (b -> t ) -> (s -> Either t a ) -> Prism s t a b
6970prism to fro pab = dimap fro (either id id) (right (rmap to pab))
7071
7172-- | Create a `Prism` from a constructor and a "focus" function that
72- -- | produces an `Maybe`:
73+ -- | produces a `Maybe`:
7374-- |
7475-- | ```purescript
75- -- | solidFocus' :: Prism' Fill Color
76- -- | solidFocus' = prism' Solid case _ of
76+ -- | solidFocus :: Prism' Fill Color
77+ -- | solidFocus = prism' Solid case _ of
7778-- | Solid color -> Just color
7879-- | _ -> Nothing
7980-- | ```
@@ -123,7 +124,6 @@ only x = nearly x (_ == x)
123124-- | Create the "whole" corresponding to a specific "part":
124125-- |
125126-- | ```purescript
126- -- | -- solidFocus is a `Prism Fill Color`
127127-- | review solidFocus Color.white == Solid Color.white
128128-- | ```
129129review :: 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
139139matching :: forall s t a b . APrism s t a b -> s -> Either t a
140140matching l = withPrism l \_ f -> f
141141
142- -- | Would `preview prism` produce a `Just`?
142+ -- | Ask if `preview prism` would produce a `Just`.
143143is :: forall s t a b r . HeytingAlgebra r => APrism s t a b -> s -> r
144144is l = either (const ff) (const tt) <<< matching l
145145
146- -- | Would `preview prism` produce a `Nothing`?
146+ -- | Ask if `preview prism` would produce a `Nothing`.
147147isn't :: forall s t a b r . HeytingAlgebra r => APrism s t a b -> s -> r
148148isn't l = not <<< is l
0 commit comments