diff options
Diffstat (limited to 'Types/TrustLevel.hs')
-rw-r--r-- | Types/TrustLevel.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Types/TrustLevel.hs b/Types/TrustLevel.hs index 99d749730..83e4e5a5e 100644 --- a/Types/TrustLevel.hs +++ b/Types/TrustLevel.hs @@ -7,7 +7,9 @@ module Types.TrustLevel ( TrustLevel(..), - TrustMap + TrustMap, + readTrustLevel, + showTrustLevel, ) where import qualified Data.Map as M @@ -15,6 +17,19 @@ import qualified Data.Map as M import Types.UUID data TrustLevel = Trusted | SemiTrusted | UnTrusted | DeadTrusted - deriving Eq + deriving (Eq, Enum, Ord) type TrustMap = M.Map UUID TrustLevel + +readTrustLevel :: String -> Maybe TrustLevel +readTrustLevel "trusted" = Just Trusted +readTrustLevel "untrusted" = Just UnTrusted +readTrustLevel "semitrusted" = Just SemiTrusted +readTrustLevel "dead" = Just DeadTrusted +readTrustLevel _ = Nothing + +showTrustLevel :: TrustLevel -> String +showTrustLevel Trusted = "trusted" +showTrustLevel UnTrusted = "untrusted" +showTrustLevel SemiTrusted = "semitrusted" +showTrustLevel DeadTrusted = "dead" |