module Servant.Server.Auth.Token.Common where
import Database.Persist.Sql
import qualified Data.Text as T
import qualified Data.ByteString.Lazy.Char8 as BSL
showb :: Show a => a -> BSL.ByteString
showb = BSL.pack . show
showt :: Show a => a -> T.Text
showt = T.pack . show
whenNothing :: Applicative m => Maybe a -> m () -> m ()
whenNothing Nothing m = m
whenNothing (Just _) _ = pure ()
whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()
whenJust Nothing _ = pure ()
whenJust (Just x) m = m x
fromKey :: (Integral a, ToBackendKey SqlBackend record)
=> Key record -> a
fromKey = fromIntegral . fromSqlKey
toKey :: (Integral a, ToBackendKey SqlBackend record)
=> a -> Key record
toKey = toSqlKey . fromIntegral