{"action":"created","issue":{"url":"https://api.github.com/repos/agrafix/elm-bridge/issues/31","repository_url":"https://api.github.com/repos/agrafix/elm-bridge","labels_url":"https://api.github.com/repos/agrafix/elm-bridge/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/agrafix/elm-bridge/issues/31/comments","events_url":"https://api.github.com/repos/agrafix/elm-bridge/issues/31/events","html_url":"https://github.com/agrafix/elm-bridge/issues/31","id":326320828,"number":31,"title":"ETypeDef instances for base types","user":{"login":"tmbull","id":8029789,"avatar_url":"https://avatars1.githubusercontent.com/u/8029789?v=4","gravatar_id":"","url":"https://api.github.com/users/tmbull","html_url":"https://github.com/tmbull","followers_url":"https://api.github.com/users/tmbull/followers","following_url":"https://api.github.com/users/tmbull/following{/other_user}","gists_url":"https://api.github.com/users/tmbull/gists{/gist_id}","starred_url":"https://api.github.com/users/tmbull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmbull/subscriptions","organizations_url":"https://api.github.com/users/tmbull/orgs","repos_url":"https://api.github.com/users/tmbull/repos","events_url":"https://api.github.com/users/tmbull/events{/privacy}","received_events_url":"https://api.github.com/users/tmbull/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-24T22:37:53Z","updated_at":"2018-05-25T21:10:25Z","closed_at":null,"author_association":"NONE","body":"Hi, I am looking at porting `servant-elm` to `elm-bridge` or creating a similar library that works with `elm-bridge`. The reason being is that I really like that `elm-bridge` generates types that are \"aeson compatible\" , and that `elm-bridge` is more flexible in types that it supports (ie. sum types). \r\n\r\nHowever, one current stumbling block is that a servant JSON API can be created that returns any type with a FromJSON instance. Since `aeson` has built-in instances for most base types ([a], Either, Maybe, etc.) and a lot of common types (like Text), there's a lot of types that will work out of the box in servant responses that don't have ETypeDef instances. \r\n\r\nDo you think it makes sense to include default instances for types that already have analogs in Elm? Or do you think there is a better approach to solving this problem? Thanks."},"comment":{"url":"https://api.github.com/repos/agrafix/elm-bridge/issues/comments/392188130","html_url":"https://github.com/agrafix/elm-bridge/issues/31#issuecomment-392188130","issue_url":"https://api.github.com/repos/agrafix/elm-bridge/issues/31","id":392188130,"user":{"login":"tmbull","id":8029789,"avatar_url":"https://avatars1.githubusercontent.com/u/8029789?v=4","gravatar_id":"","url":"https://api.github.com/users/tmbull","html_url":"https://github.com/tmbull","followers_url":"https://api.github.com/users/tmbull/followers","following_url":"https://api.github.com/users/tmbull/following{/other_user}","gists_url":"https://api.github.com/users/tmbull/gists{/gist_id}","starred_url":"https://api.github.com/users/tmbull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmbull/subscriptions","organizations_url":"https://api.github.com/users/tmbull/orgs","repos_url":"https://api.github.com/users/tmbull/repos","events_url":"https://api.github.com/users/tmbull/events{/privacy}","received_events_url":"https://api.github.com/users/tmbull/received_events","type":"User","site_admin":false},"created_at":"2018-05-25T21:10:25Z","updated_at":"2018-05-25T21:10:25Z","author_association":"NONE","body":"I agree that it makes sense to add Elm helpers to the `json-helper` library where necessary. However, my use case is a little different than what is currently supported by `elm-bridge`... \r\n\r\nTo give a little background, in case you are not familiar with servant, the `servant-foreign` package provides helpers for generating clients to servant APIs. You first have to implement the `HasForeignType` class (here)[https://hackage.haskell.org/package/servant-foreign-0.11.1/docs/Servant-Foreign.html#t:HasForeignType], which tells servant how to convert the types in your API (whether they be response bodies, request bodies, query params, path params, etc.) to your \"foreign\" language. In my case, I have defined an instance as follows: \r\n\r\n```\r\ninstance (IsElmDefinition a) => HasForeignType LangElm ETypeDef a where\r\n  typeFor _ _ _ =\r\n    compileElmDef (Proxy :: Proxy a)\r\n\r\n```\r\n\r\nThis works fine for any response or request body that is of a type that I generate using `elm-bridge`. However, This doesn't work for example, a response body of type `[Foo]`. Maybe this could be solved by creating an instance of `IsElmDefinition` like:\r\n\r\n```\r\ninstance (IsElmDefinition a) => [a] where\r\n  compileElmDef = ...\r\n```\r\n\r\nThe same thing could be done for Maybe, and other types that exist in both Haskell and Elm. There are a few other requirements unique to my use case, but I would like to know if this makes sense first. I understand that what I am asking for is beyond the original scope of `elm-bridge`."}}
{"actor":{"display_login":"tmbull"}}