summaryrefslogtreecommitdiff
path: root/Database/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Database/Types.hs')
-rw-r--r--Database/Types.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/Database/Types.hs b/Database/Types.hs
index 1476a693a..6667bc343 100644
--- a/Database/Types.hs
+++ b/Database/Types.hs
@@ -27,6 +27,24 @@ fromSKey (SKey s) = fromMaybe (error $ "bad serialied Key " ++ s) (file2key s)
derivePersistField "SKey"
+-- A Key index. More efficient than SKey, but its Read instance does not
+-- work when it's used in any kind of complex data structure.
+newtype IKey = IKey String
+
+instance Read IKey where
+ readsPrec _ s = [(IKey s, "")]
+
+instance Show IKey where
+ show (IKey s) = s
+
+toIKey :: Key -> IKey
+toIKey = IKey . key2file
+
+fromIKey :: IKey -> Key
+fromIKey (IKey s) = fromMaybe (error $ "bad serialied Key " ++ s) (file2key s)
+
+derivePersistField "IKey"
+
-- A serialized InodeCache
newtype SInodeCache = I String
deriving (Show, Read)