I wrote a function in Haskell
toInt :: Float -> Int
toInt x = round $fromIntegral x
It is supposed to take in an Float and return the equivalent Int. I come from a C programming background, and in C, we could just cast it as an int.
However, in this case, I get the following compile error
No instance for (Integral Float)
arising from a use of `fromIntegral'
In the second argument of `($)', namely `fromIntegral x'
In the expression: round $ fromIntegral x
In an equation for `toInt': toInt x = round $ fromIntegral x
Any idea on how to fix this?
round 3.2 :: Int.Float -> Intthen your can search for functions of that type either on Hayoo or Hoogle