module Network.MoHWS.Logger.Level (T(..)) where

import qualified Data.Map as Map


data T =
     Debug
   | Info
   | Notice
   | Warn
   | Error
   | Crit
   | Alert
   | Emerg
     deriving (T -> T -> Bool
(T -> T -> Bool) -> (T -> T -> Bool) -> Eq T
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: T -> T -> Bool
$c/= :: T -> T -> Bool
== :: T -> T -> Bool
$c== :: T -> T -> Bool
Eq,Eq T
Eq T
-> (T -> T -> Ordering)
-> (T -> T -> Bool)
-> (T -> T -> Bool)
-> (T -> T -> Bool)
-> (T -> T -> Bool)
-> (T -> T -> T)
-> (T -> T -> T)
-> Ord T
T -> T -> Bool
T -> T -> Ordering
T -> T -> T
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: T -> T -> T
$cmin :: T -> T -> T
max :: T -> T -> T
$cmax :: T -> T -> T
>= :: T -> T -> Bool
$c>= :: T -> T -> Bool
> :: T -> T -> Bool
$c> :: T -> T -> Bool
<= :: T -> T -> Bool
$c<= :: T -> T -> Bool
< :: T -> T -> Bool
$c< :: T -> T -> Bool
compare :: T -> T -> Ordering
$ccompare :: T -> T -> Ordering
$cp1Ord :: Eq T
Ord,Int -> T
T -> Int
T -> [T]
T -> T
T -> T -> [T]
T -> T -> T -> [T]
(T -> T)
-> (T -> T)
-> (Int -> T)
-> (T -> Int)
-> (T -> [T])
-> (T -> T -> [T])
-> (T -> T -> [T])
-> (T -> T -> T -> [T])
-> Enum T
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: T -> T -> T -> [T]
$cenumFromThenTo :: T -> T -> T -> [T]
enumFromTo :: T -> T -> [T]
$cenumFromTo :: T -> T -> [T]
enumFromThen :: T -> T -> [T]
$cenumFromThen :: T -> T -> [T]
enumFrom :: T -> [T]
$cenumFrom :: T -> [T]
fromEnum :: T -> Int
$cfromEnum :: T -> Int
toEnum :: Int -> T
$ctoEnum :: Int -> T
pred :: T -> T
$cpred :: T -> T
succ :: T -> T
$csucc :: T -> T
Enum,T
T -> T -> Bounded T
forall a. a -> a -> Bounded a
maxBound :: T
$cmaxBound :: T
minBound :: T
$cminBound :: T
Bounded)


names :: Map.Map T String
names :: Map T String
names =
   [(T, String)] -> Map T String
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(T, String)] -> Map T String) -> [(T, String)] -> Map T String
forall a b. (a -> b) -> a -> b
$
   (T
Debug,  String
"debug")  (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Info,   String
"info")   (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Notice, String
"notice") (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Warn,   String
"warn")   (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Error,  String
"error")  (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Crit,   String
"crit")   (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Alert,  String
"alert")  (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   (T
Emerg,  String
"emerg")  (T, String) -> [(T, String)] -> [(T, String)]
forall a. a -> [a] -> [a]
:
   []

instance Show T where
    show :: T -> String
show T
l =
       String -> T -> Map T String -> String
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault
          (ShowS
forall a. HasCallStack => String -> a
error ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
"LogLevel.names is incomplete") T
l Map T String
names

instance Read T where
    readsPrec :: Int -> ReadS T
readsPrec Int
_ String
s = [ (T
l,String
"") | (T
l,String
n) <- Map T String -> [(T, String)]
forall k a. Map k a -> [(k, a)]
Map.toList Map T String
names, String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
s ]