6 ms·
I think the experience of Haskell is relevant here. Once Haskell introduced first class functions, everyone stopped using typeclasses. [edit: apparently my sar
by yummyfajitas 15y ago
I think the experience of Haskell is relevant here. Once Haskell introduced first class functions, everyone stopped using typeclasses.
[edit: apparently my sarcasm was too subtle. HOF and typeclasses are both vitally important pieces of Haskell, which are orthogonal to each other. I'm pretty sure both were in Haskell from day 1. Some code for which both are essential:
class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
fail :: String -> m a
]
- CodeMage 15y agoI'm genuinely curious: is this because Haskell is generally hard to learn[] or because of some inherent property of Haskell that makes type classes unnecessary when you have first class functions? [] This statement is based purely on my own experience. I find the Haskell documentation a bit unfriendly with its "academic" style. The content is great, but the form makes it a bit hard to assimilate. Monads were especially painful.
- xyzzyz 15y agoOnce Haskell introduced first class functions, everyone stopped using typeclasses. What do you mean? From what I've seen, everyone uses typeclasses in Haskell.
- calpaterson 15y agoI don't think typeclasses were in from day one, they were added quite late in the development of the language (but some years before H98). I don't think they're in Miranda, for example. Here's a paper introducing them. http://dl.acm.org/citation.cfm?id=227700 http://dl.acm.org/citation.cfm?id=227700
- yummyfajitas 15y agoI stand corrected. I guess Haskell before H98 was a very different language than it is today.
- SamReidHughes 15y agoType classes were in Haskell 1.0. See http://webcache.googleusercontent.com/search?q=cache:rtFsiQCtqxYJ:www.haskell.org/definition/haskell-report-1.0.ps.gz+&cd=2&hl=en&ct=clnk&gl=us http://webcache.googleusercontent.com/search?q=cache:rtFsiQC...