-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
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
Inheritance #45
Comments
To this end, I've started work on a repo here: https://github.com/mitchellwrosen/java-apache-lucene/blob/master/jvm-extra/src/Language/Java/Extra.hs However, the interface is inchoate and unstable, as there are many details in the Java type system (inheritance, generics, bounded generics in class/interface definitions e.g. I only mention my work here so anyone else interested in tackling this problem can get in touch to compare notes. Or, if there's prior work in this area, maybe I'm wasting my time. Either way, it's fun! |
Another possible design is having a class class Extends (ty1 :: JType) (ty2 :: JType) where and functions upcast :: Extends ty1 ty2 => J ty1 -> J ty2
downcast :: Extends ty1 ty2 => J ty2 -> IO (J ty1)
-- Doesn't check at runtime if the input reference has the expected type.
unsafeDowncast :: Extends ty1 ty2 => J ty2 -> J ty1 For a class instance like class MyClass<A extends BClass & CInterface> extends MySuperClass<A> {
} We could generate with Java reflection and template haskell: instance (Extends ty ('Class "BClass"), Extends ty ('Iface "CInterface")) => Extends ('Class "MyClass" <> '[ ty ]) ('Class "MySuperClass" <> '[ ty ]) |
I think Eta did a good job at this. It's very similar to what you've proposed @facundominguez. |
Hi, are there any plans to add support for Java inheritance? From scanning the docs, all I found was
and
However, it would be nice to have some sort of
instead.
Thanks!
The text was updated successfully, but these errors were encountered: