diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-10-08 16:55:11 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-10-08 16:55:11 -0400 |
commit | d5494842274030d21356c7492e6de5969173c34d (patch) | |
tree | a1c25eacba4e6b98b0b1bf275a89ecc7ea0e20d2 /Types/UUID.hs | |
parent | 55fb90edfc8732b08bea9239a6f4a471ac7867c3 (diff) |
add VerifiedCopy data type
There should be no behavior changes in this commit, it just adds a more
expressive data type and adjusts code that had been passing around a [UUID]
or sometimes a Maybe Remote to instead use [VerifiedCopy].
Although, since some functions were taking two different [UUID] lists,
there's some potential for me to have gotten it horribly wrong.
Diffstat (limited to 'Types/UUID.hs')
-rw-r--r-- | Types/UUID.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Types/UUID.hs b/Types/UUID.hs index de7ddd65d..27d82b86c 100644 --- a/Types/UUID.hs +++ b/Types/UUID.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} + module Types.UUID where import qualified Data.Map as M @@ -19,9 +21,12 @@ fromUUID :: UUID -> String fromUUID (UUID u) = u fromUUID NoUUID = "" -toUUID :: String -> UUID -toUUID [] = NoUUID -toUUID s = UUID s +class ToUUID a where + toUUID :: a -> UUID + +instance ToUUID String where + toUUID [] = NoUUID + toUUID s = UUID s isUUID :: String -> Bool isUUID = isJust . U.fromString |