guibou / PyF

Haskell QuasiQuoter for String Formatting
BSD 3-Clause "New" or "Revised" License
66 stars 13 forks source link

Consider avoiding the `unsafeRunTcM` trick #115

Closed michaelpj closed 2 years ago

michaelpj commented 2 years ago

... or perhaps provide a flag to turn it off (at the cost of worse error reporting).

I don't have a smoking gun, but I suspect this is related to whatever was causing my issues in https://github.com/guibou/PyF/issues/111, and I have word from a GHC expert that this will definitely not work when cross-compiling/using the external interpreter, which is a thing that people want to do (and it'll be fairly obscure to discover the problem).

guibou commented 2 years ago

There are two use cases for unsafeRunTcM in the PyF codebase.

guibou commented 2 years ago

@michaelpj I've tested the problem in your codebase based on what you describe in https://github.com/input-output-hk/plutus/pull/4862 and indeed, the use of unsafeRunTcM was responsible for the problem.

I'm refactoring to remove the usage of unsafeRunTcM in the "normal" path, leaving the only use case for the "error" path.

guibou commented 2 years ago

See #117

michaelpj commented 2 years ago

Wonderful, thank you! I think this should also work with cross-compilation since the error case won't be hit in the normal case, and if there's an error then users should be able to detect that in normal compilation :+1: