3 ms·
In the computer, you also have no descriptive variable names and make excessive use of gotos. This is far from a good argument. > Haskell does support mutatio
by BillMryes 12y ago
In the computer, you also have no descriptive variable names and make excessive use of gotos. This is far from a good argument.
> Haskell does support mutation, but inside of particular monads.
You are mistaken. Monads do not involve mutation; that would defeat their entire purpose. Although it's true that the monadic code is being compiled into assembly that involves mutation, just as $LANGUAGE code is being compiled into assembly that includes a lot of goto.
- tome 12y ago> You are mistaken. Monads do not involve mutation. Indeed. IO and ST involve mutation. They just so happen to be instances of Monad, but that's tangential.
- rtpg 12y agothey don't involve mutation on the language semantics level. The mutation happens through the runtime (via calls to the C FFI). In reality they're implemented in a mutation-heavy way for performaance reasons, but on the language level absolutely no mutation happens ( it's the whole World -> (Result, World) analogy)
- carterschonwald 12y agoThey're not done via cffi . its all compiler supported primops that get optimized and lowered to target native assembly.
- theseoafs 12y agoThe whole point about where the mutation happens and how the language remains pure in spite of it is not awfully relevant. The point is that Haskell does support real, bona-fide mutation in its standard library (see for example its support for stateful IO arrays). So obviously mutation is useful, regardless of whether you're doing that mutation behind a pure interface.
- BillMryes 12y agoTo add to what rtpg says, if you look at an actual, monadic example of an IO: putStrLn "What is your name?" >> getLine >>= \name -> putStrLn ("Hi, " ++ name ++ "!") It's just a giant chain of instructions, each previous result feeding into the next. Nowhere do we assign anything, modify anything, etc. No mutation.
- tel 12y agoThis is said a lot and technically valid in a sense, but I think over-pedantic. Some monads, IO, ST, State, do support mutation in the internal language. Then their implementation, their representation in the meta language, Haskell, can be "pure or whatever who cares". http://www.reddit.com/r/haskell/comments/30l46z/haskell_for_all_algebraic_side_effects/cptlduv
- im2w1l 12y agoIt's an implementation of mutability in a non-mutable language implemented on a platform with mutability.