module { export = [possibleUnsafeSclValueByName, unsafeSclValueByName, sclModuleNames, moduleByName] } include "./CurrentModuleRepository" include "./Module" importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where // data ModuleRepository // defined in CurrentModuleRepository @JavaName getValue unsafeSclValueByName_ :: ModuleRepository -> String -> a @JavaName getSourceRepository moduleSourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository @JavaName getModule moduleByName_ :: ModuleRepository -> String -> Failable Module importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where data ModuleSourceRepository @JavaName getModuleNames sclModuleNames_ :: ModuleSourceRepository -> [String] importJava "org.simantics.scl.compiler.errors.Failable" where data Failable a didSucceed :: Failable a -> Boolean getResult :: Failable a -> Maybe a unsafeSclValueByName :: String -> a unsafeSclValueByName = unsafeSclValueByName_ MODULE_REPOSITORY possibleUnsafeSclValueByName :: String -> Maybe a possibleUnsafeSclValueByName name = Just (unsafeSclValueByName name) `catch` \(_ :: Exception) -> Nothing sclModuleNames :: [String] sclModuleNames = sclModuleNames_ (moduleSourceRepositoryOf MODULE_REPOSITORY) moduleByName :: String -> Maybe Module moduleByName name = getResult failable where failable = moduleByName_ MODULE_REPOSITORY name