5 ms·
>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 nothin
by woolion 3y ago
>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.
- kaba0 3y agof :: 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.
- louthy 3y agoWho 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!
- woolion 3y agoHere 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!
- sterlind 3y agoComposing pure functions is equivalent to defining a new function, that's the idea behind the set of combinators being Turing-complete.