News for hackers. Stuff that matters.
Re:The Cult of the Haskell Programmer by friend_and_foe on Monday May 13, 2024 @11:44PM (#40351449)
Well, I wrote a series of functions doing a bunch of mathematical calculations, making lists and that. But when I went to 1) read a file, 2) output results to a file, I ran into some trouble. This was for a real use case I had. Writing the code to do all the calculation was really enjoyable and pretty easy to pick up. Actually turning it into a useful program not so much.

I used no libraries and wrote all the math myself, because when I went to investigate libraries none of them seemed to explain what they do in language someone who didn't already know would understand. When I went in stackexchange and other community spaces I got similar results.

Re:The Cult of the Haskell Programmer by simonmic on Tuesday May 14, 2024 @04:11AM (#40352762)
It's normal to hit some walls, usually from lack of/difficulty of finding the right kind of intro material. I encourage you to try again. I'll/we'll be happy to help with IO and "useful program" knowhow in chat (http://matrix.to/#/#haskell:matrix.org).
Re:The Cult of the Haskell Programmer by kreyenborgi on Tuesday May 14, 2024 @04:25AM (#40352839)
For reading line by line from stdin you can do something like

    import qualified Data.Text as T
    import qualified Data.Text.IO as T
    ...
    -- maybe you're reading things into a Set or something named acc
    go acc = do
      eof <- isEOF
      if eof then pure acc
      else do 
        line <- T.getLine
        T.putStrLn ("LINE IS "<>line)
        go (insert line acc)
There's hGetLine, hPutStrLn and hIsEOF for file handles, use withFile https://hackage.haskell.org/package/base-4.19.1.0/docs/Syste... which will close the handle when you exit the block. There are many more ways of doing this stuff of course, but the above will work fine for most stuff without any special libraries.

In general, use Data.Text for anything that you don't consider binary data (human-readable text as well as code, config files and such). Use Data.ByteString if you're thinking of it as pure encoded bytes.

Re:The Cult of the Haskell Programmer by tome on Tuesday May 14, 2024 @06:37AM (#40353663)
> When I went in stackexchange and other community spaces I got similar results

Could you post some examples of interactions you had on stackexchange? I'm interesting in improving the onboarding experience for new users, and knowing what do avoid will be helpful.

Re:The Cult of the Haskell Programmer by mcguire on Tuesday May 14, 2024 @02:36PM (#40358541)
That's exactly why I went through the exercise of translating Kernighan and Plauger's Software Tools in Pascal into Haskell.

https://web.archive.org/web/20171020034308/https://crsr.net/...