summaryrefslogtreecommitdiff
path: root/Types/UUID.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-11-07 14:46:01 -0400
committerJoey Hess <joey@kitenet.net>2011-11-07 15:59:16 -0400
commit63a292324d20832b68c92f784828e55e644481cc (patch)
treef49c7077caf738cd285681421f9c9baa03068c99 /Types/UUID.hs
parentb08f7c428b4bc9eabd95596d08594ddd1057a0bf (diff)
add a UUID type
Should have done this a long time ago.
Diffstat (limited to 'Types/UUID.hs')
-rw-r--r--Types/UUID.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/Types/UUID.hs b/Types/UUID.hs
index eb3497fa94..f7232d0b97 100644
--- a/Types/UUID.hs
+++ b/Types/UUID.hs
@@ -7,5 +7,15 @@
module Types.UUID where
--- might be nice to have a newtype, but lots of stuff treats uuids as strings
-type UUID = String
+-- A UUID is either an arbitrary opaque string, or UUID info may be missing.
+data UUID = NoUUID | UUID String
+ deriving (Eq, Ord)
+
+instance Show UUID where
+ show (UUID u) = u
+ show NoUUID = ""
+
+instance Read UUID where
+ readsPrec _ s
+ | null s = [(NoUUID, "")]
+ | otherwise = [(UUID s, "")]