Commit aec9e75b authored by Simon Peyton Jones's avatar Simon Peyton Jones

Improve documentation of defaulting rules with OverloadedStrings

See #9206
parent cdc74311
......@@ -5253,21 +5253,30 @@ it explicitly (for example, to give an instance declaration for it), you can imp
from module <literal>GHC.Exts</literal>.
Haskell's defaulting mechanism is extended to cover string literals, when <option>-XOverloadedStrings</option> is specified.
Haskell's defaulting mechanism (<ulink url="">Haskell Report, Section 4.3.4</ulink>)
is extended to cover string literals, when <option>-XOverloadedStrings</option> is specified.
Each type in a default declaration must be an
Each type in a <literal>default</literal> declaration must be an
instance of <literal>Num</literal> <emphasis>or</emphasis> of <literal>IsString</literal>.
The standard defaulting rule (<ulink url="">Haskell Report, Section 4.3.4</ulink>)
If no <literal>default</literal> declaration is given, then it is just as if the module
contained the declaration <literal>default( Integer, Double, String)</literal>.
The standard defaulting rule
is extended thus: defaulting applies when all the unresolved constraints involve standard classes
<emphasis>or</emphasis> <literal>IsString</literal>; and at least one is a numeric class
<emphasis>or</emphasis> <literal>IsString</literal>.
So, for example, the expression <literal>length "foo"</literal> will give rise
to an ambiguous use of <literal>IsString a0</literal> which, becuase of the above
rules, will default to <literal>String</literal>.
A small example:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment