namme-anetten / epigram

Automatically exported from code.google.com/p/epigram
0 stars 0 forks source link

RFC: Error report machinery #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, the error report machinery is based on an ADT of the following shape:

> data ErrorTok t = StrMsg String
>                 | ErrorTm       (t       :<: Maybe t)
>                 | (...)

This is all right in, say, Cochon where we just print out the error message 
directly to the user. However, in a more high-level setting, we might want to 
give a better diagnostic message than the one we wrote in the source code.

I suggest to adopt an approach similar (but obviously more typed) to the 
infamous errno.h in Unix: we define an Error ADT that lists all possible causes 
of error. Typically:

> data Errors t = ErrorTelCheck
>               | ErrorOpTyArity Op
>               | ErrorCanTy (Can t) TY
>               | (...)

Based on this ADT, we can have a pretty-printer, giving a result similar to the 
currently hard-coded outputs. But we also gain the ability to analyze stuffs, 
decide what to report, what not to report, etc.

Implementing this should be an opportunity to extract the error stuff out of 
Tm.lhs.

Original issue reported on code.google.com by pedag...@gmail.com on 11 Aug 2010 at 5:10

GoogleCodeExporter commented 9 years ago

Original comment by pedag...@gmail.com on 11 Aug 2010 at 6:53

GoogleCodeExporter commented 9 years ago
Sounds good to me. Perhaps we should use an aspect to allow error data 
constructors to be added post hoc?

Original comment by adamgundry on 12 Aug 2010 at 7:48

GoogleCodeExporter commented 9 years ago
Good idea, indeed.

Original comment by pedag...@gmail.com on 12 Aug 2010 at 9:32