You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iterator <-
[java| new Iterator() {
private boolean end = false;
private Object lookahead;
@Override
public boolean hasNext() { return !end; }
@Override
public Object next() {
if (hasNext()) {
final Object temp = lookahead;
lookahead = hsNext();
return temp;
} else
throw new java.util.NoSuchElementException();
}
@Override
public void remove() { throw new UnsupportedOperationException(); }
private native void hsFinalize(long tblPtr);
private native Object hsNext();
@Override
public void finalize() { hsFinalize($tblPtr); }
} |]
The iterator is passed to a function that will retrieve values from Haskell via the native methods of our anonymous Iterator class.
Various housekeeping tasks are necessary to link Haskell functions with those native methods. This issue is about designing and implementing a mechanism that would allow to automate the housekeeping. Suppose we implemented somehow a new quasiquoter like:
iterator <-
[new| Iterator() {
private boolean end = false;
private Object lookahead;
@Override
public boolean hasNext() { return !end; }
@Override
public Object next() {
if (hasNext()) {
final Object temp = lookahead;
lookahead = hsNext();
return temp;
} else
throw new java.util.NoSuchElementException();
}
@Override
public void remove() { throw new UnsupportedOperationException(); }
private native Object $$hsNext();
@Override
public void finalize() { hsFinalize(); }
} |]
Which is capable of identifying hsNext, link it with the corresponding Haskell function and automatically synthesize hsFinalize.
A major challenge with this approach is to produce the FFI wrappers of the haskell functions. Template Haskell can produce FFI wrappers with addTopDecls, but the type information necessary to do so would be available only after type-checking.
The text was updated successfully, but these errors were encountered:
Many libraries in java call back into user code to perform its functions. One notable example is GUI libraries. We have another example in jvm-streaming. https://github.com/tweag/inline-java/blob/master/jvm-streaming/src/main/haskell/Language/Java/Streaming.hs#L92
The iterator is passed to a function that will retrieve values from Haskell via the native methods of our anonymous Iterator class.
Various housekeeping tasks are necessary to link Haskell functions with those native methods. This issue is about designing and implementing a mechanism that would allow to automate the housekeeping. Suppose we implemented somehow a new quasiquoter like:
Which is capable of identifying
hsNext
, link it with the corresponding Haskell function and automatically synthesizehsFinalize
.A major challenge with this approach is to produce the FFI wrappers of the haskell functions. Template Haskell can produce FFI wrappers with
addTopDecls
, but the type information necessary to do so would be available only after type-checking.The text was updated successfully, but these errors were encountered: