aboutsummaryrefslogtreecommitdiff
path: root/src/Utils/Maybe.elm
blob: 355ded9d2c0142fd45fae52dfe799876861169df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Utils.Maybe
  ( filterMaybe
  , orElse
  ) where

filterMaybe : (a -> Bool) -> Maybe a -> Maybe a
filterMaybe cond maybe =
  case maybe of
    Just x ->
      if cond x
        then Just x
        else Nothing
    Nothing ->
      Nothing

orElse : Maybe a -> Maybe a -> Maybe a
orElse mb1 mb2 =
  case mb1 of
    Just x -> Just x
    Nothing -> mb2