Skip to content

Commit 8a0ff53

Browse files
author
Serhii Khoma
authored
(\/) function -> add comment
1 parent 79b660e commit 8a0ff53

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Data/Either/Nested.purs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ import Data.Void (Void, absurd)
2929

3030
infixr 6 type Either as \/
3131

32-
-- | Allows to match nested eithers. For example:
32+
-- | The `\/` operator alias for the `either` function allows easy matching on nested Eithers. For example, consider the function
3333
-- |
3434
-- | ```purescript
3535
-- | f :: (Int \/ String \/ Boolean) -> String
36-
-- | f = show \/ identity \/ if _ then "yes" else "no"
36+
-- | f (Left x) = show x
37+
-- | f (Right (Left y)) = y
38+
-- | f (Right (Right z)) = if z then "Yes" else "No"
39+
-- | ```
40+
-- |
41+
-- | The `\/` operator alias allows us to rewrite this function as
42+
-- |
43+
-- | ```purescript
44+
-- | f :: (Int \/ String \/ Boolean) -> String
45+
-- | f = show \/ identity \/ if _ then "Yes" else "No"
3746
-- | ```
3847
infixr 6 either as \/
3948

0 commit comments

Comments
 (0)