J'espérais que quelqu'un pourrait expliquer le comportement suivant dans GHCi, lorsque vous utilisez la fonction fromIntegral:comportement incompatible avec fromIntegral dans GHCi
Prelude> let x = 1 :: Integer
Prelude> :t x
x :: Integer
Prelude> sqrt $ fromIntegral x
1.0
Prelude> let y = fromIntegral x
Prelude> sqrt y
<interactive>:181:1:
No instance for (Floating Integer)
arising from a use of `sqrt'
Possible fix: add an instance declaration for (Floating Integer)
In the expression: sqrt y
In an equation for `it': it = sqrt y
Pourquoi importe si je mets y
puis prendre son sqrt
ou tout simplement directement Prenez le sqrt
?
duplication possible de [Pourquoi 3 et x (qui a été affecté 3) ont différents types inférés dans Haskell?] (Http://stackoverflow.com/questions/7055146/why-do-3-and-x-which -was-assigned-3-have-différent-inferred-types-in-haskell) –