abau / co4

COmplexity COncerned COnstraint COmpiler
GNU General Public License v3.0
2 stars 3 forks source link

assertKnownWithMsg :: String -> a -> a #100

Closed jwaldmann closed 10 years ago

jwaldmann commented 10 years ago

Currently we have assertKnown :: a -> a for run-time checks. If there are several such checks in the code, and one of them fails, I don't see which one. Ideally, I'd want the source location of the failing assertKnown in the error message.

As a work-around, we can have the programmer write a message in the assert, as in

case assertKnownWithMessage "foobar" xs of [] -> ...

of course a shorter name is preferred. The idea is similar to http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/profiling.html#scc-pragma .

abau commented 10 years ago

When compiling with CO4.Compilation.compileFile (as in most non-trivial use-cases) all assertKnown are converted to assertKnownLoc: if assertKnowLoc fails, its location in the source file is dumped.

This does not work when compiling with CO4.Compilation.compile, because source locations are provided by Language.Haskell.Exts which is not used in CO4.Compilation.compile. Again, this should't be a problem because CO4.Compilation.compile is merely used for simple examples.