News for hackers. Stuff that matters.
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by dan-robertson on Saturday June 12, 2021 @07:31PM (#27488358)
Laziness in haskell is a weird issue. It makes compilation harder and it makes it much harder to predict a program’s performance, or the global performance impact of a local change (eg a change might be locally good but change to no longer evaluate so many things at once, deferring that evaluation to happen when it is more expensive—because eg the compiler can’t inline or there is no cache efficiency). Indeed Peyton Jones has said that the next haskell [family language] would be strict.

On the other hand, it allows for many programs to be written in nicer, more direct and declarative ways. As well as allowing for weirdness like in this article. But maybe a lot of that is more coming from code transformations enabled by purity and something like clojure-style lazy sequences (or strict if they are finite) plus aggressive inclining and stream fusion would be sufficient.

Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by andrepd on Saturday June 12, 2021 @09:46PM (#27489075)
The answer is simple: make strictness the default and laziness opt-in, by giving a keyword/operator to turn something into a lazy thunk.
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by whateveracct on Saturday June 12, 2021 @09:53PM (#27489109)
Laziness being the default means libraries compose better though.

I quite like how Haskell does it now, and reasoning about its performance honestly isn't bad. And that's worn GHC optimizing like crazy (which is actually what makes Haskell performance wonky to think about - not laziness.)

Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by dan-robertson on Sunday June 13, 2021 @06:55AM (#27491523)
Agreed. The laziness seems to only be useful when it is pervasive. Having only a little laziness isn’t so difficult from having none at all (eg OCaml has optional laziness but it is hardly used at all)
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by siraben on Saturday June 12, 2021 @10:24PM (#27489253)
Fixpoints are one of the most important concepts in denotational semantics and domain theory (see [0] for a good introduction). Denotational semantics lets you precisely specify the meaning of a program as a mathematical object, and also nicely integrates partiality and nontermination. It's quite motivating to learn order theory this way as well.

[0] https://en.wikibooks.org/wiki/Haskell/Denotational_semantics

Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by danidiaz on Sunday June 13, 2021 @03:44AM (#27490644)
One practical use of "fix" is emulating Python-like decorators in Haskell: http://web.cecs.pdx.edu/~ntc2/haskell-decorator-paper.pdf

Fixed points are also an important part of the technique described in the paper "Abstracting Definitional Interpreters" https://arxiv.org/pdf/1707.04755.pdf

Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by patrakov on Saturday June 12, 2021 @06:11PM (#27487830)
A well-written article, understandable even to people who are not familiar with Haskell. But, unfortunately, with some typos.
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by tome on Sunday June 13, 2021 @03:56AM (#27490700)
Here's the source, if you want to submit an issue/PR.

https://github.com/rebeccaskinner/rebeccaskinner.github.io/b...

Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by patrakov on Sunday June 13, 2021 @05:08AM (#27491013)
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by tome on Sunday June 13, 2021 @06:34AM (#27491424)
Nice! Open source contribution at its finest.
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by hydroxonium on Sunday June 13, 2021 @01:11AM (#27489921)
There's something wrong with your comment, but I won't tell you where.
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by somethingsright on Sunday June 13, 2021 @02:10AM (#27490200)
laziness . pure
Re:The Fixed Point: Laziness, Recursion and Fixed Points in ... by skybrian on Sunday June 13, 2021 @04:06AM (#27490736)
The factorial function can be useful for explaining the basics since it’s so simple, but it makes a poor example for showing when foldr is better than direct recursion.