3 ms·
Haskell has typeclasses which would probably correspond to structural typing in Scala. This type signature: Functor f => (a -> b) -> f a -> f b Defines map fo
by timclark 15y ago
Haskell has typeclasses which would probably correspond to structural typing in Scala. This type signature:
Functor f => (a -> b) -> f a -> f b
Defines map for any type that implements the type class functor. Lots of types will implement functor and it is easy to implement it yourself.
- masklinn 15y ago> Haskell has typeclasses which would probably correspond to structural typing in Scala. Nah, typeclasses are nominative typing but added post-facto (you can define a typeclass instance for a third party's type). Typeclasses are similar to Scala's traits I think (I don't know if you can add traits to a library's types though).
- jfager 15y agoYou get typeclasses in Scala via an interaction between traits and implicits. See http://www.sidewayscoding.com/2011/01/introduction-to-type-classes-in-scala.html http://www.sidewayscoding.com/2011/01/introduction-to-type-c... for a super-quick overview and a link to a more comprehensive paper.
- soc88 15y agohttp://hackerne.ws/item?id=3265598 http://hackerne.ws/item?id=3265598