[Haskell-beginners] Got "Non type-variable argument in the constraint" error for a simple function
raabe at froglogic.com
Mon Feb 8 16:32:36 UTC 2016
On 2016-02-08 17:24, wizard wrote:
> Dear all,
> I just started to learn Haskell with learnyouahaskell.com and at the very
> beginning, I met a strange issue with following simple function:
> -- why does work with "toZero 10" but not for "toZero -10"?
> toZero :: (Integral t) => t -> [t]
> This function works as expected for positive arguments, e.g., "toZero 10"
> gives me [10,9,8,7,6,5,4,3,2,1,0]. However, GHCI will raise following error
> if I give it a negative argument, e.g., "toZero -10":
The issue is that 'toZero -10' is parsed as 'toZero minus 10', i.e. it's not
a negative value you're passing there. It expects 'toZero' to be a numeric
Try toZero (-10) instead.
Frerich Raabe - raabe at froglogic.com
www.froglogic.com - Multi-Platform GUI Testing
More information about the Beginners