[ANN] j 0.1.0.0 - repa interface with J language

Have a look! http://hackage.haskell.org/package/j-0.1.0.0/docs/Language-J.html

1 Like

Would you consider a similar port for massiv?

Nice job snagging a single-letter library name, by the way.

1 Like

Thanks :slight_smile:

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 tried bsDispatch jenv "load'plot'" I just got value 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 the getJData 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?
2 Likes

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

2 Likes

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 :slight_smile:

Neat, thanks for pointing that out!

Okay, added 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 :slight_smile:

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 :slight_smile:

1 Like

Huh. My J defaults to pdf anyways :thinking:

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.