[Haskell-cafe] Confusing type specialisation in ghci

Isaac Dupree isaacdupree at charter.net
Fri Oct 5 12:01:26 EDT 2007


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


More information about the Haskell-Cafe mailing list