
On 2004-12-23 at 15:09-0200 =?ISO-8859-1?Q?Maur=EDcio?= wrote:
Guys,
What is wrong with this code?
************** import Complex roots :: (Complex, Complex, Complex) -> (Complex, Complex); roots (a,b,c) = (x1,x2) where { x1 = (b*b + (sqrt_delta))/(2*a); x2 = (b*b - (sqrt_delta))/(2*a); sqrt_delta = sqrt 4*a*c} **************
I load it into GHCi and get:
************** Kind error: `Complex' is not applied to enough type arguments
That means what it says: Complex takes an argument, namely the type for the real and imaginary parts. You need to choose from Float, Double or some RealFloat. Try this in ghci: Prelude> :m Complex Prelude Complex> :info Complex -- Complex is a type constructor data (RealFloat a) => Complex a = (:+) !a !a and then
type Compl = Complex Double roots :: (Compl, Compl, Compl) -> (Compl, Compl)
-- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk