Last active
December 31, 2015 09:29
-
-
Save carymrobbins/7966732 to your computer and use it in GitHub Desktop.
Output dependency versions for cabal sandbox.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env runghc | |
| import Data.Tuple | |
| import System.Process | |
| main = do | |
| out <- getBash "ls .cabal-sandbox/lib/*" | |
| let packages = lines out | |
| let packageVersions = map (tjoin "==" . splitVersion) packages | |
| putStrLn . unlines $ packageVersions | |
| getBash cmd = readProcess "bash" ["-c", cmd] "" | |
| splitOn p = fmap (drop 1) . break p | |
| splitVersion = swap . tmap reverse . splitOn (=='-') . reverse | |
| tmap f (x, y) = (f x, f y) | |
| tjoin s (x, y) = x ++ s ++ y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import commands | |
| import re | |
| out = commands.getoutput('ls .cabal-sandbox/lib/*') | |
| packages = out.split('\n') | |
| package_names = [re.split(r'\-\d\.', x, maxsplit=1)[0] for x in packages] | |
| package_map = zip(package_names, packages) | |
| version_map = [(k, v[len(k)+1:]) for k, v in package_map] | |
| result = '\n'.join("{}=={}".format(k, v) for k, v in version_map) | |
| print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment