import Var ( TyVar )
import Name ( getOccName, getSrcLoc )
import NameSet ( NameSet, mkNameSet, elemNameSet )
-import Class ( classBigSig )
+import Class ( classBigSig, classKey )
import FunDeps ( oclose, grow, improve, pprEquationDoc )
import PrelInfo ( isNumericClass, isCreturnableClass, isCcallishClass )
-import PrelNames ( splitName, fstName, sndName, showClassKey )
+import PrelNames ( splitName, fstName, sndName, showClassKey, eqClassKey, ordClassKey)
import HscTypes ( GhciMode(Interactive) )
import Subst ( mkTopTyVarSubst, substTheta, substTy )
std_default_class cls
= isNumericClass cls
- || (ghci_mode == Interactive && cls `hasKey` showClassKey)
+ || (ghci_mode == Interactive &&
+ classKey cls `elem` [showClassKey, eqClassKey, ordClassKey])
-- In interactive mode, we default Show a to Show ()
-- to avoid graututious errors on "show []"
However, it is tiresome for the user to have to specify the type, so GHCi extends Haskell's type-defaulting
rules (Section 4.3.4 of the Haskell 98 Report (Revised)) as follows. If the expression yields a set of
type constraints that are all from standard classes (<literal>Num</literal>, <literal>Eq</literal> etc.),
- and at least one is either a numeric class <emphasis>or the <literal>Show</literal> class</emphasis>,
+ and at least one is either a numeric class <emphasis>or the <literal>Show</literal>,
+ <literal>Eq</literal>, or <literal>Ord</literal> class</emphasis>,
GHCi will try to use one of the <literal>default</literal> types, just as described in the Report.
</para>
</sect2>