File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,21 @@ import Data.Semigroup (append)
18
18
-- |
19
19
-- | For example, the `Array` (`[]`) type is an instance of `Alt`, where
20
20
-- | `(<|>)` is defined to be concatenation.
21
+ -- |
22
+ -- | A common use case is to select the first "valid" item, or, if all items
23
+ -- | are "invalid", the last "invalid" item.
24
+ -- |
25
+ -- | For example:
26
+ -- |
27
+ -- | ```purescript
28
+ -- | import Control.Alt ((<|>))
29
+ -- | import Data.Maybe (Maybe(..)
30
+ -- | import Data.Either (Either(..))
31
+ -- |
32
+ -- | Nothing <|> Just 1 <|> Just 2 == Just 1
33
+ -- | Left "err" <|> Right 1 <|> Right 2 == Right 1
34
+ -- | Left "err 1" <|> Left "err 2" <|> Left "err 3" == Left "err 3"
35
+ -- | ```
21
36
class Functor f <= Alt f where
22
37
alt :: forall a . f a -> f a -> f a
23
38
You can’t perform that action at this time.
0 commit comments