summaryrefslogtreecommitdiff
path: root/Types/UUID.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-11-07 23:21:22 -0400
committerJoey Hess <joey@kitenet.net>2011-11-08 00:17:54 -0400
commitb11a63a860e8446cf3a4b35a5d8ef76329d5135c (patch)
treec8ae0c94d6473a3ccc7b15bdbc72d5b5c6ae96b3 /Types/UUID.hs
parentfdf988be6d2b3bb931a9eb3dcf3fbb83b1fb8c17 (diff)
clean up read/show abuse
Avoid ever using read to parse a non-haskell formatted input string. show :: Key is arguably still show abuse, but displaying Keys as filenames is just too useful to give up.
Diffstat (limited to 'Types/UUID.hs')
-rw-r--r--Types/UUID.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/Types/UUID.hs b/Types/UUID.hs
index f7232d0b97..767cd0dfe8 100644
--- a/Types/UUID.hs
+++ b/Types/UUID.hs
@@ -9,13 +9,12 @@ module Types.UUID where
-- A UUID is either an arbitrary opaque string, or UUID info may be missing.
data UUID = NoUUID | UUID String
- deriving (Eq, Ord)
+ deriving (Eq, Ord, Show)
-instance Show UUID where
- show (UUID u) = u
- show NoUUID = ""
+fromUUID :: UUID -> String
+fromUUID (UUID u) = u
+fromUUID NoUUID = ""
-instance Read UUID where
- readsPrec _ s
- | null s = [(NoUUID, "")]
- | otherwise = [(UUID s, "")]
+toUUID :: String -> UUID
+toUUID [] = NoUUID
+toUUID s = UUID s