RE: overzealous defaulting?

There's some documentation on this in the User's Guide: http://www.haskell.org/ghc/docs/latest/html/users_guide/x1075.html#GHCI- DEFAULTING Cheers, Simon On 23 August 2004 17:15, Simon Peyton-Jones wrote:
The binding let t = printQ falls under the monomorphism restriction. The Haskell Report would not default (Show a), so you might think you'd get an "ambiguous type variable" error. But it's so annoying to get this error for ghci> show [] that GHCi is a bit more eager about defaulting ambiguous types: it'll apply defaulting if all the constrained classes are standard, and at least one of them is numeric *or* is Show, Eq or Ord. The *or* part is the non-standard bit.
Admittedly, I'm not sure this is documented.
Simon
-----Original Message----- From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- bounces@haskell.org] On Behalf Of Abraham Egnor Sent: 23 August 2004 16:02 To: glasgow-haskell-users@haskell.org Subject: overzealous defaulting?
I'm not sure if this is an actual bug, as opposed to an odd instance of defaulting:
*GUI.Parser> let printQ q = runQ q >>= print *GUI.Parser> :t printQ printQ :: forall a. (Show a) => Q a -> IO () *GUI.Parser> let p = printQ *GUI.Parser> :t p p :: Q Integer -> IO ()
...but I'm not sure when that would ever be the correct behavior.
Abe _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

This reminds me of something I have not quite figured out what should happen from the report module A where import B a = 32 + b default (Integer) module B where import A b = 32 + a default (Int) so, what types do 'a' and 'b' get? ghc sort of sidesteps the issues with the hi-boot files, so they will get whatever is declared in those, but what is the correct thing that should happen in a fully recursive module supporting haskell compiler? John -- John Meacham - ⑆repetae.net⑆john⑈

John Meacham
module A where import B a = 32 + b default (Integer)
module B where import A b = 32 + a default (Int)
so, what types do 'a' and 'b' get? ghc sort of sidesteps the issues with the hi-boot files, so they will get whatever is declared in those, but what is the correct thing that should happen in a fully recursive module supporting haskell compiler?
My guess is that technically the program is ambiguous: both a and b could be either Int or Integer, and in the absence of .hi-boot file there is not enough information available to the compiler to choose one over the other. Ideally, the ambiguity should be reported as an error to be fixed by the user. It isn't so terribly different from the (show . read) ambiguity, in that it can easily be resolved by adding a type signature. Regards, Malcolm
participants (3)
-
John Meacham
-
Malcolm Wallace
-
Simon Marlow