Re: [Haskell-cafe] Trouble with non-exhaustive patterns

2008-07-21 Thread Austin Seipp
Hi Fernando, > final [] = [] - I consider that the end of an empty list is the empty list > final [a] = a > final (_:t) = final t > > Suddenly, the function stoped working with a rather cryptic (for a newbie > at least) error message: > > *Temp> final [4,5] > > :1:9: > No instance for (Nu

Re: [Haskell-cafe] Trouble with non-exhaustive patterns

2008-07-21 Thread Chaddaï Fouché
2008/7/21 Fernando Rodriguez <[EMAIL PROTECTED]>: > Suddenly, the function stoped working with a rather cryptic (for a newbie at > least) error message: > > *Temp> final [4,5] > > :1:9: > No instance for (Num [a]) > arising from the literal `5' at :1:9 > Possible fix: add an instance declar

Re: [Haskell-cafe] Trouble with non-exhaustive patterns

2008-07-21 Thread C.M.Brown
Hi Fernando, I hope you don't mind, but I've moved this over to the Haskell-beginners mailing list, where I think this kind of question will be more appropriate. In Haskell, it helps to think of functions in terms of an input and an output, that is, what is the thing that is going into the functi

Re: [Haskell-cafe] Trouble with non-exhaustive patterns

2008-07-21 Thread Janis Voigtlaender
Fernando Rodriguez wrote: Hi, I defiend the following function to get the last element of a list: final [a] = a final (_:t) = final t and it works as expected. Since I didn't want to have a non exhaustive pattern, I added the following case: final [] = [] - I consider that the end of an

[Haskell-cafe] Trouble with non-exhaustive patterns

2008-07-21 Thread Fernando Rodriguez
Hi, I defiend the following function to get the last element of a list: final [a] = a final (_:t) = final t and it works as expected. Since I didn't want to have a non exhaustive pattern, I added the following case: final [] = [] - I consider that the end of an empty list is the empty lis