elm-review/tests/Simplify/Match.elm

39 lines
546 B
Elm
Raw Normal View History

2022-04-17 09:59:11 +03:00
module Simplify.Match exposing
( Match(..)
, map
, maybeAndThen
)
{-|
@docs Match
@docs map
@docs maybeAndThen
-}
type Match a
= Determined a
| Undetermined
map : (a -> b) -> Match a -> Match b
map mapper match =
case match of
Determined a ->
Determined (mapper a)
Undetermined ->
Undetermined
maybeAndThen : (a -> Match b) -> Maybe a -> Match b
maybeAndThen fn maybe =
case maybe of
Just a ->
fn a
Nothing ->
Undetermined