{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Clash.Core.Var
( Var (..)
, Id
, TyVar
, modifyVarName
)
where
import Control.DeepSeq (NFData (..))
import Data.Hashable (Hashable)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Unbound.Generics.LocallyNameless (Alpha,Embed,Subst(..))
import Clash.Core.Name (Name)
import {-# SOURCE #-} Clash.Core.Term (Term)
import {-# SOURCE #-} 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,Hashable)
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