Yes, and there is no need to only imagine it, since that already *is* a
legal use of Haskell-style where. But I have doubts about its readability,
with the adjacent where lines towards the bottom, where only indentation
determines what the scope of the respective definitions is. And since Colin
probably knows that that way of writing the example would have been legal
as well, his giving another version with where instead may indicate he also
considers these “adjacent wheres” undesirable in terms of
clarity/readability of the code.

In any case, even just the fact that let (with in) is a
two-keywords-construct makes it clearer for nested uses.
​

2017-01-03 10:43 GMT+01:00 David Andrews <[email protected]>:

> You could also imagine a parsing of where, where the following would be
> the way to write this:
> f tree =
>   case tree of
>     Leaf x ->
>       munge a b
>       where
>         b = ...
>     Node s t ->
>       munge a c
>       where
>         c = ...
>   where
>     a = ...
>
>
>
>
>
> On Tuesday, January 3, 2017 at 1:26:33 AM UTC-5, Janis Voigtländer wrote:
>>
>> And do you like that version? It seems to not have the advantages usually
>> claimed for "where" in this discussion. For example, you define "a" before
>> using it. What about "intent first" here? And in some sense, this
>> formulation now looks like a dual to the workaround Joey proposed with
>> "let" to please "where" proponents. Isn't it strange that "a" and "work"
>> look like they might be mutually recursive now, when they are actually not
>> and when the "let"-formulation made that explicitly visible?
>>
>> Am 02.01.2017 um 23:10 schrieb Colin Woodbury <[email protected]>:
>>
>> @Janis, I suppose the `where` version of that formation would have to be:
>>
>> f tree = work
>>   where a = ...
>>         work = case tree of
>>           Leaf x -> -- using a and b
>>
>>             where b = ...
>>           Node s t -> -- using a c
>>
>>             where c = ...
>>
>>
>> On Sunday, 1 January 2017 12:21:47 UTC-8, Janis Voigtländer wrote:
>>>
>>> Janis, the following compiles for me: …
>>>
>>> Right, where does not work for expressions, but for right-hand sides,
>>> of which pattern match branches are an instance.
>>>
>>> The next question would be, still under the assumption that a choice has
>>> to be made between where and let because both won’t be made available
>>> at the same time, how well “where-only” would work if in addition one
>>> wants to have a local binding that spans all pattern match branches, i.e.,
>>> something one would currently write in Elm like so:
>>>
>>> f tree =
>>>   let
>>>     a = ... something ...
>>>   in
>>>     case tree of
>>>       Leaf x -> let b = ... in ... using a and b ...
>>>       Node s t -> let c = ... in ... using a and c ...
>>>
>>> ​
>>>
>> --
>> 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.
>

-- 
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