| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
| Extensions |
|
Libjwt.Flag
Description
Support for simple sum types.
Synopsis
- newtype Flag a = Flag {
- getFlag :: a
- class AFlag a where
- getFlagValue :: a -> ASCII
- setFlagValue :: ASCII -> Maybe a
Documentation
Value that is encoded and decoded as AFlag
Flags provide a way to automatically encode and decode simple sum types.
data Scope = Login | Extended | UserRead | UserWrite | AccountRead | AccountWrite
deriving stock (Show, Eq, Generic)
instance AFlag Scope
mkPayload = jwtPayload
(withIssuer "myApp" <> withRecipient "https://myApp.com" <> setTtl 300)
( #user_name ->> "John Doe"
, #is_root ->> False
, #user_id ->> (12345 :: Int)
, #scope ->> Flag Login
)
Instances
| AFlag a => JwtRep ASCII (Flag a) Source # | |
| Eq a => Eq (Flag a) Source # | |
| Show a => Show (Flag a) Source # | |
| AFlag a => AFlag (Flag a) Source # | |
Defined in Libjwt.Flag | |
| AFlag a => JsonParser (Flag a) Source # | |
Defined in Libjwt.Classes | |
| AFlag a => JsonBuilder (Flag a) Source # | |
Defined in Libjwt.Classes Methods jsonBuilder :: Flag a -> Builder Source # | |
Types that can be used as flags . That is, they support conversion to/from ASCII values, for example, simple sum types are good candidates that can even be generically derived
data Scope = Login | Extended | UserRead | UserWrite | AccountRead | AccountWrite deriving stock (Show, Eq, Generic) instance AFlag Scope
>>>getFlagValue UserWriteASCII {getASCII = "userWrite"}
>>>setFlagValue (ASCII "userWrite") :: Maybe ScopeJust UserWrite
Minimal complete definition
Nothing