From 381ffaf8c61dca8930a45e413fbcb8df404dd4c3 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 24 Feb 2023 02:40:13 -0800 Subject: [PATCH] Print current time --- app/Main.hs | 7 ++++++- haskell-clock.cabal | 3 +++ package.yaml | 1 + src/Lib.hs | 12 +++++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 74c45f0..1de115b 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -3,4 +3,9 @@ module Main (main) where import Lib main :: IO () -main = putStrLn someFunc +main = do + putStrLn "haskell-clock" + t <- curTimeString + putStrLn t + + diff --git a/haskell-clock.cabal b/haskell-clock.cabal index cb79f29..168f353 100644 --- a/haskell-clock.cabal +++ b/haskell-clock.cabal @@ -33,6 +33,7 @@ library ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints build-depends: base >=4.7 && <5 + , time default-language: Haskell2010 executable haskell-clock-exe @@ -45,6 +46,7 @@ executable haskell-clock-exe build-depends: base >=4.7 && <5 , haskell-clock + , time default-language: Haskell2010 test-suite haskell-clock-test @@ -58,4 +60,5 @@ test-suite haskell-clock-test build-depends: base >=4.7 && <5 , haskell-clock + , time default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index 27e1e44..7b5c2b8 100644 --- a/package.yaml +++ b/package.yaml @@ -21,6 +21,7 @@ description: Please see the README on GitHub at = 4.7 && < 5 +- time ghc-options: - -Wall diff --git a/src/Lib.hs b/src/Lib.hs index 54781bc..3544653 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -1,6 +1,12 @@ module Lib - ( someFunc + ( + curTimeString ) where -someFunc :: String -someFunc = "someFunc" +import Data.Time.Clock + +curTimeString :: IO String +curTimeString = do + t <- getCurrentTime + return $ show $ t +