What are comparable types?

type FruitSort =
    | Orange
    | Banana

type alias Fruit =
    { sort: FruitSort
    , name: String

{-| Fruit needs to be "comparable". What do i need to do?
type Basket =
    Dict Fruit Int


Dict needs the first type to be comparable. What does that mean?


Int, Float, Char, String, Tuple comparable comparable and List comparable are comparable types. So you need to convert Fruit into a comparable type like Tuple Int String.

Further reading

Last updated