[Haskell-cafe] What does "1 = 2" mean in Haskell?

Alexey Muranov alexey.muranov at gmail.com
Sat Feb 25 22:58:28 UTC 2017


It seems weird however that Haskell allows

  let 1 = 0

but does not allow

  let (f x, g y z) = (x*x, y*z)

Alexey.

On Friday, February 24, 2017 at 4:53:59 AM UTC+1, Brandon Allbery wrote:
>
> Without a binding it is useless at top level, but if you strictify the 
> pattern it can be useful in `let` (possibly as a sanity check where you 
> want the program to abort if it fails). I don't recall offhand if it 
> desugars usefully in list comprehensions, but if so it would work as a 
> filter. There may also be other specialized use cases; general syntax tends 
> to get reused a lot in Haskell, so making this case a syntax error could 
> make it difficult to support actually useful cases. :)
>
> (Also I'm sure someone overly clever could figure out some way to abuse 
> it. :)
>
> On Thu, Feb 23, 2017 at 10:41 PM, Harendra Kumar <harendr... at gmail.com 
> <javascript:>> wrote:
>
>> On 24 February 2017 at 08:45, Brandon Allbery <allb... at gmail.com 
>> <javascript:>> wrote:
>>
>>> Literally the only use I've seen for this was a CCC puzzle. However, it 
>>> is the trivial case of something that is more useful: pattern matching the 
>>> result of an expression (say, a Data.Map.lookup when you know the key 
>>> exists).
>>>
>>
>> Can you explain how that will be useful (without a binding)? Will the 
>> pattern match be ever actually tried when there is no binding?
>>
>> -harendra 
>>
>
>
>
> -- 
> brandon s allbery kf8nh                               sine nomine 
> associates
> allb... at gmail.com <javascript:>                                  
> ball... at sinenomine.net <javascript:>
> unix, openafs, kerberos, infrastructure, xmonad        
> http://sinenomine.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170225/12ce620f/attachment.html>


More information about the Haskell-Cafe mailing list