module CLaSH.Core.Var
( Var (..)
, Id
, TyVar
, modifyVarName
)
where
import Control.DeepSeq (NFData (..))
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Unbound.Generics.LocallyNameless (Alpha,Embed,Name,Subst(..))
import Unbound.Generics.LocallyNameless.Extra ()
import CLaSH.Core.Term (Term)
import CLaSH.Core.Type (Kind, Type)
data Var a
= TyVar
{ varName :: Name a
, varKind :: Embed Kind
}
| Id
{ varName :: Name a
, varType :: Embed Type
}
deriving (Eq,Show,Generic,NFData)
type Id = Var Term
type TyVar = Var Type
instance (Typeable a, Alpha a) => Alpha (Var a)
instance Generic b => Subst Term (Var b)
instance Generic b => Subst Type (Var b)
modifyVarName ::
(Name a -> Name a)
-> Var a
-> Var a
modifyVarName f (TyVar n k) = TyVar (f n) k
modifyVarName f (Id n t) = Id (f n) t