ghc-8.4.4: The GHC API

Safe HaskellNone
LanguageHaskell2010

HsPat

Synopsis

Documentation

data Pat p Source #

Constructors

WildPat (PostTc p Type)

Wildcard Pattern The sole reason for a type on a WildPat is to support hsPatType :: Pat Id -> Type

VarPat (Located (IdP p))

Variable Pattern

LazyPat (LPat p)

Lazy Pattern ^ - AnnKeywordId : AnnTilde

AsPat (Located (IdP p)) (LPat p)

As pattern ^ - AnnKeywordId : AnnAt

ParPat (LPat p)

Parenthesised pattern See Note [Parens in HsSyn] in HsExpr ^ - AnnKeywordId : AnnOpen '(', AnnClose ')'

BangPat (LPat p)

Bang pattern ^ - AnnKeywordId : AnnBang

ListPat [LPat p] (PostTc p Type) (Maybe (PostTc p Type, SyntaxExpr p))

Syntactic List

TuplePat [LPat p] Boxity [PostTc p Type]

Tuple sub-patterns

SumPat (LPat p) ConTag Arity (PostTc p [Type])

Anonymous sum pattern

PArrPat [LPat p] (PostTc p Type)
ConPatIn (Located (IdP p)) (HsConPatDetails p)

Constructor Pattern In

ConPatOut

Constructor Pattern Out

ViewPat (LHsExpr p) (LPat p) (PostTc p Type)

View Pattern

SplicePat (HsSplice p)

Splice Pattern (Includes quasi-quotes)

LitPat (HsLit p)

Literal Pattern Used for *non-overloaded* literal patterns: Int, Int, Char, String, etc.

NPat (Located (HsOverLit p)) (Maybe (SyntaxExpr p)) (SyntaxExpr p) (PostTc p Type)

Natural Pattern

NPlusKPat (Located (IdP p)) (Located (HsOverLit p)) (HsOverLit p) (SyntaxExpr p) (SyntaxExpr p) (PostTc p Type)

n+k pattern

SigPatIn (LPat p) (LHsSigWcType p)

Pattern with a type signature

SigPatOut (LPat p) Type

Pattern with a type signature

CoPat HsWrapper (Pat p) Type

Coercion Pattern

Instances
DataId p => Data (Pat p) Source # 
Instance details

Defined in HsPat

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Pat p -> c (Pat p) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Pat p) #

toConstr :: Pat p -> Constr #

dataTypeOf :: Pat p -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Pat p)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pat p)) #

gmapT :: (forall b. Data b => b -> b) -> Pat p -> Pat p #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pat p -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pat p -> r #

gmapQ :: (forall d. Data d => d -> u) -> Pat p -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Pat p -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Pat p -> m (Pat p) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Pat p -> m (Pat p) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Pat p -> m (Pat p) #

(SourceTextX pass, OutputableBndrId pass) => Outputable (Pat pass) Source # 
Instance details

Defined in HsPat

Methods

ppr :: Pat pass -> SDoc Source #

pprPrec :: Rational -> Pat pass -> SDoc Source #

type InPat p = LPat p Source #

type OutPat p = LPat p Source #

type LPat p = Located (Pat p) Source #

type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) Source #

Haskell Constructor Pattern Details

data HsRecFields p arg Source #

Haskell Record Fields

HsRecFields is used only for patterns and expressions (not data type declarations)

Constructors

HsRecFields 

Fields

Instances
Functor (HsRecFields p) Source # 
Instance details

Defined in HsPat

Methods

fmap :: (a -> b) -> HsRecFields p a -> HsRecFields p b #

(<$) :: a -> HsRecFields p b -> HsRecFields p a #

Foldable (HsRecFields p) Source # 
Instance details

Defined in HsPat

Methods

fold :: Monoid m => HsRecFields p m -> m #

foldMap :: Monoid m => (a -> m) -> HsRecFields p a -> m #

foldr :: (a -> b -> b) -> b -> HsRecFields p a -> b #

foldr' :: (a -> b -> b) -> b -> HsRecFields p a -> b #

foldl :: (b -> a -> b) -> b -> HsRecFields p a -> b #

foldl' :: (b -> a -> b) -> b -> HsRecFields p a -> b #

foldr1 :: (a -> a -> a) -> HsRecFields p a -> a #

foldl1 :: (a -> a -> a) -> HsRecFields p a -> a #

toList :: HsRecFields p a -> [a] #

null :: HsRecFields p a -> Bool #

length :: HsRecFields p a -> Int #

elem :: Eq a => a -> HsRecFields p a -> Bool #

maximum :: Ord a => HsRecFields p a -> a #

minimum :: Ord a => HsRecFields p a -> a #

sum :: Num a => HsRecFields p a -> a #

product :: Num a => HsRecFields p a -> a #

Traversable (HsRecFields p) Source # 
Instance details

Defined in HsPat

Methods

traverse :: Applicative f => (a -> f b) -> HsRecFields p a -> f (HsRecFields p b) #

sequenceA :: Applicative f => HsRecFields p (f a) -> f (HsRecFields p a) #

mapM :: Monad m => (a -> m b) -> HsRecFields p a -> m (HsRecFields p b) #

sequence :: Monad m => HsRecFields p (m a) -> m (HsRecFields p a) #

(DataId p, Data arg) => Data (HsRecFields p arg) Source # 
Instance details

Defined in HsPat

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsRecFields p arg -> c (HsRecFields p arg) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsRecFields p arg) #

