{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
module Clash.Core.DataCon
( DataCon (..)
, DcName
, ConTag
)
where
import Control.DeepSeq (NFData(..))
import Data.Binary (Binary)
import Data.Hashable (Hashable)
import qualified Data.Text as Text
import GHC.Generics (Generic)
import Clash.Core.Name (Name (..))
import {-# SOURCE #-} Clash.Core.Type (Type)
import Clash.Core.Var (TyVar)
import Clash.Unique
import Clash.Util
data DataCon
= MkData
{ DataCon -> DcName
dcName :: !DcName
, DataCon -> Unique
dcUniq :: {-# UNPACK #-} !Unique
, DataCon -> Unique
dcTag :: !ConTag
, DataCon -> Type
dcType :: !Type
, DataCon -> [TyVar]
dcUnivTyVars :: [TyVar]
, DataCon -> [TyVar]
dcExtTyVars :: [TyVar]
, DataCon -> [Type]
dcArgTys :: [Type]
, DataCon -> [Text]
dcFieldLabels :: [Text.Text]
} deriving ((forall x. DataCon -> Rep DataCon x)
-> (forall x. Rep DataCon x -> DataCon) -> Generic DataCon
forall x. Rep DataCon x -> DataCon
forall x. DataCon -> Rep DataCon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataCon x -> DataCon
$cfrom :: forall x. DataCon -> Rep DataCon x
Generic,DataCon -> ()
(DataCon -> ()) -> NFData DataCon
forall a. (a -> ()) -> NFData a
rnf :: DataCon -> ()
$crnf :: DataCon -> ()
NFData,Unique -> DataCon -> Unique
DataCon -> Unique
(Unique -> DataCon -> Unique)
-> (DataCon -> Unique) -> Hashable DataCon
forall a. (Unique -> a -> Unique) -> (a -> Unique) -> Hashable a
hash :: DataCon -> Unique
$chash :: DataCon -> Unique
hashWithSalt :: Unique -> DataCon -> Unique
$chashWithSalt :: Unique -> DataCon -> Unique
Hashable,Get DataCon
[DataCon] -> Put
DataCon -> Put
(DataCon -> Put)
-> Get DataCon -> ([DataCon] -> Put) -> Binary DataCon
forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
putList :: [DataCon] -> Put
$cputList :: [DataCon] -> Put
get :: Get DataCon
$cget :: Get DataCon
put :: DataCon -> Put
$cput :: DataCon -> Put
Binary)
instance Show DataCon where
show :: DataCon -> String
show = DcName -> String
forall a. Show a => a -> String
show (DcName -> String) -> (DataCon -> DcName) -> DataCon -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataCon -> DcName
dcName
instance Eq DataCon where
== :: DataCon -> DataCon -> Bool
(==) = Unique -> Unique -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Unique -> Unique -> Bool)
-> (DataCon -> Unique) -> DataCon -> DataCon -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` DataCon -> Unique
dcUniq
/= :: DataCon -> DataCon -> Bool
(/=) = Unique -> Unique -> Bool
forall a. Eq a => a -> a -> Bool
(/=) (Unique -> Unique -> Bool)
-> (DataCon -> Unique) -> DataCon -> DataCon -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` DataCon -> Unique
dcUniq
instance Ord DataCon where
compare :: DataCon -> DataCon -> Ordering
compare = Unique -> Unique -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Unique -> Unique -> Ordering)
-> (DataCon -> Unique) -> DataCon -> DataCon -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` DataCon -> Unique
dcUniq
instance Uniquable DataCon where
getUnique :: DataCon -> Unique
getUnique = DataCon -> Unique
dcUniq
setUnique :: DataCon -> Unique -> DataCon
setUnique dc :: DataCon
dc u :: Unique
u = DataCon
dc {dcUniq :: Unique
dcUniq=Unique
u, dcName :: DcName
dcName=(DataCon -> DcName
dcName DataCon
dc){nameUniq :: Unique
nameUniq=Unique
u}}
type ConTag = Int
type DcName = Name DataCon