We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d65c49b commit 185c084Copy full SHA for 185c084
src/Control/Alt.purs
@@ -18,6 +18,21 @@ import Data.Semigroup (append)
18
-- |
19
-- | For example, the `Array` (`[]`) type is an instance of `Alt`, where
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
+-- | ```
36
class Functor f <= Alt f where
37
alt :: forall a. f a -> f a -> f a
38
0 commit comments