Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Examples.Account.SimpleDomain
Synopsis
- data AccountsError
- type AccountsT m = ExceptT AccountsError (StateT Register m)
- ensureExistingUser :: Monad m => String -> AccountsT m Account
- ensureNonExistingUser :: Monad m => String -> AccountsT m ()
- modifyAccounts :: Monad m => (Map String Account -> Map String Account) -> AccountsT m ()
- ensureExistingPolicy :: Monad m => String -> AccountsT m Policy
- ensureNonExistingPolicy :: Monad m => String -> AccountsT m ()
- modifyPolicies :: Monad m => (Map String Policy -> Map String Policy) -> AccountsT m ()
- runAccountsT :: Monad m => Register -> AccountsT m a -> m (Either AccountsError a, Map String Account)
Documentation
data AccountsError Source #
Errors raised by the domain
Constructors
NoSuchAccount String | |
AlreadyExistingAccount String | |
NoSuchPolicy String | |
AlreadyExistingPolicy String | |
PolicyError |
Instances
Show AccountsError Source # | |
Defined in Examples.Account.SimpleDomain Methods showsPrec :: Int -> AccountsError -> ShowS # show :: AccountsError -> String # showList :: [AccountsError] -> ShowS # | |
MonadPlus m => Alternative (AccountsT m) Source # | |
MonadPlus m => MonadPlus (AccountsT m) Source # | |
Monad m => MonadAccounts (AccountsT m) Source # | |
Defined in Examples.Account.SimpleDomain Methods addUser :: String -> Integer -> AccountsT m () Source # addPolicy :: String -> Policy -> AccountsT m () Source # allPolicies :: AccountsT m [String] Source # subscribeToPolicy :: String -> String -> AccountsT m () Source # unsubscribeToPolicy :: String -> String -> AccountsT m () Source # simulate :: AccountsT m a -> AccountsT m (Maybe a) Source # issuePayment :: Payment -> AccountsT m () Source # |
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