yeganesh 2.2 → 2.2.1
raw patch · 2 files changed
+44/−2 lines, 2 filesdep ~base
Dependency ranges changed: base
Files
- Version.hs +41/−0
- yeganesh.cabal +3/−2
+ Version.hs view
@@ -0,0 +1,41 @@+-- boilerplate {{{+module Version (CurrentFormat, parseCurrentFormat, version) where+import Data.Map (Map, elems, empty)+import Data.Time (UTCTime, getCurrentTime)++type CurrentFormat = FormatV2+version :: String+parseCurrentFormat :: String -> IO CurrentFormat++version = "yeganesh version 2.2.1"+parseCurrentFormat = parseFormatV2+-- }}}+-- v2 {{{+type FormatV2 = (UTCTime, FormatV1)++parseFormatV2 :: String -> IO FormatV2+parseFormatV2 = parse parseFormatV1 upgradeFormatV1+-- }}}+-- v1 {{{+type FormatV1 = Map String Double++upgradeFormatV1 :: FormatV1 -> IO FormatV2+upgradeFormatV1 v1 = fmap (flip (,) popularities) getCurrentTime where+ maximal = case (elems v1, maximum (elems v1)) of+ ([], _) -> 1+ (_ , 0) -> 1+ (_ , m) -> m+ popularities = fmap (/maximal) v1++parseFormatV1 :: String -> IO FormatV1+parseFormatV1 = parse (const (return empty)) return+-- }}}+-- utilities {{{+parse :: Read new => (String -> IO old) -> (old -> IO new) -> (String -> IO new)+parse old upgrade s = maybe (old s >>= upgrade) return (readMaybe s)++readMaybe :: Read a => String -> Maybe a+readMaybe s = case reads s of+ [(x, "")] -> Just x+ _ -> Nothing+-- }}}
yeganesh.cabal view
@@ -1,5 +1,5 @@ name: yeganesh-version: 2.2+version: 2.2.1 cabal-version: >=1.2 build-type: Simple license: BSD3@@ -12,10 +12,11 @@ programs I use every day aren't at the beginning of the list. Let's make it so, and automatically! category: Text+extra-source-files: Version.hs Executable yeganesh main-is: yeganesh.hs- build-depends: base >= 3 && <= 4,+ build-depends: base >= 3 && < 5, containers >= 0.1, directory >= 1.0, filepath >= 1.1,