HsLit

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

HsLit

Synopsis

- data HsLit x
  - = HsChar (XHsChar x) Char
  - | HsCharPrim (XHsCharPrim x) Char
  - | HsString (XHsString x) FastString
  - | HsStringPrim (XHsStringPrim x) ByteString
  - | HsInt (XHsInt x) IntegralLit
  - | HsIntPrim (XHsIntPrim x) Integer
  - | HsWordPrim (XHsWordPrim x) Integer
  - | HsInt64Prim (XHsInt64Prim x) Integer
  - | HsWord64Prim (XHsWord64Prim x) Integer
  - | HsInteger (XHsInteger x) Integer Type
  - | HsRat (XHsRat x) FractionalLit Type
  - | HsFloatPrim (XHsFloatPrim x) FractionalLit
  - | HsDoublePrim (XHsDoublePrim x) FractionalLit
  - | XLit (XXLit x)
- data HsOverLit p
  - = OverLit {
    - ol_ext :: XOverLit p
    - ol_val :: OverLitVal
    - ol_witness :: HsExpr p
    }
  - | XOverLit (XXOverLit p)
- data OverLitTc = OverLitTc {
  - ol_rebindable :: Bool
  - ol_type :: Type
  }
- data OverLitVal
  - = HsIntegral !IntegralLit
  - | HsFractional !FractionalLit
  - | HsIsString !SourceText !FastString
- negateOverLitVal :: OverLitVal -> OverLitVal
- overLitType :: HsOverLit GhcTc -> Type
- convertLit :: ConvertIdX a b => HsLit a -> HsLit b
- pp_st_suffix :: SourceText -> SDoc -> SDoc -> SDoc
- pmPprHsLit :: HsLit (GhcPass x) -> SDoc
- hsLitNeedsParens :: PprPrec -> HsLit x -> Bool
- hsOverLitNeedsParens :: PprPrec -> HsOverLit x -> Bool

# Documentation

data HsLit x #

Haskell Literal

Constructors

HsChar (XHsChar x) Char | Character
HsCharPrim (XHsCharPrim x) Char | Unboxed character
HsString (XHsString x) FastString | String
HsStringPrim (XHsStringPrim x) ByteString | Packed bytes
HsInt (XHsInt x) IntegralLit | Genuinely an Int; arises from `TcGenDeriv`, and from TRANSLATION
HsIntPrim (XHsIntPrim x) Integer | literal `Int#`
HsWordPrim (XHsWordPrim x) Integer | literal `Word#`
HsInt64Prim (XHsInt64Prim x) Integer | literal `Int64#`
HsWord64Prim (XHsWord64Prim x) Integer | literal `Word64#`
HsInteger (XHsInteger x) Integer Type | Genuinely an integer; arises only from TRANSLATION (overloaded literals are done with HsOverLit)
HsRat (XHsRat x) FractionalLit Type | Genuinely a rational; arises only from TRANSLATION (overloaded literals are done with HsOverLit)
HsFloatPrim (XHsFloatPrim x) FractionalLit | Unboxed Float
HsDoublePrim (XHsDoublePrim x) FractionalLit | Unboxed Double
XLit (XXLit x) |

Instances

