graft-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Examples.Account.SimpleDomain

Synopsis

Documentation

type AccountsT m = ExceptT AccountsError (StateT Register m) Source #

Our domain implementation

Some helper functions over AccountsT m

ensureExistingUser :: Monad m => String -> AccountsT m Account Source #

Ensures a user is registered and returns the associated account

ensureNonExistingUser :: Monad m => String -> AccountsT m () Source #

Ensures a user is not registered

modifyAccounts :: Monad m => (Map String Account -> Map String Account) -> AccountsT m () Source #

Modifies the current map of accounts

ensureExistingPolicy :: Monad m => String -> AccountsT m Policy Source #

Ensures a policy is registered and executes an action based on its value

ensureNonExistingPolicy :: Monad m => String -> AccountsT m () Source #

Ensures a policy is not present and executes an action

modifyPolicies :: Monad m => (Map String Policy -> Map String Policy) -> AccountsT m () Source #

Modifies the current map of policies

runAccountsT :: Monad m => Register -> AccountsT m a -> m (Either AccountsError a, Map String Account) Source #

A function to run the domain and return relevant information