Skip to content

Commit 4437fec

Browse files
Show Maybe's "do notation" similarity to nested if-then-else statement (#48)
* Show Maybe's "do notation" similarity to nested if-then-else statement * Desugar `bind` into pattern matching * Remove JavaScript example of Maybe's do notation
1 parent 6a20755 commit 4437fec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Data/Maybe.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ instance bindMaybe :: Bind Maybe where
141141
-- | ``` purescript
142142
-- | x >>= (\x' -> y >>= (\y' -> pure (f x' y')))
143143
-- | ```
144+
-- |
145+
-- | Which is equivalent to:
146+
-- |
147+
-- | ``` purescript
148+
-- | case x of
149+
-- | Nothing -> Nothing
150+
-- | Just x' -> case y of
151+
-- | Nothing -> Nothing
152+
-- | Just y' -> Just (f x' y')
153+
-- | ```
144154
instance monadMaybe :: Monad Maybe
145155

146156
instance monadZeroMaybe :: MonadZero Maybe

0 commit comments

Comments
 (0)