-fno-monomorphism-restriction != dynamic
Section 4.18 claims -fno-monomorphism-restriction is
dynamic. ":set"ting it in GHCi seems to have no
affect:
Loading:
> i = 1
> y = (1::Int) + i
> x = 1.1 + i
> main = error "main"
with -fno-monomorphism-restriction :set (but not set
on the command line) gives:
Prelude> fmap (filter (==
"-fno-monomorphism-restriction")) System.getArgs >>= print
[]
Prelude> :set -fno-monomorphism-restriction
Prelude> Compiling Main (
/home/gunter/haskell/TestMonomorphism.hs, interpreted )
/home/gunter/haskell/TestMonomorphism.hs:3:
No instance for (Fractional Int)
arising from the literal `1.1' at
/home/gunter/haskell/TestMonomorphism.hs:3
In the first argument of `(+)', namely `1.1'
In the definition of `x': 1.1 + i
Failed, modules loaded: none.
Prelude>
whereas with -fno-monomorphism-restriction set on
the command line gives the expected result:
Prelude> Compiling Main (
/home/gunter/haskell/TestMonomorphism.hs, interpreted )
Ok, modules loaded: Main.
Main> fmap (filter (==
"-fno-monomorphism-restriction")) System.getArgs >>= print
["-fno-monomorphism-restriction"]
Main> x
2.1
Main> y
2
It would be better to make
-fno-monomorphism-restriction dynamic but at least
the documentation should be fixed.
thanks,
mike
Trac metadata
| Trac field | Value |
|---|---|
| Version | 5.02 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | ResolvedFixed |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |