I'd like to natively declare a java interface in Frege that has a generic type. For example let's take an ObservableList from JavaFX.
Leaving out the generic type E, it works to define
data ObservableList = mutable native javafx.collections.ObservableList where
but when I try
data ObservableList e = mutable native javafx.collections.ObservableList where
native addAll :: ObservableList e -> MutableIO (JArray e) -> IO Bool
see the full example here
I get
kind error, type constructor `ObservableList` has kind ?->generic, expected was *
What is the advised way of handling this?
This is interesting, since it works for me out of the box:
ingo@freguntu:~/Frege/frege$ java -jar ../eclipse-plugin/lib/fregec.jar -version
3.23.247-gd535935
runtime 0.064 wallclock seconds.
ingo@freguntu:~/Frege/frege$ cat frege/StackOverflow.fr
package StackOverflow where
data ObservableList e = mutable native javafx.collections.ObservableList where
native addAll :: ObservableList e -> MutableIO (JArray e) -> IO Bool
ingo@freguntu:~/Frege/frege$ java -jar ../eclipse-plugin/lib/fregec.jar -d /tmp frege/StackOverflow.fr
calling: javac -cp ../eclipse-plugin/lib/fregec.jar:/tmp -d /tmp -sourcepath . -encoding UTF-8 /tmp/StackOverflow.java
Note: /tmp/StackOverflow.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
runtime 1.897 wallclock seconds.
ingo@freguntu:~/Frege/frege$
To be sure, the java compiler complains about the un-generic code that Frege emits, but there is no point in typechecking it again, only weaker :)
Please try the fregec that comes with the last eclipse plugin, it should work.
Also, when in eclipse, make sure you are not fooled by error markers not going away. For example, when you save, the errors become sticky and won't go away without recompilation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.