News for hackers. Stuff that matters.
Re:Hell: A Haskell Shell by marcosdumay on Friday November 22, 2013 @08:11AM (#6780498)
A shell made in a pure functional language... It does not look apealing (the main use of a shell is to create side effects), but I'll sure try it.
Re:Hell: A Haskell Shell by Hemospectrum on Friday November 22, 2013 @08:35AM (#6780577)
There's a misunderstanding at work here about how Haskell actually regards side effects. In a few words: It provides an API for declaring side effects, and forces you to use this API when chaining them together, but it does not refuse to acknowledge their existence.

Haskell's reputation exaggerates how this API was less powerful, or missing altogether, in early versions of the language. But its reputation is not what you write programs in.

Re:Hell: A Haskell Shell by marcosdumay on Friday November 22, 2013 @04:07PM (#6783752)
No misunderstanding. I know Haskell, and I do like it. But monads (each one) are better constrained to a small part of your code, otherwise you negate all the power you gain by declaring the side effects. And the entire point of a shell is to do IO all over the place.
Re:Hell: A Haskell Shell by Sirenos on Friday November 22, 2013 @08:45AM (#6780618)
sigh

Functional languages are all about keeping side effects under control so that you can tell what will and what will not change the state of the system. Think of it as incorporating awareness of program state into the type-system of the language.

Re:Hell: A Haskell Shell by DanWaterworth on Friday November 22, 2013 @08:28AM (#6780551)
The main use of Haskell is to create side effects. It just does so in a principled, constrained manner.
Re:Hell: A Haskell Shell by deckiedan on Friday November 22, 2013 @01:06PM (#6782496)
As others have replied to you, I think you misunderstand what side effects & IO are.

Imagine a "normal" shell type chain:

    ps -ef | grep 'elephant' | sort -nk2 >> logfile.txt
neither `grep`, nor `sort` should have any side effects, and if they do, then you have potential for weird bugs later on. (imagine your / is mounted read only, and sort has a side effect of writing everything to a temp file. now suddenly this otherwise sane looking chain stops working).

In the command, you have a single input, and a single output (which has a specific mode, append). Those are the only IO functions which you've specified, but you have no guarantee that anything else will not make a mess of things.

The dream for "pure functional" shell scripting would be where the side effects are more obvious, and controllable, not to eliminate them.

Re:Hell: A Haskell Shell by joeyh on Friday November 22, 2013 @02:43PM (#6783244)
Sort does have the side effect of writing to a temp file, when the input to be sorted is large. :)
Re:Hell: A Haskell Shell by yongjik on Friday November 22, 2013 @03:01PM (#6783354)
Except that usually grep and sort can read files, or entire directories, which is considered a "side effect" in Haskell.

(Not to mention checking locales to decide how to sort, checking if the output is terminal so that we can add colors, but only if the environment variable says so, and on, and on...)

Re:Hell: A Haskell Shell by freyrs3 on Friday November 22, 2013 @03:27PM (#6783486)
And almost all Haskell programs do perform side-effects, they just demarcate the sections of their logic that do and don't have effects.

The meme that Haskell can't do side-effects or that's its hard just won't die...

Re:Hell: A Haskell Shell by IsTom on Friday November 22, 2013 @02:59PM (#6783343)
You can write C in Haskell (I do sometimes, for SPOJ or something) if you really want. However, Haskell lets you say that something has no side effects, which is very useful for reasoning about programs.