Skip to content

Instantly share code, notes, and snippets.

@gigobyte
Created January 11, 2019 20:16
Show Gist options
  • Save gigobyte/be13ba03b9873ecaba45e9bd8334eab9 to your computer and use it in GitHub Desktop.
Save gigobyte/be13ba03b9873ecaba45e9bd8334eab9 to your computer and use it in GitHub Desktop.
Infix vs do notation
headerToUsername :: Text -> Maybe Text
headerToUsername authHeader = do
JWT.stringOrURIToText <$> (JWT.sub =<< JWT.claims <$> JWT.decode authHeader)
headerToUsernameDo :: Text -> Maybe Text
headerToUsernameDo authHeader = do
unverifiedJwt <- JWT.decode authHeader
subject <- JWT.sub $ JWT.claims unverifiedJwt
return $ JWT.stringOrURIToText subject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment