diff options
author | Joris | 2017-03-24 09:21:06 +0000 |
---|---|---|
committer | Joris | 2017-03-24 09:21:06 +0000 |
commit | c0ac16a713c4e53cf6af8e72a6d5f6b8ac5d6456 (patch) | |
tree | 8a438430cee7411259fc395d8f3898488e85d750 /src/client/elm/Utils/Maybe.elm | |
parent | 293eb8295162bf0a038f488237db9c9d1316c04d (diff) | |
parent | cfca18262c1ff48dcb683ddab7d03cf8e55573ff (diff) |
Merge branch 'features/categories' into 'master'
Features/categories
See merge request !1
Diffstat (limited to 'src/client/elm/Utils/Maybe.elm')
-rw-r--r-- | src/client/elm/Utils/Maybe.elm | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/client/elm/Utils/Maybe.elm b/src/client/elm/Utils/Maybe.elm index 4a94aa5..46456e1 100644 --- a/src/client/elm/Utils/Maybe.elm +++ b/src/client/elm/Utils/Maybe.elm @@ -1,7 +1,8 @@ module Utils.Maybe exposing ( isJust - , catMaybes - , maybeToList + , cat + , toList + , orElse ) isJust : Maybe a -> Bool @@ -10,8 +11,8 @@ isJust maybe = Just _ -> True Nothing -> False -catMaybes : List (Maybe a) -> List a -catMaybes = +cat : List (Maybe a) -> List a +cat = List.foldr (\mb xs -> case mb of @@ -20,8 +21,14 @@ catMaybes = ) [] -maybeToList : Maybe a -> List a -maybeToList mb = +toList : Maybe a -> List a +toList mb = case mb of Just a -> [a] Nothing -> [] + +orElse : Maybe a -> Maybe a -> Maybe a +orElse mb1 mb2 = + case mb1 of + Just x -> Just x + Nothing -> mb2 |