Skip to content

Support type classes #38

@techtangents

Description

@techtangents

As a driving example, the Dict class doesn't make sense without typeclasses. Right now, it's unclear how exactly the Dict implementation gets the "compare" function - it looks like duck typing.

Without type classes, passing in an Ord instance is preferable to duck typing.

e.g.
instead of:
singleton :: k -> v -> Dict k v

do this:
data Ordering = LT | EQ | GT
data Ord a = Ord (a -> Ordering)
singleton :: Ord k -> k -> v -> Dict k v

Alternatives include generalised implicit parameters.

I think, given Elm's Haskell heritage, Haskell-style type classes would be nice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions