File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -280,9 +280,23 @@ fromJust (Just x) = x
280
280
281
281
-- | One or none.
282
282
-- |
283
- -- | ``` purescript
283
+ -- | ```purescript
284
284
-- | optional empty = pure Nothing
285
- -- | optional (pure x) = pure (Just x)
285
+ -- | ```
286
+ -- |
287
+ -- | The behaviour of `optional (pure x)` depends on whether the `Alt` instance
288
+ -- | satisfy the left catch law (`pure a <|> b = pure a`).
289
+ -- |
290
+ -- | `Either e` does:
291
+ -- |
292
+ -- | ```purescript
293
+ -- | optional (Right x) = Right (Just x)
294
+ -- | ```
295
+ -- |
296
+ -- | But `Array` does not:
297
+ -- |
298
+ -- | ```purescript
299
+ -- | optional [x] = [Just x, Nothing]
286
300
-- | ```
287
301
optional :: forall f a . Alt f => Applicative f => f a -> f (Maybe a )
288
302
optional a = map Just a <|> pure Nothing
You can’t perform that action at this time.
0 commit comments