Error.hs revision f586a20f0d391470365243cc1405af39c92c6372
-- error messages
module Error where
import Id
data Diagnosis = Error String Pos
| Warning String Pos
newtype Result a = Result ([Diagnosis],Maybe a)
instance Monad Result where
return x = Result ([],Just x)
Result (errs, Nothing) >>= f = Result (errs,Nothing)
Result (errs1, Just x) >>= f = Result (errs1++errs2,y)
where Result (errs2,y) = f x
fail s = Result ([Error ("Fail: "++s) nullPos],Nothing)