Make the type-defaulting in GHCi use () as the first default type
authorsimonpj@microsoft.com <unknown>
Thu, 15 Mar 2007 14:28:12 +0000 (14:28 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 15 Mar 2007 14:28:12 +0000 (14:28 +0000)
commitd4b95ea994e850f2c85e418b5625874fd25b0ebf
treeeaf9061922613e4942bba568e170c0f47b79984b
parentcbb81129fe303877062079d26505e8cbe0f2a7c9
Make the type-defaulting in GHCi use () as the first default type

See Trac #1200

This is a somewhat experimental fix.  I'm not sure we want it in 6.6.1

The idea is explained in Note [Default unitTy] in TcSimplify.  In
interative mode (or with -fextended-default-rules) we add () as the
first type we try when defaulting.  This has very little real impact,
except in the following case.  Consider:
Text.Printf.printf "hello"
This has type (forall a. IO a); it prints "hello", and returns
'undefined'.  We don't want the GHCi repl loop to try to print that
'undefined'.  The neatest thing is to default the 'a' to (), rather
than to Integer (which is what would otherwise happen; and then GHCi
doesn't attempt to print the ().  So in interactive mode, we add () to
the list of defaulting types.
compiler/typecheck/TcDefaults.lhs
compiler/typecheck/TcRnMonad.lhs
compiler/typecheck/TcSimplify.lhs