-
-
Save alpmestan/145fc5783f00bab9214b7302418aef49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this is the input file we're processing | |
module Foo where | |
{-# ANN module () #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ... many things ... | |
convertAnnotationWrapper :: ForeignHValue -> TcM (Either MsgDoc Serialized) | |
convertAnnotationWrapper fhv = do | |
liftIO (putStrLn "§§§ in convertAnnotationWrapper") | |
dflags <- getDynFlags | |
liftIO (putStrLn "§§§ got the dynflag") | |
if gopt Opt_ExternalInterpreter dflags | |
then do | |
liftIO (putStrLn "§§§ we have an external interpreter") >> (Right <$> runTH THAnnWrapper fhv) | |
else do | |
liftIO (putStrLn "§§§ no external interpreter!") | |
annotation_wrapper <- liftIO $ wormhole dflags fhv | |
liftIO (putStrLn "§§§ after wormhole, about to return") | |
let serialized_data = case unsafeCoerce# annotation_wrapper of | |
AnnotationWrapper value | let serialized = toSerialized serializeWithData value -> | |
-- Got the value and dictionaries: build the serialized value and | |
-- call it a day. We ensure that we seq the entire serialized value | |
-- in order that any errors in the user-written code for the | |
-- annotation are exposed at this point. This is also why we are | |
-- doing all this stuff inside the context of runMeta: it has the | |
-- facilities to deal with user error in a meta-level expression | |
seqSerialized serialized `seq` serialized | |
liftIO (evaluate serialized_data) | |
liftIO (putStrLn "§§§ unsafeCoerce# went fine, leaving convertAnnotationWrapper") | |
return $ Right serialized_data | |
-- ... many other things ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[... a lot of things before ...] | |
§§§ in convertAnnotationWrapper | |
§§§ got the dynflag | |
§§§ no external interpreter! | |
§§§ after wormhole, about to return | |
Segmentation fault (core dumped) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment