Without any background in Haskell to speak of, may I ask why this would be 
preferable? How would I discern the intent of line 4 without having to look up 
what "a" and "b" are? Is it not a lot more fragile to rely upon sensibly chosen 
names than to state the prerequisites up front? Naming is one of the hardest 
problems, not only in computer science.

Note that I am not arguing about “intent first”; I am questioning whether that 
maxim can be effectively implemented in practice using “where” syntax.

Regards,

Roland

> 3 jan. 2017 kl. 10:43 skrev 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] 
> <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 
>> <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] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <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