-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
+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