Commit 3e0909fc authored by simonpj's avatar simonpj
Browse files

[project @ 2002-11-18 14:35:57 by simonpj]

A TH fix; and implicit-parameter documentation
parent 4e84be0c
......@@ -1555,7 +1555,7 @@ implicitly parameterized by a comparison function named <literal>cmp</literal>.
The dynamic binding constraints are just a new form of predicate in the type class system.
An implicit parameter occurs in an exprssion using the special form <literal>?x</literal>,
An implicit parameter occurs in an expression using the special form <literal>?x</literal>,
where <literal>x</literal> is
any valid identifier (e.g. <literal>ord ?x</literal> is a valid expression).
Use of this construct also introduces a new
......@@ -1608,6 +1608,19 @@ Reason: exactly which implicit parameter you pick up depends on exactly where
you invoke a function. But the ``invocation'' of instance declarations is done
behind the scenes by the compiler, so it's hard to figure out exactly where it is done.
Easiest thing is to outlaw the offending types.</para>
Implicit-parameter constraints do not cause ambiguity. For example, consider:
f :: (?x :: [a]) => Int -> Int
f n = n + length ?x
g :: (Read a, Show a) => String -> String
g s = show (read s)
Here, <literal>g</literal> has an ambiguous type, and is rejected, but <literal>f</literal>
is fine. The binding for <literal>?x</literal> at <literal>f</literal>'s call site is
quite unambiguous, and fixes the type <literal>a</literal>.
......@@ -3271,12 +3284,6 @@ Tim Sheard is going to expand it.)
If the module contains any top-level splices that must be run, you must use GHC with
<literal>--make</literal> or <literal>--interactive</literal> flags. (Reason: that
means it walks the dependency tree and knows what modules must be linked etc.)
You can only run a function at compile time if it is imported from another module. That is,
you can't define a function in a module, and call it from within a splice in the same module.
......@@ -3288,6 +3295,10 @@ Tim Sheard is going to expand it.)
<para> Template Haskell works in any mode (<literal>--make</literal>, <literal>--interactive</literal>,
or file-at-a-time). There used to be a restriction to the former two, but that restriction
has been lifted.
Supports Markdown
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