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

Harendra Kumar harendra.kumar at gmail.com
Fri Feb 24 06:22:09 UTC 2017


On 24 February 2017 at 11:25, Jeff Clites <jclites at mac.com> wrote:

> On Feb 23, 2017, at 9:49 PM, Brandon Allbery <allbery.b at gmail.com> wrote:
>
> On Fri, Feb 24, 2017 at 12:38 AM, Harendra Kumar <harendra.kumar at gmail.com
> > wrote:
>
>> In these examples, we can identify the constructor (capitalized first
>> letter) on the LHS and so we are trained to know that it is a pattern
>> match. The original point related to number specialness was that "1 = 2" is
>> not easily identifiable as a pattern match because there are no explicit
>> constructors. The literal "1" here is neither an "explicit constructor" nor
>> a binding symbol.
>
>
> Yes, at this point you just have to know that the Report specifies a bunch
> of special handling for numeric literals.
>
>
> Also:  "day" = "night"
>
> Isn't every "=" a pattern match?
>

Every "=" with a constructor on the LHS. String is also a special case
similar to numeric literals. The above example should be equivalent to:

'd' : 'a' : 'y' : [] = "night"

-harendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170224/89038532/attachment-0001.html>


More information about the Haskell-Cafe mailing list