haskell - What's the right way to divide two Int values to obtain a Float? -


I want to divide two int values ​​in Haskell and return result to float < / Code>. I tried to do this:

  foo :: int -> Int - & gt; Float Foo AB = Sealational $ a% b  

But GHC (version 6.12.1) tells me "Expected Type 'Integer' to 'Code> A' in Expression. / P>

I understand why: fromRational calls is required (%) a integer to output , hence operand It requires a integer instead of integer but the values ​​I am dividing anywhere near the int range That's why using an arbitrary-precise, bignum type looks like over-the-counter.

What is the correct way to do this? Should I call toInteger on my operators , Or is there a better way (possibly (%) and the ratio is not included) I do not know?

You have to change the operators before and then split them, else you would enter an integer at '

  foo = (/) `  

is less for foo ab = (integral a) / (integral b)

. With

  foo :: int - & gt; Int - & gt; Float  

Comments