[Haskell-cafe] Re: Field names

Daryoush Mehrtash dmehrtash at gmail.com
Tue Sep 9 01:28:45 EDT 2008


Thanks.

Pattern matching and memory management in Haskell (or may be GHC
implementation of it) is somewhat of a mystery to me.  Are there any
references that explains the underlying implementation?

Daryoush

On Mon, Sep 8, 2008 at 6:37 PM, Mauricio <briqueabraque at yahoo.com> wrote:

>
>     abs (Pt {pointx = x, pointy = y}) = sqrt (x*x + y+y)
>>
>> Why is it pointx=x and not x=pointx?
>>
>>
> Your intuition is probably telling you that this
> is something like:
>
> abs (point) = sqrt (x*x+y*y)
>  where {x=pointx point ; y=pointy point}
>
> Actually, it's an example of pattern matching:
>
> abs (Pt {pointx=3 , pointy=4}) = 5
> abs (Pt {pointx=3 , pointy=y}) = sqrt (9+y*y)
> abs (Pt {pointx=z , pointy=z}) = (sqrt 2)*z
>
> etc.
>
> Best,
> Maurício
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Daryoush

Weblog: http://perlustration.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080908/ab6e770c/attachment.htm


More information about the Haskell-Cafe mailing list