Skip to content

Commit a3bd3f0

Browse files
committed
Add a “what are Prisms anyway?” header.
1 parent 863c1c2 commit a3bd3f0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/src/PrismsForSumTypes.purs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
module PrismsForSumTypes where
22

3+
{- Prisms are optics that "focus" on one case of a sum type. They can
4+
also be used for other kinds of case analysis, but sum types are most
5+
common. This introduction only discusses sum types.
6+
7+
Use a Prism if you want to write code like this:
8+
9+
preview prismForSolidFill $ Solid Color.white
10+
-- (Just rgba 255 255 255 1.0)
11+
12+
preview prismForSolidCase NoFill
13+
-- Nothing
14+
15+
review prismForSolidFill Color.white
16+
-- (Solid rgba 255 255 255 1.0)
17+
-}
18+
19+
320
{- If you want to try out examples, paste the following into the repl.
421
522
import PrismsForSumTypes
@@ -13,6 +30,7 @@ See `README.md` if you're wondering why code is formatted the way it is.
1330
1431
-}
1532

33+
1634
import Prelude
1735
import Data.Lens (Prism', is, isn't, nearly, only, preview, prism, prism', review)
1836

0 commit comments

Comments
 (0)