I'm guessing that the problem is that
fos -0.5 [1,1,1,1]
is being parsed as
((fos) - (0.5)) [1,1,1,1]
so that the 0.5 implies an instance of class Fractional which implies
by the type of (-)
(-) :: Num a => a -> a -> a
that fos is also an instance of class Fractional
But since it isnt we get an error
if you do a
fos (-0.5) [1,1,1,1]
this is parsed as
fos (negate 0.5) [1,1,1,1] ... etc
This is the reason I prefer the notation
negate x = ~x
and subtract x y = x - y
which means that (-x) is a section and (~x) is a negation
As I say I am not completely sure this is the 'exact' reason
since I thought that the above example would parse as
(fos) - (0.5 [1,1,1,1])
Clearly garbage!
it will however certainly be along these lines.
Hope this helps
Chris
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On
> Behalf Of Matthew Donadio
> Sent: Monday, November 09, 1998 2:02 PM
> To: Haskell List
> Subject: Haskel Type Question
>
>
> 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
>
> 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.
>
> --
> Matt Donadio ([EMAIL PROTECTED]) | 43 Leopard Rd, Suite 102
> Sr. Software Engineer | Paoli, PA 19301-1552
> Image & Signal Processing, Inc. | Phone: +1 610 407 4391
> http://www.isptechinc.com | FAX: +1 610 407 4405
>