mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-02 00:07:55 +03:00
39 lines
546 B
Elm
39 lines
546 B
Elm
|
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
|