News for hackers. Stuff that matters.
Re:God Writes Haskell by kaba0 on Thursday September 07, 2023 @09:21AM (#37418530)
If you can reason about f and g that doesn’t mean that you can tell anything useful about f o g, so no, this is a factually incorrect statement. Sure, if we have a separate unit of functionality, write a function for that. But that’s no silver bullet - complexity is unbounded.
Re:God Writes Haskell by louthy on Thursday September 07, 2023 @10:01AM (#37419043)
That isn’t true. If f and g are pure then the composition holds the same guarantees as the component parts
Re:God Writes Haskell by woolion on Thursday September 07, 2023 @10:08AM (#37419119)
>If you can reason about f and g that doesn’t mean that you can tell anything useful about f o g

I'm confused. If you can reason about f and g, there is nothing more to know about f o g -- provided f and g are pure functions. The whole thing is about making sure side-effects are properly pushed at the boundaries so that you can keep working with pure functions. Haskell just provides more help (or more constraints) to ensure that you work with pure functions. Because if you aren't, all bets are off, and indeed the case of f o g may be a haze.

Re:God Writes Haskell by kaba0 on Thursday September 07, 2023 @10:34AM (#37419494)

  f  :: Integer -> Boolean

  g f n = if (f n) then (g f (n+1)) else (is_it_reachable)
Will it ever terminate (or insert any other interesting property that you wish) with f = collatz?

I know this is the atomic bomb case, but you can actually quite easily increase the complexity in realistic programs by just a few compositions, it doesn’t take much.

Re:God Writes Haskell by louthy on Thursday September 07, 2023 @10:50AM (#37419738)
Who said anything about termination? The original point was about composition. The guarantees of the component parts are the same as the composition. It's neither clear that f or g will terminate, and it's the same for f . g

If the halting problem is really your biggest concern when developing software then you're lucky!

Re:God Writes Haskell by kaba0 on Thursday September 07, 2023 @11:53AM (#37420830)
The Halting problem’s immediate consequence is Rice’s theorem, which is much more wide-reaching then termination.
Re:God Writes Haskell by Quekid5 on Thursday September 07, 2023 @03:52PM (#37424671)
... and entirely irrelevant when talking about function composition.
Re:God Writes Haskell by woolion on Thursday September 07, 2023 @11:41AM (#37420614)
Here you are defining a new function, not composing two functions.

But if you consider a program implementation of pure functions, this might not be true; for example f and g use a quantity of RAM, but the RAM used by f o g exceeds your computer RAM and thus explodes. Or, if we work with objects, some values (e.g. internal values of the object, or context values) may be changed that make the final result of f o g different from what you would normally expect.

The promise of working "functionally" is to avoid the second class of problems. For the first class this is just a problem of computer systems, but pure functions means that the memory should be able to be reclaimed efficiently. And for the limits of computability theory (like the halting problem), nothing works except oracle machines, but no startup has ever delivered a functional one!

Re:God Writes Haskell by sterlind on Friday September 08, 2023 @02:59PM (#37437871)
Composing pure functions is equivalent to defining a new function, that's the idea behind the set of combinators being Turing-complete.
Re:God Writes Haskell by whateveracct on Thursday September 07, 2023 @12:57PM (#37421944)
> If you can reason about f and g that doesn’t mean that you can tell anything useful about f o g

What? The ability to reason about f o g (for various definitions of o) is the promise of Haskell and one of its entire ecosystem's foundational principles.

Local reasoning is absolutely possible.