{"action":"created","issue":{"url":"https://api.github.com/repos/ekmett/lens/issues/520","labels_url":"https://api.github.com/repos/ekmett/lens/issues/520/labels{/name}","comments_url":"https://api.github.com/repos/ekmett/lens/issues/520/comments","events_url":"https://api.github.com/repos/ekmett/lens/issues/520/events","html_url":"https://github.com/ekmett/lens/issues/520","id":57141404,"number":520,"title":"overM and setM","user":{"login":"yongqli","id":67243,"avatar_url":"https://avatars.githubusercontent.com/u/67243?v=3","gravatar_id":"","url":"https://api.github.com/users/yongqli","html_url":"https://github.com/yongqli","followers_url":"https://api.github.com/users/yongqli/followers","following_url":"https://api.github.com/users/yongqli/following{/other_user}","gists_url":"https://api.github.com/users/yongqli/gists{/gist_id}","starred_url":"https://api.github.com/users/yongqli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yongqli/subscriptions","organizations_url":"https://api.github.com/users/yongqli/orgs","repos_url":"https://api.github.com/users/yongqli/repos","events_url":"https://api.github.com/users/yongqli/events{/privacy}","received_events_url":"https://api.github.com/users/yongqli/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-10T07:45:58Z","updated_at":"2015-02-10T07:52:55Z","closed_at":"2015-02-10T07:52:55Z","body":"Do these functions exist already? I cannot find them, and they seem generally useful.\r\n\r\n    overM :: Monad m => ASetter s t a b -> (a -> m b) -> s -> m t\r\n\r\n    setM :: Monad m => ASetter s t a b -> m b -> s -> m t\r\n    setM setter valM target = do\r\n      val <- valM\r\n      return $ target & setter .~ val\r\n    {-# INLINE setM #-}\r\n\r\nWhat's the easiest way to write `overM`? \r\n\r\nI use `setM` quite a bit as I have a lot of \"pure\" computations that are stuck inside of a `MonadRandom`."},"comment":{"url":"https://api.github.com/repos/ekmett/lens/issues/comments/73657946","html_url":"https://github.com/ekmett/lens/issues/520#issuecomment-73657946","issue_url":"https://api.github.com/repos/ekmett/lens/issues/520","id":73657946,"user":{"login":"ekmett","id":304657,"avatar_url":"https://avatars.githubusercontent.com/u/304657?v=3","gravatar_id":"","url":"https://api.github.com/users/ekmett","html_url":"https://github.com/ekmett","followers_url":"https://api.github.com/users/ekmett/followers","following_url":"https://api.github.com/users/ekmett/following{/other_user}","gists_url":"https://api.github.com/users/ekmett/gists{/gist_id}","starred_url":"https://api.github.com/users/ekmett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekmett/subscriptions","organizations_url":"https://api.github.com/users/ekmett/orgs","repos_url":"https://api.github.com/users/ekmett/repos","events_url":"https://api.github.com/users/ekmett/events{/privacy}","received_events_url":"https://api.github.com/users/ekmett/received_events","type":"User","site_admin":false},"created_at":"2015-02-10T07:52:55Z","updated_at":"2015-02-10T07:52:55Z","body":"You can't write them. a setter isn't powerful enough to allow monadic effects.\r\n\r\nYou can write them with a `Traversal`, that is `overM` is `mapMOf`.\r\n\r\nStick a `const` in the right place and you can write your `setM` as well, but it isn't named as there isn't a named analogue in `Traversable."}}