module Database.Ferry.Compiler.Error.Error where
import Control.Monad.Error
import Database.Ferry.TypedCore.Data.Type
import Text.ParserCombinators.Parsec (ParseError())
data FerryError = NoSuchFile String
| ParserError ParseError
| UnificationError FType FType
| UnificationRecError [(RLabel, FType)] [(RLabel, FType)]
| ClassAlreadyDefinedError String
| SuperClassNotDefined String [String]
| ClassNotDefined String
| RecordDuplicateFields (Maybe String) [(RLabel, FType)]
| NotARecordType FType
| RecordWithoutI FType String
| UnificationOfRecordFieldsFailed RLabel RLabel
| UnificationFail RLabel RLabel
| ProcessComplete
deriving Show
instance Error FerryError where
noMsg = error "This function should not be used Error.hs noMsg"
strMsg = error "This function should not be used Error.hs strMsg"
handleError :: FerryError -> IO ()
handleError ProcessComplete = return ()
handleError (ParserError e) = putStrLn $ show e
handleError e = putStrLn $ show e