summaryrefslogtreecommitdiff
path: root/Coolbal/DataVersionTag.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-07-11 17:56:34 +0200
committerTom Smeding <tom@tomsmeding.com>2021-07-11 17:56:34 +0200
commitf57e800a1d1a8e9f2bed34428f7f58a375f178fb (patch)
tree7164b0a9bcf03703a6a7f44f5fa04e5847d876e5 /Coolbal/DataVersionTag.hs
parent317f1e27688a082926f39ec897f5a38d01a07ce7 (diff)
WIP splitting of Target module and towards parallel buildsHEADmaster
Diffstat (limited to 'Coolbal/DataVersionTag.hs')
-rw-r--r--Coolbal/DataVersionTag.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Coolbal/DataVersionTag.hs b/Coolbal/DataVersionTag.hs
new file mode 100644
index 0000000..a994e90
--- /dev/null
+++ b/Coolbal/DataVersionTag.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE KindSignatures #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE TypeOperators #-}
+module Coolbal.DataVersionTag where
+
+import Data.Binary
+import GHC.TypeNats
+
+
+data DataVersionTag (n :: Nat) = DataVersionTag
+ deriving (Show, Eq, Ord)
+
+instance (KnownNat n, n <= 255) => Binary (DataVersionTag n) where
+ put v = putWord8 (fromIntegral (natVal v))
+ get = do
+ b <- getWord8
+ let result = DataVersionTag :: DataVersionTag n
+ if b == fromIntegral (natVal result)
+ then return result
+ else fail ("DataVersionTag: read version " ++ show b ++ ", application expects version " ++ show (natVal result))