graft-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Examples.Account.AbstractDomain

Synopsis

Depiction of the domain

type Payment = (String, Integer, String) Source #

A payment contains a sender, an amount and a recipient

type Policy Source #

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

type Account = (Integer, Set String) Source #

An account contains the balance and set of policies

data Register Source #

The register associates:

  • policy names with policies
  • user names with accounts

class Monad m => MonadAccounts m where Source #

Our domain specification: users can be added, payments can be attempted and balances can be requested.

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

Instances details
((), MonadAccounts m) => InterpretEffect m MonadAccountsEffect Source # 
Instance details

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 # 
Instance details

Defined in Examples.Account.PaymentMod

MonadAccounts m => InterpretMod AccountsMod m MonadAccountsEffect Source # 
Instance details

Defined in Examples.Account.PaymentMod

Methods

interpretMod :: forall (dummy :: [Effect]) a. MonadAccountsEffect (AST dummy) a -> ModInterp AccountsMod m a Source #