-- This corresponds to src/Comp/Type.hs in bsc.
module Language.Bluespec.Classic.AST.Builtin.Types where

import Language.Bluespec.Classic.AST.Builtin.Ids
import Language.Bluespec.Classic.AST.Id
import Language.Bluespec.Classic.AST.Position
import Language.Bluespec.Classic.AST.Type
import Language.Bluespec.Prelude
import Language.Bluespec.Pretty

infixr 4 `fn`

-- XXX these definitions should be synced with StdPrel.hs where applicable

tArrow, tBit, tInt :: Type
tArrow :: Type
tArrow = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idArrow Position
noPosition) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar))) TISort
TIabstract)
tBit :: Type
tBit = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idBit (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) TISort
TIabstract)
tInt :: Type
tInt = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idInt (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) TISort
TIabstract)

tIntAt :: Position -> Type
tIntAt :: Position -> Type
tIntAt Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idIntAt Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) TISort
TIabstract)

tiData, tiEnum :: [Id] -> TISort
tiEnum :: [Id] -> TISort
tiEnum [Id]
cons = TIdata { tidata_cons :: [Id]
tidata_cons = [Id]
cons, tidata_enum :: Bool
tidata_enum = Bool
True }
tiData :: [Id] -> TISort
tiData [Id]
cons = TIdata { tidata_cons :: [Id]
tidata_cons = [Id]
cons, tidata_enum :: Bool
tidata_enum = Bool
False }

tUInt, tBool, tPrimUnit :: Type
tUInt :: Type
tUInt = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idUInt (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) TISort
TIabstract)
tBool :: Type
tBool = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idBool (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) ([Id] -> TISort
tiEnum [Id
idFalse, Id
idTrue]))
--tArray = TCon (TyCon idArray (Just (Kfun KNum (Kfun KNum KStar))) (TIstruct SInterface [id_sub, id_upd]))
tPrimUnit :: Type
tPrimUnit = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idPrimUnit (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct []))

tPrimUnitAt :: Position -> Type
tPrimUnitAt :: Position -> Type
tPrimUnitAt Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idPrimUnitAt Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct []))

tInteger, tReal :: Type
tInteger :: Type
tInteger = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idInteger (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tReal :: Type
tReal = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idReal (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)

tRealAt :: Position -> Type
tRealAt :: Position -> Type
tRealAt Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idRealAt Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)

tClock, tReset, tInout, tInout_, tChar, tString :: Type
tClock :: Type
tClock = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idClock (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tReset :: Type
tReset = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idReset (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tInout :: Type
tInout = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idInout (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar)) TISort
TIabstract)
tInout_ :: Type
tInout_ = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idInout_ (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) TISort
TIabstract)
tString :: Type
tString = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idString (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tChar :: Type
tChar = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idChar (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)

tFmt, tName, tPosition, tType :: Type
tFmt :: Type
tFmt = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idFmt (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tName :: Type
tName = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idName (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tPosition :: Type
tPosition = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idPosition (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tType :: Type
tType = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idType (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)

tPred, tAttributes, tPrimPair, tSizeOf :: Type
tPred :: Type
tPred = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idPred (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tAttributes :: Type
tAttributes = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idAttributes (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tPrimPair :: Type
tPrimPair = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idPrimPair (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar))) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct [Id
idPrimFst, Id
idPrimSnd]))
tSizeOf :: Type
tSizeOf = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idSizeOf (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KNum)) TISort
TIabstract)

tAction, tActionValue, tActionValue_, tAction_:: Type
tAction :: Type
tAction = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idAction (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) (Integer -> Type -> TISort
TItype Integer
0 (Type -> Type -> Type
TAp Type
tActionValue Type
tPrimUnit)))
tActionValue :: Type
tActionValue = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idActionValue (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar)) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct [Id
id__value, Id
id__action]))
tActionValue_ :: Type
tActionValue_ = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idActionValue_ (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct [Id
id__value, Id
id__action]))
tAction_ :: Type
tAction_ = Type -> Type -> Type
TAp Type
tActionValue_ (Integer -> Position -> Type
tOfSize Integer
0 Position
noPosition)

tActionAt, tActionValueAt, tActionValue_At :: Position -> Type
tActionAt :: Position -> Type
tActionAt Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idActionAt Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) (Integer -> Type -> TISort
TItype Integer
0 (Type -> Type -> Type
TAp (Position -> Type
tActionValueAt Position
pos) (Position -> Type
tPrimUnitAt Position
pos))))
tActionValueAt :: Position -> Type
tActionValueAt Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idActionValueAt Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar)) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct [Position -> Id
id__value_at Position
pos, Position -> Id
id__action_at Position
pos]))
tActionValue_At :: Position -> Type
tActionValue_At Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idActionValue_At Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct [Position -> Id
id__value_at Position
pos, Position -> Id
id__action_at Position
pos]))

