
5 Oct
2007
5 Oct
'07
4:01 p.m.
David Carter wrote:
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
The dreaded Monomorphism Restriction, which GHCi chooses to apply after every line you input. You could say "let sqlist a = map sq a" (syntactically having arguments makes the defaulting of (Num a => [a] -> [a]) not apply), or just use `ghci -fno-monomorphism-restriction`. Isaac