joneshf/elm-these/1.0.1

NOTE: this package is not compatible with Elm 0.19.1

These

A type that may be an a, a b, or both an a and a b at once.

type These a b
= This a
| That b
| These a b

This type is very closely related to Result a b.

While Result a b models exclusive-or, this type models inclusive-or.

these : (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c

Destroy the structure of a These a b.

The first two functions are applied to the This a and That b values, respectively. The third function is applied to the These a b value.

mapBoth : (a -> c) -> (b -> d) -> These a b -> These c d

There is only one implementation of this function. It is fully described by the type signature.

Replace any as with cs and replace any bs with ds.

mergeWith : (c -> c -> c) -> (a -> c) -> (b -> c) -> These a b -> c

Similar to these.

The difference is that in the These a b case we apply the second and third functions and merge the results with the first function.

merge : (a -> a -> a) -> These a a -> a

A version of mergeWith that does not modify the This a or That a values.