{"action":"created","issue":{"url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/issues/431","labels_url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/issues/431/labels{/name}","comments_url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/issues/431/comments","events_url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/issues/431/events","html_url":"https://github.com/ucsd-progsys/liquidhaskell/issues/431","id":102853984,"number":431,"title":"Change how Configs are merged","user":{"login":"christetreault","id":5084845,"avatar_url":"https://avatars.githubusercontent.com/u/5084845?v=3","gravatar_id":"","url":"https://api.github.com/users/christetreault","html_url":"https://github.com/christetreault","followers_url":"https://api.github.com/users/christetreault/followers","following_url":"https://api.github.com/users/christetreault/following{/other_user}","gists_url":"https://api.github.com/users/christetreault/gists{/gist_id}","starred_url":"https://api.github.com/users/christetreault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christetreault/subscriptions","organizations_url":"https://api.github.com/users/christetreault/orgs","repos_url":"https://api.github.com/users/christetreault/repos","events_url":"https://api.github.com/users/christetreault/events{/privacy}","received_events_url":"https://api.github.com/users/christetreault/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"christetreault","id":5084845,"avatar_url":"https://avatars.githubusercontent.com/u/5084845?v=3","gravatar_id":"","url":"https://api.github.com/users/christetreault","html_url":"https://github.com/christetreault","followers_url":"https://api.github.com/users/christetreault/followers","following_url":"https://api.github.com/users/christetreault/following{/other_user}","gists_url":"https://api.github.com/users/christetreault/gists{/gist_id}","starred_url":"https://api.github.com/users/christetreault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christetreault/subscriptions","organizations_url":"https://api.github.com/users/christetreault/orgs","repos_url":"https://api.github.com/users/christetreault/repos","events_url":"https://api.github.com/users/christetreault/events{/privacy}","received_events_url":"https://api.github.com/users/christetreault/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-08-24T17:56:29Z","updated_at":"2015-08-24T18:48:14Z","closed_at":null,"body":"Currently, the Liquid Haskell `Config` type has a `Monoid` instance and this is used to merge configurations (environment variable + command linea args = `Config`). \r\n\r\nAfter [some discussion](https://github.com/ucsd-progsys/liquid-fixpoint/issues/90#issuecomment-133581372) it seems that this might not be the best way. @gridaphobe suggested a new function `mergeConfig :: Config -> Config -> Config`, not bound by the `Monoid` laws that can be used to merge the configs an a sane manner. This function would merge the configs such that higher priority items override lower priority with `priority = env < file < cmdline`."},"comment":{"url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/issues/comments/134335368","html_url":"https://github.com/ucsd-progsys/liquidhaskell/issues/431#issuecomment-134335368","issue_url":"https://api.github.com/repos/ucsd-progsys/liquidhaskell/issues/431","id":134335368,"user":{"login":"ranjitjhala","id":1650232,"avatar_url":"https://avatars.githubusercontent.com/u/1650232?v=3","gravatar_id":"","url":"https://api.github.com/users/ranjitjhala","html_url":"https://github.com/ranjitjhala","followers_url":"https://api.github.com/users/ranjitjhala/followers","following_url":"https://api.github.com/users/ranjitjhala/following{/other_user}","gists_url":"https://api.github.com/users/ranjitjhala/gists{/gist_id}","starred_url":"https://api.github.com/users/ranjitjhala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranjitjhala/subscriptions","organizations_url":"https://api.github.com/users/ranjitjhala/orgs","repos_url":"https://api.github.com/users/ranjitjhala/repos","events_url":"https://api.github.com/users/ranjitjhala/events{/privacy}","received_events_url":"https://api.github.com/users/ranjitjhala/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T18:48:14Z","updated_at":"2015-08-24T18:48:14Z","body":"This seems too complicated.\nCan someone remind me of what the problem is with chris' monoid suggestion?\n\n> On Aug 24, 2015, at 11:22 AM, Eric Seidel <notifications@github.com> wrote:\n> \n> That's not quite what I meant, so let me elaborate. My suggestion is that instead of having the config-parser return a full Config it should return a function from Config -> Config, e.g.\n> \n> parseFlag :: String -> (Config -> Config)\n> -- parseFlag \"--no-termination\" = \\cfg -> cfg { noTermination = True }\n> -- parseFlag \"--idirs src\" = \\cfg -> cfg { idirs = \"src\" : idirs cfg }\n> -- etc.\n> The comments are examples of how this function should behave, not a suggested implementation :) Then we could run the parser on the three different sources of flags and combine the resulting functions (incidentally, these Config -> Config functions do form a Monoid, where mappend = (.) and mempty = id), giving us a single Config -> Config function that we can apply to the default Config. So the top-level parser would look something like\n> \n> getOpts :: FilePath -> IO Config\n> getOpts file = do\n>   envT <- parseFlags <$> lookupEnv \"LIQUIDHASKELL_OPTS\"\n>   fileT <- parseFlags <$> readPragmas file\n>   argsT <- parseFlags <$> getArgs\n>   return (argsT . fileT . envT $ defaultConfig)\n> I don't know how difficult it would be to rewrite our config-parser in this manner, it probably depends on the API the underlying parser library provides. Currently we use http://hackage.haskell.org/package/cmdargs.\n> \n> —\n> Reply to this email directly or view it on GitHub.\n> \n"}}