8 ms·
Haskell is category theory as a language. I disagree with this. Haskell's creation [1, 2] predates the realisation (by the FP community at large) of the cl
by YorkshireSeason 9y ago
Haskell is category theory
as a language.
I disagree with this. Haskell's creation [1, 2] predates the realisation (by the FP community at large)
of the close connection between parts of category theory and parts of
pure functional programming, which happened in the 1990s, perhaps
driven by Moggi's realisation that monads are a fundamental
abstraction in computation that can reconcile effects with pure functional computation. More importantly, there is no category
"Hask" of Haskell programs, and there isn't even a candidate category that's even close.
One of Odersky's motives in creating Scala was bringing the power of
Haskell into the JVM world, although this is not the only motive
(tight integration of OO and FP being another).
Haskell's key innovation over its predecessors (Miranda and ML) was
the addition of higher-kinded types, which in turn made ad-hoc
polymorphism digestable in a typed world (in the form of type-classes). The combination of HKTs and
type-classes enables the monadic abstractions that contemporary
Haskell programming is widely known for today.
Note that Scala has HKTs and type classes (via implicits), so Haskell
programs can typically transliterated into idiomatic Scala without
major complications.
[1] P. Hudak, J. Hughes, S. Peyton Jones, P. Wadler, A History of
Haskell: Being Lazy With Class. http://haskell.cs.yale.edu/wp-content/uploads/2011/02/history.pdf http://haskell.cs.yale.edu/wp-content/uploads/2011/02/histor...
[2] Interview with Simon Peyton-Jones. http://www.cs.cmu.edu/~popl-interviews/peytonjones.html http://www.cs.cmu.edu/~popl-interviews/peytonjones.html
[3] E. Moggi, Notions of Computation and Monads. https://core.ac.uk/download/pdf/21173011.pdf https://core.ac.uk/download/pdf/21173011.pdf
- jowiar 9y agoWould love to see a citation re: Odersky (or if he'd chime in here). My general assumption is that if Scala was intended to be category theory, implemented, something along the lines of scalaz or cats would have been built into the language -- the philosophy of the language does not include a JS-esque philosophy of small stdlib, big library ecosystem.
- yawaramin 9y agoSee this talk https://youtu.be/P8jrvyxHodU https://youtu.be/P8jrvyxHodU He mentions module systems fairly early on.
- lptk 9y agoWhat does this have to do with the original assertion that "one of Odersky's motives in creating Scala was bringing the power of Haskell into the JVM world"? AFAIK, Odersky doesn't particularly like people trying to replicate Haskell patterns in Scala. For example, he thinks using monads for most effects is inappropriate.
- yawaramin 9y agoThreading fail. I thought I was replying to someone who had asked for a citation for: > Odersky has long claimed ML as his primary functional programming influence, not Haskell.
- saosebastiao 9y ago> One of Odersky's motives in creating Scala was bringing the power of Haskell into the JVM world, although this is not the only motive (thigh integration of OO and FP being another). I'm not sure why you would think that. Odersky has long claimed ML as his primary functional programming influence, not Haskell. It does have HKT, so there's that...but that's about it. Typeclasses aren't really a part of the language. They were made possible by implicits. They have since had some language level support (context bounds), but that is more of a nice to have than a primary influence. Just because Scala can "do" Haskell doesn't mean odersky was inspired by it any more than ML or Java.
- YorkshireSeason 9y agoFrom an abstract PL theory POV, Haskell's key innovation over ML was HKTs. It was an experiment at the time, but one that was successful beyond all expectation: I cannot imagine designing a new PL without HKTs. (Note that Rust is also trying to add HKTs, but has been running into difficulties with type-based lifetime tracking IIRC.) Implicits are a generalisation of default arguments (I don't know where they were pioneered, maybe C++). Implicits were first tried in Haskell [1]. Scala refined them in several steps, the last being [2] which represents implicits on the type leve. Mimicking type classes via implicits is a well-established Scala idiom [3]. [1] J. R. Lewis, J. Launchbury, E. Meijer, M. B. Shields, Implicit Parameters: Dynamic Scoping with Static Types. https://galois.com/wp-content/uploads/2014/08/pub_JL_ImplicitParameters.pdf https://galois.com/wp-content/uploads/2014/08/pub_JL_Implici... [2] M. Odersky, A. Biboudis, F. Liu, O. Blanvillain, Simplicitly: Foundations and Applications of Implicit Function Types. https://infoscience.epfl.ch/record/229878/files/simplicitly_1.pdf https://infoscience.epfl.ch/record/229878/files/simplicitly_... [3] B. C. d. S. Oliveira, A. Moors, M. Odersky, Type Classes as Objects and Implicits. http://ropas.snu.ac.kr/~bruno/papers/TypeClasses.pdf http://ropas.snu.ac.kr/~bruno/papers/TypeClasses.pdf
- saosebastiao 9y ago> Implicits are a generalisation of default arguments. There is an extreme semantic difference between an implicit parameter and a default argument. Have you spent any time at all using them? That's like claiming HKT is just a generalization of type constructors. Would you claim that HKT isn't anything new or novel because constructors have been around forever?