Eq (HsLit x) # |
Instance details Defined in HsLit Methods (==) :: HsLit x -> HsLit x -> Bool # (/=) :: HsLit x -> HsLit x -> Bool #
Data (HsLit GhcTc) # |
Instance details Defined in HsInstances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsLit GhcTc -> c (HsLit GhcTc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsLit GhcTc) Source # toConstr :: HsLit GhcTc -> Constr Source # dataTypeOf :: HsLit GhcTc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsLit GhcTc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsLit GhcTc)) Source # gmapT :: (forall b. Data b => b -> b) -> HsLit GhcTc -> HsLit GhcTc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsLit GhcTc -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsLit GhcTc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HsLit GhcTc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsLit GhcTc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsLit GhcTc -> m (HsLit GhcTc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLit GhcTc -> m (HsLit GhcTc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLit GhcTc -> m (HsLit GhcTc) Source #
Data (HsLit GhcRn) # |
Instance details Defined in HsInstances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsLit GhcRn -> c (HsLit GhcRn) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsLit GhcRn) Source # toConstr :: HsLit GhcRn -> Constr Source # dataTypeOf :: HsLit GhcRn -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsLit GhcRn)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsLit GhcRn)) Source # gmapT :: (forall b. Data b => b -> b) -> HsLit GhcRn -> HsLit GhcRn Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsLit GhcRn -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsLit GhcRn -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HsLit GhcRn -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsLit GhcRn -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsLit GhcRn -> m (HsLit GhcRn) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLit GhcRn -> m (HsLit GhcRn) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLit GhcRn -> m (HsLit GhcRn) Source #
Data (HsLit GhcPs) # |
Instance details Defined in HsInstances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsLit GhcPs -> c (HsLit GhcPs) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsLit GhcPs) Source # toConstr :: HsLit GhcPs -> Constr Source # dataTypeOf :: HsLit GhcPs -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsLit GhcPs)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsLit GhcPs)) Source # gmapT :: (forall b. Data b => b -> b) -> HsLit GhcPs -> HsLit GhcPs Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsLit GhcPs -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsLit GhcPs -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HsLit GhcPs -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsLit GhcPs -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsLit GhcPs -> m (HsLit GhcPs) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLit GhcPs -> m (HsLit GhcPs) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsLit GhcPs -> m (HsLit GhcPs) Source #
p ~ GhcPass pass => Outputable (HsLit p) # |
Instance details Defined in HsLit Methods ppr :: HsLit p -> SDoc # pprPrec :: Rational -> HsLit p -> SDoc #

data HsOverLit p #

Haskell Overloaded Literal

Constructors

OverLit |
Fields ol_ext :: XOverLit p ol_val :: OverLitVal ol_witness :: HsExpr p
XOverLit (XXOverLit p) |

Instances

Eq (XXOverLit p) => Eq (HsOverLit p) # |
Instance details Defined in HsLit Methods (==) :: HsOverLit p -> HsOverLit p -> Bool # (/=) :: HsOverLit p -> HsOverLit p -> Bool #
Data (HsOverLit GhcTc) # |
Instance details Defined in HsInstances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsOverLit GhcTc -> c (HsOverLit GhcTc) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsOverLit GhcTc) Source # toConstr :: HsOverLit GhcTc -> Constr Source # dataTypeOf :: HsOverLit GhcTc -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsOverLit GhcTc)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsOverLit GhcTc)) Source # gmapT :: (forall b. Data b => b -> b) -> HsOverLit GhcTc -> HsOverLit GhcTc Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsOverLit GhcTc -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsOverLit GhcTc -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HsOverLit GhcTc -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsOverLit GhcTc -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsOverLit GhcTc -> m (HsOverLit GhcTc) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsOverLit GhcTc -> m (HsOverLit GhcTc) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsOverLit GhcTc -> m (HsOverLit GhcTc) Source #
Data (HsOverLit GhcRn) # |
Instance details Defined in HsInstances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsOverLit GhcRn -> c (HsOverLit GhcRn) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsOverLit GhcRn) Source # toConstr :: HsOverLit GhcRn -> Constr Source # dataTypeOf :: HsOverLit GhcRn -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsOverLit GhcRn)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsOverLit GhcRn)) Source # gmapT :: (forall b. Data b => b -> b) -> HsOverLit GhcRn -> HsOverLit GhcRn Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsOverLit GhcRn -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsOverLit GhcRn -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HsOverLit GhcRn -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsOverLit GhcRn -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsOverLit GhcRn -> m (HsOverLit GhcRn) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsOverLit GhcRn -> m (HsOverLit GhcRn) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsOverLit GhcRn -> m (HsOverLit GhcRn) Source #
Data (HsOverLit GhcPs) # |
Instance details Defined in HsInstances Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HsOverLit GhcPs -> c (HsOverLit GhcPs) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HsOverLit GhcPs) Source # toConstr :: HsOverLit GhcPs -> Constr Source # dataTypeOf :: HsOverLit GhcPs -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HsOverLit GhcPs)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HsOverLit GhcPs)) Source # gmapT :: (forall b. Data b => b -> b) -> HsOverLit GhcPs -> HsOverLit GhcPs Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HsOverLit GhcPs -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HsOverLit GhcPs -> r Source # gmapQ :: (forall d. Data d => d -> u) -> HsOverLit GhcPs -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> HsOverLit GhcPs -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HsOverLit GhcPs -> m (HsOverLit GhcPs) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HsOverLit GhcPs -> m (HsOverLit GhcPs) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HsOverLit GhcPs -> m (HsOverLit GhcPs) Source #
Ord (XXOverLit p) => Ord (HsOverLit p) # |
Instance details Defined in HsLit 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 #
(p ~ GhcPass pass, OutputableBndrId p) => Outputable (HsOverLit p) # |
Instance details Defined in HsLit Methods ppr :: HsOverLit p -> SDoc # pprPrec :: Rational -> HsOverLit p -> SDoc #

