Thanks for your reply,
i just simply removed the first line and it works, but i dont understand why 1/x is not Float.

It depends on the type of 'x'. If 'x' is a Float, (1/x) will be a Float. If 'x' is a Double, (1/x) will be a Double. If 'x' is an Integer (1/x) will not typecheck because (/) is only defined for Fractional arguments, and Integer is not an element of Fractional. In your case, you had constrained 'x' to be an Integer, so it requires a cast to perform the division and get a Float.

Removing the type signature allows the compiler to assign a more general type to 'x', and so it typechecks.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to