
Am Mittwoch, 22. Oktober 2008 23:44 schrieb Antoine Latter:
On Wed, Oct 22, 2008 at 4:10 PM, Jason Dusek
wrote: Can you explain why you think you need that annotation? I can't see an ambiguous interpretation of your code.
The confusion is that the 'Val' constructor is for the 'Expr' type, which has a phantom type parameter in its type constructor.
Can you load that up into GHCi and type:
:t val_9
which should cause GHCi to print out what it thinks the type of that expression is.
-Antoine
ghci correctly thinks that has the type Expr e. Much like *Main> :t [] [] :: [a] I think what goes on here is defaulting (deviating from Section 4.3.4 of the report, but it's the same deviation that allows [] to be printed). To print it, ghci picks some default type for e, probably Integer, as the defaut default is (Integer, Double), doesn't influence the result of show. If you muck around with the Show instance, you can easily get compilation errors like "Ambiguous type variable..." (e.g. if you add a (Show e) constraint to the Show instance for (Expr e), but not if you add a (Num e) or an (Integral e) constraint).