What are comparable types?

type FruitSort =
    Apple
    | 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

Question

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

Answer

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