{"action":"created","issue":{"url":"https://api.github.com/repos/sviperll/adt4j/issues/15","repository_url":"https://api.github.com/repos/sviperll/adt4j","labels_url":"https://api.github.com/repos/sviperll/adt4j/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/sviperll/adt4j/issues/15/comments","events_url":"https://api.github.com/repos/sviperll/adt4j/issues/15/events","html_url":"https://github.com/sviperll/adt4j/issues/15","id":57316085,"number":15,"title":"Add support for Generalized Algebraic Data Types","user":{"login":"jbgi","id":221929,"avatar_url":"https://avatars.githubusercontent.com/u/221929?v=3","gravatar_id":"","url":"https://api.github.com/users/jbgi","html_url":"https://github.com/jbgi","followers_url":"https://api.github.com/users/jbgi/followers","following_url":"https://api.github.com/users/jbgi/following{/other_user}","gists_url":"https://api.github.com/users/jbgi/gists{/gist_id}","starred_url":"https://api.github.com/users/jbgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbgi/subscriptions","organizations_url":"https://api.github.com/users/jbgi/orgs","repos_url":"https://api.github.com/users/jbgi/repos","events_url":"https://api.github.com/users/jbgi/events{/privacy}","received_events_url":"https://api.github.com/users/jbgi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sviperll/adt4j/labels/research","name":"research","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-02-11T13:34:53Z","updated_at":"2016-02-17T22:03:19Z","closed_at":null,"body":"This probably requires a new specialized annotation, but it would be really cool if adt4j could help to define GADTs in Java!\r\nThis is what I am after: https://gist.github.com/jbgi/208a1733f15cdcf78eb5\r\n"},"comment":{"url":"https://api.github.com/repos/sviperll/adt4j/issues/comments/185427878","html_url":"https://github.com/sviperll/adt4j/issues/15#issuecomment-185427878","issue_url":"https://api.github.com/repos/sviperll/adt4j/issues/15","id":185427878,"user":{"login":"jbgi","id":221929,"avatar_url":"https://avatars.githubusercontent.com/u/221929?v=3","gravatar_id":"","url":"https://api.github.com/users/jbgi","html_url":"https://github.com/jbgi","followers_url":"https://api.github.com/users/jbgi/followers","following_url":"https://api.github.com/users/jbgi/following{/other_user}","gists_url":"https://api.github.com/users/jbgi/gists{/gist_id}","starred_url":"https://api.github.com/users/jbgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbgi/subscriptions","organizations_url":"https://api.github.com/users/jbgi/orgs","repos_url":"https://api.github.com/users/jbgi/repos","events_url":"https://api.github.com/users/jbgi/events{/privacy}","received_events_url":"https://api.github.com/users/jbgi/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T22:03:19Z","updated_at":"2016-02-17T22:03:19Z","body":"Interesting. but it looks like javac does not keep-up with you and gives up pretty easily, because this compile:\r\n```java\r\n  public static void main(String[] args) {\r\n    Monad.Util<List.TypeConstructor, List<?>> monad = List.empty().monad();\r\n    System.out.println(unitOneIsString(monad));\r\n  }\r\n\r\n  static <C extends Type.Constructor<C, CA>, CA extends Monad<C, CA, ? extends CA, ?>>\r\n  String unitOneIsString(Monad.Util<C, CA> monad) {\r\n    return monad.unit(1);\r\n  }\r\n```\r\nIt should of course be a type error.\r\nIf it were a type error then I think the correct return type would be ```Monad<C, CA, ?, Integer>``` but then I face this problem:\r\n```java\r\n  public static void main(String[] args) {\r\n    Monad.Util<List.TypeConstructor, List<?>> monad = List.empty().monad();\r\n    Monad<List.TypeConstructor, List<?>, ?, Integer> unitOne = unitOne(monad);\r\n    List<Integer> unitOneList = ??? // how to recover a List<Integer> from a Monad<List.TypeConstructor, List<?>, ?, Integer> ?\r\n    System.out.println(unitOneList);\r\n  }\r\n\r\n  static <C extends Type.Constructor<C, CA>, CA extends Monad<C, CA, ? extends CA, ?>>\r\n  Monad<C, CA, ?, Integer> unitOne(Monad.Util<C, CA> monad) {\r\n    return monad.unit(1);\r\n  }\r\n```\r\nThere may be something wrong in my type signatures... but I think this scenario should be covered by a HKT encoding."}}