Error in marshal data between R and Haskell

57 views
Skip to first unread message

Boyun Tang

unread,
Sep 14, 2015, 4:10:24 AM9/14/15
to haskellr
Sorry for my poor English.

I tried a fresh installation of inline-r:

rm -rf ~/.ghc && cabal update && cabal install inline-r

And Following code:

-- Main.hs
{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE QuasiQuotes         #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import           Data.Vector.SEXP
import qualified Foreign.R        as R
import           H.Prelude        as H
import           Language.R.QQ
main :: IO ()
main = H.withEmbeddedR defaultConfig $ H.runRegion $ do
  (vs :: R.SEXP s 'R.Real) <- toSEXP (fromList [1..3::Double])
  [r|print(vs_hs)|] >> return ()

Compiling the code and run it, I got this result:
./test  
[1] 1.244398e-316 1.895079e-316 1.244393e-316

Am I doing sth wrong?

Boespflug, Mathieu

unread,
Sep 14, 2015, 6:12:02 AM9/14/15
to Boyun Tang, haskellr
Hi Boyun,

there seems to be a bug when copying vectors in some situations. We
filed a new issue to Github to track the fix:

https://github.com/tweag/HaskellR/issues/204

In the meantime, a workaround is to not copy the vector. That means
changing your code to:

main = H.withEmbeddedR defaultConfig $ H.runRegion $ do
(vs :: R.SEXP s 'R.Real) <- unsafeToSEXP (fromList [1..3::Double])
[r|print(vs_hs)|] >> return ()
--
Mathieu Boespflug
Founder at http://tweag.io.
> --
> You received this message because you are subscribed to the Google Groups
> "haskellr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to haskellr+u...@googlegroups.com.
> To post to this group, send email to hask...@googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/haskellr/2255a57f-6567-4e50-ab7f-4a47c1b4f8d2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Boespflug, Mathieu

unread,
Sep 14, 2015, 7:58:55 PM9/14/15
to Boyun Tang, haskellr
Hi Boyun,

quick followup: the bug has been fixed and a new release of inline-r
has been uploaded to Hackage. Thanks for the bug report!

Best,
--
Mathieu Boespflug
Founder at http://tweag.io.


Reply all
Reply to author
Forward
0 new messages