
Isaac Dupree wrote:
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
Thanks -- I had a feeling I'd seen something about it before, but couldn't remember where. Anyway it's good to know the syndrome has a name and a prevention strategy, even if not a cure :-). 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.