summaryrefslogtreecommitdiff
path: root/src/Util.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Util.hs')
-rw-r--r--src/Util.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Util.hs b/src/Util.hs
new file mode 100644
index 0000000..ca31258
--- /dev/null
+++ b/src/Util.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE DeriveFoldable #-}
+module Util (module Util, toList) where
+
+import Data.Foldable (toList)
+import Data.Word (Word8)
+
+
+data Snoc a = SnocNil | Snoc (Snoc a) a
+ deriving (Show, Foldable)
+
+-- | Time-of-day, in unspecified time zone
+data YMDHMS = YMDHMS {-# UNPACK #-} !YMD
+ {-# UNPACK #-} !HMS
+ deriving (Show)
+
+-- | Calendar day
+data YMD = YMD {-# UNPACK #-} !Int
+ {-# UNPACK #-} !Word8 -- ^ 1-based
+ {-# UNPACK #-} !Word8
+ deriving (Show)
+
+-- | Time-of-day in seconds, in unspecified time zone
+data HMS = HMS {-# UNPACK #-} !Word8
+ {-# UNPACK #-} !Word8
+ {-# UNPACK #-} !Word8
+ deriving (Show)
+
+pad :: Show a => Char -> Int -> a -> String
+pad c w val =
+ let s = show val
+ in replicate (w - length s) c ++ s