Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Examples.Account.AbstractDomain
Contents
Synopsis
- type Payment = (String, Integer, String)
- type Policy = Payment -> Integer -> String -> Bool
- type Account = (Integer, Set String)
- data Register = Register {}
- class Monad m => MonadAccounts m where
- addUser :: String -> Integer -> m ()
- addPolicy :: String -> Policy -> m ()
- allPolicies :: m [String]
- subscribeToPolicy :: String -> String -> m ()
- unsubscribeToPolicy :: String -> String -> m ()
- simulate :: m a -> m (Maybe a)
- issuePayment :: Payment -> m ()
- getUserBalance :: String -> m Integer
- data MonadAccountsEffect :: Effect where
- AddUser :: forall (m :: Type -> Type). String -> Integer -> MonadAccountsEffect m ()
- AddPolicy :: forall (m :: Type -> Type). String -> Policy -> MonadAccountsEffect m ()
- AllPolicies :: forall (m :: Type -> Type). MonadAccountsEffect m [String]
- SubscribeToPolicy :: forall (m :: Type -> Type). String -> String -> MonadAccountsEffect m ()
- UnsubscribeToPolicy :: forall (m :: Type -> Type). String -> String -> MonadAccountsEffect m ()
- Simulate :: forall (m :: Type -> Type) (a :: Type). (m a) -> MonadAccountsEffect m (Maybe a)
- IssuePayment :: forall (m :: Type -> Type). Payment -> MonadAccountsEffect m ()
- GetUserBalance :: forall (m :: Type -> Type). String -> MonadAccountsEffect m Integer
Depiction of the domain
type Payment = (String, Integer, String) Source #
A payment contains a sender, an amount and a recipient
Arguments
= Payment | The payment currently validated |
-> Integer | The funds possessed by the current user |
-> String | The current user for which validation is called |
-> Bool | Returns whether the payment should go through |
The type for policies
The register associates:
- policy names with policies
- user names with accounts
Instances
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 # |
class Monad m => MonadAccounts m where Source #
Our domain specification: users can be added, payments can be attempted and balances can be requested.
Methods
addUser :: String -> Integer -> m () Source #
addPolicy :: String -> Policy -> m () Source #
allPolicies :: m [String] Source #
subscribeToPolicy :: String -> String -> m () Source #
unsubscribeToPolicy :: String -> String -> m () Source #
simulate :: m a -> m (Maybe a) Source #
issuePayment :: Payment -> m () Source #
getUserBalance :: String -> m Integer Source #
Instances
((), EffectInject MonadAccountsEffect ops) => MonadAccounts (AST ops) Source # | |
Defined in Examples.Account.AbstractDomain Methods addUser :: String -> Integer -> AST ops () Source # addPolicy :: String -> Policy -> AST ops () Source # allPolicies :: AST ops [String] Source # subscribeToPolicy :: String -> String -> AST ops () Source # unsubscribeToPolicy :: String -> String -> AST ops () Source # simulate :: AST ops a -> AST ops (Maybe a) Source # issuePayment :: Payment -> AST ops () 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 # |
data MonadAccountsEffect :: Effect where Source #
Effects for the abstract domain
Constructors
AddUser :: forall (m :: Type -> Type). String -> Integer -> MonadAccountsEffect m () | |
AddPolicy :: forall (m :: Type -> Type). String -> Policy -> MonadAccountsEffect m () | |
AllPolicies :: forall (m :: Type -> Type). MonadAccountsEffect m [String] | |
SubscribeToPolicy :: forall (m :: Type -> Type). String -> String -> MonadAccountsEffect m () | |
UnsubscribeToPolicy :: forall (m :: Type -> Type). String -> String -> MonadAccountsEffect m () | |
Simulate :: forall (m :: Type -> Type) (a :: Type). (m a) -> MonadAccountsEffect m (Maybe a) | |
IssuePayment :: forall (m :: Type -> Type). Payment -> MonadAccountsEffect m () | |
GetUserBalance :: forall (m :: Type -> Type). String -> MonadAccountsEffect m Integer |
Instances
((), MonadAccounts m) => InterpretEffect m MonadAccountsEffect Source # | |
Defined in Examples.Account.AbstractDomain Methods interpretEffect :: forall (ops :: [Effect]) a. (forall b. AST ops b -> m b) -> MonadAccountsEffect (AST ops) a -> m a Source # | |
MonadAccounts m => InterpretLtlHigherOrder AccountsMod m MonadAccountsEffect Source # | |
Defined in Examples.Account.PaymentMod Methods interpretLtlHigherOrder :: forall (ops :: [Effect]) a. MonadAccountsEffect (AST ops) a -> LtlInterpHigherOrder AccountsMod m ops a Source # | |
MonadAccounts m => InterpretMod AccountsMod m MonadAccountsEffect Source # | |
Defined in Examples.Account.PaymentMod Methods interpretMod :: forall (dummy :: [Effect]) a. MonadAccountsEffect (AST dummy) a -> ModInterp AccountsMod m a Source # |