Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
626cf6b6
Commit
626cf6b6
authored
Dec 13, 2011
by
Simon Peyton Jones
Browse files
Document typechecking of pattern bindings
parent
0f34f308
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/typecheck/TcBinds.lhs
View file @
626cf6b6
...
...
@@ -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
...
...
compiler/typecheck/TcHsType.lhs
View file @
626cf6b6
...
...
@@ -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 {
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment