{-# LANGUAGE CPP #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
module Cryptol.ModuleSystem.Env where
#ifndef RELOCATABLE
import Paths_cryptol (getDataDir)
#endif
import Cryptol.Backend.FFI (ForeignSrc, unloadForeignSrc, getForeignSrcPath)
import Cryptol.Eval (EvalEnv)
import Cryptol.ModuleSystem.Fingerprint
import Cryptol.ModuleSystem.Interface
import Cryptol.ModuleSystem.Name (Name,Supply,emptySupply)
import qualified Cryptol.ModuleSystem.NamingEnv as R
import Cryptol.Parser.AST
import qualified Cryptol.TypeCheck as T
import qualified Cryptol.TypeCheck.Interface as T
import qualified Cryptol.TypeCheck.AST as T
import Cryptol.Utils.PP (PP(..),text,parens,NameDisp)
import Data.ByteString(ByteString)
import Control.Monad (guard,mplus)
import qualified Control.Exception as X
import Data.Function (on)
import Data.Set(Set)
import qualified Data.Set as Set
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Semigroup
import Data.Maybe(fromMaybe)
import System.Directory (getAppUserDataDirectory, getCurrentDirectory)
import System.Environment(getExecutablePath)
import System.FilePath ((</>), normalise, joinPath, splitPath, takeDirectory)
import qualified Data.List as List
import Data.Foldable
import GHC.Generics (Generic)
import Control.DeepSeq
import Prelude ()
import Prelude.Compat
import Cryptol.Utils.Panic(panic)
import Cryptol.Utils.PP(pp)
data ModuleEnv = ModuleEnv
{ ModuleEnv -> LoadedModules
meLoadedModules :: LoadedModules
, ModuleEnv -> NameSeeds
meNameSeeds :: T.NameSeeds
, ModuleEnv -> EvalEnv
meEvalEnv :: EvalEnv
, ModuleEnv -> CoreLint
meCoreLint :: CoreLint
, ModuleEnv -> Bool
meMonoBinds :: !Bool
, ModuleEnv -> Maybe ModName
meFocusedModule :: Maybe ModName
, ModuleEnv -> [String]
meSearchPath :: [FilePath]
, ModuleEnv -> DynamicEnv
meDynEnv :: DynamicEnv
, ModuleEnv -> Supply
meSupply :: !Supply
} deriving forall x. Rep ModuleEnv x -> ModuleEnv
forall x. ModuleEnv -> Rep ModuleEnv x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModuleEnv x -> ModuleEnv
$cfrom :: forall x. ModuleEnv -> Rep ModuleEnv x
Generic
instance NFData ModuleEnv where
rnf :: ModuleEnv -> ()
rnf ModuleEnv
x = ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
x seq :: forall a b. a -> b -> b
`seq` ModuleEnv -> EvalEnv
meEvalEnv ModuleEnv
x seq :: forall a b. a -> b -> b
`seq` ModuleEnv -> DynamicEnv
meDynEnv ModuleEnv
x seq :: forall a b. a -> b -> b
`seq` ()
data CoreLint = NoCoreLint
| CoreLint
deriving (forall x. Rep CoreLint x -> CoreLint
forall x. CoreLint -> Rep CoreLint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoreLint x -> CoreLint
$cfrom :: forall x. CoreLint -> Rep CoreLint x
Generic, CoreLint -> ()
forall a. (a -> ()) -> NFData a
rnf :: CoreLint -> ()
$crnf :: CoreLint -> ()
NFData)
resetModuleEnv :: ModuleEnv -> IO ModuleEnv
resetModuleEnv :: ModuleEnv -> IO ModuleEnv
resetModuleEnv ModuleEnv
env = do
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ (LoadedModules -> [LoadedModule]
getLoadedModules forall a b. (a -> b) -> a -> b
$ ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
env) forall a b. (a -> b) -> a -> b
$ \LoadedModule
lm ->
case LoadedModuleData -> Maybe ForeignSrc
lmForeignSrc (forall a. LoadedModuleG a -> a
lmData LoadedModule
lm) of
Just ForeignSrc
fsrc -> ForeignSrc -> IO ()
unloadForeignSrc ForeignSrc
fsrc
Maybe ForeignSrc
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ModuleEnv
env
{ meLoadedModules :: LoadedModules
meLoadedModules = forall a. Monoid a => a
mempty
, meNameSeeds :: NameSeeds
meNameSeeds = NameSeeds
T.nameSeeds
, meEvalEnv :: EvalEnv
meEvalEnv = forall a. Monoid a => a
mempty
, meFocusedModule :: Maybe ModName
meFocusedModule = forall a. Maybe a
Nothing
, meDynEnv :: DynamicEnv
meDynEnv = forall a. Monoid a => a
mempty
}
initialModuleEnv :: IO ModuleEnv
initialModuleEnv :: IO ModuleEnv
initialModuleEnv = do
String
curDir <- IO String
getCurrentDirectory
#ifndef RELOCATABLE
dataDir <- getDataDir
#endif
String
binDir <- String -> String
takeDirectory forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` IO String
getExecutablePath
let instDir :: String
instDir = String -> String
normalise forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
joinPath forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
init forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
splitPath forall a b. (a -> b) -> a -> b
$ String
binDir
let handle :: X.IOException -> IO String
handle :: IOException -> IO String
handle IOException
_e = forall (m :: * -> *) a. Monad m => a -> m a
return String
""
String
userDir <- forall e a. Exception e => IO a -> (e -> IO a) -> IO a
X.catch (String -> IO String
getAppUserDataDirectory String
"cryptol") IOException -> IO String
handle
let searchPath :: [String]
searchPath = [ String
curDir
, String
userDir
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
, instDir </> "cryptol"
#else
, String
instDir String -> String -> String
</> String
"share" String -> String -> String
</> String
"cryptol"
#endif
#ifndef RELOCATABLE
, dataDir
#endif
]
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleEnv
{ meLoadedModules :: LoadedModules
meLoadedModules = forall a. Monoid a => a
mempty
, meNameSeeds :: NameSeeds
meNameSeeds = NameSeeds
T.nameSeeds
, meEvalEnv :: EvalEnv
meEvalEnv = forall a. Monoid a => a
mempty
, meFocusedModule :: Maybe ModName
meFocusedModule = forall a. Maybe a
Nothing
, meSearchPath :: [String]
meSearchPath = [String]
searchPath
, meDynEnv :: DynamicEnv
meDynEnv = forall a. Monoid a => a
mempty
, meMonoBinds :: Bool
meMonoBinds = Bool
True
, meCoreLint :: CoreLint
meCoreLint = CoreLint
NoCoreLint
, meSupply :: Supply
meSupply = Supply
emptySupply
}
focusModule :: ModName -> ModuleEnv -> Maybe ModuleEnv
focusModule :: ModName -> ModuleEnv -> Maybe ModuleEnv
focusModule ModName
n ModuleEnv
me = do
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (ModName -> LoadedModules -> Bool
isLoaded ModName
n (ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
me))
forall (m :: * -> *) a. Monad m => a -> m a
return ModuleEnv
me { meFocusedModule :: Maybe ModName
meFocusedModule = forall a. a -> Maybe a
Just ModName
n }
loadedModules :: ModuleEnv -> [T.Module]
loadedModules :: ModuleEnv -> [Module]
loadedModules = forall a b. (a -> b) -> [a] -> [b]
map LoadedModule -> Module
lmModule forall b c a. (b -> c) -> (a -> b) -> a -> c
. LoadedModules -> [LoadedModule]
getLoadedModules forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleEnv -> LoadedModules
meLoadedModules
loadedNonParamModules :: ModuleEnv -> [T.Module]
loadedNonParamModules :: ModuleEnv -> [Module]
loadedNonParamModules = forall a b. (a -> b) -> [a] -> [b]
map LoadedModule -> Module
lmModule forall b c a. (b -> c) -> (a -> b) -> a -> c
. LoadedModules -> [LoadedModule]
lmLoadedModules forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleEnv -> LoadedModules
meLoadedModules
loadedNewtypes :: ModuleEnv -> Map Name T.Newtype
loadedNewtypes :: ModuleEnv -> Map Name Newtype
loadedNewtypes ModuleEnv
menv = forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
Map.unions
[ IfaceDecls -> Map Name Newtype
ifNewtypes (forall name. IfaceG name -> IfaceDecls
ifDefines Iface
i) forall a. Semigroup a => a -> a -> a
<> IfaceDecls -> Map Name Newtype
ifNewtypes (forall name. IfaceG name -> IfaceDecls
ifDefines Iface
i)
| Iface
i <- forall a b. (a -> b) -> [a] -> [b]
map LoadedModule -> Iface
lmInterface (LoadedModules -> [LoadedModule]
getLoadedModules (ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
menv))
]
hasParamModules :: ModuleEnv -> Bool
hasParamModules :: ModuleEnv -> Bool
hasParamModules = Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall b c a. (b -> c) -> (a -> b) -> a -> c
. LoadedModules -> [LoadedModule]
lmLoadedParamModules forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleEnv -> LoadedModules
meLoadedModules
allDeclGroups :: ModuleEnv -> [T.DeclGroup]
allDeclGroups :: ModuleEnv -> [DeclGroup]
allDeclGroups = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall mname. ModuleG mname -> [DeclGroup]
T.mDecls forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleEnv -> [Module]
loadedNonParamModules
data ModContextParams =
InterfaceParams T.ModParamNames
| FunctorParams T.FunctorParams
| NoParams
modContextParamNames :: ModContextParams -> T.ModParamNames
modContextParamNames :: ModContextParams -> ModParamNames
modContextParamNames ModContextParams
mp =
case ModContextParams
mp of
InterfaceParams ModParamNames
ps -> ModParamNames
ps
FunctorParams FunctorParams
ps -> FunctorParams -> ModParamNames
T.allParamNames FunctorParams
ps
ModContextParams
NoParams -> FunctorParams -> ModParamNames
T.allParamNames forall a. Monoid a => a
mempty
data ModContext = ModContext
{ ModContext -> ModContextParams
mctxParams :: ModContextParams
, ModContext -> Set Name
mctxExported :: Set Name
, ModContext -> IfaceDecls
mctxDecls :: IfaceDecls
, ModContext -> NamingEnv
mctxNames :: R.NamingEnv
, ModContext -> NameDisp
mctxNameDisp :: NameDisp
}
instance Semigroup ModContext where
ModContext
x <> :: ModContext -> ModContext -> ModContext
<> ModContext
y = ModContext { mctxParams :: ModContextParams
mctxParams = ModContextParams -> ModContextParams -> ModContextParams
jnPs (ModContext -> ModContextParams
mctxParams ModContext
x) (ModContext -> ModContextParams
mctxParams ModContext
y)
, mctxExported :: Set Name
mctxExported = ModContext -> Set Name
mctxExported ModContext
x forall a. Semigroup a => a -> a -> a
<> ModContext -> Set Name
mctxExported ModContext
y
, mctxDecls :: IfaceDecls
mctxDecls = ModContext -> IfaceDecls
mctxDecls ModContext
x forall a. Semigroup a => a -> a -> a
<> ModContext -> IfaceDecls
mctxDecls ModContext
y
, mctxNames :: NamingEnv
mctxNames = NamingEnv
names
, mctxNameDisp :: NameDisp
mctxNameDisp = NamingEnv -> NameDisp
R.toNameDisp NamingEnv
names
}
where
names :: NamingEnv
names = ModContext -> NamingEnv
mctxNames ModContext
x NamingEnv -> NamingEnv -> NamingEnv
`R.shadowing` ModContext -> NamingEnv
mctxNames ModContext
y
jnPs :: ModContextParams -> ModContextParams -> ModContextParams
jnPs ModContextParams
as ModContextParams
bs =
case (ModContextParams
as,ModContextParams
bs) of
(ModContextParams
NoParams,ModContextParams
_) -> ModContextParams
bs
(ModContextParams
_,ModContextParams
NoParams) -> ModContextParams
as
(FunctorParams FunctorParams
xs, FunctorParams FunctorParams
ys) -> FunctorParams -> ModContextParams
FunctorParams (FunctorParams
xs forall a. Semigroup a => a -> a -> a
<> FunctorParams
ys)
(ModContextParams, ModContextParams)
_ -> forall a. HasCallStack => String -> [String] -> a
panic String
"(<>) @ ModContext" [String
"Can't combine parameters"]
instance Monoid ModContext where
mempty :: ModContext
mempty = ModContext { mctxParams :: ModContextParams
mctxParams = ModContextParams
NoParams
, mctxDecls :: IfaceDecls
mctxDecls = forall a. Monoid a => a
mempty
, mctxExported :: Set Name
mctxExported = forall a. Monoid a => a
mempty
, mctxNames :: NamingEnv
mctxNames = forall a. Monoid a => a
mempty
, mctxNameDisp :: NameDisp
mctxNameDisp = NamingEnv -> NameDisp
R.toNameDisp forall a. Monoid a => a
mempty
}
modContextOf :: ModName -> ModuleEnv -> Maybe ModContext
modContextOf :: ModName -> ModuleEnv -> Maybe ModContext
modContextOf ModName
mname ModuleEnv
me =
do LoadedModule
lm <- ModName -> ModuleEnv -> Maybe LoadedModule
lookupModule ModName
mname ModuleEnv
me
let localIface :: Iface
localIface = LoadedModule -> Iface
lmInterface LoadedModule
lm
localNames :: NamingEnv
localNames = forall a. LoadedModuleG a -> NamingEnv
lmNamingEnv LoadedModule
lm
loadedDecls :: [IfaceDecls]
loadedDecls = forall a b. (a -> b) -> [a] -> [b]
map (forall name. IfaceG name -> IfaceDecls
ifDefines forall b c a. (b -> c) -> (a -> b) -> a -> c
. LoadedModule -> Iface
lmInterface)
forall a b. (a -> b) -> a -> b
$ LoadedModules -> [LoadedModule]
getLoadedModules (ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
me)
params :: FunctorParams
params = forall name. IfaceG name -> FunctorParams
ifParams Iface
localIface
forall (f :: * -> *) a. Applicative f => a -> f a
pure ModContext
{ mctxParams :: ModContextParams
mctxParams = if forall k a. Map k a -> Bool
Map.null FunctorParams
params then ModContextParams
NoParams
else FunctorParams -> ModContextParams
FunctorParams FunctorParams
params
, mctxExported :: Set Name
mctxExported = forall name. IfaceNames name -> Set Name
ifsPublic (forall name. IfaceG name -> IfaceNames name
ifNames Iface
localIface)
, mctxDecls :: IfaceDecls
mctxDecls = forall a. Monoid a => [a] -> a
mconcat (forall name. IfaceG name -> IfaceDecls
ifDefines Iface
localIface forall a. a -> [a] -> [a]
: [IfaceDecls]
loadedDecls)
, mctxNames :: NamingEnv
mctxNames = NamingEnv
localNames
, mctxNameDisp :: NameDisp
mctxNameDisp = NamingEnv -> NameDisp
R.toNameDisp NamingEnv
localNames
}
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
do LoadedSignature
lm <- ModName -> ModuleEnv -> Maybe LoadedSignature
lookupSignature ModName
mname ModuleEnv
me
let localNames :: NamingEnv
localNames = forall a. LoadedModuleG a -> NamingEnv
lmNamingEnv LoadedSignature
lm
loadedDecls :: [IfaceDecls]
loadedDecls = forall a b. (a -> b) -> [a] -> [b]
map (forall name. IfaceG name -> IfaceDecls
ifDefines forall b c a. (b -> c) -> (a -> b) -> a -> c
. LoadedModule -> Iface
lmInterface)
forall a b. (a -> b) -> a -> b
$ LoadedModules -> [LoadedModule]
getLoadedModules (ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
me)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ModContext
{ mctxParams :: ModContextParams
mctxParams = ModParamNames -> ModContextParams
InterfaceParams (forall a. LoadedModuleG a -> a
lmData LoadedSignature
lm)
, mctxExported :: Set Name
mctxExported = forall a. Set a
Set.empty
, mctxDecls :: IfaceDecls
mctxDecls = forall a. Monoid a => [a] -> a
mconcat [IfaceDecls]
loadedDecls
, mctxNames :: NamingEnv
mctxNames = NamingEnv
localNames
, mctxNameDisp :: NameDisp
mctxNameDisp = NamingEnv -> NameDisp
R.toNameDisp NamingEnv
localNames
}
dynModContext :: ModuleEnv -> ModContext
dynModContext :: ModuleEnv -> ModContext
dynModContext ModuleEnv
me = forall a. Monoid a => a
mempty { mctxNames :: NamingEnv
mctxNames = NamingEnv
dynNames
, mctxNameDisp :: NameDisp
mctxNameDisp = NamingEnv -> NameDisp
R.toNameDisp NamingEnv
dynNames
, mctxDecls :: IfaceDecls
mctxDecls = DynamicEnv -> IfaceDecls
deIfaceDecls (ModuleEnv -> DynamicEnv
meDynEnv ModuleEnv
me)
}
where dynNames :: NamingEnv
dynNames = DynamicEnv -> NamingEnv
deNames (ModuleEnv -> DynamicEnv
meDynEnv ModuleEnv
me)
focusedEnv :: ModuleEnv -> ModContext
focusedEnv :: ModuleEnv -> ModContext
focusedEnv ModuleEnv
me =
case ModuleEnv -> Maybe ModName
meFocusedModule ModuleEnv
me of
Maybe ModName
Nothing -> ModuleEnv -> ModContext
dynModContext ModuleEnv
me
Just ModName
fm -> case ModName -> ModuleEnv -> Maybe ModContext
modContextOf ModName
fm ModuleEnv
me of
Just ModContext
c -> ModuleEnv -> ModContext
dynModContext ModuleEnv
me forall a. Semigroup a => a -> a -> a
<> ModContext
c
Maybe ModContext
Nothing -> forall a. HasCallStack => String -> [String] -> a
panic String
"focusedEnv"
[ String
"Focused modules not loaded: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall a. PP a => a -> Doc
pp ModName
fm) ]
data ModulePath = InFile FilePath
| InMem String ByteString
deriving (Int -> ModulePath -> String -> String
[ModulePath] -> String -> String
ModulePath -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [ModulePath] -> String -> String
$cshowList :: [ModulePath] -> String -> String
show :: ModulePath -> String
$cshow :: ModulePath -> String
showsPrec :: Int -> ModulePath -> String -> String
$cshowsPrec :: Int -> ModulePath -> String -> String
Show, forall x. Rep ModulePath x -> ModulePath
forall x. ModulePath -> Rep ModulePath x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModulePath x -> ModulePath
$cfrom :: forall x. ModulePath -> Rep ModulePath x
Generic, ModulePath -> ()
forall a. (a -> ()) -> NFData a
rnf :: ModulePath -> ()
$crnf :: ModulePath -> ()
NFData)
instance Eq ModulePath where
ModulePath
p1 == :: ModulePath -> ModulePath -> Bool
== ModulePath
p2 =
case (ModulePath
p1,ModulePath
p2) of
(InFile String
x, InFile String
y) -> String
x forall a. Eq a => a -> a -> Bool
== String
y
(InMem String
a ByteString
_, InMem String
b ByteString
_) -> String
a forall a. Eq a => a -> a -> Bool
== String
b
(ModulePath, ModulePath)
_ -> Bool
False
instance Ord ModulePath where
compare :: ModulePath -> ModulePath -> Ordering
compare ModulePath
p1 ModulePath
p2 =
case (ModulePath
p1,ModulePath
p2) of
(InFile String
x, InFile String
y) -> forall a. Ord a => a -> a -> Ordering
compare String
x String
y
(InMem String
a ByteString
_, InMem String
b ByteString
_) -> forall a. Ord a => a -> a -> Ordering
compare String
a String
b
(InMem {}, InFile {}) -> Ordering
LT
(InFile {}, InMem {}) -> Ordering
GT
instance PP ModulePath where
ppPrec :: Int -> ModulePath -> Doc
ppPrec Int
_ ModulePath
e =
case ModulePath
e of
InFile String
p -> String -> Doc
text String
p
InMem String
l ByteString
_ -> Doc -> Doc
parens (String -> Doc
text String
l)
modulePathLabel :: ModulePath -> String
modulePathLabel :: ModulePath -> String
modulePathLabel ModulePath
p =
case ModulePath
p of
InFile String
path -> String
path
InMem String
lab ByteString
_ -> String
lab
data LoadedModules = LoadedModules
{ LoadedModules -> [LoadedModule]
lmLoadedModules :: [LoadedModule]
, LoadedModules -> [LoadedModule]
lmLoadedParamModules :: [LoadedModule]
, LoadedModules -> [LoadedSignature]
lmLoadedSignatures :: ![LoadedSignature]
} deriving (Int -> LoadedModules -> String -> String
[LoadedModules] -> String -> String
LoadedModules -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [LoadedModules] -> String -> String
$cshowList :: [LoadedModules] -> String -> String
show :: LoadedModules -> String
$cshow :: LoadedModules -> String
showsPrec :: Int -> LoadedModules -> String -> String
$cshowsPrec :: Int -> LoadedModules -> String -> String
Show, forall x. Rep LoadedModules x -> LoadedModules
forall x. LoadedModules -> Rep LoadedModules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoadedModules x -> LoadedModules
$cfrom :: forall x. LoadedModules -> Rep LoadedModules x
Generic, LoadedModules -> ()
forall a. (a -> ()) -> NFData a
rnf :: LoadedModules -> ()
$crnf :: LoadedModules -> ()
NFData)
data LoadedEntity =
ALoadedModule LoadedModule
| ALoadedFunctor LoadedModule
| ALoadedInterface LoadedSignature
getLoadedEntities ::
LoadedModules -> Map ModName LoadedEntity
getLoadedEntities :: LoadedModules -> Map ModName LoadedEntity
getLoadedEntities LoadedModules
lm =
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall a b. (a -> b) -> a -> b
$ [ (forall a. LoadedModuleG a -> ModName
lmName LoadedModule
x, LoadedModule -> LoadedEntity
ALoadedModule LoadedModule
x) | LoadedModule
x <- LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
lm ] forall a. [a] -> [a] -> [a]
++
[ (forall a. LoadedModuleG a -> ModName
lmName LoadedModule
x, LoadedModule -> LoadedEntity
ALoadedFunctor LoadedModule
x) | LoadedModule
x <- LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
lm ] forall a. [a] -> [a] -> [a]
++
[ (forall a. LoadedModuleG a -> ModName
lmName LoadedSignature
x, LoadedSignature -> LoadedEntity
ALoadedInterface LoadedSignature
x) | LoadedSignature
x <- LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
lm ]
getLoadedModules :: LoadedModules -> [LoadedModule]
getLoadedModules :: LoadedModules -> [LoadedModule]
getLoadedModules LoadedModules
x = LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
x forall a. [a] -> [a] -> [a]
++ LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
x
getLoadedNames :: LoadedModules -> Set ModName
getLoadedNames :: LoadedModules -> Set ModName
getLoadedNames LoadedModules
lm = forall a. Ord a => [a] -> Set a
Set.fromList
forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall a. LoadedModuleG a -> ModName
lmName (LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
lm)
forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map forall a. LoadedModuleG a -> ModName
lmName (LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
lm)
forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map forall a. LoadedModuleG a -> ModName
lmName (LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
lm)
instance Semigroup LoadedModules where
LoadedModules
l <> :: LoadedModules -> LoadedModules -> LoadedModules
<> LoadedModules
r = LoadedModules
{ lmLoadedModules :: [LoadedModule]
lmLoadedModules = forall a. (a -> a -> Bool) -> [a] -> [a] -> [a]
List.unionBy (forall a. Eq a => a -> a -> Bool
(==) forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a. LoadedModuleG a -> ModName
lmName)
(LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
l) (LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
r)
, lmLoadedParamModules :: [LoadedModule]
lmLoadedParamModules = LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
l forall a. [a] -> [a] -> [a]
++ LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
r
, lmLoadedSignatures :: [LoadedSignature]
lmLoadedSignatures = LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
l forall a. [a] -> [a] -> [a]
++ LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
r
}
instance Monoid LoadedModules where
mempty :: LoadedModules
mempty = LoadedModules { lmLoadedModules :: [LoadedModule]
lmLoadedModules = []
, lmLoadedParamModules :: [LoadedModule]
lmLoadedParamModules = []
, lmLoadedSignatures :: [LoadedSignature]
lmLoadedSignatures = []
}
mappend :: LoadedModules -> LoadedModules -> LoadedModules
mappend = forall a. Semigroup a => a -> a -> a
(<>)
data LoadedModuleG a = LoadedModule
{ forall a. LoadedModuleG a -> ModName
lmName :: ModName
, forall a. LoadedModuleG a -> ModulePath
lmFilePath :: ModulePath
, forall a. LoadedModuleG a -> String
lmModuleId :: String
, forall a. LoadedModuleG a -> NamingEnv
lmNamingEnv :: !R.NamingEnv
, forall a. LoadedModuleG a -> FileInfo
lmFileInfo :: !FileInfo
, forall a. LoadedModuleG a -> a
lmData :: a
} deriving (Int -> LoadedModuleG a -> String -> String
forall a. Show a => Int -> LoadedModuleG a -> String -> String
forall a. Show a => [LoadedModuleG a] -> String -> String
forall a. Show a => LoadedModuleG a -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [LoadedModuleG a] -> String -> String
$cshowList :: forall a. Show a => [LoadedModuleG a] -> String -> String
show :: LoadedModuleG a -> String
$cshow :: forall a. Show a => LoadedModuleG a -> String
showsPrec :: Int -> LoadedModuleG a -> String -> String
$cshowsPrec :: forall a. Show a => Int -> LoadedModuleG a -> String -> String
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (LoadedModuleG a) x -> LoadedModuleG a
forall a x. LoadedModuleG a -> Rep (LoadedModuleG a) x
$cto :: forall a x. Rep (LoadedModuleG a) x -> LoadedModuleG a
$cfrom :: forall a x. LoadedModuleG a -> Rep (LoadedModuleG a) x
Generic, forall a. NFData a => LoadedModuleG a -> ()
forall a. (a -> ()) -> NFData a
rnf :: LoadedModuleG a -> ()
$crnf :: forall a. NFData a => LoadedModuleG a -> ()
NFData)
type LoadedModule = LoadedModuleG LoadedModuleData
lmModule :: LoadedModule -> T.Module
lmModule :: LoadedModule -> Module
lmModule = LoadedModuleData -> Module
lmdModule forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> a
lmData
lmInterface :: LoadedModule -> Iface
lmInterface :: LoadedModule -> Iface
lmInterface = LoadedModuleData -> Iface
lmdInterface forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> a
lmData
data LoadedModuleData = LoadedModuleData
{ LoadedModuleData -> Iface
lmdInterface :: Iface
, LoadedModuleData -> Module
lmdModule :: T.Module
, LoadedModuleData -> Maybe ForeignSrc
lmForeignSrc :: Maybe ForeignSrc
} deriving (Int -> LoadedModuleData -> String -> String
[LoadedModuleData] -> String -> String
LoadedModuleData -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [LoadedModuleData] -> String -> String
$cshowList :: [LoadedModuleData] -> String -> String
show :: LoadedModuleData -> String
$cshow :: LoadedModuleData -> String
showsPrec :: Int -> LoadedModuleData -> String -> String
$cshowsPrec :: Int -> LoadedModuleData -> String -> String
Show, forall x. Rep LoadedModuleData x -> LoadedModuleData
forall x. LoadedModuleData -> Rep LoadedModuleData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoadedModuleData x -> LoadedModuleData
$cfrom :: forall x. LoadedModuleData -> Rep LoadedModuleData x
Generic, LoadedModuleData -> ()
forall a. (a -> ()) -> NFData a
rnf :: LoadedModuleData -> ()
$crnf :: LoadedModuleData -> ()
NFData)
type LoadedSignature = LoadedModuleG T.ModParamNames
isLoaded :: ModName -> LoadedModules -> Bool
isLoaded :: ModName -> LoadedModules -> Bool
isLoaded ModName
mn LoadedModules
lm = ModName
mn forall a. Ord a => a -> Set a -> Bool
`Set.member` LoadedModules -> Set ModName
getLoadedNames LoadedModules
lm
isLoadedParamMod :: ModName -> LoadedModules -> Bool
isLoadedParamMod :: ModName -> LoadedModules -> Bool
isLoadedParamMod ModName
mn LoadedModules
ln = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((ModName
mn forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> ModName
lmName) (LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
ln)
isLoadedInterface :: ModName -> LoadedModules -> Bool
isLoadedInterface :: ModName -> LoadedModules -> Bool
isLoadedInterface ModName
mn LoadedModules
ln = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((ModName
mn forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> ModName
lmName) (LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
ln)
lookupTCEntity :: ModName -> ModuleEnv -> Maybe (LoadedModuleG T.TCTopEntity)
lookupTCEntity :: ModName -> ModuleEnv -> Maybe (LoadedModuleG TCTopEntity)
lookupTCEntity ModName
m ModuleEnv
env =
case ModName -> ModuleEnv -> Maybe LoadedModule
lookupModule ModName
m ModuleEnv
env of
Just LoadedModule
lm -> forall (f :: * -> *) a. Applicative f => a -> f a
pure LoadedModule
lm { lmData :: TCTopEntity
lmData = Module -> TCTopEntity
T.TCTopModule (LoadedModule -> Module
lmModule LoadedModule
lm) }
Maybe LoadedModule
Nothing ->
do LoadedSignature
lm <- ModName -> ModuleEnv -> Maybe LoadedSignature
lookupSignature ModName
m ModuleEnv
env
forall (f :: * -> *) a. Applicative f => a -> f a
pure LoadedSignature
lm { lmData :: TCTopEntity
lmData = ModName -> ModParamNames -> TCTopEntity
T.TCTopSignature ModName
m (forall a. LoadedModuleG a -> a
lmData LoadedSignature
lm) }
lookupModule :: ModName -> ModuleEnv -> Maybe LoadedModule
lookupModule :: ModName -> ModuleEnv -> Maybe LoadedModule
lookupModule ModName
mn ModuleEnv
me = forall {t :: * -> *} {a}.
Foldable t =>
(LoadedModules -> t (LoadedModuleG a)) -> Maybe (LoadedModuleG a)
search LoadedModules -> [LoadedModule]
lmLoadedModules forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` forall {t :: * -> *} {a}.
Foldable t =>
(LoadedModules -> t (LoadedModuleG a)) -> Maybe (LoadedModuleG a)
search LoadedModules -> [LoadedModule]
lmLoadedParamModules
where
search :: (LoadedModules -> t (LoadedModuleG a)) -> Maybe (LoadedModuleG a)
search LoadedModules -> t (LoadedModuleG a)
how = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
List.find ((ModName
mn forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> ModName
lmName) (LoadedModules -> t (LoadedModuleG a)
how (ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
me))
lookupSignature :: ModName -> ModuleEnv -> Maybe LoadedSignature
lookupSignature :: ModName -> ModuleEnv -> Maybe LoadedSignature
lookupSignature ModName
mn ModuleEnv
me =
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
List.find ((ModName
mn forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> ModName
lmName) (LoadedModules -> [LoadedSignature]
lmLoadedSignatures (ModuleEnv -> LoadedModules
meLoadedModules ModuleEnv
me))
addLoadedSignature ::
ModulePath -> String ->
FileInfo ->
R.NamingEnv ->
ModName -> T.ModParamNames ->
LoadedModules -> LoadedModules
addLoadedSignature :: ModulePath
-> String
-> FileInfo
-> NamingEnv
-> ModName
-> ModParamNames
-> LoadedModules
-> LoadedModules
addLoadedSignature ModulePath
path String
ident FileInfo
fi NamingEnv
nameEnv ModName
nm ModParamNames
si LoadedModules
lm
| ModName -> LoadedModules -> Bool
isLoaded ModName
nm LoadedModules
lm = LoadedModules
lm
| Bool
otherwise = LoadedModules
lm { lmLoadedSignatures :: [LoadedSignature]
lmLoadedSignatures = LoadedSignature
loaded forall a. a -> [a] -> [a]
: LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
lm }
where
loaded :: LoadedSignature
loaded = LoadedModule
{ lmName :: ModName
lmName = ModName
nm
, lmFilePath :: ModulePath
lmFilePath = ModulePath
path
, lmModuleId :: String
lmModuleId = String
ident
, lmNamingEnv :: NamingEnv
lmNamingEnv = NamingEnv
nameEnv
, lmData :: ModParamNames
lmData = ModParamNames
si
, lmFileInfo :: FileInfo
lmFileInfo = FileInfo
fi
}
addLoadedModule ::
ModulePath ->
String ->
FileInfo ->
R.NamingEnv ->
Maybe ForeignSrc ->
T.Module -> LoadedModules -> LoadedModules
addLoadedModule :: ModulePath
-> String
-> FileInfo
-> NamingEnv
-> Maybe ForeignSrc
-> Module
-> LoadedModules
-> LoadedModules
addLoadedModule ModulePath
path String
ident FileInfo
fi NamingEnv
nameEnv Maybe ForeignSrc
fsrc Module
tm LoadedModules
lm
| ModName -> LoadedModules -> Bool
isLoaded (forall mname. ModuleG mname -> mname
T.mName Module
tm) LoadedModules
lm = LoadedModules
lm
| forall mname. ModuleG mname -> Bool
T.isParametrizedModule Module
tm = LoadedModules
lm { lmLoadedParamModules :: [LoadedModule]
lmLoadedParamModules = LoadedModule
loaded forall a. a -> [a] -> [a]
:
LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
lm }
| Bool
otherwise = LoadedModules
lm { lmLoadedModules :: [LoadedModule]
lmLoadedModules =
LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
lm forall a. [a] -> [a] -> [a]
++ [LoadedModule
loaded] }
where
loaded :: LoadedModule
loaded = LoadedModule
{ lmName :: ModName
lmName = forall mname. ModuleG mname -> mname
T.mName Module
tm
, lmFilePath :: ModulePath
lmFilePath = ModulePath
path
, lmModuleId :: String
lmModuleId = String
ident
, lmNamingEnv :: NamingEnv
lmNamingEnv = NamingEnv
nameEnv
, lmData :: LoadedModuleData
lmData = LoadedModuleData
{ lmdInterface :: Iface
lmdInterface = forall name. ModuleG name -> IfaceG name
T.genIface Module
tm
, lmdModule :: Module
lmdModule = Module
tm
, lmForeignSrc :: Maybe ForeignSrc
lmForeignSrc = Maybe ForeignSrc
fsrc
}
, lmFileInfo :: FileInfo
lmFileInfo = FileInfo
fi
}
removeLoadedModule ::
(forall a. LoadedModuleG a -> Bool) -> LoadedModules -> LoadedModules
removeLoadedModule :: (forall a. LoadedModuleG a -> Bool)
-> LoadedModules -> LoadedModules
removeLoadedModule forall a. LoadedModuleG a -> Bool
rm LoadedModules
lm =
LoadedModules
{ lmLoadedModules :: [LoadedModule]
lmLoadedModules = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> Bool
rm) (LoadedModules -> [LoadedModule]
lmLoadedModules LoadedModules
lm)
, lmLoadedParamModules :: [LoadedModule]
lmLoadedParamModules = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> Bool
rm) (LoadedModules -> [LoadedModule]
lmLoadedParamModules LoadedModules
lm)
, lmLoadedSignatures :: [LoadedSignature]
lmLoadedSignatures = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LoadedModuleG a -> Bool
rm) (LoadedModules -> [LoadedSignature]
lmLoadedSignatures LoadedModules
lm)
}
data FileInfo = FileInfo
{ FileInfo -> Fingerprint
fiFingerprint :: Fingerprint
, FileInfo -> Set String
fiIncludeDeps :: Set FilePath
, FileInfo -> Set ModName
fiImportDeps :: Set ModName
, FileInfo -> Set String
fiForeignDeps :: Set FilePath
} deriving (Int -> FileInfo -> String -> String
[FileInfo] -> String -> String
FileInfo -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [FileInfo] -> String -> String
$cshowList :: [FileInfo] -> String -> String
show :: FileInfo -> String
$cshow :: FileInfo -> String
showsPrec :: Int -> FileInfo -> String -> String
$cshowsPrec :: Int -> FileInfo -> String -> String
Show,forall x. Rep FileInfo x -> FileInfo
forall x. FileInfo -> Rep FileInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileInfo x -> FileInfo
$cfrom :: forall x. FileInfo -> Rep FileInfo x
Generic,FileInfo -> ()
forall a. (a -> ()) -> NFData a
rnf :: FileInfo -> ()
$crnf :: FileInfo -> ()
NFData)
fileInfo ::
Fingerprint ->
Set FilePath ->
Set ModName ->
Maybe ForeignSrc ->
FileInfo
fileInfo :: Fingerprint
-> Set String -> Set ModName -> Maybe ForeignSrc -> FileInfo
fileInfo Fingerprint
fp Set String
incDeps Set ModName
impDeps Maybe ForeignSrc
fsrc =
FileInfo
{ fiFingerprint :: Fingerprint
fiFingerprint = Fingerprint
fp
, fiIncludeDeps :: Set String
fiIncludeDeps = Set String
incDeps
, fiImportDeps :: Set ModName
fiImportDeps = Set ModName
impDeps
, fiForeignDeps :: Set String
fiForeignDeps = forall a. a -> Maybe a -> a
fromMaybe forall a. Set a
Set.empty
do ForeignSrc
src <- Maybe ForeignSrc
fsrc
forall a. a -> Set a
Set.singleton forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ForeignSrc -> Maybe String
getForeignSrcPath ForeignSrc
src
}
data DynamicEnv = DEnv
{ DynamicEnv -> NamingEnv
deNames :: R.NamingEnv
, DynamicEnv -> [DeclGroup]
deDecls :: [T.DeclGroup]
, DynamicEnv -> Map Name TySyn
deTySyns :: Map Name T.TySyn
, DynamicEnv -> EvalEnv
deEnv :: EvalEnv
} deriving forall x. Rep DynamicEnv x -> DynamicEnv
forall x. DynamicEnv -> Rep DynamicEnv x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DynamicEnv x -> DynamicEnv
$cfrom :: forall x. DynamicEnv -> Rep DynamicEnv x
Generic
instance Semigroup DynamicEnv where
DynamicEnv
de1 <> :: DynamicEnv -> DynamicEnv -> DynamicEnv
<> DynamicEnv
de2 = DEnv
{ deNames :: NamingEnv
deNames = DynamicEnv -> NamingEnv
deNames DynamicEnv
de1 forall a. Semigroup a => a -> a -> a
<> DynamicEnv -> NamingEnv
deNames DynamicEnv
de2
, deDecls :: [DeclGroup]
deDecls = DynamicEnv -> [DeclGroup]
deDecls DynamicEnv
de1 forall a. Semigroup a => a -> a -> a
<> DynamicEnv -> [DeclGroup]
deDecls DynamicEnv
de2
, deTySyns :: Map Name TySyn
deTySyns = DynamicEnv -> Map Name TySyn
deTySyns DynamicEnv
de1 forall a. Semigroup a => a -> a -> a
<> DynamicEnv -> Map Name TySyn
deTySyns DynamicEnv
de2
, deEnv :: EvalEnv
deEnv = DynamicEnv -> EvalEnv
deEnv DynamicEnv
de1 forall a. Semigroup a => a -> a -> a
<> DynamicEnv -> EvalEnv
deEnv DynamicEnv
de2
}
instance Monoid DynamicEnv where
mempty :: DynamicEnv
mempty = DEnv
{ deNames :: NamingEnv
deNames = forall a. Monoid a => a
mempty
, deDecls :: [DeclGroup]
deDecls = forall a. Monoid a => a
mempty
, deTySyns :: Map Name TySyn
deTySyns = forall a. Monoid a => a
mempty
, deEnv :: EvalEnv
deEnv = forall a. Monoid a => a
mempty
}
mappend :: DynamicEnv -> DynamicEnv -> DynamicEnv
mappend = forall a. Semigroup a => a -> a -> a
(<>)
deIfaceDecls :: DynamicEnv -> IfaceDecls
deIfaceDecls :: DynamicEnv -> IfaceDecls
deIfaceDecls DEnv { deDecls :: DynamicEnv -> [DeclGroup]
deDecls = [DeclGroup]
dgs, deTySyns :: DynamicEnv -> Map Name TySyn
deTySyns = Map Name TySyn
tySyns } =
IfaceDecls { ifTySyns :: Map Name TySyn
ifTySyns = Map Name TySyn
tySyns
, ifNewtypes :: Map Name Newtype
ifNewtypes = forall k a. Map k a
Map.empty
, ifAbstractTypes :: Map Name AbstractType
ifAbstractTypes = forall k a. Map k a
Map.empty
, ifDecls :: Map Name IfaceDecl
ifDecls = Map Name IfaceDecl
decls
, ifModules :: Map Name (IfaceNames Name)
ifModules = forall k a. Map k a
Map.empty
, ifFunctors :: Map Name (IfaceG Name)
ifFunctors = forall k a. Map k a
Map.empty
, ifSignatures :: Map Name ModParamNames
ifSignatures = forall k a. Map k a
Map.empty
}
where
decls :: Map Name IfaceDecl
decls = forall a. Monoid a => [a] -> a
mconcat
[ forall k a. k -> a -> Map k a
Map.singleton (IfaceDecl -> Name
ifDeclName IfaceDecl
ifd) IfaceDecl
ifd
| Decl
decl <- forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap DeclGroup -> [Decl]
T.groupDecls [DeclGroup]
dgs
, let ifd :: IfaceDecl
ifd = Decl -> IfaceDecl
T.mkIfaceDecl Decl
decl
]