News for hackers. Stuff that matters.
Re:Professor Frisby's mostly adequate guide to functional pr... by SirensOfTitan on Sunday March 22, 2020 @03:07PM (#22657609)
I’d just recommend skimming over something like Haskell book to gain some vague familiarity with what concepts exist, then just write code and learn applicative/monad/monoid etc as you run into walls.

Generalizations are notoriously hard to describe as they become more general. Better to understand where and when to use those patterns over being able to write a blog post about what a monad is.

Re:Professor Frisby's mostly adequate guide to functional pr... by awinter-py on Sunday March 22, 2020 @03:11PM (#22657655)
at this point I'm desperate for good docs / resources -- link to anything you particularly like

spent hours figuring out how to debug-print a value from a pure function and still haven't gotten there

Re:Professor Frisby's mostly adequate guide to functional pr... by unhammer on Sunday March 22, 2020 @03:22PM (#22657745)

    import Debug.Trace
    
    myPureThing :: Bool -> Int
    myPureThing b = if b 
                    then traceShow "yay True" 42 
                    else traceShow "oh noes False" 13
…

    λ> myPureThing True
    "yay True"
    42
    λ> myPureThing False
    "oh noes False"
    13

I don't know if they're good for others, but I read Real World Haskell[1] and Learn You a Haskell[2]. There's also Graham Hutton's book which people like and which is free to read this month or something[3].

[1] http://book.realworldhaskell.org/ – see also the in-progress updated version at https://github.com/tssm/up-to-date-real-world-haskell

[2] http://learnyouahaskell.com/

[3] https://www.cambridge.org/core/books/programming-in-haskell/...

Re:Professor Frisby's mostly adequate guide to functional pr... by awinter-py on Sunday March 22, 2020 @03:24PM (#22657766)
ack sorry, I meant how to add a debug statement to an existing pure function

while still having it return the original value

EDIT per comment below, I totally misread this! yes exactly, traceShow ftw

You saved me another N hours

Re:Professor Frisby's mostly adequate guide to functional pr... by tome on Sunday March 22, 2020 @04:03PM (#22658107)
Isn't that exactly what unhammer is demonstrating?
Re:Professor Frisby's mostly adequate guide to functional pr... by awinter-py on Sunday March 22, 2020 @04:11PM (#22658189)
oops yes
Re:Professor Frisby's mostly adequate guide to functional pr... by smabie on Sunday March 22, 2020 @05:04PM (#22658635)
You could also use unsafePerformIO
Re:Professor Frisby's mostly adequate guide to functional pr... by tome on Monday March 23, 2020 @06:22AM (#22662570)
Really don't.
Re:Professor Frisby's mostly adequate guide to functional pr... by hopia on Sunday March 22, 2020 @07:04PM (#22659610)
In principle, you wouldn't do any logging, even debug logging, in a pure function. It always returns the same output for the same input anyway. You'd just check its output.
Re:Professor Frisby's mostly adequate guide to functional pr... by nh2 on Sunday March 22, 2020 @08:46PM (#22660253)
> spent hours figuring out how to debug-print a value from a pure function

What method did you try to figure it out?

If I google "haskell debug print pure function", the first three results I get are:

* https://hackage.haskell.org/package/base-4.12.0.0/docs/Debug...

* https://stackoverflow.com/questions/13265783/trace-output-in...

* https://en.wikibooks.org/wiki/Haskell/Debugging

and they all have easy, one-line, correct examples of how to do it, within the first 20 seconds of reading.

(This is not to criticise -- sometimes one misses the forest for the trees -- as a professional Haskell consultant who runs trainings I am genuinely interested into what problems people face and why.)

Re:Professor Frisby's mostly adequate guide to functional pr... by awinter-py on Sunday March 22, 2020 @08:54PM (#22660306)
saw a lot of these links and passed over them -- I had it in my head that I could use the `print` command and that I didn't need the debug lib

shrug

there's always an adjustment process when learning something new