PPWUPLXPI6R2XJEETPWWYYMW72C4SQXWVJ6XFPVSYF65XBLBFG5AC package idris2-dep-graph-testversion = 0.1.0authors = "Tomáš Zemanovič"-- maintainers =-- license =-- brief =-- readme =-- homepage =-- sourceloc =-- bugtracker =-- the Idris2 version required (e.g. langversion >= 0.5.1)-- langversion-- packages to add to search pathdepends = idris2-dep-graph-- modules to install-- modules =-- main file (i.e. file to load at REPL)main = Main-- name of executableexecutable = "idris2-dep-graph-test"-- opts =sourcedir = "src"-- builddir =-- outputdir =-- script to run before building-- prebuild =-- script to run after building-- postbuild =-- script to run after building, before installing-- preinstall =-- script to run after installing-- postinstall =-- script to run before cleaning-- preclean =-- script to run after cleaning-- postclean =
module Mainmain : IO ()main = putStrLn "Test successful!"
module Mainimport DepGraph.Dataimport DepGraph.Cliimport Idris.Package.Extraimport Idris.Driver.Extraimport Compiler.Commonimport Core.Contextimport Core.Directoryimport Core.InitPrimitivesimport Data.Stringimport Idris.Errorimport Idris.Prettyimport Idris.ModTreeimport Idris.SetOptionsimport Idris.Syntaximport Idris.REPLimport Systemimport System.Fileimport System.Termimport Libraries.Data.StringMapimport Libraries.System.Directory.Treeimport Libraries.Utils.Path%hide Idris.Syntax.Module -- DepGraph.Data.Module---------------------------------------------------------------------------------- Common utils--------------------------------------------------------------------------------loadPkg :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->String ->Core (PkgDesc, String)loadPkg file = dolet Just (root, filename) = splitParent file| _ => throw $ InternalError "Tried to split empty string"let True = isSuffixOf ".ipkg" filename| _ => docoreLift $ putStrLn $"Packages must have an '.ipkg' extension: " ++ show file ++ "."coreLift $ exitWith $ ExitFailure 1setWorkingDir rootpkg <- parsePkgFile True filenamepure (pkg, root)||| Ensure file path is absolute (uses `getWorkingDir`)toAbsolute : String -> Core StringtoAbsolute path = doif isAbsolute paththen pure pathelse dowdir <- getWorkingDirpure $ wdir </> path---------------------------------------------------------------------------------- Modules dependency graph--------------------------------------------------------------------------------processMod :(modFilter : List ModuleIdent -> List ModuleIdent) ->BuildMod ->ModuleprocessMod modFilter mod =MkModule{ name = show mod.buildNS, deps = show <$> modFilter mod.imports}record RawPkgModules whereconstructor MkRawPkgModulesname : Stringroot : String||| Absolute paths to modulesmods : List StringbuildMods : List BuildModprocessPkgMods :ModOpts ->(localMods : List ModuleIdent) ->RawPkgModules ->PkgModulesprocessPkgMods opts localMods rawPkg = dolet MkRawPkgModules { name, root, mods, buildMods } = rawPkglet modules = (processMod modFilter) <$> buildModsMkPkgModules { name, modules }wheremodFilter : List ModuleIdent -> List ModuleIdentmodFilter =if opts.withExternalthen idelse filter $ \mod => any (== mod) localModsgetLocalMods :ModOpts ->(localFiles : List String) ->RawPkgModules ->List ModuleIdentgetLocalMods opts localFiles rawPkg =buildNS <$> (modFilter rawPkg.root) rawPkg.buildModswheremodFilter : String -> List BuildMod -> List BuildModmodFilter dir =if opts.withExternalthen idelse filter $ \mod =>any (\local => (dir </> buildFile mod) == local) localFilesfindPkgModules :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->PkgDesc ->Core (List String)findPkgModules pkg = dowithWarnings $ addDeps pkgrunScript (prebuild pkg)pure $ maybe (map snd (modules pkg))(\m => snd m :: map snd (modules pkg))(mainmod pkg)getAllBuildMods :{auto c : Ref Ctxt Defs} ->{auto o : Ref ROpts REPLOpts} ->FC -> (done : List BuildMod) ->(allFiles : List String) ->Core (List BuildMod)getAllBuildMods fc done [] = pure donegetAllBuildMods fc done (f :: fs) = doms <- getBuildMods fc done fgetAllBuildMods fc (ms ++ done) fsloadPkgModules :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->String ->Core RawPkgModulesloadPkgModules file = do(pkg, root) <- loadPkg filewhenJust (builddir pkg) setBuildDirsetOutputDir (outputdir pkg)mods <- traverse toAbsolute !(findPkgModules pkg)-- There might be duplicates, so if something is already processed, drop itbuildMods <- dropLater <$> getAllBuildMods EmptyFC [] modspure $ MkRawPkgModules { name = pkg.name, root, mods, buildMods }wheredropLater : List BuildMod -> List BuildModdropLater [] = []dropLater (b :: bs)= b :: dropLater (filter (\x => buildFile x /= buildFile b) bs)modMain :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->ModOpts ->List String ->Core ()modMain opts files = dopkgs <- for files loadPkgModuleslet localFiles = concat $ mods <$> pkgslet localMods = concat $ getLocalMods opts localFiles <$> pkgslet modules = (processPkgMods opts localMods) <$> pkgscoreLift $ putStrLn $ show modules---------------------------------------------------------------------------------- Package dependency graph--------------------------------------------------------------------------------processPackage :(isLocal : Bool) ->(localOnly : Bool) ->(localPkgs : List String) ->PkgDesc ->Core PackageprocessPackage isLocal localOnly localPkgs pkg = dopure $ MkPackage pkg.name deps isLocalwheredepName : Depends -> StringdepName dep = dep.pkgnamepkgFilter : List String -> List StringpkgFilter = if localOnlythen filter $ \pkg => any (== pkg) localPkgselse iddeps : List Stringdeps = pkgFilter $ depName <$> pkg.dependsrecord Candidate whereconstructor MkCandidatename : Stringversion : Maybe PkgVersiondirectory : StringtoCandidate : (name : String) -> (String,Maybe PkgVersion) -> CandidatetoCandidate name (dir,v) = MkCandidate name v dirrecord ResolutionError whereconstructor MkREdecisions : List Candidatedepends : Dependsversion : Maybe PkgVersionprepend : Candidate -> ResolutionError -> ResolutionErrorprepend p = { decisions $= (p ::)}reason : Maybe PkgVersion -> Stringreason Nothing = "no matching version is installed."reason (Just x) = "only found version \{show x} which is out of bounds."printResolutionError : ResolutionError -> StringprintResolutionError (MkRE ds d v) = go [<] dswhere go : SnocList String -> List Candidate -> Stringgo ss [] =let pre := "Required \{d.pkgname} \{show d.pkgbounds} but"failure := "\{pre} \{reason v}"candidates := case ss of[<] => ""ss => " Resolved transitive dependencies: " ++ (fastConcat $ intersperse "; " $ cast ss) ++ "."in failure ++ candidatesgo ss (c :: cs) =let v := fromMaybe defaultVersion c.versionin go (ss :< "\{c.name}-\{show v}") csdata ResolutionRes : Type whereResolved : List String -> ResolutionResFailed : List ResolutionError -> ResolutionResprintErrs : (pkgDirs : List String) -> PkgDesc -> List ResolutionError -> StringprintErrs pkgDirs x es =let errors := unlines $ "Failed to resolve the dependencies for \{x.name}:":: map (indent 2 . printResolutionError) esdirs := unlines $ "Searched for packages in:":: map (indent 2) pkgDirsin """\{errors}\{dirs}For more details on what packages Idris2 can locate, run `idris2 --list-packages`"""-- try all possible resolution paths, keeping the first-- that workstryAll : List Candidate-> (Candidate -> Core ResolutionRes)-> Core ResolutionRestryAll ps f = go [<] pswhere go : SnocList ResolutionError-> List Candidate-> Core ResolutionResgo se [] = pure (Failed $ se <>> [])go se (x :: xs) = doFailed errs <- f x | Resolved res => pure (Resolved res)go (se <>< map (prepend x) errs) xspkgDirs :{auto c : Ref Ctxt Defs} ->Core (List String)pkgDirs = dolocaldir <- pkgLocalDirectoryd <- getDirspure (localdir :: (show <$> d.package_search_paths))||| Find all dependencies (transitively) from the given package file.findDeps :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->PkgDesc ->Core (List String)findDeps pkg = doResolved allPkgs <- getTransitiveDeps pkg.depends empty| Failed errs => throw $ GenericMsg EmptyFC (printErrs !pkgDirs pkg errs)log "package.depends" 10 $ "all depends: \{show allPkgs}"pure allPkgswhere-- Note: findPkgDir throws an error if a package is not found-- *unless* --ignore-missing-ipkg is enabled-- therefore, if findPkgDir returns Nothing, skip the package---- We use a backtracking algorithm here: If several versions of-- a package are installed, we must try all, which are are-- potentially in bounds, because their set of dependencies-- might be different across versions and not all of them-- might lead to a resolvable situation.getTransitiveDeps :List Depends ->(done : StringMap (Maybe PkgVersion, String)) ->Core ResolutionResgetTransitiveDeps [] done = doms <- for (StringMap.toList done) $\(pkg, (mv, pkgFile)) => do pure $ (</> pkgFile) <$> !(findPkgDir pkg (exactBounds mv))pure . Resolved $ catMaybes msgetTransitiveDeps (dep :: deps) done =case lookup dep.pkgname done ofJust (mv, pkgFile) =>if inBounds mv dep.pkgbounds-- already resolved dependency is in bounds-- so we keep it and resolve remaining depsthen getTransitiveDeps deps done-- the resolved dependency does not satisfy the-- current bounds. we return an error and backtrackelse pure (Failed [MkRE [] dep $ mv <|> Just defaultVersion])Nothing => dolog "package.depends" 50 "adding new dependency: \{dep.pkgname} (\{show dep.pkgbounds})"pkgDirs <- findPkgDirs dep.pkgname dep.pkgboundslet candidates := toCandidate dep.pkgname <$> pkgDirscase candidates of[] => dodefs <- get Ctxtif defs.options.session.ignoreMissingPkg-- this corresponds to what `findPkgDir` does in-- case of `ignoreMissingPkg` being set to `True`then getTransitiveDeps deps doneelse pure (Failed [MkRE [] dep Nothing])_ => tryAll candidates $ \(MkCandidate name mv pkgDir) => dolet pkgFile = pkgDir </> name <.> "ipkg"True <- coreLift $ exists pkgFile| False => getTransitiveDeps deps (insert name (mv, pkgFile) done)pkg <- parsePkgFile False pkgFilegetTransitiveDeps(pkg.depends ++ deps)(insert pkg.name (pkg.version, pkgFile) done)pkgMain :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->PkgOpts ->List String ->Core ()pkgMain opts files = dolet MkPkgOpts {localOnly} = optspkgsWithRoots <- for files loadPkglet pkgs = fst <$> pkgsWithRootslet localPkgs = (.name) <$> pkgsdeps <- if localOnlythen pure []else do-- Remove duplicatesdeps <- dropLater <$> concat <$> for pkgs findDepspkgsWithRoots <- for deps loadPkglet deps = fst <$> pkgsWithRoots-- There might also be local pkgs in deps, remove those toopure $ filter (\d => all (\local => local /= d.name) localPkgs) depslocal <- for pkgs $ processPackage True localOnly localPkgsdeps <- for deps $ processPackage False localOnly localPkgscoreLift $ putStrLn $ show (local ++ deps)wheredropLater : List String -> List StringdropLater [] = []dropLater (b :: bs)= b :: dropLater (filter (/= b) bs)---------------------------------------------------------------------------------- Common--------------------------------------------------------------------------------setupPackPkgPath :{auto c : Ref Ctxt Defs} ->Core BoolsetupPackPkgPath = do(res, code) <- coreLift $ run "pack package-path"let success = code >= 0when success $traverseList1_ addPackageSearchPath $ splitPaths respure successfindIpkgs : {root : Path} -> Tree root -> IO (List String)findIpkgs t = depthFirst check t (pure [])wherecheck : {root : Path} -> FileName root ->Lazy (IO (List String)) -> IO (List String)check fn next = doif ".ipkg" `isSuffixOf` fileName fnthen do pure $ (toFilePath fn) :: !nextelse next||| If the user did not provide any package file we can look in the working||| directory.localPackageFiles : List String -> Core (List String)localPackageFiles pkgs@(_ :: _) = for pkgs toAbsolutelocalPackageFiles _ = dowdir <- getWorkingDirtree <- coreLift $ filter filePred dirPred <$> (explore $ parse wdir)candidates <- coreLift $ findIpkgs treelet pkgs = filter (".ipkg" `isSuffixOf`) candidatesfor pkgs toAbsolutewherefilePred : {root : _} -> FileName root -> BoolfilePred name = TruedirPred : {root : _} -> FileName root -> BooldirPred name = all (/= fileName name) ignorewhereignore : List Stringignore = [".git", ".pijul"]handleSubCmd :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->List String ->List CLOpt ->Core ()handleSubCmd pathargs opts = dofiles <- localPackageFiles pathargscase subCmd opts ofSubCmdMod opts => modMain opts filesSubCmdPkg opts => pkgMain opts filesquitWithError :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->Error ->Core aquitWithError err = dodoc <- display errmsg <- render doccoreLift (die msg)auxMain : List CLOpt -> Core ()auxMain opts = dodefs <- initDefsc <- newRef Ctxt defss <- newRef Syn initSyntaxsetCG {c} ChezaddPrimitivessetWorkingDir "."let outmode = REPL InfoLvlo <- newRef ROpts (REPL.Opts.defaultOpts Nothing outmode [])True <- setupPackPkgPath| False => updateEnvlet ipkgs = findInputs optsflip catch quitWithError $ handleSubCmd ipkgs optsmain : IO ()main = doRight opts <- getCmdOpts| Left err => do ignore $ fPutStrLn stderr $ "Error: " ++ errexitWith (ExitFailure 1)continue <- quitOpts optswhen continue $ dosetupTermcoreRun (auxMain opts)(\err : Error => do ignore $ fPutStrLn stderr $ "Uncaught error: " ++ show errexitWith (ExitFailure 1))(\res => pure ())
||| Re-exports Idris.Package with some private declarations.|||||| `Idris.Package` private items are visible here because of the common module||| prefix.|||||| Last updated with Idris2 commit 80fd5e4d754888e02a734b05011a98ee4334fd20.module Idris.Package.Extraimport public Idris.Packageimport Idris.Package as Pimport Idris.REPLimport Idris.Syntaximport IdrisPaths||| Emit captured warnings from inner scope and clear them||| afterwards (to avoid emitting them in some unrelated||| codepath later).exportwithWarnings : Ref Ctxt Defs =>Ref Syn SyntaxInfo =>Ref ROpts REPLOpts =>Core a -> Core awithWarnings = P.withWarningsexportrunScript : Maybe (FC, String) -> Core ()runScript = P.runScript||| Add all dependencies (transitively) from the given package file into the||| context so modules from each is accessible during compilation.exportaddDeps :{auto c : Ref Ctxt Defs} ->{auto s : Ref Syn SyntaxInfo} ->{auto o : Ref ROpts REPLOpts} ->PkgDesc ->Core ()addDeps = P.addDeps
||| Re-exports Idris.Driver with some private declarations.|||||| `Idris.Driver` private items are visible here because of the common module||| prefix.|||||| Last updated with Idris2 commit 80fd5e4d754888e02a734b05011a98ee4334fd20.module Idris.Driver.Extraimport public Idris.Driverimport Core.Contextimport Data.List1import Idris.Driver as Dimport Idris.REPLexportupdateEnv : {auto c : Ref Ctxt Defs} ->{auto o : Ref ROpts REPLOpts} ->Core ()updateEnv = D.updateEnvexportsplitPaths : String -> List1 StringsplitPaths = D.splitPaths
module DepGraph.Dataimport Data.String%default totaldquote : String -> Stringdquote str = "\"" ++ str ++ "\""joinSemicolon : List String -> StringjoinSemicolon = joinBy "; "---------------------------------------------------------------------------------- Modules dependency graph--------------------------------------------------------------------------------public exportrecord Module whereconstructor MkModulename : Stringdeps : List Stringpublic exportrecord PkgModules whereconstructor MkPkgModulesname : Stringmodules : List Modulepublic exportPkgsModules : TypePkgsModules = List PkgModulesexportShow PkgsModules whereshow pkgs = "digraph { splines=\"ortho\";" ++ subgraphs ++ edges ++ "}"wheredepEdge : String -> String -> StringdepEdge srcName destName = dquote srcName ++ " -> " ++ dquote destNamemoduleEdge : Module -> StringmoduleEdge mod = joinSemicolon $ depEdge mod.name <$> mod.depspkgEdge : PkgModules -> StringpkgEdge pkg = concat $ moduleEdge <$> pkg.modulesmoduleNode : Module -> StringmoduleNode mod = dquote mod.name ++ "[style=\"filled\", fillcolor=white]"pkgSubgraph : PkgModules -> StringpkgSubgraph pkg =-- prefix the name with "cluster" to group its nodes in a labelled box"subgraph " ++ (dquote $ "cluster_" ++ pkg.name)++ "{"++ "style=\"filled\"; fillcolor = \"linen\";"++ "label=" ++ dquote pkg.name ++ ";"++ (joinSemicolon $ moduleNode <$> pkg.modules)++ "}"subgraphs, edges : Stringsubgraphs = concat $ pkgSubgraph <$> pkgsedges = concat $ pkgEdge <$> pkgs---------------------------------------------------------------------------------- Packages dependency graph--------------------------------------------------------------------------------public exportrecord Package whereconstructor MkPackagename : Stringdeps : List StringisLocal : Boolpublic exportPackages : TypePackages = List PackageexportShow Packages whereshow pkgs = "digraph {" ++ inner ++ "}"wheredepEdge : String -> String -> StringdepEdge srcName destName = dquote srcName ++ " -> " ++ dquote destNamepkgEdge : Package -> List StringpkgEdge pkg = depEdge pkg.name <$> pkg.depspkgNode : Package -> StringpkgNode pkg =(dquote pkg.name)++ "["++ (if pkg.isLocalthen "style=\"filled\"; fillcolor =\"linen\";"else "")++ "]"edges = concat $ pkgEdge <$> pkgsnodes = pkgNode <$> pkgsinner = joinSemicolon (nodes ++ edges)
module DepGraph.Cliimport Data.List1import Data.Stringimport Systempublic exportrecord ModOpts whereconstructor MkModOptswithExternal : Boolpublic exportrecord PkgOpts whereconstructor MkPkgOptslocalOnly : Bool||| CLOpt - possible command line optionspublic exportdata CLOpt=||| Module import graphModule ModOpts |||| Package dependency graphPackage PkgOpts |||| The input Idris fileInputFile String |||| Display help textHelp |||| Display app versionVersiondata OptType= Required String| Optional String| Flag Stringpublic exportdata SubCmd =||| Module import graphSubCmdMod ModOpts |||| Package dependency graphSubCmdPkg PkgOptsShow OptType whereshow (Required a) = "<" ++ a ++ ">"show (Optional a) = "[" ++ a ++ "]"show (Flag a) = "[--" ++ a ++ "]"ActType : List OptType -> TypeActType [] = List CLOptActType (Required a :: as) = String -> ActType asActType (Optional a :: as) = Maybe String -> ActType asActType (Flag a :: as) = Bool -> ActType asrecord OptDesc whereconstructor MkOptflags : List Stringargdescs : List OptTypeaction : ActType argdescshelp : Maybe StringoptSeparator : OptDescoptSeparator = MkOpt [] [] [] NothingshowDefault : Show a => a -> StringshowDefault x = "(default " ++ show x ++ ")"options : List OptDescoptions =[ MkOpt ["package", "pkg", "p"] [Flag "local-only"](\localOnly => [Package $ MkPkgOpts {localOnly}])(Just "(default) Generate a package dependency graph"), MkOpt ["module", "mod", "m"] [Flag "with-external"](\withExternal => [Module $ MkModOpts {withExternal}])(Just "Generate a module import graph"), MkOpt ["--help", "-h", "-?"] [] [Help](Just "Display help text"), MkOpt ["--version", "-v"] [] [Version](Just "Display version string")]optShow : OptDesc -> (String, Maybe String)optShow (MkOpt [] _ _ _) = ("", Just "")optShow (MkOpt flags argdescs action help) =(showSep ", " flags ++ " " ++ showSep " " (map show argdescs), help)whereshowSep : String -> List String -> StringshowSep sep [] = ""showSep sep [x] = xshowSep sep (x :: xs) = x ++ sep ++ showSep sep xsfirstColumnWidth : NatfirstColumnWidth = foldr max 0 $ map (length . fst . optShow) optionsmakeTextFromOptionsOrEnvs : List (String, Maybe String) -> StringmakeTextFromOptionsOrEnvs rows = concatMap (optUsage firstColumnWidth) rowswhereoptUsage : Nat -> (String, Maybe String) -> StringoptUsage maxOpt (optshow, help) =maybe"" -- Don't show anything if there's no help string (that means-- it's an internal option)(\h =>" " ++ optshow ++pack (List.replicate (minus (maxOpt + 2) (length optshow)) ' ') ++h ++ "\n")helpoptsUsage : StringoptsUsage = makeTextFromOptionsOrEnvs $ map optShow options-- TODO get version from .ipkgexportversionMsg : StringversionMsg = "Dep-graph version 0.1.0"exportusage : Stringusage = """\{ versionMsg }Usage: dep-graph [options] [ipkg file...]Available options:\{ optsUsage }"""processArgs : String -> (args : List OptType) -> List String -> ActType args ->Either String (List CLOpt, List String)processArgs flag [] xs f = Right (f, xs)-- Missing required argumentsprocessArgs flag (opt@(Required _) :: as) [] f =Left $ "Missing required argument " ++ show opt ++ " for flag " ++ flagprocessArgs flag (Optional a :: as) [] f =processArgs flag as [] (f Nothing)processArgs flag (Flag a :: as) [] f =processArgs flag as [] (f False)-- Happy casesprocessArgs flag (Required a :: as) (x :: xs) f =processArgs flag as xs (f x)processArgs flag (Optional a :: as) (x :: xs) f =if isPrefixOf "-" xthen processArgs flag as (x :: xs) (f Nothing)else processArgs flag as xs (f $ Just x)processArgs flag (Flag a :: as) (x :: xs) f =if x == "--" ++ athen processArgs flag as xs (f True)else processArgs flag as (x :: xs) (f False)matchFlag : (d : OptDesc) -> List String ->Either String (Maybe (List CLOpt, List String))matchFlag d [] = Right Nothing -- Nothing left to matchmatchFlag d (x :: xs) =if x `elem` flags dthen doargs <- processArgs x (argdescs d) xs (action d)Right (Just args)else Right NothingfindMatch : List OptDesc -> List String ->Either String (List CLOpt, List String)findMatch [] [] = Right ([], [])findMatch [] (f :: args) =case unpack f of'-' :: '-' :: _ => Left "Unknown flag \{f}"_ => Right ([InputFile f], args)findMatch (d :: ds) args =case !(matchFlag d args) ofNothing => findMatch ds argsJust res => Right resparseOpts : List OptDesc -> List String -> Either String (List CLOpt)parseOpts opts [] = Right []parseOpts opts args = do(cl, rest) <- findMatch opts argscls <- assert_total (parseOpts opts rest) -- 'rest' smaller than 'args'pure (cl ++ cls)exportgetCmdOpts : IO (Either String (List CLOpt))getCmdOpts = do(_ :: opts) <- getArgs| _ => pure (Left "Invalid command line")pure $ parseOpts options optsexportfindInputs : List CLOpt -> List StringfindInputs [] = []findInputs (InputFile f :: fs) = f :: findInputs fsfindInputs (_ :: fs) = findInputs fsexportquitOpts : List CLOpt -> IO BoolquitOpts [] = pure TruequitOpts (Version :: _) = doputStrLn versionMsgpure FalsequitOpts (Help :: _) = doputStrLn usagepure FalsequitOpts (_ :: opts) = quitOpts optsexportsubCmd : List CLOpt -> SubCmdsubCmd [] = SubCmdPkg $ MkPkgOpts {localOnly = False} -- defaultsubCmd (Module opts :: _) = SubCmdMod optssubCmd (Package opts :: _) = SubCmdPkg optssubCmd (f :: fs) = subCmd fs
[custom.all.idris2-dep-graph]type = "local"path = "."ipkg = "idris2-dep-graph.ipkg"test = "test/test.ipkg"[custom.all.idris2-dep-graph-test]type = "local"path = "test"ipkg = "test.ipkg"
package idris2-dep-graphversion = 0.1.0authors = "Tomáš Zemanovič"-- maintainers =-- license =-- brief =-- readme =-- homepage =-- sourceloc =-- bugtracker =-- the Idris2 version required (e.g. langversion >= 0.5.1)-- langversion-- packages to add to search pathdepends= idris2 >= 0.8.0-- modules to installmodules= DepGraph.Data, DepGraph.Cli, Idris.Driver.Extra, Idris.Package.Extra-- main file (i.e. file to load at REPL)main = Main-- name of executableexecutable = "idris2-dep-graph"-- opts =sourcedir = "src"-- builddir =-- outputdir =-- script to run before building-- prebuild =-- script to run after building-- postbuild =-- script to run after building, before installing-- preinstall =-- script to run after installing-- postinstall =-- script to run before cleaning-- preclean =-- script to run after cleaning-- postclean =
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!-- Generated by graphviz version 2.43.0 (0)--><!-- Title: %3 Pages: 1 --><svg width="225pt" height="332pt"viewBox="0.00 0.00 225.08 332.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 328)"><title>%3</title><polygon fill="white" stroke="transparent" points="-4,4 -4,-328 221.08,-328 221.08,4 -4,4"/><!-- idris2-dep-graph --><g id="node1" class="node"><title>idris2-dep-graph</title><ellipse fill="linen" stroke="black" cx="108.54" cy="-234" rx="87.99" ry="18"/><text text-anchor="middle" x="108.54" y="-230.3" font-family="Times,serif" font-size="14.00">idris2-dep-graph</text></g><!-- idris2 --><g id="node3" class="node"><title>idris2</title><ellipse fill="none" stroke="black" cx="108.54" cy="-162" rx="37.89" ry="18"/><text text-anchor="middle" x="108.54" y="-158.3" font-family="Times,serif" font-size="14.00">idris2</text></g><!-- idris2-dep-graph->idris2 --><g id="edge1" class="edge"><title>idris2-dep-graph->idris2</title><path fill="none" stroke="black" d="M108.54,-215.7C108.54,-207.98 108.54,-198.71 108.54,-190.11"/><polygon fill="black" stroke="black" points="112.04,-190.1 108.54,-180.1 105.04,-190.1 112.04,-190.1"/></g><!-- idris2-dep-graph-test --><g id="node2" class="node"><title>idris2-dep-graph-test</title><ellipse fill="linen" stroke="black" cx="108.54" cy="-306" rx="108.58" ry="18"/><text text-anchor="middle" x="108.54" y="-302.3" font-family="Times,serif" font-size="14.00">idris2-dep-graph-test</text></g><!-- idris2-dep-graph-test->idris2-dep-graph --><g id="edge2" class="edge"><title>idris2-dep-graph-test->idris2-dep-graph</title><path fill="none" stroke="black" d="M108.54,-287.7C108.54,-279.98 108.54,-270.71 108.54,-262.11"/><polygon fill="black" stroke="black" points="112.04,-262.1 108.54,-252.1 105.04,-262.1 112.04,-262.1"/></g><!-- network --><g id="node5" class="node"><title>network</title><ellipse fill="none" stroke="black" cx="108.54" cy="-90" rx="48.99" ry="18"/><text text-anchor="middle" x="108.54" y="-86.3" font-family="Times,serif" font-size="14.00">network</text></g><!-- idris2->network --><g id="edge3" class="edge"><title>idris2->network</title><path fill="none" stroke="black" d="M108.54,-143.7C108.54,-135.98 108.54,-126.71 108.54,-118.11"/><polygon fill="black" stroke="black" points="112.04,-118.1 108.54,-108.1 105.04,-118.1 112.04,-118.1"/></g><!-- linear --><g id="node4" class="node"><title>linear</title><ellipse fill="none" stroke="black" cx="108.54" cy="-18" rx="37.89" ry="18"/><text text-anchor="middle" x="108.54" y="-14.3" font-family="Times,serif" font-size="14.00">linear</text></g><!-- network->linear --><g id="edge4" class="edge"><title>network->linear</title><path fill="none" stroke="black" d="M108.54,-71.7C108.54,-63.98 108.54,-54.71 108.54,-46.11"/><polygon fill="black" stroke="black" points="112.04,-46.1 108.54,-36.1 105.04,-46.1 112.04,-46.1"/></g></g></svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!-- Generated by graphviz version 2.43.0 (0)--><!-- Title: %3 Pages: 1 --><svg width="797pt" height="171pt"viewBox="0.00 0.00 797.00 171.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 167)"><title>%3</title><polygon fill="white" stroke="transparent" points="-4,4 -4,-167 793,-167 793,4 -4,4"/><g id="clust1" class="cluster"><title>cluster_idris2-dep-graph</title><polygon fill="linen" stroke="black" points="8,-8 8,-155 781,-155 781,-8 8,-8"/><text text-anchor="middle" x="394.5" y="-139.8" font-family="Times,serif" font-size="14.00">idris2-dep-graph</text></g><!-- DepGraph.Data --><g id="node1" class="node"><title>DepGraph.Data</title><ellipse fill="white" stroke="black" cx="99" cy="-34" rx="83.39" ry="18"/><text text-anchor="middle" x="99" y="-30.3" font-family="Times,serif" font-size="14.00">DepGraph.Data</text></g><!-- DepGraph.Cli --><g id="node2" class="node"><title>DepGraph.Cli</title><ellipse fill="white" stroke="black" cx="274" cy="-34" rx="73.39" ry="18"/><text text-anchor="middle" x="274" y="-30.3" font-family="Times,serif" font-size="14.00">DepGraph.Cli</text></g><!-- Idris.Package.Extra --><g id="node3" class="node"><title>Idris.Package.Extra</title><ellipse fill="white" stroke="black" cx="467" cy="-34" rx="102.08" ry="18"/><text text-anchor="middle" x="467" y="-30.3" font-family="Times,serif" font-size="14.00">Idris.Package.Extra</text></g><!-- Idris.Driver.Extra --><g id="node4" class="node"><title>Idris.Driver.Extra</title><ellipse fill="white" stroke="black" cx="680" cy="-34" rx="92.88" ry="18"/><text text-anchor="middle" x="680" y="-30.3" font-family="Times,serif" font-size="14.00">Idris.Driver.Extra</text></g><!-- Main --><g id="node5" class="node"><title>Main</title><ellipse fill="white" stroke="black" cx="370" cy="-106" rx="34.39" ry="18"/><text text-anchor="middle" x="370" y="-102.3" font-family="Times,serif" font-size="14.00">Main</text></g><!-- Main->DepGraph.Data --><g id="edge1" class="edge"><title>Main->DepGraph.Data</title><path fill="none" stroke="black" d="M335.4,-106C262.34,-106 99,-106 99,-106 99,-106 99,-62.17 99,-62.17"/><polygon fill="black" stroke="black" points="102.5,-62.17 99,-52.17 95.5,-62.17 102.5,-62.17"/></g><!-- Main->DepGraph.Cli --><g id="edge2" class="edge"><title>Main->DepGraph.Cli</title><path fill="none" stroke="black" d="M341.5,-95.68C341.5,-95.68 341.5,-51.24 341.5,-51.24"/><polygon fill="black" stroke="black" points="345,-51.24 341.5,-41.24 338,-51.24 345,-51.24"/></g><!-- Main->Idris.Package.Extra --><g id="edge3" class="edge"><title>Main->Idris.Package.Extra</title><path fill="none" stroke="black" d="M384.7,-89.66C384.7,-89.66 384.7,-54.69 384.7,-54.69"/><polygon fill="black" stroke="black" points="388.2,-54.69 384.7,-44.69 381.2,-54.69 388.2,-54.69"/></g><!-- Main->Idris.Driver.Extra --><g id="edge4" class="edge"><title>Main->Idris.Driver.Extra</title><path fill="none" stroke="black" d="M404.66,-106C485.55,-106 680,-106 680,-106 680,-106 680,-62.17 680,-62.17"/><polygon fill="black" stroke="black" points="683.5,-62.17 680,-52.17 676.5,-62.17 683.5,-62.17"/></g></g></svg>
# Idris2-dep-graphProduce graphiz (dot) graph of package dependencies or module imports of Idris2 packages.## UsageThis app works by default with [pack](https://github.com/stefan-hoeck/idris2-pack) by looking up its package dir via `pack package-path`. Alternatively, you can use the same env vars as with Idris2 (e.g. `IDRIS2_PACKAGE_PATH`).To use, run the tool in the directory of the package(s) of interest:```bash# Package dependency graph# Use `--local-only` to exclude non-local packageidris2-dep-graph pkg# Module imports graph:# Use `--with-external` to include modules imported from other packages (non-transitive)idris2-dep-graph mod# Usually you'll just pipe the result to `dot` and save the resultidris2-dep-graph ... | dot -Tsvg > graph.svg```You can give it one or more .ipkg paths after the sub-command for a specific selection. If you don't specify any .ipkg paths, it will recursively look for all in the current dir.## Example outputs on this package### Package dependencies### Module imports
# Idrisbuild/
build/*.*~.pijul