You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
The documentation for
optional
states thatbut the second equation holds only for types satisfying the left catch law (
pure a <|> b = pure a
), likeAff
, and not those satisfying the distributivity law ((f <*> a) <|> (g <*> a) = (f <|> g) <*> a
), likeArray
.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]
withArray
for instance), so perhaps we should document both the left catch and distributivity behaviours?The text was updated successfully, but these errors were encountered: