[Haskell-cafe] Confusing type specialisation in ghci
David Carter
dmc at sanger.ac.uk
Fri Oct 5 11:45:07 EDT 2007
Hello,
Can someone elucidate to me this behaviour from ghci 6.6.1? Why is the
type of sqlist specialised to Integer?
Prelude> let sq x = x * x
Prelude> :t sq
sq :: (Num a) => a -> a
Prelude> sq 2.5
6.25
Prelude> :t map sq
map sq :: (Num a) => [a] -> [a]
Prelude> map sq [2.5]
[6.25]
This is all as I would expect so far, but:
Prelude> let sqlist = map sq
Prelude> :t sqlist
sqlist :: [Integer] -> [Integer]
And indeed, I get
Prelude> sqlist [2.5]
<interactive>:1:8:
No instance for (Fractional Integer)
... etc
Thanks!
David
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
More information about the Haskell-Cafe
mailing list