Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
anyone know of a comfy method to run a code snippet (like a quasiquote) in the current environment and extract the error message as a string? like I want to run a tasty test I check like this:
test = do err <- extractCompileError?? [|5 :: Text|] assert (err == "No instance (Num Text)")
I looked at hint and th-test-utils, but they were both unsuitable.
hint
th-test-utils
my provisional solution will be to put the tested expression in a separate file, turning on -fdeferred-type-errors and catching TypeError in the test!
-fdeferred-type-errors
TypeError
I know Franklin Chen had something like this at some point, IIRC I think he solved it how you say you are solving it
I shot him an email asking about it
there's should-not-typecheck on hackage that leverages this for hunit
should-not-typecheck
Ah yes, that helped me find what I was looking for: https://github.com/FranklinChen/twenty-four-days2015-of-hackage/blob/2d452a9ce3133a908aa3058bf8a2fea5b06246f1/test/ShouldNotTypecheckExampleSpec.hs
anyone know of a comfy method to run a code snippet (like a quasiquote) in the current environment and extract the error message as a string?
like I want to run a tasty test I check like this:
I looked at
hint
andth-test-utils
, but they were both unsuitable.my provisional solution will be to put the tested expression in a separate file, turning on
-fdeferred-type-errors
and catchingTypeError
in the test!I know Franklin Chen had something like this at some point, IIRC I think he solved it how you say you are solving it
I shot him an email asking about it
there's
should-not-typecheck
on hackage that leverages this for hunitAh yes, that helped me find what I was looking for: https://github.com/FranklinChen/twenty-four-days2015-of-hackage/blob/2d452a9ce3133a908aa3058bf8a2fea5b06246f1/test/ShouldNotTypecheckExampleSpec.hs