Commit 52b02e66 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Comments only (isIrrefutablePat)

parent 741f837d
......@@ -540,8 +540,12 @@ isIrrefutableHsPat :: OutputableBndr id => LPat id -> Bool
-- (NB: this is not quite the same as the (silly) defn
-- in 3.17.2 of the Haskell 98 report.)
-- isIrrefutableHsPat returns False if it's in doubt; specifically
-- on a ConPatIn it doesn't know the size of the constructor family
-- WARNING: isIrrefutableHsPat returns False if it's in doubt.
-- Specifically on a ConPatIn, which is what it sees for a
-- (LPat Name) in the renamer, it doesn't know the size of the
-- constructor family, so it returns False. Result: only
-- tuple patterns are considered irrefuable at the renamer stage.
-- But if it returns True, the pattern is definitely irrefutable
isIrrefutableHsPat pat
= go pat
......@@ -1437,6 +1437,11 @@ ado _ctxt [] tail _ = return (tail, emptyNameSet)
-- the bind form, which would give rise to a Monad constraint.
ado ctxt [(L _ (BindStmt pat rhs _ _),_)] tail _
| isIrrefutableHsPat pat, (False,tail') <- needJoin tail
-- WARNING: isIrrefutableHsPat on (HsPat Name) doesn't have enough info
-- to know which types have only one constructor. So only
-- tuples come out as irrefutable; other single-constructor
-- types, and newtypes, will not. See the code for
-- isIrrefuatableHsPat
= mkApplicativeStmt ctxt [ApplicativeArgOne pat rhs] False tail'
ado _ctxt [(one,_)] tail _ = return (one:tail, emptyNameSet)
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