{"action":"closed","issue":{"url":"https://api.github.com/repos/kolmodin/binary/issues/108","repository_url":"https://api.github.com/repos/kolmodin/binary","labels_url":"https://api.github.com/repos/kolmodin/binary/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/kolmodin/binary/issues/108/comments","events_url":"https://api.github.com/repos/kolmodin/binary/issues/108/events","html_url":"https://github.com/kolmodin/binary/issues/108","id":138673813,"number":108,"title":"instance Binary Bool (get) throws exception on invalid inputs","user":{"login":"iphydf","id":10647936,"avatar_url":"https://avatars.githubusercontent.com/u/10647936?v=3","gravatar_id":"","url":"https://api.github.com/users/iphydf","html_url":"https://github.com/iphydf","followers_url":"https://api.github.com/users/iphydf/followers","following_url":"https://api.github.com/users/iphydf/following{/other_user}","gists_url":"https://api.github.com/users/iphydf/gists{/gist_id}","starred_url":"https://api.github.com/users/iphydf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iphydf/subscriptions","organizations_url":"https://api.github.com/users/iphydf/orgs","repos_url":"https://api.github.com/users/iphydf/repos","events_url":"https://api.github.com/users/iphydf/events{/privacy}","received_events_url":"https://api.github.com/users/iphydf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"kolmodin","id":157261,"avatar_url":"https://avatars.githubusercontent.com/u/157261?v=3","gravatar_id":"","url":"https://api.github.com/users/kolmodin","html_url":"https://github.com/kolmodin","followers_url":"https://api.github.com/users/kolmodin/followers","following_url":"https://api.github.com/users/kolmodin/following{/other_user}","gists_url":"https://api.github.com/users/kolmodin/gists{/gist_id}","starred_url":"https://api.github.com/users/kolmodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolmodin/subscriptions","organizations_url":"https://api.github.com/users/kolmodin/orgs","repos_url":"https://api.github.com/users/kolmodin/repos","events_url":"https://api.github.com/users/kolmodin/events{/privacy}","received_events_url":"https://api.github.com/users/kolmodin/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-03-05T12:18:57Z","updated_at":"2016-03-06T14:01:30Z","closed_at":"2016-03-06T14:01:30Z","body":"In Data.Binary.Class:\r\n```haskell\r\ninstance Binary Bool where\r\n    put     = putWord8 . fromIntegral . fromEnum\r\n    get     = liftM (toEnum . fromIntegral) getWord8\r\n```\r\n\r\nIn GHC.Enum:\r\n```haskell\r\ninstance Enum Bool where\r\n  -- [...]\r\n  toEnum n | n == 0    = False\r\n           | n == 1    = True\r\n           | otherwise = error \"Prelude.Enum.Bool.toEnum: bad argument\"\r\n ```\r\n\r\nThis makes Binary unusable for any data structure containing Bool. I don't want runGetIncremental to throw exceptions, I want it to return Fail. A workaround for this is to have a newtype around Bool and define a non-throwing Binary instance on it: https://github.com/TokTok/hstox/blob/master/src/Network/Tox/Encoding.hs#L15 (no guarantees for stability of this link)."}}