3 ms·
Is Haskell the only FP language where chaining instructions one after the other in not available by default ?
by lolive 8y ago
Is Haskell the only FP language where chaining instructions one after the other in not available by default ?
- weavie 8y agoAny purely functional language will : https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Pure https://en.wikipedia.org/wiki/List_of_programming_languages_... If a language is pure then there is no point running an instruction other than to return a result since the only point in ignoring a result would be if the instruction had a side efffect, which a purely functional language disallows. Haskell does simulate this chaining instruction via the do notation.. do a <- getLine b <- getLine putStrLn ( a ++ b ) It looks like it is chaining instructions, but really this gets rewritten by the compiler to something like this (in pseudo js) : bind(getLine, function(a) { bind(getLine, function (b) { putStrLn a + b; }) })
- lolive 8y agoI have spent ages understanding this. And I am super happy that what you summarize is the mental model I have made up.