Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Typeclass names could be made redundant in Haskell. If one could state a constraint in terms of a typeclass member, things would be more simple.

E.g., "classOf fmap" as a synonym for Functor.



I tried this out in PureScript [1]. I also made each type class have only one member and didn't specify any class hierarchy. I like how it works, but I don't know if anyone else does. It allows you to recreate the category theory type classes [2] if you want to:

    class (HasMap f) <= Functor f
    class (Functor f, HasApply f) <= Apply f
    class (Apply f, HasPure f) <= Applicative f
    class (Apply m, HasChain m) <= Bind m
    class (Applicative m, Bind m) <= Monad m
[1]: https://github.com/tfausak/purescript-neon/blob/v0.5.4/src/N... [2]: https://pursuit.purescript.org/packages/purescript-prelude/1...




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: