plugins
plugins copied to clipboard
Update for 9.6.2
@drvink @Kleidukos this builds now and make
, load
and unsafeEval
mostly work, even on a relatively complicated test:
main = do fn <- unsafeEval_ "(\\x -> (x,x::Int))" [] ["-O2","-v","-g","-threaded","-with-rtsopts=-N"] [] [] :: IO (Either [String] (Int -> (Int,Int)))
case fn of
Right fn -> putStrLn $ show $ fn 8
Left err -> putStrLn $ "error top level"
whoop <- atomically $ newTMVar 1
whoop2 <- atomically $ newTMVar 2
whoop3 <- atomically $ newTMVar 3
-- when (isJust fn) $ putStrLn $ show $ (fromRight fn) 7
danger <- unsafeEval_ "(\\w -> (atomically $ takeTMVar w) >>= putStrLn . show >> threadDelay 5000000 >> (atomically $ putTMVar w 5)) :: TMVar Int -> IO ()" ["Control.Concurrent.STM","Control.Concurrent.STM.TMVar","Control.Concurrent"] ["-O2","-v","-g","-threaded","-with-rtsopts=-N"] [] [] :: IO (Either [String] (TMVar Int -> IO ()))
case danger of
Right fn -> do
tid <- forkIO $ fn whoop
return ()
Left err -> mapM putStrLn err >> return ()
-- hmm <- atomically $ readTMVar whoop2
-- putStrLn . show $ hmm
threadDelay 2000000
hmm2 <- atomically $ do
hhhh <- tryTakeTMVar whoop
case hhhh of
Just ok -> return ok
Nothing -> retry
putStrLn . show $ hmm2
I'm getting a solid full terminal of warnings such as this though:
Symbol type mismatch.
Symbol stg_ap_pppppp_fast was defined by /home/wrath/.ghcup/ghc/9.6.2/lib/ghc-9.6.2/lib/../lib/x86_64-linux-ghc-9.6.2/rts-1.0.2/libHSrts-1.0.2.a to be a code symbol.
yet was defined by <builtin> to be a data symbol.
I was getting those even on very basic tests and thought maybe it's because I had ghc flags different in my main project than in the eval
ed code, but they're the same even when I tested:
main = do fn <- unsafeEval "(\\x -> (x,x::Int))" [] :: IO (Maybe (Int -> (Int,Int)))
when (isJust fn) $ putStrLn $ show $ (fromJust fn) 7
oh wow that's wonderful, thanks a lot for this work!
Hi! Ran into this one today.
Does this build with GHC 9.2 and is mostly safe to use?
the other pull request might work better for 9.2 but I don't remember when the API changes were made. I don't know enough about the GHC API and to tell whether this is still safe. The code means exactly the same as it did before. Whether that still makes sense on the ABI level is another matter. I was hoping someone who knows this better would help debug it