diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-03-29 23:25:10 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-03-29 23:25:10 +0200 |
| commit | f21dcde54b09913550036e6501cca935278597d9 (patch) | |
| tree | 505f373b1bce690f0bafc2038636721126d9bcad /src/Util.hs | |
Initial
Diffstat (limited to 'src/Util.hs')
| -rw-r--r-- | src/Util.hs | 31 |
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 |
