diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-07 14:46:01 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-07 15:59:16 -0400 |
commit | 63a292324d20832b68c92f784828e55e644481cc (patch) | |
tree | f49c7077caf738cd285681421f9c9baa03068c99 /Types/UUID.hs | |
parent | b08f7c428b4bc9eabd95596d08594ddd1057a0bf (diff) |
add a UUID type
Should have done this a long time ago.
Diffstat (limited to 'Types/UUID.hs')
-rw-r--r-- | Types/UUID.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Types/UUID.hs b/Types/UUID.hs index eb3497fa9..f7232d0b9 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, "")] |