add a UUID type

Should have done this a long time ago.
This commit is contained in:
Joey Hess 2011-11-07 14:46:01 -04:00
parent b08f7c428b
commit 63a292324d
18 changed files with 67 additions and 55 deletions

View file

@ -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, "")]