gribouille/elm-prelude/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Prelude

Extra standard functions.

Tuples

fst : ( a1, a2 ) -> a1

Alias of Tuple.first

snd : ( a1, a2 ) -> a2

Alias of Tuple.second.

fst3 : ( a1, a2, a3 ) -> a1

Extract the first component of a triplet.

snd3 : ( a1, a2, a3 ) -> a2

Extract the second component of a triplet.

thd3 : ( a1, a2, a3 ) -> a3

Extract the third component of a triplet.

Maybe

maybe : b -> (a -> b) -> Maybe a -> b

Takes a default value, a function, and a Maybe value. If the Maybe value is Nothing, the function returns the default value. Otherwise, it applies the function to the value inside the Just and returns the result.

mapMaybe : (a -> Maybe b) -> List a -> List b

Version of map which throw out elements.

catMaybes : List (Maybe a) -> List a

Takes a list of Maybe and returns a list of all the Just values.

isJust : Maybe a -> Bool

Returns True if its argument is of the form Just _

isNothing : Maybe a -> Bool

Returns True if its argument is Nothing

Result

result : (a -> c) -> (b -> c) -> Result a b -> c

Case analysis for the Result type. If the value is Err a, apply the first function to a; if it is Ok b, apply the second function to b.

isOk : Result a b -> Bool

True if the Result is an Ok value.

isErr : Result a b -> Bool

True if the Result is an Err value.

resultFlip : Result a b -> Result b a

Flip the Err and Ok values.

resultValues : List (Result a b) -> List b

Extracts from a list of Result all the Err elements.

resultErrors : List (Result a b) -> List a

Extracts from a list of Result all the Ok elements.

Other

const : a -> b -> a

Unary function which evaluates to x for all inputs.

uncurry3 : (a -> b -> c -> d) -> ( a, b, c ) -> d

Converts a curried function with 3 parameters to a function on pairs.

curry3 : (( a, b, c ) -> d) -> a -> b -> c -> d

Converts an uncurried function with 3 parameters to a curried function.