Skip to content

Instantly share code, notes, and snippets.

@toastal
Last active November 4, 2016 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toastal/e524790e45715ae42cac9c2d3a0604a8 to your computer and use it in GitHub Desktop.
Save toastal/e524790e45715ae42cac9c2d3a0604a8 to your computer and use it in GitHub Desktop.
module OnFail exposing (onFail)
onFail : (a -> Maybe b) -> (a -> b) -> a -> b
onFail f g x =
case f x of
Just y ->
y
Nothing ->
g x
infixl 2 ?>
(?>) : (a -> Maybe b) -> (a -> b) -> a -> b
(?>) =
onFail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment