[Haskell] Re: Implicit type of numeric constants
Robert Stroud
R.J.Stroud at ncl.ac.uk
Thu Sep 21 10:34:51 EDT 2006
On 20 Sep 2006, at 22:21, Ashley Yakeley wrote:
> Arie Peterson wrote:
>
>> You absolutely right about this defaulting breaking referential
>> transparency.
>
> Do you know if it can be switched off in GHC? I know one can switch
> on warnings when it happens, but I don't think that's the same thing.
You can use an empty default declaration to switch off default types
for a particular module, but I don't think you can do this for all
modules, or at least not in standard Haskell - section 4.3.4 of the
language manual says:
"Only one default declaration is permitted per module, and its effect
is limited to that module. If no default declaration is given in a
module then it assumed to be:
default (Integer, Double)
The empty default declaration, default (), turns off all defaults in
a module."
Switching off default types may introduce error messages about top-
level declarations with unbound type variables - for example
Ambiguous type variable `t' in the constraint:
`Num t' arising from the literal `2' at /tmp/test.hs:3:4
Possible cause: the monomorphism restriction applied to the
following:
k :: t (bound at /tmp/test.hs:3:0)
Probable fix: give these definition(s) an explicit type signature
or use -fno-monomorphism-restriction
Turning off the monomorphism restriction makes the errors go away,
but adding an explicit polymorphic type signature is probably better.
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell/attachments/20060921/653bea45/attachment.htm
More information about the Haskell
mailing list