toConstr :: HsRecFields p arg -> Constr #

dataTypeOf :: HsRecFields p arg -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsRecFields p arg)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsRecFields p arg)) #

gmapT :: (forall b. Data b => b -> b) -> HsRecFields p arg -> HsRecFields p arg #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsRecFields p arg -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsRecFields p arg -> r #

gmapQ :: (forall d. Data d => d -> u) -> HsRecFields p arg -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> HsRecFields p arg -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsRecFields p arg -> m (HsRecFields p arg) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsRecFields p arg -> m (HsRecFields p arg) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsRecFields p arg -> m (HsRecFields p arg) #

Outputable arg => Outputable (HsRecFields p arg) Source # 
Instance details

Defined in HsPat

Methods

ppr :: HsRecFields p arg -> SDoc Source #

pprPrec :: Rational -> HsRecFields p arg -> SDoc Source #

data HsRecField' id arg Source #

Haskell Record Field

For details on above see note [Api annotations] in ApiAnnotation

Constructors

HsRecField 

Fields

Instances
Functor (HsRecField' id) Source # 
Instance details

Defined in HsPat

Methods

fmap :: (a -> b) -> HsRecField' id a -> HsRecField' id b #

(<$) :: a -> HsRecField' id b -> HsRecField' id a #

Foldable (HsRecField' id) Source # 
Instance details

Defined in HsPat

Methods

fold :: Monoid m => HsRecField' id m -> m #

foldMap :: Monoid m => (a -> m) -> HsRecField' id a -> m #

foldr :: (a -> b -> b) -> b -> HsRecField' id a -> b #

foldr' :: (a -> b -> b) -> b -> HsRecField' id a -> b #

foldl :: (b -> a -> b) -> b -> HsRecField' id a -> b #

foldl' :: (b -> a -> b) -> b -> HsRecField' id a -> b #

foldr1 :: (a -> a -> a) -> HsRecField' id a -> a #

foldl1 :: (a -> a -> a) -> HsRecField' id a -> a #

toList :: HsRecField' id a -> [a] #

null :: HsRecField' id a -> Bool #

length :: HsRecField' id a -> Int #

elem :: Eq a => a -> HsRecField' id a -> Bool #

maximum :: Ord a => HsRecField' id a -> a #

minimum :: Ord a => HsRecField' id a -> a #

sum :: Num a => HsRecField' id a -> a #

product :: Num a => HsRecField' id a -> a #

Traversable (HsRecField' id) Source # 
Instance details

Defined in HsPat

Methods

traverse :: Applicative f => (a -> f b) -> HsRecField' id a -> f (HsRecField' id b) #

sequenceA :: Applicative f => HsRecField' id (f a) -> f (HsRecField' id a) #

mapM :: Monad m => (a -> m b) -> HsRecField' id a -> m (HsRecField' id b) #

sequence :: Monad m => HsRecField' id (m a) -> m (HsRecField' id a) #

(Data id, Data arg) => Data (HsRecField' id arg) Source # 
Instance details

Defined in HsPat

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsRecField' id arg -> c (HsRecField' id arg) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsRecField' id arg) #

toConstr :: HsRecField' id arg -> Constr #

dataTypeOf :: HsRecField' id arg -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsRecField' id arg)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsRecField' id arg)) #

gmapT :: (forall b. Data b => b -> b) -> HsRecField' id arg -> HsRecField' id arg #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsRecField' id arg -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsRecField' id arg -> r #

gmapQ :: (forall d. Data d => d -> u) -> HsRecField' id arg -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> HsRecField' id arg -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsRecField' id arg -> m (HsRecField' id arg) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsRecField' id arg -> m (HsRecField' id arg) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsRecField' id arg -> m (HsRecField' id arg) #

(Outputable p, Outputable arg) => Outputable (HsRecField' p arg) Source # 
Instance details

Defined in HsPat

Methods

ppr :: HsRecField' p arg -> SDoc Source #

pprPrec :: Rational -> HsRecField' p arg -> SDoc Source #

type LHsRecField' p arg = Located (HsRecField' p arg) Source #

Located Haskell Record Field

type HsRecField p arg = HsRecField' (FieldOcc p) arg Source #

Haskell Record Field

type LHsRecField p arg = Located (HsRecField p arg) Source #

Located Haskell Record Field

type HsRecUpdField p = HsRecField' (AmbiguousFieldOcc p) (LHsExpr p) Source #

Haskell Record Update Field

type LHsRecUpdField p = Located (HsRecUpdField p) Source #

Located Haskell Record Update Field

hsRecFieldSel :: HsRecField pass arg -> Located (PostRn pass (IdP pass)) Source #

hsPatNeedsParens :: Pat a -> Bool Source #

Returns True if a pattern must be parenthesized in order to parse (e.g., the (x :: Int) in f (x :: Int) = x).

isCompoundPat :: Pat a -> Bool Source #

Returns True for compound patterns that need parentheses when used in an argument position.

Note that this is different from hsPatNeedsParens, which only says if a pattern needs to be parenthesized to parse in any position, whereas isCompountPat says if a pattern needs to be parenthesized in an argument position. In other words, hsPatNeedsParens x implies isCompoundPat x, but not necessarily the other way around.

parenthesizeCompoundPat :: LPat p -> LPat p Source #

parenthesizeCompoundPat p checks if isCompoundPat p is true, and if so, surrounds p with a ParPat. Otherwise, it simply returns p.