ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Hs.Lit

Contents

- Orphan instances

Description

Source-language literals

Synopsis

- module Language.Haskell.Syntax.Lit
- data HsLitTc
  - = HsInteger SourceText Integer Type
  - | HsRat FractionalLit Type
- data OverLitRn = OverLitRn {
  - ol_rebindable :: Bool
  - ol_from_fun :: LIdP GhcRn
  }
- data OverLitTc = OverLitTc {
  - ol_rebindable :: Bool
  - ol_witness :: HsExpr GhcTc
  - ol_type :: Type
  }
- pprXOverLit :: forall (p :: Pass). GhcPass p -> XOverLit (GhcPass p) -> SDoc
- overLitType :: HsOverLit GhcTc -> Type
- hsOverLitNeedsParens :: PprPrec -> HsOverLit x -> Bool
- hsLitNeedsParens :: forall (x :: Pass). IsPass x => PprPrec -> HsLit (GhcPass x) -> Bool
- convertLit :: forall (p :: Pass) (p' :: Pass). XXLit (GhcPass p) ~ DataConCantHappen => HsLit (GhcPass p) -> HsLit (GhcPass p')
- pmPprHsLit :: forall (p :: Pass). IsPass p => HsLit (GhcPass p) -> SDoc
- negateOverLitVal :: OverLitVal -> OverLitVal

# Documentation

module Language.Haskell.Syntax.Lit

data HsLitTc #

Constructors

HsInteger SourceText Integer Type | Genuinely an integer; arises only from TRANSLATION (overloaded literals are done with HsOverLit)
HsRat FractionalLit Type | Genuinely a rational; arises only from TRANSLATION (overloaded literals are done with HsOverLit)

#### Instances

Instances details

Data HsLitTc # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsLitTc -> c HsLitTc # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c HsLitTc # toConstr :: HsLitTc -> Constr # dataTypeOf :: HsLitTc -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c HsLitTc) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsLitTc) # gmapT :: (forall b. Data b => b -> b) -> HsLitTc -> HsLitTc # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsLitTc -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsLitTc -> r # gmapQ :: (forall d. Data d => d -> u) -> HsLitTc -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsLitTc -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsLitTc -> m HsLitTc # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLitTc -> m HsLitTc # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLitTc -> m HsLitTc #
Eq HsLitTc # |
Instance details Defined in GHC.Hs.Lit Methods (==) :: HsLitTc -> HsLitTc -> Bool # (/=) :: HsLitTc -> HsLitTc -> Bool #

data OverLitRn #

Constructors

OverLitRn |
Fields ol_rebindable :: Bool ol_from_fun :: LIdP GhcRn

#### Instances

Instances details

Data OverLitRn # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OverLitRn -> c OverLitRn # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OverLitRn # toConstr :: OverLitRn -> Constr # dataTypeOf :: OverLitRn -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OverLitRn) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OverLitRn) # gmapT :: (forall b. Data b => b -> b) -> OverLitRn -> OverLitRn # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OverLitRn -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OverLitRn -> r # gmapQ :: (forall d. Data d => d -> u) -> OverLitRn -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> OverLitRn -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> OverLitRn -> m OverLitRn # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OverLitRn -> m OverLitRn # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OverLitRn -> m OverLitRn #

data OverLitTc #

Constructors

OverLitTc |
Fields ol_rebindable :: Bool ol_witness :: HsExpr GhcTc ol_type :: Type

#### Instances

Instances details

Data OverLitTc # |
Instance details Defined in GHC.Hs.Instances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OverLitTc -> c OverLitTc # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OverLitTc # toConstr :: OverLitTc -> Constr # dataTypeOf :: OverLitTc -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OverLitTc) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OverLitTc) # gmapT :: (forall b. Data b => b -> b) -> OverLitTc -> OverLitTc # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OverLitTc -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OverLitTc -> r # gmapQ :: (forall d. Data d => d -> u) -> OverLitTc -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> OverLitTc -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> OverLitTc -> m OverLitTc # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OverLitTc -> m OverLitTc # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OverLitTc -> m OverLitTc #

pprXOverLit :: forall (p :: Pass). GhcPass p -> XOverLit (GhcPass p) -> SDoc #

overLitType :: HsOverLit GhcTc -> Type #

hsOverLitNeedsParens :: PprPrec -> HsOverLit x -> Bool #

``hsOverLitNeedsParens` p ol` returns `True` if an overloaded literal `ol` needs to be parenthesized under precedence `p`.

hsLitNeedsParens :: forall (x :: Pass). IsPass x => PprPrec -> HsLit (GhcPass x) -> Bool #

``hsLitNeedsParens` p l` returns `True` if a literal `l` needs to be parenthesized under precedence `p`.

See Note [Printing of literals in Core] in GHC.Types.Literal for the reasoning.

convertLit :: forall (p :: Pass) (p' :: Pass). XXLit (GhcPass p) ~ DataConCantHappen => HsLit (GhcPass p) -> HsLit (GhcPass p') #

Convert a literal from one index type to another. The constraint XXLit (GhcPass p)~DataConCantHappen means that once the XLit constructor is inhabited, we can no longer go back to the case where its not. In practice it just means you can't just convertLit to go from (HsLit GhcTc) -> (HsLit GhcPs/GhcRn), while all other conversions are fine.

pmPprHsLit :: forall (p :: Pass). IsPass p => HsLit (GhcPass p) -> SDoc #

pmPprHsLit pretty prints literals and is used when pretty printing pattern match warnings. All are printed the same (i.e., without hashes if they are primitive and not wrapped in constructors if they are boxed). This happens mainly for too reasons: * We do not want to expose their internal representation * The warnings become too messy

negateOverLitVal :: OverLitVal -> OverLitVal #

# Orphan instances

Outputable OverLitVal # |
Instance details Methods ppr :: OverLitVal -> SDoc #
IsPass p => Outputable (HsLit (GhcPass p)) # |
Instance details Methods ppr :: HsLit (GhcPass p) -> SDoc #
OutputableBndrId p => Outputable (HsOverLit (GhcPass p)) # |
Instance details Methods ppr :: HsOverLit (GhcPass p) -> SDoc #
Eq (XXOverLit p) => Eq (HsOverLit p) # |
Instance details Methods (==) :: HsOverLit p -> HsOverLit p -> Bool # (/=) :: HsOverLit p -> HsOverLit p -> Bool #
Ord (XXOverLit p) => Ord (HsOverLit p) # |
Instance details Methods compare :: HsOverLit p -> HsOverLit p -> Ordering # (<) :: HsOverLit p -> HsOverLit p -> Bool # (<=) :: HsOverLit p -> HsOverLit p -> Bool # (>) :: HsOverLit p -> HsOverLit p -> Bool # (>=) :: HsOverLit p -> HsOverLit p -> Bool # max :: HsOverLit p -> HsOverLit p -> HsOverLit p # min :: HsOverLit p -> HsOverLit p -> HsOverLit p #