>I have two functions
>
>> fos    :: Num a -> [a] -> [a]
>> fos a x = fos' a 0 x
>
>> fos'            :: Num a -> a -> [a] -> [a]
>> fos' _ _  []     = []
>> fos' a y1 (x:xs) = y : fos' a y xs
>>                    where y = a * y1 + x

First of all, I think your type signatures are wrong, unless you've defined your own 
type constructor Num elsewhere.  fos should have a signature like:

fos :: (Num a) => a -> [a] -> [a]

The Num from the prelude is a class, not a type: the context (the part before =>) says 
that the type "a" is an instance of Num.

>Why does
>
>> fos -0.5 [ 1, 1, 1, 1 ]
>
>give me
>
>[a] -> b -> [b] -> [b] is not an instance of class "Fractional"
>
>while
>
>> fos (-0.5) [ 1, 1, 1, 1 ]
>
>evaluates just fine?  I'm using Hugs 1.4.  Thanks.

Without the parentheses, -0.5 is recognized as two lexemes, - and 0.5, with types:

(-) :: (Num a) => a -> a -> a
0.5 :: (Fractional a) => a

Note that, because of the funny precedence rules associated with -, its type here is 
that of a binary function.  I'm not sure why you get exactly the above type error, but 
it's related to this fact.

--FC



Reply via email to