4 ms·
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., "classO
by pklausler 10y ago
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.
- taylorfausak 10y agoI 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/Neon/Class/HasMap.purs https://github.com/tfausak/purescript-neon/blob/v0.5.4/src/N... [2]: https://pursuit.purescript.org/packages/purescript-prelude/1.0.1/docs/Control.Monad#t:Monad https://pursuit.purescript.org/packages/purescript-prelude/1...