2

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?

Dierk
  • 1,308
  • 7
  • 13

1 Answers1

2

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.

Ingo
  • 36,037
  • 5
  • 53
  • 100
  • ok, thanks. The point was really not in the code at all but in the handling of properly recompiling everything after the code change and reading the error messages that come from _users_ of this type, which have not yet been updated to reflect the type change. *For other readers of this issue*: just do the "normal" thing in type declarations with classes, interfaces, generics, and the likes and it will work :-) My initial question was misleading. – Dierk Jul 03 '15 at 11:02