Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-24 Thread frantisek kocun
Hi Raeck, as I see what types you defined, don't you doing School of Expression? (In summer I made my way to FAL chapter, but I had no time more (school), but I will definitely finish that book:) Fero ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.o

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-24 Thread Ryan Ingram
Here's a tip: leave off the type signature, and ask ghci what it is. $ ghci Prelude> let contain x [] = False ; contain x (y:ys) = if x == y then True else contain x ys Prelude> :t contain contain :: (Eq a) => a -> [a] -> Bool -- ryan 2008/12/22 Raeck Zhao : > I am trying to define a containin

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-23 Thread Gwern Branwen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On Tue, Dec 23, 2008 at 10:48 PM, Henning Thielemann wrote: > Andrew Wagner schrieb: >> The problem here is even slightly deeper than you might realize. For >> example, what if you have a list of functions. How do you compare two >> functions to eac

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-23 Thread Henning Thielemann
Andrew Wagner schrieb: > The problem here is even slightly deeper than you might realize. For > example, what if you have a list of functions. How do you compare two > functions to each other to see if they're equal? There is no good way > really to do it! So, not only is == not completely polymorp

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Luke Palmer
2008/12/22 Raeck Zhao > Thank you very much for your reply! It is really helpful! > > But I just found another 'problem', I just realize that the list does not > support the user-defined data type? > the list is also depending on the Eq function? > > For example, > > data Shape = Square | Triang

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Miguel Mitrofanov
On 22 Dec 2008, at 17:35, Raeck Zhao wrote: But I just found another 'problem', I just realize that the list does not support the user-defined data type? Don't worry, it does. the list is also depending on the Eq function? No, it doesn't. data Shape = Square | Triangle | Circle [Squar

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Andrew Wagner
s > > Raeck > > > -- > Date: Mon, 22 Dec 2008 09:02:53 -0500 > From: wagner.and...@gmail.com > To: ra...@msn.com > Subject: Re: [Haskell-cafe] Defining a containing function on polymorphic > list > CC: haskell-cafe@haskell.org; beginn...@h

RE: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Raeck Zhao
2:53 -0500 From: wagner.and...@gmail.com To: ra...@msn.com Subject: Re: [Haskell-cafe] Defining a containing function on polymorphic list CC: haskell-cafe@haskell.org; beginn...@haskell.org The problem here is even slightly deeper than you might realize. For example, what if you have a list of func

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Thomas Davie
On 22 Dec 2008, at 15:18, Andrew Wagner wrote: Yes, of course, sorry for the typo. On Mon, Dec 22, 2008 at 9:17 AM, Denis Bueno wrote: 2008/12/22 Andrew Wagner : > The problem here is even slightly deeper than you might realize. For > example, what if you have a list of functions. How do you

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Andrew Wagner
Yes, of course, sorry for the typo. On Mon, Dec 22, 2008 at 9:17 AM, Denis Bueno wrote: > 2008/12/22 Andrew Wagner : > > The problem here is even slightly deeper than you might realize. For > > example, what if you have a list of functions. How do you compare two > > functions to each other to s

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Denis Bueno
2008/12/22 Andrew Wagner : > The problem here is even slightly deeper than you might realize. For > example, what if you have a list of functions. How do you compare two > functions to each other to see if they're equal? There is no good way really > to do it! So, not only is == not completely poly

Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Andrew Wagner
The problem here is even slightly deeper than you might realize. For example, what if you have a list of functions. How do you compare two functions to each other to see if they're equal? There is no good way really to do it! So, not only is == not completely polymorphic, but it CAN'T be. There is

[Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Raeck Zhao
I am trying to define a containing function to see if a value is one of the elements within a list which is polymorphic, but failed with the following codes: > contain :: a -> [a] -> Bool > contain x [] = False > contain x (y:ys) = if x == y then True else contain x ys it seems that the pr