-data InPat name
- = WildPatIn -- wild card
- | VarPatIn name -- variable
- | LitPatIn HsLit -- literal
- | LazyPatIn (InPat name) -- lazy pattern
- | AsPatIn name -- as pattern
- (InPat name)
- | SigPatIn (InPat name)
- (HsType name)
- | ConPatIn name -- constructed type
- [InPat name]
- | ConOpPatIn (InPat name)
- name
- Fixity -- c.f. OpApp in HsExpr
- (InPat name)
-
- | NPatIn HsOverLit
-
- | NPlusKPatIn name -- n+k pattern
- HsOverLit -- It'll always be an HsIntegral
- Name -- Name of '-' (see RnEnv.lookupSyntaxName)
-
- -- We preserve prefix negation and parenthesis for the precedence parser.
-
- | ParPatIn (InPat name) -- parenthesised pattern
-
- | ListPatIn [InPat name] -- syntactic list
- -- must have >= 1 elements
- | PArrPatIn [InPat name] -- syntactic parallel array
- -- must have >= 1 elements
- | TuplePatIn [InPat name] Boxity -- tuple (boxed?)
-
- | RecPatIn name -- record
- [(name, InPat name, Bool)] -- True <=> source used punning
-
--- Generics
- | TypePatIn (HsType name) -- Type pattern for generic definitions
+type InPat id = LPat id -- No 'Out' constructors
+type OutPat id = LPat id -- No 'In' constructors
+
+type LPat id = Located (Pat id)
+
+data Pat id
+ = ------------ Simple patterns ---------------
+ WildPat PostTcType -- Wild card
+ | VarPat id -- Variable
+ | VarPatOut id (DictBinds id) -- Used only for overloaded Ids; the
+ -- bindings give its overloaded instances
+ | LazyPat (LPat id) -- Lazy pattern
+ | AsPat (Located id) (LPat id) -- As pattern
+ | ParPat (LPat id) -- Parenthesised pattern
+
+ ------------ Lists, tuples, arrays ---------------
+ | ListPat [LPat id] -- Syntactic list
+ PostTcType -- The type of the elements
+
+ | TuplePat [LPat id] -- Tuple
+ Boxity -- UnitPat is TuplePat []
+
+ | PArrPat [LPat id] -- Syntactic parallel array
+ PostTcType -- The type of the elements
+
+ ------------ Constructor patterns ---------------
+ | ConPatIn (Located id)
+ (HsConDetails id (LPat id))
+
+ | ConPatOut (Located DataCon)
+ [TyVar] -- Existentially bound type variables
+ [id] -- Ditto dictionaries
+ (DictBinds id) -- Bindings involving those dictionaries
+ (HsConDetails id (LPat id))
+ Type -- The type of the pattern
+
+ ------------ Literal and n+k patterns ---------------
+ | LitPat HsLit -- Used for *non-overloaded* literal patterns:
+ -- Int#, Char#, Int, Char, String, etc.
+
+ | NPat (HsOverLit id) -- *Always* positive
+ (Maybe (SyntaxExpr id)) -- Just (Name of 'negate') for negative
+ -- patterns, Nothing otherwise
+ (SyntaxExpr id) -- Equality checker, of type t->t->Bool
+ PostTcType -- Type of the pattern
+
+ | NPlusKPat (Located id) -- n+k pattern
+ (HsOverLit id) -- It'll always be an HsIntegral
+ (SyntaxExpr id) -- (>=) function, of type t->t->Bool
+ (SyntaxExpr id) -- Name of '-' (see RnEnv.lookupSyntaxName)
+
+ ------------ Generics ---------------
+ | TypePat (LHsType id) -- Type pattern for generic definitions