Closed
Description
The documentation for optional
states that
optional empty = pure Nothing
optional (pure x) = pure (Just x)
but the second equation holds only for types satisfying the left catch law (pure a <|> b = pure a
), like Aff
, and not those satisfying the distributivity law ((f <*> a) <|> (g <*> a) = (f <|> g) <*> a
), like Array
.
We should at least remove the second equation but I find both equations helpful together to explain the behaviour of optional
and I think its behaviour for types satisfying distributivity instead of left catch can be surprising at first (optional [x] = [Just x, Nothing]
with Array
for instance), so perhaps we should document both the left catch and distributivity behaviours?
Metadata
Metadata
Assignees
Labels
No labels