1 import Base 2 3 type Granted is Data: 4 Granted{} 5 6 type Grant is Data: 7 NoStructural{} 8 Structural{} 9 type Context is Data: 10 Context{namespace:U32,id:U32,grant:Grant} 11 type Permit is Data: 12 Authorized{namespace:U32,id:U32} 13 Unauthorized{} 14 15 # The prepared framework boundary supplies Context from its actual owner and 16 # closed command declaration. Gameplay bodies quantify an abstract Permit. 17 def qualified(context:Context) -> Permit: 18 match context: 19 case Context{namespace,id,Structural{}}:Authorized{namespace,id} 20 case Context{_,_,NoStructural{}}:Unauthorized{} 21 def admitted(permit:Permit,namespace:U32,identity:Maybe<&2,U32>) -> Bool: 22 match permit identity: 23 case Authorized{actual,id} Some{expected}:Bool.and(U32.is_eq(actual,namespace),U32.is_eq(id,expected)) 24 case _ _:False{}