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