{-# LANGUAGE CPP #-}
module GHC.SourceGen.Type
( HsType'
, tyPromotedVar
, stringTy
, numTy
, listTy
, listPromotedTy
, tuplePromotedTy
, (-->)
, forall'
, HsTyVarBndr'
, (==>)
, kindedVar
) where
import Data.String (fromString)
import GHC.Hs.Types
import GHC.SourceGen.Syntax.Internal
import GHC.SourceGen.Lit.Internal (noSourceText)
import GHC.SourceGen.Name.Internal
import GHC.SourceGen.Type.Internal
tyPromotedVar :: RdrNameStr -> HsType'
tyPromotedVar = noExt HsTyVar promoted . typeRdrName
stringTy :: String -> HsType'
stringTy = noExt HsTyLit . noSourceText HsStrTy . fromString
numTy :: Integer -> HsType'
numTy = noExt HsTyLit . noSourceText HsNumTy
listTy :: HsType' -> HsType'
listTy = noExt HsListTy . builtLoc
listPromotedTy :: [HsType'] -> HsType'
listPromotedTy = withPlaceHolder (noExt HsExplicitListTy promoted) . map builtLoc
tuplePromotedTy :: [HsType'] -> HsType'
tuplePromotedTy = withPlaceHolders (noExt HsExplicitTupleTy) . map builtLoc
(-->) :: HsType' -> HsType' -> HsType'
a --> b = noExt HsFunTy (parenthesizeTypeForFun $ builtLoc a) (builtLoc b)
infixr 0 -->
forall' :: [HsTyVarBndr'] -> HsType' -> HsType'
forall' ts = noExt HsForAllTy
#if MIN_VERSION_ghc(8,10,0)
ForallInvis
#endif
(map builtLoc ts) . builtLoc
(==>) :: [HsType'] -> HsType' -> HsType'
(==>) cs = noExt HsQualTy (builtLoc (map builtLoc cs)) . builtLoc
infixr 0 ==>
kindedVar :: OccNameStr -> HsType' -> HsTyVarBndr'
kindedVar v t = noExt KindedTyVar (typeRdrName $ UnqualStr v)
(builtLoc t)