module Drasil.GOOL.CodeAnalysis (
ExceptionType(..), Exception(loc, exc), printExc, hasLoc, exception, stdExc,
HasException(..)
) where
data ExceptionType = Standard | FileNotFound | IO deriving ExceptionType -> ExceptionType -> Bool
(ExceptionType -> ExceptionType -> Bool)
-> (ExceptionType -> ExceptionType -> Bool) -> Eq ExceptionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExceptionType -> ExceptionType -> Bool
== :: ExceptionType -> ExceptionType -> Bool
$c/= :: ExceptionType -> ExceptionType -> Bool
/= :: ExceptionType -> ExceptionType -> Bool
Eq
data Exception = Exc {
Exception -> String
loc :: String,
Exception -> String
exc :: String
}
printExc :: Exception -> String
printExc :: Exception -> String
printExc (Exc String
l String
e) = if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
l then String
e else String
l String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"." String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
e
hasLoc :: Exception -> Bool
hasLoc :: Exception -> Bool
hasLoc (Exc [] String
_) = Bool
False
hasLoc (Exc (Char
_:String
_) String
_) = Bool
True
exception :: String -> String -> Exception
exception :: String -> String -> Exception
exception = String -> String -> Exception
Exc
stdExc :: String -> Exception
stdExc :: String -> Exception
stdExc = String -> String -> Exception
Exc String
""
class HasException r where
toConcreteExc :: ExceptionType -> r Exception