News for hackers. Stuff that matters.
Re:Why Functional Programming Matters (1984) [pdf] by kqr on Thursday December 08, 2016 @09:32AM (#13130451)
Look, I fixed their code in so many ways:

    main =
        runConduitRes                        -- dealing with finite resources
             ( sourceFileBS "input.txt"      -- read input.txt as binary data
            .| decodeC utf8                  -- decode assuming UTF-8
            .| linesC                        -- split into lines
            .| mapC parseList                -- parse each line into list of text
            .| mapC (get 5)                  -- get sixth element of list
            .| catMaybeC                     -- discard lines with no sixth element
            .| encodeC utf8                  -- encode as UTF-8
            .| sinkFileBS "output.txt"       -- dump into output.txt
             )
And it's still very functional, if not more so!

This will run in constant space and linear time, it will buffer reasonably, it will not leak file handles, it will gracefully clean up on exceptions, it will not crash when it fails to parse something correctly, and it makes the encoding assumption explicit (you cannot split into lines unless you know the encoding).

Dealing with I/O is not hard when you use the correct primitives.

Re:Why Functional Programming Matters (1984) [pdf] by tdb7893 on Thursday December 08, 2016 @01:03PM (#13132477)
It seems to me that part of the problem he was having is that he didn't really understand how these methods were being implemented internally. I know that all languages inevitably have these problems but how do the amount of leaky abstractions compare in Haskell to other languages?
Re:Why Functional Programming Matters (1984) [pdf] by kqr on Thursday December 08, 2016 @03:37PM (#13134046)
I don't think Haskell is worse than any other language in that regard. What perhaps sets it apart is how much of its functionality is implemented in third-party libraries, which may be difficult for a beginner to come to grips with. "Why should I download a library to use efficient arrays? Shouldn't they be built in, like in Python?"

I can come up with two explanations for this reliance on third-party libraries.

1) Haskell has always been a quickly evolving language attracting research-minded people which in turn go on to develop really cool libraries that are much better than conventional ways of doing things. The interpretation of this explanation is that it's simply not possible to keep the standard library up to date with the latest library developments.

It may also be the case that

2) Haskell has always been a really powerful language capable of offloading important tasks to libraries. What would need to be built-in functionality in other languages can be implemented as libraries with no sort of special treatment in Haskell, so people do it that way because they can, and because it keeps the base simple.

Re:Why Functional Programming Matters (1984) [pdf] by cousin_it on Friday December 09, 2016 @02:59AM (#13137391)
> > how do the amount of leaky abstractions compare in Haskell to other languages?

> I don't think Haskell is worse than any other language in that regard.

Many Haskellers are happy about this kind of stuff:

    min = head . sort
which is the very definition of a leaky abstraction. The blame lies with laziness, because it allows code to depend on implementation details of other code in crazy ways: "sort is O(n log n) unless you ask for only the first element, in which case it's O(n). What if you ask for the last element? Uhhh..."
Re:Why Functional Programming Matters (1984) [pdf] by codygman on Friday December 09, 2016 @03:13PM (#13141440)
I wouldn't depend on invocations of sort to be anything but the worst case.
Re:Why Functional Programming Matters (1984) [pdf] by tome on Friday December 09, 2016 @03:04AM (#13137405)
Absolutely agreed! 'head . sort' is efficient by accident!
Re:Why Functional Programming Matters (1984) [pdf] by bunderbunder on Thursday December 08, 2016 @03:55PM (#13134200)
I'm leaning toward #2, largely because I know that's the Scheme approach, and I get the impression that Schemers and Haskellers have similar feelings about protecting the design purity of the language. By contrast, the Python community has always been pragmatic, arguably to a fault.

I can say that newcomers also seem to get a lot of advice that's directly at odds with how the Haskell community seems to think people should use the language. For example, Learn You A Haskell starts right off the bat by encouraging people to use the "list of characters" version of strings, even though that approach courts serious performance concerns.

Re:Why Functional Programming Matters (1984) [pdf] by dTal on Friday December 09, 2016 @11:00AM (#13139446)
>"Why should I download a library to use efficient arrays? Shouldn't they be built in, like in Python?"

Python does in fact use a third-party library for efficient arrays (Numpy) and its use is so widespread as to be a defacto language unto itself.

Re:Why Functional Programming Matters (1984) [pdf] by tome on Thursday December 08, 2016 @04:22PM (#13134413)
It might be simpler than that. Array syntax is not built in in Haskell therefore the array implementation needn't be built in.
Re:Why Functional Programming Matters (1984) [pdf] by kqr on Thursday December 08, 2016 @05:47PM (#13135029)
I'm sure I misunderstand you, because it sounds to me like other languages were designed on the basis of "Wait! How did this array syntax get built into my language? Oh well, now that it's there I guess I might as well build in arrays..."

I would guess those languages get built-in array syntax specifically because they have built-in arrays. The arrays come first, the syntax later.

Re:Why Functional Programming Matters (1984) [pdf] by tome on Friday December 09, 2016 @03:03AM (#13137399)
I suspect that typically both arrive at the same time!