Commit 626cf6b6 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Document typechecking of pattern bindings

parent 0f34f308
......@@ -793,6 +793,28 @@ for a non-overloaded function.
@tcMonoBinds@ deals with a perhaps-recursive group of HsBinds.
The signatures have been dealt with already.
Note [Pattern bindings]
~~~~~~~~~~~~~~~~~~~~~~~
The rule for typing pattern bindings is this:
..sigs..
p = e
where 'p' binds v1..vn, and 'e' may mention v1..vn,
typechecks exactly like
..sigs..
x = e -- Inferred type
v1 = case x of p -> v1
..
vn = case x of p -> vn
Note that
(f :: forall a. a -> a) = id
should not typecheck because
case id of { (f :: forall a. a->a) -> f }
will not typecheck.
\begin{code}
tcMonoBinds :: TcSigFun -> LetBndrSpec
-> RecFlag -- Whether the binding is recursive for typechecking purposes
......
......@@ -1113,8 +1113,7 @@ tcPatSig ctxt sig res_ty
-- that should be brought into scope
; if null sig_tvs then do {
-- The type signature binds no type variables,
-- and hence is rigid, so use it to zap the res_ty
-- Just do the subsumption check and return
wrap <- tcSubType PatSigOrigin ctxt res_ty sig_ty
; return (sig_ty, [], wrap)
} else do {
......
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