-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 name)
-
- | NPlusKPatIn name -- n+k pattern
- (HsOverLit name) -- It'll always be an HsIntegral, but
- -- we need those names to support -fuser-numerics
- name -- Name for "-"; this supports -fuser-numerics
- -- We don't do the same for >= because that isn't
- -- affected by -fuser-numerics
-
- -- We preserve prefix negation and parenthesis for the precedence parser.
-
- | ParPatIn (InPat name) -- parenthesised pattern
-
- | ListPatIn [InPat name] -- syntactic list
- -- 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 = Pat id -- No 'Out' constructors
+type OutPat id = Pat id -- No 'In' constructors
+
+data Pat id
+ = ------------ Simple patterns ---------------
+ WildPat PostTcType -- Wild card
+ | VarPat id -- Variable
+ | LazyPat (Pat id) -- Lazy pattern
+ | AsPat id (Pat id) -- As pattern
+ | ParPat (Pat id) -- Parenthesised pattern
+
+ ------------ Lists, tuples, arrays ---------------
+ | ListPat [Pat id] -- Syntactic list
+ PostTcType -- The type of the elements
+
+ | TuplePat [Pat id] -- Tuple
+ Boxity -- UnitPat is TuplePat []
+
+ | PArrPat [Pat id] -- Syntactic parallel array
+ PostTcType -- The type of the elements
+
+ ------------ Constructor patterns ---------------
+ | ConPatIn id
+ (HsConDetails id (Pat id))
+
+ | ConPatOut DataCon
+ (HsConDetails id (Pat id))
+ Type -- The type of the pattern
+ [TyVar] -- Existentially bound type variables
+ [id] -- Ditto dictionaries
+
+ ------------ Literal and n+k patterns ---------------
+ | LitPat HsLit -- Used for *non-overloaded* literal patterns:
+ -- Int#, Char#, Int, Char, String, etc.
+
+ | NPatIn HsOverLit -- Always positive
+ (Maybe SyntaxName) -- Just (Name of 'negate') for negative
+ -- patterns, Nothing otherwise
+
+ | NPatOut HsLit -- Used for literal patterns where there's an equality function to call
+ -- The literal is retained so that the desugarer can readily identify
+ -- equations with identical literal-patterns
+ -- Always HsInteger, HsRat or HsString.
+ -- Always HsInteger, HsRat or HsString.
+ -- *Unlike* NPatIn, for negative literals, the
+ -- literal is acutally negative!
+ Type -- Type of pattern, t
+ (HsExpr id) -- Of type t -> Bool; detects match
+
+ | NPlusKPatIn id -- n+k pattern
+ HsOverLit -- It'll always be an HsIntegral
+ SyntaxName -- Name of '-' (see RnEnv.lookupSyntaxName)
+
+ | NPlusKPatOut id
+ Integer
+ (HsExpr id) -- Of type t -> Bool; detects match
+ (HsExpr id) -- Of type t -> t; subtracts k
+
+
+ ------------ Generics ---------------
+ | TypePat (HsType id) -- Type pattern for generic definitions