{"action":"created","issue":{"url":"https://api.github.com/repos/ekmett/mtl/issues/32","repository_url":"https://api.github.com/repos/ekmett/mtl","labels_url":"https://api.github.com/repos/ekmett/mtl/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/ekmett/mtl/issues/32/comments","events_url":"https://api.github.com/repos/ekmett/mtl/issues/32/events","html_url":"https://github.com/ekmett/mtl/issues/32","id":138742069,"number":32,"title":"Add MonadDeclare","user":{"login":"fizruk","id":686582,"avatar_url":"https://avatars.githubusercontent.com/u/686582?v=3","gravatar_id":"","url":"https://api.github.com/users/fizruk","html_url":"https://github.com/fizruk","followers_url":"https://api.github.com/users/fizruk/followers","following_url":"https://api.github.com/users/fizruk/following{/other_user}","gists_url":"https://api.github.com/users/fizruk/gists{/gist_id}","starred_url":"https://api.github.com/users/fizruk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fizruk/subscriptions","organizations_url":"https://api.github.com/users/fizruk/orgs","repos_url":"https://api.github.com/users/fizruk/repos","events_url":"https://api.github.com/users/fizruk/events{/privacy}","received_events_url":"https://api.github.com/users/fizruk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-03-06T01:29:27Z","updated_at":"2016-07-08T17:12:25Z","closed_at":null,"body":"`swagger2` makes use of a [`DeclareT` monad transformer](http://hackage.haskell.org/package/swagger2-2.0.1/docs/Data-Swagger-Declare.html) which lies between the `WriterT` and `StateT`.\r\nIt also provides an `mtl`-style `MonadDeclare` type class with some laws.\r\nSince the construction is not specific to `swagger2`, it might make sense to add it to `mtl` and `transformers`.\r\n\r\nA corresponding [issue for `transformers` is here](http://hub.darcs.net/ross/transformers/issue/24).\r\n\r\nThe rationale for `Declare` is generating a list of Swagger schema definitions.\r\nTo avoid duplicates and to fix recursive schemas we need to `look` at the previous definitions.\r\nBut we don't want a full `State` because we don't want someone to accidentally erase/change all/some previous definitions in a `ToSchema` instance for a user data type.\r\nThe laziness plays nice part here and allows (mutually) recursive schemas to be written easily (e.g. see [sources for `declareSchemaRef`](http://hackage.haskell.org/package/swagger2-2.0.1/docs/src/Data-Swagger-Internal-Schema.html#declareSchemaRef)).\r\n"},"comment":{"url":"https://api.github.com/repos/ekmett/mtl/issues/comments/231417398","html_url":"https://github.com/ekmett/mtl/issues/32#issuecomment-231417398","issue_url":"https://api.github.com/repos/ekmett/mtl/issues/32","id":231417398,"user":{"login":"ElvishJerricco","id":1365692,"avatar_url":"https://avatars.githubusercontent.com/u/1365692?v=3","gravatar_id":"","url":"https://api.github.com/users/ElvishJerricco","html_url":"https://github.com/ElvishJerricco","followers_url":"https://api.github.com/users/ElvishJerricco/followers","following_url":"https://api.github.com/users/ElvishJerricco/following{/other_user}","gists_url":"https://api.github.com/users/ElvishJerricco/gists{/gist_id}","starred_url":"https://api.github.com/users/ElvishJerricco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElvishJerricco/subscriptions","organizations_url":"https://api.github.com/users/ElvishJerricco/orgs","repos_url":"https://api.github.com/users/ElvishJerricco/repos","events_url":"https://api.github.com/users/ElvishJerricco/events{/privacy}","received_events_url":"https://api.github.com/users/ElvishJerricco/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T17:12:25Z","updated_at":"2016-07-08T17:12:25Z","body":"It is possible, when working directly in `DeclareT`, to erase declared values.\r\n\r\n```haskell\r\nghci> execDeclare [] $ do\r\n  declare [1]\r\n  DeclareT $ const $ return ([], ())\r\n[]\r\n```\r\n\r\nNow, I see that the laws are carefully constructed such that this isn't a violation of any sort. But it does make me question the *usefulness* of those laws. When given an arbitrary `MonadDeclare d m => m a`, you have no idea if it behaves as a state monad or a declare monad, as it might wipe any declarations you make before using it. I imagine this should be seen as a problem?"}}
{"actor":{"display_login":"ElvishJerricco"}}