We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is your feature request related to a problem? Please describe.
It is difficult to use quasiquotations that are type safe and can be reused with different types.
f :: (IsReferenceType a, Coercible a) => a -> IO a f obj = [java| $obj |]
The above code is rejected because at compile time, inline-java doesn't know which Java type to give to $obj. We can do casts instead:
$obj
f :: (IsReferenceType a, Coercible a) => a -> IO a f (coerce -> JObject obj) = unsafeUncoerce . JObject <$> [java| $obj |]
which can fail at runtime if the user gets the types wrong.
Describe the solution you'd like
Ideally, we would have in Java code like
public <A> A f (A $obj) { return $obj; }
and our initial definition would be accepted
The code generated by inline-java would be responsible for making the appropriate casts.
There is some room to decide where type variables are allowed in a type. Here's an example where the type variable appears nested within a type.
f :: (IsReferenceType a, Coercible a) => a -> IO (J ('Iface "java.util.List" <> '[ Ty a ])) f _ = [java| new ArrayList<A>() |]
And we also would have to consider if/how to deal with bounded type parameters.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is your feature request related to a problem? Please describe.
It is difficult to use quasiquotations that are type safe and can be reused with different types.
The above code is rejected because at compile time, inline-java doesn't know which Java type to give to
$obj
.We can do casts instead:
which can fail at runtime if the user gets the types wrong.
Describe the solution you'd like
Ideally, we would have in Java code like
and our initial definition would be accepted
The code generated by inline-java would be responsible for making the appropriate casts.
There is some room to decide where type variables are allowed in a type. Here's an example where the type variable appears nested within a type.
And we also would have to consider if/how to deal with bounded type parameters.
The text was updated successfully, but these errors were encountered: