While the two should be equivalent:
Prelude> :t \x -> fromIntegral (round x)
\x -> fromIntegral (round x) :: (Num b, RealFrac a) => a -> b
Prelude> :t fromIntegral . round
fromIntegral . round :: (Num c, RealFrac a) => a -> c
(it's just a different placeholder that is inferred, but the signatures are equivalent).
Prelude> fromIntegral (round (pi * 100))
314
works fine, but the following does not:
Prelude> fromIntegral . round (pi * 100)
<interactive>:34:1:
No instance for (Integral b0) arising from a use of `fromIntegral'
The type variable `b0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Integral Int -- Defined in `GHC.Real'
instance Integral Integer -- Defined in `GHC.Real'
instance Integral GHC.Types.Word -- Defined in `GHC.Real'
In the first argument of `(.)', namely `fromIntegral'
In the expression: fromIntegral . round (pi * 100)
In an equation for `it': it = fromIntegral . round (pi * 100)
<interactive>:34:16:
No instance for (Integral (a0 -> b0)) arising from a use of `round'
Possible fix: add an instance declaration for (Integral (a0 -> b0))
In the second argument of `(.)', namely `round (pi * 100)'
In the expression: fromIntegral . round (pi * 100)
In an equation for `it': it = fromIntegral . round (pi * 100)
this again, does:
Prelude> fromIntegral . round $ pi * 100
314
-- I don't understand, why, given the same signature, and also the equivalence of $
to parentheses to the end of line the parenthesis version does not work?
I thought the last three calls should be completely equivalent?