data OverLitTc #

Constructors

OverLitTc |
Fields ol_rebindable :: Bool ol_type :: Type

Instances

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

data OverLitVal #

Overloaded Literal Value

Constructors

HsIntegral !IntegralLit | Integer-looking literals;
HsFractional !FractionalLit | Frac-looking literals
HsIsString !SourceText !FastString | String-looking literals

Instances

Eq OverLitVal # |
Instance details Defined in HsLit Methods (==) :: OverLitVal -> OverLitVal -> Bool # (/=) :: OverLitVal -> OverLitVal -> Bool #
Data OverLitVal # |
Instance details Defined in HsLit Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OverLitVal -> c OverLitVal Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OverLitVal Source # toConstr :: OverLitVal -> Constr Source # dataTypeOf :: OverLitVal -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OverLitVal) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OverLitVal) Source # gmapT :: (forall b. Data b => b -> b) -> OverLitVal -> OverLitVal Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OverLitVal -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OverLitVal -> r Source # gmapQ :: (forall d. Data d => d -> u) -> OverLitVal -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> OverLitVal -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> OverLitVal -> m OverLitVal Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OverLitVal -> m OverLitVal Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OverLitVal -> m OverLitVal Source #
Ord OverLitVal # |
Instance details Defined in HsLit Methods compare :: OverLitVal -> OverLitVal -> Ordering # (<) :: OverLitVal -> OverLitVal -> Bool # (<=) :: OverLitVal -> OverLitVal -> Bool # (>) :: OverLitVal -> OverLitVal -> Bool # (>=) :: OverLitVal -> OverLitVal -> Bool # max :: OverLitVal -> OverLitVal -> OverLitVal # min :: OverLitVal -> OverLitVal -> OverLitVal #
Outputable OverLitVal # |
Instance details Defined in HsLit Methods ppr :: OverLitVal -> SDoc # pprPrec :: Rational -> OverLitVal -> SDoc #

negateOverLitVal :: OverLitVal -> OverLitVal #

overLitType :: HsOverLit GhcTc -> Type #

convertLit :: ConvertIdX a b => HsLit a -> HsLit b #

Convert a literal from one index type to another, updating the annotations according to the relevant `Convertable` instance

pp_st_suffix :: SourceText -> SDoc -> SDoc -> SDoc #

pmPprHsLit :: HsLit (GhcPass x) -> 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

hsLitNeedsParens :: PprPrec -> HsLit x -> Bool #

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

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

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