Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/opvasger/comparable is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 1.1.0 found (60 same-name repos checked); no cached copy. Use another version.
This package contains replacements for functions in the core modules that rely on implicit comparison of values.
Implicit comparison relies on the convenient comparable type-variable which
has special semantics. This is useful for numbers, characters, strings, lists of
comparable things, and tuples of comparable things.
module Example exposing (N, compare, oneAndTwo, sort, toInt)
import Comparable
import Comparable.Set as Set exposing (Set)
type N = One | Two | Three
-- sort of nice, no?
sort : List N -> List N
sort = Comparable.sort compare
-- dict/set are available too.
oneAndTwo : Set N
oneAndTwo = Set.fromList compare [One,Two,Two,Two,Two]
-- this one builds on Basics.compare, which is usually what you want.
compare : N -> N -> Order
compare a b = Basics.compare (toInt a) (toInt b)
-- these conversions are often implemented for other purposes too.
toInt : N -> Int
toInt n =
case n of
One -> 1
Two -> 2
Three -> 3The core modules for Elm are documented here.