Make comments clearer

This commit is contained in:
patrick brisbin 2018-07-29 09:59:59 -04:00
parent dacc71f008
commit db65bbc528
No known key found for this signature in database
GPG Key ID: 4243EA839B9CC425

View File

@ -62,21 +62,17 @@ authOAuth2Widget widget name oauth getCreds =
where where
login tm = [whamlet|<a href=@{tm $ oauth2Url name}>^{widget}|] login tm = [whamlet|<a href=@{tm $ oauth2Url name}>^{widget}|]
-- | Read from the values set via @'setExtra'@ -- | Read the @'AccessToken'@ from the values set via @'setExtra'@
getAccessToken :: Creds m -> Maybe AccessToken getAccessToken :: Creds m -> Maybe AccessToken
getAccessToken = getAccessToken =
(AccessToken <$>) . lookup "accessToken" . credsExtra (AccessToken <$>) . lookup "accessToken" . credsExtra
-- | Read from the values set via @'setExtra'@ -- | Read the original profile response from the values set via @'setExtra'@
getUserResponse :: Creds m -> Maybe ByteString getUserResponse :: Creds m -> Maybe ByteString
getUserResponse = getUserResponse =
(fromStrict . encodeUtf8 <$>) . lookup "userResponse" . credsExtra (fromStrict . encodeUtf8 <$>) . lookup "userResponse" . credsExtra
-- | Read from the values set via @'setExtra'@, decode as JSON -- | @'getUserResponse'@, and decode as JSON
--
-- This is unsafe if the key is missing, but safe with respect to parsing
-- errors.
--
getUserResponseJSON :: FromJSON a => Creds m -> Either String a getUserResponseJSON :: FromJSON a => Creds m -> Either String a
getUserResponseJSON = getUserResponseJSON =
eitherDecode <=< note "userResponse key not present" . getUserResponse eitherDecode <=< note "userResponse key not present" . getUserResponse