Ah, I think I understand now. Removing '::b' from (fromInteger 1) changes
the error to:
ERROR "Matrix.hs" (line 40): Inferred type is not general enough
*** Expression : det
*** Expected type : (Ix a, Num b) => Array (a,a) b -> b
*** Inferred type : (Ix a, Num Double) => Array (a,a) Double -> Double
Then changing the declared signature to
det :: (Ix a, Fractional b) => Array (a,a) b -> b
makes it work. Apparently Hugs infers the constraint Fractional b,
defaults it to Double, then complains because Num Double doesn't satisfy
the constraint Fractional b.
Removing the declared signature also makes it compile fine, and the
resulting function still seems to have the more general type (Ix a,
Fractional b) => Array (a,a) b -> b -- at least, writing
> det (listArray ((0,0),(1,1)) [1%1,2%2,2%2,1%1] yields
-3 % 1 :: Ratio Integer
as it should. But
> det
ERROR: Unresolved overloading
*** Type : Ix a => Array (a,a) Double -> Double
*** Expression : det
It confuses me that the numeric type is defaulted and the other type
isn't.
Thanks very much for your help. I knew it was something simple.
peace,
Chris Jeris (wishes he could get paid to write in Haskell)