Alex Jacobson <[EMAIL PROTECTED]> writes:

> I'd like to have code not compile if it doesn't pass the tests.
>
> Is there a way to use TH to generate compiler errors if the tests
> don't pass?

What about something like this?

    import Language.Haskell.TH

    import Tests         -- this should export "testsPass :: Bool"

    -- don't bother trying to call this function.
    check = $( if testsPass then [| () |]
               else error "test failed" )

    main = print "hi"

If testsPass returns False, the compiler will throw an exception during
compilation, like this:

    Exception when trying to run compile-time code:
      test failed
      [...]
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to