module CLaSH.Core.Literal
( Literal (..)
, literalType
)
where
import Unbound.LocallyNameless as Unbound
import Unbound.LocallyNameless.Alpha
import CLaSH.Core.Term (Term)
import CLaSH.Core.Type (Type)
import CLaSH.Core.TysPrim (intPrimTy, voidPrimTy)
data Literal
= IntegerLiteral Integer
| StringLiteral String
deriving (Eq,Ord,Show)
Unbound.derive [''Literal]
instance Alpha Literal where
fv' _ _ = emptyC
acompare' _ (IntegerLiteral i) (IntegerLiteral j) = compare i j
acompare' c l1 l2 = acompareR1 rep1 c l1 l2
instance Subst Type Literal
instance Subst Term Literal
literalType :: Literal
-> Type
literalType (IntegerLiteral _) = intPrimTy
literalType (StringLiteral _) = voidPrimTy