Sometimes, ghc throws following error:
:7:21:
Couldn't match expected type Double' with actual type
Int'
In the second argument of (/)', namely
(3 :: Int)'
In the expression: (10.0 :: Double) / (3 :: Int)
In an equation for `it': it = (10.0 :: Double) / (3 :: Int)
(/) required to have the same type, which is Fractional type class.
Prelude> :t (/)
(/) :: Fractional a => a -> a -> a
Prelude> :i Int
data Int = GHC.Types.I# GHC.Prim.Int# -- Defined in `GHC.Types'
instance Bounded Int -- Defined in `GHC.Enum'
instance Enum Int -- Defined in `GHC.Enum'
instance Eq Int -- Defined in `GHC.Classes'
instance Integral Int -- Defined in `GHC.Real'
instance Num Int -- Defined in `GHC.Num'
instance Ord Int -- Defined in `GHC.Classes'
instance Read Int -- Defined in `GHC.Read'
instance Real Int -- Defined in `GHC.Real'
instance Show Int -- Defined in `GHC.Show'
fromIntegral helps to convert Integer or Int to Num.
Prelude> :t fromIntegral
fromIntegral :: (Integral a, Num b) => a -> b
Still Num is not Fractional.