Have a look! http://hackage.haskell.org/package/j-0.1.0.0/docs/Language-J.html
Would you consider a similar port for massiv?
Nice job snagging a single-letter library name, by the way.
Thanks
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
plot
in Haskell, but when I triedbsDispatch jenv "load'plot'"
I just gotvalue error: load
instead. - The example at the top of
Language.J
didn’t compile for me, giving an ambiguous type error instead. I had to add an@R.DIM1
type annotation to thegetJData
call in order to fix that. -
libWindows
isn’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?) -
JVersion
doesn’t seem to have any documentation, so I’m not quite sure I’m supposed to use it — is it supposed to be[901]
or[9,0,1]
or some other variation on that?
I think these are what you’re looking for:
http://hackage.haskell.org/package/massiv-0.5.4.0/docs/Data-Massiv-Array-Unsafe.html#g:12
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!
Okay, added jLoad
to the latest release: Language.J
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 [901]
> 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.