{"action":"created","issue":{"url":"https://api.github.com/repos/bjornbm/dimensional/issues/163","repository_url":"https://api.github.com/repos/bjornbm/dimensional","labels_url":"https://api.github.com/repos/bjornbm/dimensional/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/bjornbm/dimensional/issues/163/comments","events_url":"https://api.github.com/repos/bjornbm/dimensional/issues/163/events","html_url":"https://github.com/bjornbm/dimensional/issues/163","id":165568081,"number":163,"title":"Dynamic prefix selection","user":{"login":"dmcclean","id":603347,"avatar_url":"https://avatars.githubusercontent.com/u/603347?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcclean","html_url":"https://github.com/dmcclean","followers_url":"https://api.github.com/users/dmcclean/followers","following_url":"https://api.github.com/users/dmcclean/following{/other_user}","gists_url":"https://api.github.com/users/dmcclean/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcclean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcclean/subscriptions","organizations_url":"https://api.github.com/users/dmcclean/orgs","repos_url":"https://api.github.com/users/dmcclean/repos","events_url":"https://api.github.com/users/dmcclean/events{/privacy}","received_events_url":"https://api.github.com/users/dmcclean/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bjornbm/dimensional/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"dmcclean","id":603347,"avatar_url":"https://avatars.githubusercontent.com/u/603347?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcclean","html_url":"https://github.com/dmcclean","followers_url":"https://api.github.com/users/dmcclean/followers","following_url":"https://api.github.com/users/dmcclean/following{/other_user}","gists_url":"https://api.github.com/users/dmcclean/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcclean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcclean/subscriptions","organizations_url":"https://api.github.com/users/dmcclean/orgs","repos_url":"https://api.github.com/users/dmcclean/repos","events_url":"https://api.github.com/users/dmcclean/events{/privacy}","received_events_url":"https://api.github.com/users/dmcclean/received_events","type":"User","site_admin":false},"assignees":[{"login":"dmcclean","id":603347,"avatar_url":"https://avatars.githubusercontent.com/u/603347?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcclean","html_url":"https://github.com/dmcclean","followers_url":"https://api.github.com/users/dmcclean/followers","following_url":"https://api.github.com/users/dmcclean/following{/other_user}","gists_url":"https://api.github.com/users/dmcclean/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcclean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcclean/subscriptions","organizations_url":"https://api.github.com/users/dmcclean/orgs","repos_url":"https://api.github.com/users/dmcclean/repos","events_url":"https://api.github.com/users/dmcclean/events{/privacy}","received_events_url":"https://api.github.com/users/dmcclean/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-07-14T13:55:50Z","updated_at":"2016-07-14T14:01:51Z","closed_at":null,"body":"I'd like to be able to display a `Length Double` by automatically selecting an appropriate metric prefix for `meter` based on the value of the `Length Double` rather than requiring a static selection of prefix.\r\n\r\nAs far as I can tell, we don't have support for this. Now that we have reified `Prefix`es, a list of `siPrefixes`, and the `applyPrefix` function (https://github.com/bjornbm/dimensional/blob/master/src/Numeric/Units/Dimensional/SIUnits.hs#L112-L116) we are close, we just need a function to select the correct prefix.\r\n\r\nProposed interface: (the `Floating` context being required to access `logBase` and `RealFrac` being required for `truncate`)\r\n\r\n```\r\nwithAppropriatePrefix :: (Floating a, RealFrac a) => Unit 'Metric d a -> Quantity d a -> Unit 'NonMetric d a\r\n```\r\n\r\nWe could possibly also expose:\r\n\r\n```\r\nappropriatePrefix :: (Floating a, RealFrac a) => Unit 'Metric d a -> Quantity d a -> Prefix\r\n```\r\n\r\nwhere\r\n\r\n```\r\nwithAppropriatePrefix u q = applyPrefix (appropriatePrefix u q) u\r\n```\r\n\r\nAre there any reasons why this is undesirable? Are these names any good?"},"comment":{"url":"https://api.github.com/repos/bjornbm/dimensional/issues/comments/232674195","html_url":"https://github.com/bjornbm/dimensional/issues/163#issuecomment-232674195","issue_url":"https://api.github.com/repos/bjornbm/dimensional/issues/163","id":232674195,"user":{"login":"dmcclean","id":603347,"avatar_url":"https://avatars.githubusercontent.com/u/603347?v=3","gravatar_id":"","url":"https://api.github.com/users/dmcclean","html_url":"https://github.com/dmcclean","followers_url":"https://api.github.com/users/dmcclean/followers","following_url":"https://api.github.com/users/dmcclean/following{/other_user}","gists_url":"https://api.github.com/users/dmcclean/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcclean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcclean/subscriptions","organizations_url":"https://api.github.com/users/dmcclean/orgs","repos_url":"https://api.github.com/users/dmcclean/repos","events_url":"https://api.github.com/users/dmcclean/events{/privacy}","received_events_url":"https://api.github.com/users/dmcclean/received_events","type":"User","site_admin":false},"created_at":"2016-07-14T14:01:50Z","updated_at":"2016-07-14T14:01:50Z","body":"That split into `appropriatePrefix` and `withAppropriatePrefix` ignores some concerns about the fact that the appropriate prefix is sometimes no prefix at all. Change the return type of `appropriatePrefix` to be `Maybe Prefix` and the definition of `withAppropriatePrefix` to deal with it."}}
{"actor":{"display_login":"dmcclean"}}