tPrimAction, tRules :: Type
tPrimAction :: Type
tPrimAction = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idPrimAction (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tRules :: Type
tRules = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idRules (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)

tRulesAt :: Position -> Type
tRulesAt :: Position -> Type
tRulesAt Position
pos = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon (Position -> Id
idRulesAt Position
pos) (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)

tSchedPragma, tModule, tVRWireN, tId, t32 :: Type
tSchedPragma :: Type
tSchedPragma = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idSchedPragma (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tModule :: Type
tModule = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idModule (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar)) TISort
TIabstract)
tVRWireN :: Type
tVRWireN = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idVRWireN (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar)) (StructSubType -> [Id] -> TISort
TIstruct StructSubType
SStruct [Id
idWSet, Id
idWGet, Id
idWHas]))
tId :: Type
tId = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idId (Kind -> Maybe Kind
forall a. a -> Maybe a
Just (Kind -> Kind -> Kind
Kfun Kind
KStar Kind
KStar)) TISort
TIabstract)
t32 :: Type
t32 = Integer -> Position -> Type
tOfSize Integer
32 Position
noPosition

t32At :: Position -> Type
t32At :: Position -> Type
t32At Position
pos = Integer -> Position -> Type
tOfSize Integer
32 Position
pos

tOfSize :: Integer -> Position -> Type
tOfSize :: Integer -> Position -> Type
tOfSize Integer
n Position
pos = Integer -> Position -> Type
cTNum Integer
n Position
pos

tInt32At :: Position -> Type
tInt32At :: Position -> Type
tInt32At Position
pos = Type -> Type -> Type
TAp (Position -> Type
tIntAt Position
pos) (Position -> Type
t32At Position
pos)

tBitN :: Integer -> Position -> Type
tBitN :: Integer -> Position -> Type
tBitN Integer
n Position
pos = Type -> Type -> Type
TAp Type
tBit (Integer -> Position -> Type
tOfSize Integer
n Position
pos)

tNat :: Position -> Type
tNat :: Position -> Type
tNat Position
pos = Integer -> Position -> Type
tBitN Integer
32 Position
pos

tFile, tSvaParam :: Type
tFile :: Type
tFile = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idFile (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) TISort
TIabstract)
tSvaParam :: Type
tSvaParam  = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idSvaParam (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
KStar) ([Id] -> TISort
tiData [Id
idSvaBool, Id
idSvaNumber]))

fn         :: Type -> Type -> Type
Type
a fn :: Type -> Type -> Type
`fn` Type
b    = Type -> Type -> Type
TAp (Type -> Type -> Type
TAp Type
tArrow Type
a) Type
b

-- numeric kinds and type constructors
kNNN, kNN, kNNS, kNS :: Kind
kNNN :: Kind
kNNN = Kind -> Kind -> Kind
Kfun Kind
KNum Kind
kNN
kNN :: Kind
kNN = Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KNum

kNNS :: Kind
kNNS = Kind -> Kind -> Kind
Kfun Kind
KNum Kind
kNS
kNS :: Kind
kNS  = Kind -> Kind -> Kind
Kfun Kind
KNum Kind
KStar

tAdd, tSub, tMul, tDiv, tLog, tExp, tMax, tMin :: Type
tAdd :: Type
tAdd = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTAdd (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNNN) TISort
TIabstract)
tSub :: Type
tSub = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTSub (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNNN) TISort
TIabstract)
tMul :: Type
tMul = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTMul (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNNN) TISort
TIabstract)
tDiv :: Type
tDiv = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTDiv (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNNN) TISort
TIabstract)
tLog :: Type
tLog = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTLog (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNN)  TISort
TIabstract)
tExp :: Type
tExp = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTExp (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNN)  TISort
TIabstract)
tMax :: Type
tMax = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTMax (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNNN) TISort
TIabstract)
tMin :: Type
tMin = TyCon -> Type
TCon (Id -> Maybe Kind -> TISort -> TyCon
TyCon Id
idTMin (Kind -> Maybe Kind
forall a. a -> Maybe a
Just Kind
kNNN) TISort
TIabstract)

class HasKind t where
    kind :: t -> Kind

instance HasKind TyVar where
    kind :: TyVar -> Kind
kind (TyVar Id
_v Int
_ Kind
k) = Kind
k

instance HasKind TyCon where
    kind :: TyCon -> Kind
