|
|
|
|
|
by kmill
261 days ago
|
|
That second operator is the <|> operator, from the Alternative typeclass. The first one has some arbitrariness (do you take the left or right value if both are Just). But, thankfully the Applicative typeclass gives both <* and *>, which lets you choose which value you want: Just A <* Just B = Just A
Just A *> Just B = Just B
(There's the possibility to merge values too, with f <$> Just A <*> Just B, which evaluates to Just (f A B). I feel like this is a "don't try to understand it, just get used to it" sort of syntax. It can be pretty convenient though.) |
|