Would you consider a similar port for massiv?
Nice job snagging a single-letter library name, by the way.
I didn’t see any easy conversion to
ForeignPtr in the massiv world, I may have another look with just plain byte copying…
It seems to be getting traction in
hip at least.
I only just saw this announcement, and in a brief test,
j seems to be working perfectly — thanks for making it! A couple of questions/comments:
- Is there a way of loading libraries? When I saw this I was most excited about getting access to J’s
plotin Haskell, but when I tried
bsDispatch jenv "load'plot'"I just got
value error: loadinstead.
- The example at the top of
Language.Jdidn’t compile for me, giving an ambiguous type error instead. I had to add an
@R.DIM1type annotation to the
getJDatacall in order to fix that.
libWindowsisn’t listed in Hackage; I had to look at the source code to find it, hidden behind a conditional compilation pragma. (Why is that pragma there anyway?)
JVersiondoesn’t seem to have any documentation, so I’m not quite sure I’m supposed to use it — is it supposed to be
[9,0,1]or some other variation on that?
I think these are what you’re looking for:
As it stands,
j (the Haskell package) doesn’t load defaults. Perhaps it should! I’ll have to have a look at what the R server does
Neat, thanks for pointing that out!
jLoad to the latest release: https://hackage.haskell.org/package/j-0.1.2.0/docs/Language-J.html#v:jLoad
It seems to work approximately as the REPL
It works — thank you! Admittedly it plots to a PDF rather than to a new window as it does with J, but I can live with that
Huh. My J defaults to pdf anyways
Maybe a version thing?
It would appear from the J documentation that PDF is the default on console, and isigraph windows are the default in the GUI. A quick test reveals that PDF and HTML5 outputs work from Haskell, while isigraph, GTK, EPS, Cairo and Qt do not.
Oh, and I found a bug:
> jenv <- jinit $ libWindows  > setJData jenv "plot_data" $ JIntArr $ R.copyS $ R.map (fromIntegral @Int @CInt) $ R.fromListUnboxed (R.ix1 3) [1,10,2] > setJData jenv "plot_data" $ JIntArr $ R.copyS $ R.map (fromIntegral @Int @CInt) $ R.fromListUnboxed (R.ix1 3) [1,10,2] 0 > bsDispatch jenv "plot_data" >> bsOut jenv "42949672961 2 177495872\n" > JIntArr a :: JData R.DIM1 <- getJData jenv "plot_data" > R.toList a [1,10,2]
So the integer array undergoes the round-trip successfully, but gets messed up on the J side (so plotting and calculations won’t work correctly). I suspect a wrong conversion somewhere.
Oh wow, yeah. Time to take a look :o
Ok, fixed so it takes an array of
CLLong for integers.
Should be more correct now but might need to adjust.