-import "String"\r
-import "StringBuilder" as StringBuilder\r
-import "IterN"\r
-\r
-@private\r
-importJava "org.simantics.scl.compiler.errors.Failable" where\r
- data Failable a\r
- \r
- @JavaName getResult\r
- resultOfFailable :: Failable a -> Maybe a\r
-\r
-@private\r
-importJava "org.simantics.scl.compiler.module.ImportDeclaration" where\r
- data ImportDeclaration\r
-\r
- @JavaName moduleName\r
- moduleNameOfImportDeclaration :: ImportDeclaration -> String\r
- @JavaName localName\r
- localNameOfImportDeclaration :: ImportDeclaration -> Maybe String\r
- @JavaName getSpecString\r
- importSpecOfImportDeclaration :: ImportDeclaration -> String\r
-\r
-@private \r
-importJava "org.simantics.scl.compiler.module.Module" where\r
- data Module \r
- @JavaName getDependencies\r
- dependenciesOf :: Module -> [ImportDeclaration]\r
-\r
-@private\r
-importJava "org.simantics.scl.compiler.elaboration.modules.SCLValue" where\r
- data Value\r
- @JavaName getName\r
- nameOfValue :: Value -> Name\r
- @JavaName getType\r
- typeOfValue :: Value -> Type\r
-\r
-@private\r
-importJava "org.simantics.scl.compiler.common.names.Name" where\r
- data Name\r
- @JavaName name\r
- nameOfName :: Name -> String\r
- @JavaName module\r
- moduleOfName :: Name -> String\r
-\r
-@private\r
-importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where\r
- data ModuleRepository\r
- \r
- @JavaName getModule\r
- findModule :: ModuleRepository -> String -> <Proc> Failable Module\r
- \r
- @JavaName getValueRef\r
- findValueRef :: ModuleRepository -> String -> <Proc> Value\r
- \r
- @JavaName getValue\r
- findValue :: ModuleRepository -> String -> <Proc> a\r
- \r
- @JavaName getSourceRepository\r
- sourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository\r
-\r
-@private\r
-importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where\r
- data ModuleSourceRepository\r
- \r
-@private\r
-importJava "org.simantics.scl.compiler.module.repository.ModuleRepositories" where\r
- allValues :: ModuleRepository -> <Proc> [Value]\r
- allValuesMatching :: ModuleRepository -> String -> <Proc> [Value]\r
- \r
-@private \r
-importJava "org.simantics.scl.compiler.source.repository.SourceRepositories" where\r
- @JavaName getModuleNames\r
- moduleNames :: ModuleSourceRepository -> <Proc> [String]\r
-\r
-@private\r
-importJava "org.simantics.scl.osgi.SCLOsgi" where\r
- @JavaName MODULE_REPOSITORY\r
- ModuleRepository :: ModuleRepository\r
-\r
-@private\r
-printTable :: [[String]] -> <Proc> ()\r
-printTable [] = ()\r
-printTable rows = iter printRow rows \r
- where\r
- columnCount = maximum (map length rows)\r
- columnWidth i = maximum (map ithColumnWidth rows)\r
- where\r
- ithColumnWidth cols | length cols <= i = 0\r
- | otherwise = length (cols!i) \r
- columnWidths = mapN columnWidth columnCount\r
- printColumn i sb col = foldlN (\sb _ -> sb << " ") (sb << col) (columnWidths!i + 1 - length col)\r
- printRow row = print $ StringBuilder.toString $ foldlI printColumn StringBuilder.new row \r
-\r
-searchValue :: String -> <Proc> ()\r
-searchValue pattern = printTable $ sort $ map tableRow $ allValuesMatching ModuleRepository pattern\r
- where\r
- tableRow value = [\r
- moduleOfName $ nameOfValue value,\r
- nameOfName $ nameOfValue value,\r
- ":: " + (show $ removeForAll $ typeOfValue value)]\r
-\r
-moduleDependencyGraph :: <Proc> [(String, [(String, Maybe String, String)])]\r
-moduleDependencyGraph = mapMaybe\r
- (\moduleName -> catch \r
- (match resultOfFailable $ findModule ModuleRepository moduleName with\r
- Just module -> Just (moduleName, findDependencies module)\r
- Nothing -> Nothing\r
- ) \r
- $ \(_ :: Exception) -> Nothing\r
- ) \r
- (moduleNames $ sourceRepositoryOf ModuleRepository)\r
- where\r
- mapImportDeclaration decl = (moduleNameOfImportDeclaration decl,\r
- localNameOfImportDeclaration decl,\r
- importSpecOfImportDeclaration decl)\r
+import "String"
+import "StringBuilder" as StringBuilder
+import "IterN"
+
+@private
+importJava "org.simantics.scl.compiler.errors.Failable" where
+ data Failable a
+
+ @JavaName getResult
+ resultOfFailable :: Failable a -> Maybe a
+
+@private
+importJava "org.simantics.scl.compiler.module.ImportDeclaration" where
+ data ImportDeclaration
+
+ @JavaName moduleName
+ moduleNameOfImportDeclaration :: ImportDeclaration -> String
+ @JavaName localName
+ localNameOfImportDeclaration :: ImportDeclaration -> Maybe String
+ @JavaName getSpecString
+ importSpecOfImportDeclaration :: ImportDeclaration -> String
+
+@private
+importJava "org.simantics.scl.compiler.module.Module" where
+ data Module
+ @JavaName getDependencies
+ dependenciesOf :: Module -> [ImportDeclaration]
+
+@private
+importJava "org.simantics.scl.compiler.elaboration.modules.SCLValue" where
+ data Value
+ @JavaName getName
+ nameOfValue :: Value -> Name
+ @JavaName getType
+ typeOfValue :: Value -> Type
+
+@private
+importJava "org.simantics.scl.compiler.common.names.Name" where
+ data Name
+ @JavaName name
+ nameOfName :: Name -> String
+ @JavaName module
+ moduleOfName :: Name -> String
+
+@private
+importJava "org.simantics.scl.compiler.module.repository.ModuleRepository" where
+ data ModuleRepository
+
+ @JavaName getModule
+ findModule :: ModuleRepository -> String -> <Proc> Failable Module
+
+ @JavaName getValueRef
+ findValueRef :: ModuleRepository -> String -> <Proc> Value
+
+ @JavaName getValue
+ findValue :: ModuleRepository -> String -> <Proc> a
+
+ @JavaName getSourceRepository
+ sourceRepositoryOf :: ModuleRepository -> ModuleSourceRepository
+
+@private
+importJava "org.simantics.scl.compiler.source.repository.ModuleSourceRepository" where
+ data ModuleSourceRepository
+
+@private
+importJava "org.simantics.scl.compiler.module.repository.ModuleRepositories" where
+ allValues :: ModuleRepository -> <Proc> [Value]
+ allValuesMatching :: ModuleRepository -> String -> <Proc> [Value]
+
+@private
+importJava "org.simantics.scl.compiler.source.repository.SourceRepositories" where
+ @JavaName getModuleNames
+ moduleNames :: ModuleSourceRepository -> <Proc> [String]
+
+@private
+importJava "org.simantics.scl.osgi.SCLOsgi" where
+ @JavaName MODULE_REPOSITORY
+ ModuleRepository :: ModuleRepository
+
+@private
+printTable :: [[String]] -> <Proc> ()
+printTable [] = ()
+printTable rows = iter printRow rows
+ where
+ columnCount = maximum (map length rows)
+ columnWidth i = maximum (map ithColumnWidth rows)
+ where
+ ithColumnWidth cols | length cols <= i = 0
+ | otherwise = length (cols!i)
+ columnWidths = mapN columnWidth columnCount
+ printColumn i sb col = foldlN (\sb _ -> sb << " ") (sb << col) (columnWidths!i + 1 - length col)
+ printRow row = print $ StringBuilder.toString $ foldlI printColumn StringBuilder.new row
+
+searchValue :: String -> <Proc> ()
+searchValue pattern = printTable $ sort $ map tableRow $ allValuesMatching ModuleRepository pattern
+ where
+ tableRow value = [
+ moduleOfName $ nameOfValue value,
+ nameOfName $ nameOfValue value,
+ ":: " + (show $ removeForAll $ typeOfValue value)]
+
+moduleDependencyGraph :: <Proc> [(String, [(String, Maybe String, String)])]
+moduleDependencyGraph = mapMaybe
+ (\moduleName -> catch
+ (match resultOfFailable $ findModule ModuleRepository moduleName with
+ Just module -> Just (moduleName, findDependencies module)
+ Nothing -> Nothing
+ )
+ $ \(_ :: Exception) -> Nothing
+ )
+ (moduleNames $ sourceRepositoryOf ModuleRepository)
+ where
+ mapImportDeclaration decl = (moduleNameOfImportDeclaration decl,
+ localNameOfImportDeclaration decl,
+ importSpecOfImportDeclaration decl)