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] 
> <javascript:>>:
>
> @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] <javascript:>.
> 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