kowainik / cake-slayer

🍰🔪 Architecture of Haskell backend applications
https://kowainik.github.io/projects/cake-slayer
Mozilla Public License 2.0
132 stars 6 forks source link

Patch 'MonadJwt' to handle different payloads #21

Closed chshersh closed 5 years ago

chshersh commented 5 years ago

Currently MonadJwt typeclass looks like this:

class Monad m => MonadJwt m where
    mkJwtToken :: Int -> JwtPayload Text -> m JwtToken
    verifyJwtToken :: JwtToken -> m (Maybe (JwtPayload Text))

I propose to add one more parameter to it, like this:

class Monad m => MonadJwt payload m where
    mkJwtToken :: Int -> JwtPayload payload -> m JwtToken
    verifyJwtToken :: JwtToken -> m (Maybe (JwtPayload payload))

This approach should allow to handle different types of payloads and have multiple instances for a single monad.

What do you think?