Monadoro 0.2.1.8 → 0.2.1.9
raw patch · 8 files changed
+74/−50 lines, 8 filesdep +template-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: template-haskell
API changes (from Hackage documentation)
- Version: my_version :: FilePath -> IO String
+ Embeds: current_version :: ExpQ
+ TH: version_template :: Q Exp
+ Version: version :: IO String
Files
- Monadoro.cabal +7/−2
- README.md +3/−1
- changelog +4/−0
- src/ArgParse.hs +3/−3
- src/Embeds.hs +29/−0
- src/TH.hs +18/−0
- src/Version.hs +9/−43
- test/Spec.hs +1/−1
Monadoro.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 7767f6c6d2d1be6dce43bee7340e0b209922655948aa448f3a4c1a3c97a15bdd+-- hash: 4687ff8bc26008e3fd0703220c94a7496c612581844a4369c287e9767a003a68 name: Monadoro-version: 0.2.1.8+version: 0.2.1.9 synopsis: A minimalistic CLI Pomodoro timer. description: A Pomodoro timer with two modes: single-pomodoro (default), and four-pomodoro (`--session`). category: Tools@@ -30,7 +30,9 @@ exposed-modules: ArgParse Clock+ Embeds Pomodoro+ TH Timer Version other-modules:@@ -41,6 +43,7 @@ ansi-terminal >=0.8 && <1 , base >=4.7 && <5 , process >=1.0 && <2+ , template-haskell >=2.0 && <3 , time >=1.8 && <2 default-language: Haskell2010 @@ -56,6 +59,7 @@ , ansi-terminal >=0.8 && <1 , base >=4.7 && <5 , process >=1.0 && <2+ , template-haskell >=2.0 && <3 , time >=1.8 && <2 default-language: Haskell2010 @@ -73,5 +77,6 @@ , base >=4.7 && <5 , doctest >=0.8 , process >=1.0 && <2+ , template-haskell >=2.0 && <3 , time >=1.8 && <2 default-language: Haskell2010
README.md view
@@ -6,5 +6,7 @@ ## Goal -The simplest Pomodoro counter, ready to deploy at once on most command-line platforms to enable you to focus on your work in just a few moments, for weeks to come.+The simplest Pomodoro counter, ready to deploy at once on most command-line+platforms to enable you to focus on your work in just a few moments, for weeks+to come.
changelog view
@@ -1,3 +1,7 @@+monadoro (2.1.9)++ * Source version number from package.yaml using TemplateHaskell.+ monadoro (2.1.6) * Bump version using a script.
src/ArgParse.hs view
@@ -10,15 +10,15 @@ import System.Exit import Pomodoro (worker) import Clock (countdown)-import Version (my_version)+import Version (version) usage = putStrLn "Usage: monadoro [-vh] [--session]"-version = my_version "package.yaml" >>= putStrLn :: IO ()+soft_version = version >>= putStrLn :: IO () exit = exitWith ExitSuccess warn = putStrLn "Invalid argument." >> usage >> exitWith (ExitFailure 1) parse ["-h"] = usage >> exit-parse ["-v"] = version >> exit+parse ["-v"] = soft_version >> exit parse ["--session"] = worker parse [] = countdown parse _ = warn
+ src/Embeds.hs view
@@ -0,0 +1,29 @@+#!/usr/bin/env stack+--stack --install-ghc runghc++{-# LANGUAGE TemplateHaskell #-}++module Embeds (current_version)+ where++import System.Environment+import System.Exit+import System.Process+import Version (version)++-- | Read current package version+--+-- Example:+--+-- >>> current_version >>= putStrLn :: IO ()+-- 0.2.1.8+--++-- Embed current package version in the output binary.+--current_version = "%version"+--current_version = $(version)+current_version = [| version |]++--main :: IO ()+--main = current_version >>= putStrLn :: IO ()+
+ src/TH.hs view
@@ -0,0 +1,18 @@+#!/usr/bin/env stack+--stack --install-ghc runghc++{-# LANGUAGE TemplateHaskell #-}++module TH (version_template)+where++import Control.Monad+import Language.Haskell.TH++version_template :: Q Exp+version_template = [| \x -> x + 1 |]++main = version_template++-- More: https://markkarpov.com/tutorial/th.html+
src/Version.hs view
@@ -1,8 +1,7 @@ #!/usr/bin/env stack --stack --install-ghc runghc -module Version (my_version)- where+module Version (version) where import System.Environment import System.Exit@@ -12,53 +11,20 @@ -- -- Example: ----- >>> putStrLn $ my_version--- 0.2.1.7+-- >>> current_version >>= putStrLn :: IO ()+-- 0.2.1.8 -- ---my_version :: IO ([Char])---my_version = do--- let stdin' = ""--- (errCode, stdout', stderr') <- readProcessWithExitCode "./get_version" [""] stdin'--- return stdout'------my_version' :: IO ()---my_version' = putStr $ my_version--- get_version = my_version--- --- show_all = map putStr--- --- exit = exitWith ExitSuccess--- --- all_file = my_version >>= putStr----main = my_version >>= lines >>= unlines >>= putStr---main = show_all $ get_version--- putStrLn . show $ (!!) a 1--- See http://learnyouahaskell.com/input-and-output----my_version :: IO String---my_version = readFile "package.yaml"------firstLine :: String -> String---firstLine = head . lines------first_line_of_file = firstLine $ my_version---- Worked!---my_version = do--- contents <- readFile "package.yaml"--- let version_line = lines contents !! 1--- let version_word = words version_line !! 1--- return version_word--my_version :: FilePath -> IO String-my_version file_name = do+pkg_version :: FilePath -> IO String+pkg_version file_name = do contents <- readFile file_name let version_line = lines contents !! 1 let version_word = words version_line !! 1 return version_word +version :: IO String+version = pkg_version "package.yaml"+ main :: IO ()-main = my_version "package.yaml" >>= putStrLn :: IO ()+main = version >>= putStrLn :: IO ()
test/Spec.hs view
@@ -1,4 +1,4 @@ import Test.DocTest main :: IO ()-main = doctest ["-isrc", "src/Pomodoro.lhs", "src/Clock.lhs", "src/Timer.hs", "src/Version.hs"]+main = doctest ["-isrc", "src/Pomodoro.lhs", "src/Clock.lhs", "src/Timer.hs", "src/Version.hs", "src/TH.hs"]