module DDC.Core.Module.Import
(
ImportType (..)
, kindOfImportType
, mapKindOfImportType
, ImportCap (..)
, typeOfImportCap
, mapTypeOfImportCap
, ImportValue (..)
, typeOfImportValue
, mapTypeOfImportValue)
where
import DDC.Core.Module.Name
import DDC.Type.Exp
import Control.DeepSeq
data ImportType n
= ImportTypeAbstract
{ importTypeAbstractType :: !(Kind n) }
| ImportTypeBoxed
{ importTypeBoxed :: !(Kind n) }
deriving Show
instance NFData n => NFData (ImportType n) where
rnf is
= case is of
ImportTypeAbstract k -> rnf k
ImportTypeBoxed k -> rnf k
kindOfImportType :: ImportType n -> Kind n
kindOfImportType src
= case src of
ImportTypeAbstract k -> k
ImportTypeBoxed k -> k
mapKindOfImportType :: (Kind n -> Kind n) -> ImportType n -> ImportType n
mapKindOfImportType f isrc
= case isrc of
ImportTypeAbstract k -> ImportTypeAbstract (f k)
ImportTypeBoxed k -> ImportTypeBoxed (f k)
data ImportCap n
= ImportCapAbstract
{ importCapAbstractType :: !(Type n) }
deriving Show
instance NFData n => NFData (ImportCap n) where
rnf ii
= case ii of
ImportCapAbstract t -> rnf t
typeOfImportCap :: ImportCap n -> Type n
typeOfImportCap ii
= case ii of
ImportCapAbstract t -> t
mapTypeOfImportCap :: (Type n -> Type n) -> ImportCap n -> ImportCap n
mapTypeOfImportCap f ii
= case ii of
ImportCapAbstract t -> ImportCapAbstract (f t)
data ImportValue n
= ImportValueModule
{
importValueModuleName :: !ModuleName
, importValueModuleVar :: !n
, importValueModuleType :: !(Type n)
, importValueModuleArity :: !(Maybe (Int, Int, Int)) }
| ImportValueSea
{
importValueSeaVar :: !String
, importValueSeaType :: !(Type n) }
deriving Show
instance NFData n => NFData (ImportValue n) where
rnf is
= case is of
ImportValueModule mn n t mAV
-> rnf mn `seq` rnf n `seq` rnf t `seq` rnf mAV
ImportValueSea v t
-> rnf v `seq` rnf t
typeOfImportValue :: ImportValue n -> Type n
typeOfImportValue src
= case src of
ImportValueModule _ _ t _ -> t
ImportValueSea _ t -> t
mapTypeOfImportValue :: (Type n -> Type n) -> ImportValue n -> ImportValue n
mapTypeOfImportValue f isrc
= case isrc of
ImportValueModule mn n t a -> ImportValueModule mn n (f t) a
ImportValueSea s t -> ImportValueSea s (f t)