Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: A question about pattern matching (ARJANEN Lo?c Jean David)
2. Re: The dot operator. (Troy Pracy)
3. Re: A question about pattern matching (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Sat, 18 Feb 2012 21:23:16 +0100
From: "ARJANEN Lo?c Jean David" <[email protected]>
Subject: Re: [Haskell-beginners] A question about pattern matching
To: bahad?r altan <[email protected]>
Cc: "[email protected]" <[email protected]>
Message-ID: <2088359.vdqy1aOUME@u021>
Content-Type: text/plain; charset="iso-8859-1"
"(Eq a) =>" means that the type a in the function's signature must be an
instance of the Eq typeclass.
Instances of Eq are types where equality is defined, Eq's member functions are
(==) and (/=), equality and inequality tests.
Le samedi 18 f?vrier 2012 20:16:05, bahad?r altan a ?crit :
> Hello. I'm wondering what " (Eq a) =>" part in the code below does.. I
> couldn't figure it myself.. Thanks in advance :) isPalindrome :: (Eq a) =>
> [a] -> Bool isPalindrome xs = xs == (reverse xs)
------------------------------
Message: 2
Date: Sun, 19 Feb 2012 07:25:50 +1100
From: Troy Pracy <[email protected]>
Subject: Re: [Haskell-beginners] The dot operator.
To: Antoine Latter <[email protected]>
Cc: bahad?r altan <[email protected]>, "[email protected]"
<[email protected]>
Message-ID:
<cadl6eeyddx_ki75uruezagc-ctaua_rppahm2fq_mm5k0gp...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On 2/19/12, Antoine Latter <[email protected]> wrote:
> Since it is an ordinary haskell function, it is something you can look
> up with Hoogle:
>
> http://www.haskell.org/hoogle/?hoogle=%28.%29
More generally, you can use SymbolHound to look up anything regular
search engines ignore, eg http://symbolhound.com/?q=haskell+%28.%29
------------------------------
Message: 3
Date: Sat, 18 Feb 2012 15:28:26 -0500
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] A question about pattern matching
To: bahad?r altan <[email protected]>
Cc: "[email protected]" <[email protected]>
Message-ID:
<cakfcl4x4n-0escpjacdaovxl_xedmfamcswywmhzvrtoudv...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sat, Feb 18, 2012 at 15:16, bahad?r altan <[email protected]> wrote:
> Hello. I'm wondering what " (Eq a) =>" part in the code below does.. I
> couldn't figure it myself.. Thanks in advance :)
>
> isPalindrome :: (Eq a) => [a] -> Bool
> isPalindrome xs = xs == (reverse xs)
>
> It's a type constraint. In this case, it's saying that, rather than
isPalindrome working only for a particular type, instead it works for any
type "a" which has an implementation of the Eq class, where "a" is the type
of the items in the passed list. Technically, it's telling the compiler to
pass in the appropriate Eq implementation for whatever type isPalindrome is
being applied to; this allows the correct implementation of (==) to be
used. (And it really is passed in; it's not an accident that constraints
look rather similar to parameters.)
--
brandon s allbery [email protected]
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120218/85975021/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 44, Issue 19
*****************************************