But what if the branches are not calls to an external function like "munch", 
but are instead as originally envisioned arbitrary, in place, expressions, 
possibly using "b"/"c" several times? Then your latest solution does not apply 
since it loses sharing. (Of course one can always artificially introduce 
something like an explicit "munge"-function just for the purpose of 
guaranteeing sharing. But that might be undesirable from a readability 
standpoint.)

> Am 03.01.2017 um 17:39 schrieb Colin Woodbury <[email protected]>:
> 
> @Janis, no, truth be told I didn't like it as I was writing it, but it also 
> didn't occur to me at the time to fire `where` down at the bottom like that. 
> Doing so would satisfy "intent first", but I'd say `let` and `where` here 
> would be tied in terms of "zig-zag annoyance", which is a natural outcome of 
> the pattern of needing a shared bound value across two guards.
> 
> The next evolution, avoiding the problem of nested `where`s entirely:
> 
> f tree =
>   case tree of
>     Leaf x -> munge a (b x)
>     Node s t -> munge a (c s t)
>   where
>     a = ...
>     b x = ...
>     c s t = ...
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to