help with java method definition

23 views
Skip to first unread message

Alex Deparvu

unread,
Oct 20, 2018, 9:39:39 AM10/20/18
to Frege Programming Language
Hi,

I'm trying to define a native binding for a java method, and can't figure it out.

The method is
    Iterable<? extends PropertyState> getProperties();

I initially thought of this version:
    native getProperties :: Mutable s Tree -> ST s (Iterable (Mutable s b))

but the '? extends PropertyState' seems to break things, the error I get is:
    The parameterized method <Iterable<b>>lazy(Lazy<Iterable<b>>) of type Thunk is not applicable for the arguments (Iterable<capture#1-of ? extends PropertyState>)

I even tried the 'frege-native-gen' project, but that didn't came op with better candidates.

Can anyone suggest a better way?
Followup question, I thought I read somewhere that using '[]' for java 'Iterable' return types is possible, but I couldn't figure that one out (even for simpler examples).

thanks a lot,
alex

Ingo W.

unread,
Oct 21, 2018, 6:05:24 AM10/21/18
to Frege Programming Language
Hi Alex,

please try 

   ... (b extends PropertyState)

instead of b. Also, maybe just PropertyState will do the job as well?
If so, I would prefer the latter.

The automatic conversion of return values to lists is not supported anymore (and did work for arrays only, if I remember correctly).

Alex Deparvu

unread,
Oct 21, 2018, 1:40:12 PM10/21/18
to frege-program...@googlegroups.com
Hi,

Thanks for the quick reply!

Here's the 2 options, each with its error:
* Option 1
    native getProperties :: Mutable s Tree -> ST s (Iterable (Mutable s (b extends PropertyState)))
with error:
    -The parameterized method <Iterable<b>>lazy(Lazy<Iterable<b>>) of type Thunk is not applicable for the arguments (Iterable<capture#1-of ? extends
     PropertyState>)

* Option 2 (my original try)
    native getProperties :: Mutable s Tree -> ST s (Iterable (Mutable s PropertyState))
with error
    -The parameterized method <Iterable<PropertyState>>lazy(Lazy<Iterable<PropertyState>>) of type Thunk is not applicable for the arguments
     (Iterable<capture#1-of ? extends PropertyState>)
Option 2 was actually what I wanted to attach to my original email, but I had a copy/pasta error in frege my code snippet (tried too many things I guess).

best,
alex



--
You received this message because you are subscribed to the Google Groups "Frege Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to frege-programming-l...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ingo W.

unread,
Oct 21, 2018, 6:15:17 PM10/21/18
to Frege Programming Language
Hi Alex,

can you give me a smallest possible example that exhibits the error?
Would like to look into this.
As I'm seeing only now it will seem that the laziness is somehow the problem, not the bounded Java type variable.

Regards, Ingo
To unsubscribe from this group and stop receiving emails from it, send an email to frege-programming-language+unsub...@googlegroups.com.

Alex Deparvu

unread,
Oct 23, 2018, 2:47:40 AM10/23/18
to frege-program...@googlegroups.com
Hi Ingo,

Thank you for taking a look at this!
Here's a very reduced version [0], I was not sure if you use maven or not. let me know if this doesn't work so I can find a different approach.

For the sake of completeness the error I get now is [1]:
    frege-test-javaiterables/target/generated-sources/frege/org/example/Components.java:[120,27] no suitable method found for lazy(java.lang.Iterable<capture#1 of ? extends org.example.Property>)

best,
alex

[1]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project com.pfalabs.frege-test-javaiterables: Compilation failure
[ERROR] frege-test-javaiterables/target/generated-sources/frege/org/example/Components.java:[120,27] no suitable method found for lazy(java.lang.Iterable<capture#1 of ? extends org.example.Property>)
[ERROR]     method frege.run8.Thunk.lazy(boolean) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to boolean)
[ERROR]     method frege.run8.Thunk.lazy(byte) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to byte)
[ERROR]     method frege.run8.Thunk.lazy(short) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to short)
[ERROR]     method frege.run8.Thunk.lazy(char) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to char)
[ERROR]     method frege.run8.Thunk.lazy(int) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to int)
[ERROR]     method frege.run8.Thunk.lazy(long) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to long)
[ERROR]     method frege.run8.Thunk.lazy(double) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to double)
[ERROR]     method frege.run8.Thunk.lazy(float) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to float)
[ERROR]     method frege.run8.Thunk.<X>lazy(frege.run8.Lazy<X>) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to frege.run8.Lazy<java.lang.Iterable<𝓑>>)
[ERROR]     method frege.run8.Thunk.<X>lazy(X) is not applicable
[ERROR]       (argument mismatch; java.lang.Iterable<capture#1 of ? extends org.example.Property> cannot be converted to java.lang.Iterable<𝓑>)

Ingo W.

unread,
Oct 26, 2018, 8:39:40 AM10/26/18
to Frege Programming Language
Hi Alex,

please give me a bit of time. I've been travelling last week for business, and will also be travelling next week. I've no idea whether I can make it over the weekend, so .... but I won't forget it.

Best regards, Ingo
Reply all
Reply to author
Forward
0 new messages