{-# LANGUAGE DeriveFunctor #-}
{-# OPTIONS_HADDOCK hide #-}
module Language.Haskell.Exts.ParseSyntax where
import Language.Haskell.Exts.Syntax hiding ( Type(..), Asst(..), Exp(..), FieldUpdate(..), XAttr(..), Context(..) )
import qualified Language.Haskell.Exts.Syntax as S ( Type(..), Promoted(..) )
data PExp l
= Var l (QName l)
| OverloadedLabel l String
| IPVar l (IPName l)
| Con l (QName l)
| Lit l (Literal l)
| InfixApp l (PExp l) (QOp l) (PExp l)
| App l (PExp l) (PExp l)
| NegApp l (PExp l)
| Lambda l [Pat l] (PExp l)
| Let l (Binds l) (PExp l)
| If l (PExp l) (PExp l) (PExp l)
| MultiIf l [GuardedRhs l]
| Case l (PExp l) [Alt l]
| Do l [Stmt l]
| MDo l [Stmt l]
| TupleSection l Boxed [Maybe (PExp l)]
| UnboxedSum l Int Int (PExp l)
| List l [PExp l]
| ParArray l [PExp l]
| Paren l (PExp l)
| RecConstr l (QName l) [PFieldUpdate l]
| RecUpdate l (PExp l) [PFieldUpdate l]
| EnumFrom l (PExp l)
| EnumFromTo l (PExp l) (PExp l)
| EnumFromThen l (PExp l) (PExp l)
| EnumFromThenTo l (PExp l) (PExp l) (PExp l)
| ParArrayFromTo l (PExp l) (PExp l)
| ParArrayFromThenTo l (PExp l) (PExp l) (PExp l)
| ParComp l (PExp l) [[QualStmt l]]
| ParArrayComp l (PExp l) [[QualStmt l]]
| ExpTypeSig l (PExp l) (S.Type l)
| AsPat l (Name l) (PExp l)
| WildCard l
| IrrPat l (PExp l)
| PostOp l (PExp l) (QOp l)
| PreOp l (QOp l) (PExp l)
| ViewPat l (PExp l) (Pat l)
| SeqRP l [PExp l]
| GuardRP l (PExp l) [Stmt l]
| EitherRP l (PExp l) (PExp l)
| CAsRP l (Name l) (PExp l)
| VarQuote l (QName l)
| TypQuote l (QName l)
| BracketExp l (Bracket l)
| SpliceExp l (Splice l)
| QuasiQuote l String String
| XTag l (XName l) [ParseXAttr l] (Maybe (PExp l)) [PExp l]
| XETag l (XName l) [ParseXAttr l] (Maybe (PExp l))
| XPcdata l String
| XExpTag l (PExp l)
| XChildTag l [PExp l]
| XRPats l [PExp l]
| CorePragma l String (PExp l)
| SCCPragma l String (PExp l)
| GenPragma l String (Int, Int) (Int, Int) (PExp l)
| BangPat l (PExp l)
| Proc l (Pat l) (PExp l)
| LeftArrApp l (PExp l) (PExp l)
| RightArrApp l (PExp l) (PExp l)
| LeftArrHighApp l (PExp l) (PExp l)
| RightArrHighApp l (PExp l) (PExp l)
| LCase l [Alt l]
| TypeApp l (S.Type l)
deriving (Eq,Show,Functor)
data PFieldUpdate l
= FieldUpdate l (QName l) (PExp l)
| FieldPun l (QName l)
| FieldWildcard l
deriving (Eq,Show,Functor)
data ParseXAttr l = XAttr l (XName l) (PExp l)
deriving (Eq,Show,Functor)
instance Annotated PExp where
ann e = case e of
Var l _ -> l
OverloadedLabel l _ -> l
IPVar l _ -> l
Con l _ -> l
Lit l _ -> l
InfixApp l _ _ _ -> l
App l _ _ -> l
NegApp l _ -> l
Lambda l _ _ -> l
Let l _ _ -> l
If l _ _ _ -> l
Case l _ _ -> l
Do l _ -> l
MDo l _ -> l
TupleSection l _ _ -> l
UnboxedSum l _ _ _ -> l
List l _ -> l
ParArray l _ -> l
Paren l _ -> l
RecConstr l _ _ -> l
RecUpdate l _ _ -> l
EnumFrom l _ -> l
EnumFromTo l _ _ -> l
EnumFromThen l _ _ -> l
EnumFromThenTo l _ _ _ -> l
ParArrayFromTo l _ _ -> l
ParArrayFromThenTo l _ _ _ -> l
ParComp l _ _ -> l
ParArrayComp l _ _ -> l
ExpTypeSig l _ _ -> l
AsPat l _ _ -> l
WildCard l -> l
IrrPat l _ -> l
PostOp l _ _ -> l
PreOp l _ _ -> l
ViewPat l _ _ -> l
SeqRP l _ -> l
GuardRP l _ _ -> l
EitherRP l _ _ -> l
CAsRP l _ _ -> l
VarQuote l _ -> l
TypQuote l _ -> l
BracketExp l _ -> l
SpliceExp l _ -> l
QuasiQuote l _ _ -> l
XTag l _ _ _ _ -> l
XETag l _ _ _ -> l
XPcdata l _ -> l
XExpTag l _ -> l
XChildTag l _ -> l
XRPats l _ -> l
CorePragma l _ _ -> l
SCCPragma l _ _ -> l
GenPragma l _ _ _ _ -> l
BangPat l _ -> l
Proc l _ _ -> l
LeftArrApp l _ _ -> l
RightArrApp l _ _ -> l
LeftArrHighApp l _ _ -> l
RightArrHighApp l _ _ -> l
LCase l _ -> l
MultiIf l _ -> l
TypeApp l _ -> l
amap f e' = case e' of
Var l qn -> Var (f l) qn
OverloadedLabel l qn -> OverloadedLabel (f l) qn
IPVar l ipn -> IPVar (f l) ipn
Con l qn -> Con (f l) qn
Lit l lit -> Lit (f l) lit
InfixApp l e1 qop e2 -> InfixApp (f l) e1 qop e2
App l e1 e2 -> App (f l) e1 e2
NegApp l e -> NegApp (f l) e
Lambda l ps e -> Lambda (f l) ps e
Let l bs e -> Let (f l) bs e
If l ec et ee -> If (f l) ec et ee
Case l e alts -> Case (f l) e alts
Do l ss -> Do (f l) ss
MDo l ss -> MDo (f l) ss
TupleSection l bx mes -> TupleSection (f l) bx mes
UnboxedSum l b a e -> UnboxedSum (f l) b a e
List l es -> List (f l) es
ParArray l es -> ParArray (f l) es
Paren l e -> Paren (f l) e
RecConstr l qn fups -> RecConstr (f l) qn fups
RecUpdate l e fups -> RecUpdate (f l) e fups
EnumFrom l e -> EnumFrom (f l) e
EnumFromTo l ef et -> EnumFromTo (f l) ef et
EnumFromThen l ef et -> EnumFromThen (f l) ef et
EnumFromThenTo l ef eth eto -> EnumFromThenTo (f l) ef eth eto
ParArrayFromTo l ef et -> ParArrayFromTo (f l) ef et
ParArrayFromThenTo l ef eth eto -> ParArrayFromThenTo (f l) ef eth eto
ParComp l e qsss -> ParComp (f l) e qsss
ParArrayComp l e qsss -> ParArrayComp (f l) e qsss
ExpTypeSig l e t -> ExpTypeSig (f l) e t
AsPat l n e -> AsPat (f l) n e
WildCard l -> WildCard (f l)
IrrPat l e -> IrrPat (f l) e
PostOp l e op -> PostOp (f l) e op
PreOp l op e -> PreOp (f l) op e
ViewPat l e1 e2 -> ViewPat (f l) e1 e2
SeqRP l es -> SeqRP (f l) es
GuardRP l e ss -> GuardRP (f l) e ss
EitherRP l e1 e2 -> EitherRP (f l) e1 e2
CAsRP l n e -> CAsRP (f l) n e
BangPat l e -> BangPat (f l) e
VarQuote l qn -> VarQuote (f l) qn
TypQuote l qn -> TypQuote (f l) qn
BracketExp l br -> BracketExp (f l) br
SpliceExp l sp -> SpliceExp (f l) sp
QuasiQuote l sn se -> QuasiQuote (f l) sn se
XTag l xn xas me es -> XTag (f l) xn xas me es
XETag l xn xas me -> XETag (f l) xn xas me
XPcdata l s -> XPcdata (f l) s
XExpTag l e -> XExpTag (f l) e
XChildTag l es -> XChildTag (f l) es
XRPats l es -> XRPats (f l) es
CorePragma l s e -> CorePragma (f l) s e
SCCPragma l s e -> SCCPragma (f l) s e
GenPragma l s n12 n34 e -> GenPragma (f l) s n12 n34 e
Proc l p e -> Proc (f l) p e
LeftArrApp l e1 e2 -> LeftArrApp (f l) e1 e2
RightArrApp l e1 e2 -> RightArrApp (f l) e1 e2
LeftArrHighApp l e1 e2 -> LeftArrHighApp (f l) e1 e2
RightArrHighApp l e1 e2 -> RightArrHighApp (f l) e1 e2
LCase l alts -> LCase (f l) alts
MultiIf l alts -> MultiIf (f l) alts
TypeApp l ty -> TypeApp (f l) ty
instance Annotated PFieldUpdate where
ann (FieldUpdate l _ _) = l
ann (FieldPun l _) = l
ann (FieldWildcard l) = l
amap f (FieldUpdate l qn e) = FieldUpdate (f l) qn e
amap f (FieldPun l n) = FieldPun (f l) n
amap f (FieldWildcard l) = FieldWildcard (f l)
instance Annotated ParseXAttr where
ann (XAttr l _ _) = l
amap f (XAttr l xn e) = XAttr (f l) xn e
p_unit_con :: l -> PExp l
p_unit_con l = Con l (unit_con_name l)
p_tuple_con :: l -> Boxed -> Int -> PExp l
p_tuple_con l b i = Con l (tuple_con_name l b i)
p_unboxed_singleton_con :: l -> PExp l
p_unboxed_singleton_con l = Con l (unboxed_singleton_con_name l)
data PContext l
= CxSingle l (PAsst l)
| CxTuple l [PAsst l]
| CxEmpty l
deriving (Eq, Show, Functor)
instance Annotated PContext where
ann (CxSingle l _ ) = l
ann (CxTuple l _) = l
ann (CxEmpty l) = l
amap f (CxSingle l asst ) = CxSingle (f l) asst
amap f (CxTuple l assts) = CxTuple (f l) assts
amap f (CxEmpty l) = CxEmpty (f l)
data PType l
= TyForall l
(Maybe [TyVarBind l])
(Maybe (PContext l))
(PType l)
| TyStar l
| TyFun l (PType l) (PType l)
| TyTuple l Boxed [PType l]
| TyUnboxedSum l [PType l]
| TyList l (PType l)
| TyParArray l (PType l)
| TyApp l (PType l) (PType l)
| TyVar l (Name l)
| TyCon l (QName l)
| TyParen l (PType l)
| TyPred l (PAsst l)
| TyInfix l (PType l) (MaybePromotedName l) (PType l)
| TyKind l (PType l) (Kind l)
| TyPromoted l (S.Promoted l)
| TyEquals l (PType l) (PType l)
| TySplice l (Splice l)
| TyBang l (BangType l) (Unpackedness l) (PType l)
| TyWildCard l (Maybe (Name l))
| TyQuasiQuote l String String
deriving (Eq, Show, Functor)
instance Annotated PType where
ann t = case t of
TyForall l _ _ _ -> l
TyStar l -> l
TyFun l _ _ -> l
TyTuple l _ _ -> l
TyUnboxedSum l _ -> l
TyList l _ -> l
TyParArray l _ -> l
TyApp l _ _ -> l
TyVar l _ -> l
TyCon l _ -> l
TyParen l _ -> l
TyInfix l _ _ _ -> l
TyKind l _ _ -> l
TyPromoted l _ -> l
TyEquals l _ _ -> l
TyPred l _ -> l
TySplice l _ -> l
TyBang l _ _ _ -> l
TyWildCard l _ -> l
TyQuasiQuote l _ _ -> l
amap f t' = case t' of
TyForall l mtvs mcx t -> TyForall (f l) mtvs mcx t
TyStar l -> TyStar (f l)
TyFun l t1 t2 -> TyFun (f l) t1 t2
TyTuple l b ts -> TyTuple (f l) b ts
TyUnboxedSum l ts -> TyUnboxedSum (f l) ts
TyList l t -> TyList (f l) t
TyParArray l t -> TyParArray (f l) t
TyApp l t1 t2 -> TyApp (f l) t1 t2
TyVar l n -> TyVar (f l) n
TyCon l qn -> TyCon (f l) qn
TyParen l t -> TyParen (f l) t
TyInfix l ta qn tb -> TyInfix (f l) ta qn tb
TyKind l t k -> TyKind (f l) t k
TyPromoted l p -> TyPromoted (f l) p
TyEquals l t1 t2 -> TyEquals (f l) t1 t2
TyPred l asst -> TyPred (f l) asst
TySplice l s -> TySplice (f l) s
TyBang l b u t -> TyBang (f l) b u t
TyWildCard l mn -> TyWildCard (f l) mn
TyQuasiQuote l n s -> TyQuasiQuote (f l) n s
data PAsst l
= TypeA l (PType l)
| IParam l (IPName l) (PType l)
| ParenA l (PAsst l)
deriving (Eq, Show, Functor)
instance Annotated PAsst where
ann asst = case asst of
TypeA l _ -> l
IParam l _ _ -> l
ParenA l _ -> l
amap f asst = case asst of
TypeA l t -> TypeA (f l) t
IParam l ipn t -> IParam (f l) ipn t
ParenA l a -> ParenA (f l) a