I am trying to replicate the short-circuiting behaviour of (&&). Would Elm translate this code to only evaluate the second argument if the first were True?
(&&) : Bool -> Bool -> Bool (&&) a = case a of False -> \_ -> False True -> id
The documentation says AFAIK “discards the input”. Is the elm/compiler optimizing it then as shortcircuit?
If it doesn’t, how could I implement short circuiting as frictionless as possibe? The best I could come up with is:
type Bool = Bool BVal type BVal = True | False true : Bool true = Bool True false : Bool false = Bool False (&&) : Bool -> Bool -> Bool (&&) (Bool a) = case a of False -> \_ -> Bool False True -> id
but that’s rather ugly IMO and causes horrible code.
I have been digging in elm/compiler for two hours right now, and am unable to test/verify my assumption.
Context: elm-in-elm Issue