krisajenkins / elm-exts / Exts.Basics

Extensions to the core Basics library.

on : (a -> b) -> (b -> b -> c) -> a -> a -> c

Run a function on two inputs, before doing something with the result. Can be useful for things like sorts. For example, compare (List.length a) (List.length b) can be written on List.length compare.

See also compareBy.

compareBy : (a -> comparable) -> a -> a -> Basics.Order

Like Basics.compare, with a custom function. For example:

compareBy Date.toTime earlyDate laterDate
--> LT

maxBy : (a -> comparable) -> a -> a -> a

Like Basics.max, but it works on non-comparable types by taking a custom function. For example:

maxBy Date.toTime earlyDate laterDate
--> laterDate

minBy : (a -> comparable) -> a -> a -> a

Like Basics.min, but it works on non-comparable types by taking a custom function. For example:

minBy Date.toTime earlyDate laterDate
--> earlyDate