packages feed

format-status (empty) → 0.1.0.2

raw patch · 4 files changed

+107/−0 lines, 4 filesdep +basedep +data-concurrent-queuedep +old-localesetup-changed

Dependencies added: base, data-concurrent-queue, old-locale, text, time

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 George Rogers++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Main.lhs view
@@ -0,0 +1,60 @@+> {-# LANGUAGE OverloadedStrings, FlexibleContexts #-}+> module Main where++> import Control.Concurrent+> import qualified Data.Text as T+> import qualified Data.Text.IO as TIO+> import Control.Exception+> import System.IO.Error (IOError)+> import Data.Time+> import System.IO+> import System.Locale+> import qualified Data.Concurrent.Queue as Q++> data Msg = Line T.Text+>          | Tick+>          | Done++> gitLine :: IO (Either IOError T.Text)+> gitLine = try TIO.getLine++> ticksProc :: (Q.PutQueue q IO) => Int -> q Msg -> IO ()+> ticksProc interval chan = do+>   threadDelay (interval * 10)+>   Q.put chan $! Tick+>   ticksProc interval chan++> linesProc :: (Q.PutQueue q IO) => q Msg -> IO ()+> linesProc chan = do+>   l <- gitLine+>   case l of+>     Left err -> do+>       Q.put chan Done+>     Right line -> do+>       Q.put chan $! Line line+>       linesProc chan++> output :: (Q.TakeQueue q IO) => T.Text -> q Msg -> IO ()+> output state chan = do+>   m <- Q.take chan+>   case m of+>     Done ->+>       return ()+>     Tick ->+>       display state chan+>     Line line ->+>       display line chan++> display :: (Q.TakeQueue q IO) => T.Text -> q Msg -> IO ()+> display txt chan = do+>   time <- getZonedTime+>   TIO.putStrLn $ T.concat [txt, " | ^fg(#00ff00)", T.pack $ formatTime defaultTimeLocale (iso8601DateFormat $ Just "%H:%M:%S") time]+>   hFlush stdout+>   output txt chan++> main :: IO ()+> main = do+>   chan <- newChan+>   _ <- forkIO $ linesProc chan+>   _ <- forkIO $ ticksProc 500 chan+>   output "" chan
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ format-status.cabal view
@@ -0,0 +1,25 @@+-- Initial format-status.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++name:                format-status+version:             0.1.0.2+synopsis:            A utility for writing the date to dzen2.+-- description:         +license:             MIT+license-file:        LICENSE+author:              George Rogers+-- maintainer:          +-- copyright:           +-- category:            +build-type:          Simple+-- extra-source-files:  +cabal-version:       >=1.10++executable format-status+  main-is:             Main.lhs+  -- other-modules:       +  other-extensions:    OverloadedStrings+  build-depends:       base >=4.5 && <4.6, text >=1.1 && <1.2, time >=1.4 && <1.5, old-locale >=1.0.0 && <1.1.0, data-concurrent-queue == 0.3.0.0+  -- hs-source-dirs:      +  default-language:    Haskell2010+  ghc-options:         -O2