kind (TyCon Id
_v (Just Kind
k) TISort
_) = Kind
k
    kind (TyNum Integer
_ Position
_) = Kind
KNum
    kind (TyStr FString
_ Position
_) = Kind
KStr
    kind (TyCon Id
_v Maybe Kind
Nothing TISort
_) = [Char] -> Kind
forall a. HasCallStack => [Char] -> a
error [Char]
"HasKind(TyCon).kind: TyCon without kind"

instance HasKind Type where
    kind :: Type -> Kind
kind (TCon TyCon
tc) = TyCon -> Kind
forall t. HasKind t => t -> Kind
kind TyCon
tc
    kind (TVar TyVar
u)  = TyVar -> Kind
forall t. HasKind t => t -> Kind
kind TyVar
u
    kind tt :: Type
tt@(TAp Type
t Type
_) = case Type -> Kind
forall t. HasKind t => t -> Kind
kind Type
t of
                        Kfun Kind
_ Kind
k -> Kind
k
                        Kind
k        ->
                         [Char] -> Kind
forall a. HasCallStack => [Char] -> a
error ([Char]
"kind: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Kind -> [Char]
forall a. Pretty a => a -> [Char]
ppReadable Kind
k [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ (Type -> [Char]
forall a. Show a => a -> [Char]
show Type
tt) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"\n")
    kind (TGen Position
_ Int
_)  = [Char] -> Kind
forall a. HasCallStack => [Char] -> a
error [Char]
"HasKind(Type).kind: TGen"
    kind (TDefMonad Position
_) = [Char] -> Kind
forall a. HasCallStack => [Char] -> a
error [Char]
"HasKind(Type).kind: TDefMonad"

arrow :: Type -> Type -> Type
arrow :: Type -> Type -> Type
arrow Type
a Type
r = Type -> Type -> Type
TAp (Type -> Type -> Type
TAp Type
tArrow Type
a) Type
r


-- -------------------------

-- XXX kill this
isPrimAction :: Type -> Bool
isPrimAction :: Type -> Bool
isPrimAction Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tPrimAction

isActionValue :: Type -> Bool
isActionValue :: Type -> Bool
isActionValue (TAp Type
av Type
_) = Type
av Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tActionValue
isActionValue Type
_ = Bool
False

getAVType :: Type -> Type
getAVType :: Type -> Type
getAVType (TAp Type
av Type
t) | Type
av Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tActionValue = Type
t
getAVType Type
t = [Char] -> Type
forall a. HasCallStack => [Char] -> a
error([Char]
"getAVType not ActionValue: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Type -> [Char]
forall a. Pretty a => a -> [Char]
ppReadable Type
t)

isActionWithoutValue :: Type -> Bool
isActionWithoutValue :: Type -> Bool
isActionWithoutValue (TAp Type
av (TCon (TyNum Integer
0 Position
_))) = Type
av Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tActionValue_
isActionWithoutValue Type
_ = Bool
False

isActionWithValue :: Type -> Bool
isActionWithValue :: Type -> Bool
isActionWithValue (TAp Type
av (TCon (TyNum Integer
n Position
_))) = (Type
av Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tActionValue_) Bool -> Bool -> Bool
&& (Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
0)
isActionWithValue (TAp Type
av (TVar TyVar
_)) = Type
av Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tActionValue_
isActionWithValue Type
_ = Bool
False

isClock, isReset, isInout, isInout_ :: Type -> Bool
isClock :: Type -> Bool
isClock Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tClock
isReset :: Type -> Bool
isReset Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tReset

isInout :: Type -> Bool
isInout (TAp Type
i Type
_) = Type
i Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tInout
isInout Type
_ = Bool
False

isInout_ :: Type -> Bool
isInout_ (TAp Type
i Type
_) = Type
i Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tInout_
isInout_ Type
_ = Bool
False

isBit, isInt, isUInt, isBool, isInteger, isString, isChar, isReal, isFmt :: Type -> Bool
isBit :: Type -> Bool
isBit (TAp Type
b Type
_) = Type
b Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tBit
isBit Type
_ = Bool
False

isInt :: Type -> Bool
isInt (TAp Type
i Type
_) = Type
i Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tInt
isInt Type
_ = Bool
False

isUInt :: Type -> Bool
isUInt (TAp Type
u Type
_) = Type
u Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tUInt
isUInt Type
_ = Bool
False

isBool :: Type -> Bool
isBool Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tBool
isInteger :: Type -> Bool
isInteger Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tInteger
isString :: Type -> Bool
isString Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tString
isChar :: Type -> Bool
isChar Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tChar
isReal :: Type -> Bool
isReal Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tReal
isFmt :: Type -> Bool
isFmt Type
t = Type
t Type -> Type -> Bool
forall a. Eq a => a -> a -> Bool
== Type
tFmt

-- -------------------------