module Env.Internal.Error
( Error(..)
, AsUnset(..)
, AsEmpty(..)
, AsUnread(..)
) where
data Error
= UnsetError
| EmptyError
| UnreadError String
deriving (Int -> Error -> ShowS
[Error] -> ShowS
Error -> String
(Int -> Error -> ShowS)
-> (Error -> String) -> ([Error] -> ShowS) -> Show Error
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Error] -> ShowS
$cshowList :: [Error] -> ShowS
show :: Error -> String
$cshow :: Error -> String
showsPrec :: Int -> Error -> ShowS
$cshowsPrec :: Int -> Error -> ShowS
Show, Error -> Error -> Bool
(Error -> Error -> Bool) -> (Error -> Error -> Bool) -> Eq Error
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Error -> Error -> Bool
$c/= :: Error -> Error -> Bool
== :: Error -> Error -> Bool
$c== :: Error -> Error -> Bool
Eq)
class AsUnset e where
unset :: e
tryUnset :: e -> Maybe ()
instance AsUnset Error where
unset :: Error
unset = Error
UnsetError
tryUnset :: Error -> Maybe ()
tryUnset Error
err =
case Error
err of
Error
UnsetError -> () -> Maybe ()
forall a. a -> Maybe a
Just ()
Error
_ -> Maybe ()
forall a. Maybe a
Nothing
class AsEmpty e where
empty :: e
tryEmpty :: e -> Maybe ()
instance AsEmpty Error where
empty :: Error
empty = Error
EmptyError
tryEmpty :: Error -> Maybe ()
tryEmpty Error
err =
case Error
err of
Error
EmptyError -> () -> Maybe ()
forall a. a -> Maybe a
Just ()
Error
_ -> Maybe ()
forall a. Maybe a
Nothing
class AsUnread e where
unread :: String -> e
tryUnread :: e -> Maybe String
instance AsUnread Error where
unread :: String -> Error
unread = String -> Error
UnreadError
tryUnread :: Error -> Maybe String
tryUnread Error
err =
case Error
err of
UnreadError String
msg -> String -> Maybe String
forall a. a -> Maybe a
Just String
msg
Error
_ -> Maybe String
forall a. Maybe a
Nothing