IHaskell issues
Describe the bug The Jupyter kernel crashes with relatively simple input. The same input did not cause a crash in earlier versions of HaskellR.
To Reproduce
Open test.ipynb in Jupyter with IHaskell kernel, and
insert the following into a cell:
-- Permute a list using a specified list of indices
perm :: [Int] -> [Double] -> [Double]
perm [] _ = []
perm (x:xs) v = (v !! x):perm xs v
Running the cell causes a kernel crash.
Expected behavior
This is valid Haskell, accepted by GHC, and the function can
be tested using perm [0, 2, 1] [1,2,3]
with expected output [1.0,3.0,2.0].
Environment
- Ubuntu 24.04
- HaskellR (inline-r) v1.0.2
Additional context There are other examples that trigger the crash. Reverting to HaskellR v1.0.1 seems to resolve these problems.
Thanks @djsamperi for the report. What is the R version that is used in your setup?
I was using stack --nix build with v1.0.2, so R 4.5.0 is used.
I tried not using Nix at all, just 'stack build', and everything works until it gets to IHaskell/src/IHaskell/Display/InlineR.hs. This creates a corresponding .stack-work/.../InlineR.dyn_o, and the linker (ld.gold) fails because this was not compiled with -fPIC.
ChatGPT suggests this is due to the fact the ghc is often not compiled from source with --enable-shared, and specifying -fPIC in --ghc-options does not get propagated to code generated by TH (template Haskell), at least not for this file. If ChatGPT is right this would require recompiling ghc from source with --enable-shared. Since this issue does not arise with Nix, perhaps it uses a version of ghc that was compiled with this flag?