Skip to content

Commit

Permalink
Add IO interface for autotimestamping
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-volkov committed Mar 1, 2018
1 parent dc5cdbc commit 690422e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion eternity-timestamped.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name:
eternity-timestamped
version:
0.2.1
0.2.2
synopsis:
Automatic timestamping for Eternity
category:
Expand Down Expand Up @@ -40,6 +40,7 @@ library
Haskell2010
exposed-modules:
Eternity.Timestamped.Data
Eternity.Timestamped.IO
Eternity.Timestamped.Foldl
Eternity.Timestamped.Potoki.Consume
Eternity.Timestamped.Potoki.Produce
Expand Down
12 changes: 12 additions & 0 deletions library/Eternity/Timestamped/IO.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Eternity.Timestamped.IO
where

import Eternity.Timestamped.Prelude
import Eternity.Timestamped.Data


timestamp :: event -> IO (Timestamped event)
timestamp event =
do
posixTime <- getPOSIXTime
return (Timestamped (posixTimeTimestamp posixTime) event)
5 changes: 2 additions & 3 deletions library/Eternity/Timestamped/Potoki/Transform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ where
import Eternity.Timestamped.Prelude
import Eternity.Timestamped.Data
import Potoki.Transform
import qualified Eternity.Timestamped.IO as A


{-|
Expand All @@ -18,6 +19,4 @@ E.g., you can apply it to 'Eternity.Timestamped.Potoki.Consume.writeToDir':
-}
timestamp :: Transform event (Timestamped event)
timestamp =
mapInIO $ \ event -> do
posixTime <- getPOSIXTime
return (Timestamped (posixTimeTimestamp posixTime) event)
mapInIO A.timestamp

0 comments on commit 690422e

Please sign in to comment.