{"action":"created","issue":{"url":"https://api.github.com/repos/sannsyn/json-encoder/issues/1","labels_url":"https://api.github.com/repos/sannsyn/json-encoder/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/sannsyn/json-encoder/issues/1/comments","events_url":"https://api.github.com/repos/sannsyn/json-encoder/issues/1/events","html_url":"https://github.com/sannsyn/json-encoder/issues/1","id":122845926,"number":1,"title":"Operators for choose/divide?","user":{"login":"mitchellwrosen","id":1074598,"avatar_url":"https://avatars.githubusercontent.com/u/1074598?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellwrosen","html_url":"https://github.com/mitchellwrosen","followers_url":"https://api.github.com/users/mitchellwrosen/followers","following_url":"https://api.github.com/users/mitchellwrosen/following{/other_user}","gists_url":"https://api.github.com/users/mitchellwrosen/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellwrosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellwrosen/subscriptions","organizations_url":"https://api.github.com/users/mitchellwrosen/orgs","repos_url":"https://api.github.com/users/mitchellwrosen/repos","events_url":"https://api.github.com/users/mitchellwrosen/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellwrosen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-17T23:31:52Z","updated_at":"2015-12-18T00:12:56Z","closed_at":null,"body":"Hi, I just stumbled upon this library and tried it out. First time using `Decidable` and `Divisible` and they seem rather elegant. However, I found the code rather hard to write without infix operators similar to `<*>` and `<|>`. Moreover, I had to manually turn my ADT into a \"canonical\" form, using `Either` and `(,)`.\r\n\r\nFor example,\r\n\r\n```haskell\r\ndata Foo \r\n    = One Text \r\n    | Two Text Text \r\n    | Three Text Text Text\r\n\r\n-- it would be nice to derive this with Generics and TH\r\ngfoo :: Foo -> Either Text (Either (Text, Text) (Text, (Text, Text)))\r\ngfoo = ...\r\n\r\nfooValue :: Value Foo\r\nfooValue = contramap gfoo $\r\n    string\r\n    <||> string <//> string\r\n    <||> string <//> string <//> string\r\n\r\ninfixr 4 <||>\r\n(<||>) = chosen\r\n\r\ninfixr 5 <//>\r\n(<//>) = divided\r\n```\r\n\r\nAnyways, I guess my question is what is the recommended way of writing `Value`s? It seems wrong to include operators here that aren't defined in `contramap` - and I assume they aren't defined in `contramap` for a good reason. But, I couldn't figure out a way to write readable code without them.\r\n\r\nThanks!\r\nMitchell"},"comment":{"url":"https://api.github.com/repos/sannsyn/json-encoder/issues/comments/165621462","html_url":"https://github.com/sannsyn/json-encoder/issues/1#issuecomment-165621462","issue_url":"https://api.github.com/repos/sannsyn/json-encoder/issues/1","id":165621462,"user":{"login":"nikita-volkov","id":1560937,"avatar_url":"https://avatars.githubusercontent.com/u/1560937?v=3","gravatar_id":"","url":"https://api.github.com/users/nikita-volkov","html_url":"https://github.com/nikita-volkov","followers_url":"https://api.github.com/users/nikita-volkov/followers","following_url":"https://api.github.com/users/nikita-volkov/following{/other_user}","gists_url":"https://api.github.com/users/nikita-volkov/gists{/gist_id}","starred_url":"https://api.github.com/users/nikita-volkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikita-volkov/subscriptions","organizations_url":"https://api.github.com/users/nikita-volkov/orgs","repos_url":"https://api.github.com/users/nikita-volkov/repos","events_url":"https://api.github.com/users/nikita-volkov/events{/privacy}","received_events_url":"https://api.github.com/users/nikita-volkov/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T00:12:55Z","updated_at":"2015-12-18T00:12:55Z","body":"Wow! You're trying out a library with that quality of the documentation. You must be really desperate! :) That alone deserves respect, man!\r\n\r\nNow, concerning the recommendations.\r\n\r\nI never define custom operators, I find the existing ones of the category theory abstractions sufficient for any task. It's a personal opinion though, so I can't strongly recommend that.\r\n\r\nI would advice against the `gfoo` thing in particular, and against looking for automagical Generics-based solutions in general though. One of the primary ideas behind this library was to move away from data-type-dictated encoder specifications. Instead it aims to let the encoder specifications be specified directly using the simplest building blocks, which are functions. That is instead of having them dispersed across datatypes, weird typeclass instances and functions, as the alternative APIs tend to impose.\r\n\r\nUntil I fix the documentation issue, I recommend you to check out [the Encoders DSL of the Hasql library](http://hackage.haskell.org/package/hasql-0.15.0.2/docs/Hasql-Encoders.html), since it shares the design with this library, but has a better documentation.\r\n\r\nFor using the product types in the contravariant context I've released [a utility library](http://hackage.haskell.org/package/contravariant-extras-0.3/docs/Contravariant-Extras-Contrazip.html). I think the library could be extended in a similar fashion to cover the sum types, which you have in your case. I'll think of something later. Suggestions are welcome."}}