4 ms·
I don't know who you've been talking to that considers Haskell to be an imperative language, but that's nonsense. Haskell is about as far from multi-paradigm as
by nbouscal 13y ago
I don't know who you've been talking to that considers Haskell to be an imperative language, but that's nonsense. Haskell is about as far from multi-paradigm as you can get. Do-notation is nothing but syntactic sugar for regular monadic expressions, which are pure functional in every way.
- tel 13y agoBecause monads allow you to basically embed "Algol" into Haskell. It's super imperative, despite it being interpreted as a pure function. I'd actually go so far as to say Haskell is quite multi-paradigm but only the FP side comes close enough to Haskell's "purity" as to make a community translation. I'd be quite willing to say that Haskell has a fantastically correct if slightly difficult to use object system. It just doesn't quack anything at all like Smalltalk or Java's.
- nbouscal 12y agoI strongly disagree, but am sure that that disagreement comes only from us defining terms differently. If you define the term "imperative" widely enough to include Haskell, what language does it not include?
- tel 12y agoI wouldn't claim it excludes many languages. Prolog comes to mind. Imperative, to me, means a language structured over the execution of statements in order. I think that's a fairly common definition.
- nbouscal 12y agoThat still sounds a little weak, but even under that definition, how does Haskell qualify? Do-notation may make things look like statements, but they are still expressions!
- tel 12y agoThey are statements in an embedded language modeled by the monad. The distinction isn't great. Monad allows the implementer to capture linear action if they like. That makes them at least powerful enough to embed Algol.
- zak_mc_kracken 12y agoMerely quoting Simon Peyton Jones and Philip Wadler in their paper from 1993 "Imperative Functional Programming" [1]. Chaining monadic binds with a `do` is the textbook example of imperative programming (it's actually the very reason why the keyword 'do' was chosen for syntactic sugar, because it captures perfectly the imperative aspect: "do this and in this order"). You seem to think it's a bad word but I really don't understand that. Haskell is both functional and imperative, there's really nothing wrong about it. [1] http://research.microsoft.com/en-us/um/people/simonpj/Papers/imperative.ps.Z http://research.microsoft.com/en-us/um/people/simonpj/Papers...
- nbouscal 12y agoHuh. We clearly mean different things by "imperative programming". To me, sequential computation is a necessary but really-far-from-sufficient aspect of imperative programming. A monadic expression is still an expression, not a statement. It is still referentially transparent. I don't know how you can look at a referentially transparent expression and call it imperative other than by being very liberal with your definitions.