[Haskell-cafe] typeclass constraints

2013-08-23 Thread TP
Hi everybody, There is something I do not understand in the way typeclass constraints are inferred. 1/ Take the following function definition: sum' [] = [] sum' (x:xs) = x + sum' xs GHCI correctly gives: :t sum' sum' :: Num [a] = [[a]] - [a] So it has inferred that the type list has to

Re: [Haskell-cafe] typeclass constraints

2013-08-23 Thread Adam Gundry
Hi TP, The difference is that in your second example, you have specified the type signature p :: a - ExpQ so GHC checks whether p has this type, and correctly objects that it doesn't. If you leave off the type signature, as you did for sum', the right thing will be inferred. Hope this helps,

Re: [Haskell-cafe] typeclass constraints

2013-08-23 Thread Ivan Lazar Miljenovic
On 23 August 2013 19:23, TP paratribulati...@free.fr wrote: Hi everybody, There is something I do not understand in the way typeclass constraints are inferred. 1/ Take the following function definition: sum' [] = [] sum' (x:xs) = x + sum' xs You haven't specified a type signature here,

Re: [Haskell-cafe] typeclass constraints

2013-08-23 Thread TP
Adam Gundry wrote: If you leave off the type signature, as you did for sum', the right thing will be inferred. Thanks Adam and Ivan. Very stupid question... TP ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org