New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boolean Strictness #3457
Comments
I'm not sure how you come to that conclusion? The laziness of this is unobservable unless you're resorting to |
The printable examples are for your convenience @garyb.
What is the value of |
If we want short-circuiting &&/|| to be an explicit feature that can be relied on, instead of just an artifact of the inliner, then it probably needs to be special syntax instead of "normal" (not so) functions. Similar to the distinction between I do not oppose such an addition. In fact, if such a syntax would desugar into foo x 0 = x
foo x i = x and foo (f i) (i - 1)
=
foo x 0 = x
foo x i = if x then foo (f i) (i - 1) -- tail call
else false |
@rightfold I quite like this; I agree that it probably needs to be special syntax (or at least, I can't think of any other way of addressing it). One potential issue is that I can imagine there is a lot of code out there which uses |
Any cheers for undefined evaluation order (for function application)? |
@fehrenbach it's not clear to me how this would address the issue; can you expand a little on what your thoughts are there? |
This would no longer be true. We could keep the convenient hack for It also opens the door for lots of optimizations of the "constructor meets eliminator"-form like: Promising laziness is quite difficult without a special purpose runtime system. Promising strict left-to-right evaluation limits how much "dead" code we can eliminate. If we only promise to be somewhere in between we get a lot of freedom, at a fairly small cost (most code does not really care). |
I'm down for that, I think. The boolean strictness issue does not concern me one bit personally, as it has no effect on program outcome (aside from guarded situations of non-termination or cheating effects). In fact, really it only has benefits - if we accept that some evaluation is sometimes like that, with the benefit of being able to optimise better, it seems like a win to me. I guess the argument against it is it makes performance harder to reason about, but only in the sense that sometimes it's faster that what you'd expect naively 😁 (yeah yeah I know that's not really true either, as if you expect some optimisation to trigger and it doesn't then it will be slower also). |
Another option would be to encode the laziness into the type: (&&) :: Boolean -> Lazy Boolean -> Boolean This is exactly what Idris does. Directed by the type annotation Challenge for PureScript would be the unification of types Also, |
It could be done like https://github.com/natefaubion/purescript-call-by-name#somewhat-actually-useful-things 😄 |
Having an Idris-style |
I still think this is an edge case in the language that should be fixed one day. Can we keep this open for future reference or at least put it on a wish list somewhere?
…On 27 May 2019, 17:56 +0200, Harry Garrood ***@***.***>, wrote:
Having an Idris-style Lazy type built in to the compiler might be nice, but it seems unlikely to happen at this stage. It looks like we've come to a consensus and there's nothing left to do here (until we get around to actually specifying the language), so I think this can be closed?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I personally would like to some equivalent to |
Sounds sensible. Let's leave this open then. |
PureScript is a strict language. However, there is currently an exception to this for the Boolean instance of HeytingAlgebra.
We can see this from the REPL with this unpleasant example:
Not all HeytingAlgebra instances are nonstrict. For example, the Unit instance is strict.
How can we know whether some
f :: Boolean -> Boolean
is strict or not? Seems we cannot. Not even referential transparency can be trusted!The text was updated successfully, but these errors were encountered: