The Kleene star on containers can be conceptualised by the fixpoint noted_∗:Cont→Cont and implemented as x∗=μy.I+x⊳y. Using our query-response intuition, we read this type as a sequence of queries of x that depend on the previous query and a corresponding sequence of responses for those queries. We can hard-code a version without fixpoints by provinding types for the forward and the backward part.
public exportdata StarFw : (0 _ : Container) -> Type where Done : StarFw c More : (x : c.req) -> (c.res x -> StarFw c) -> StarFw cpublic exportdata StarBw : (0 c : Container) -> StarFw c -> Type where StarU : StarBw c Done StarM : {0 c : Container} -> {0 x1 : c.req} -> {x2 : c.res x1 -> StarFw c} -> (x : c.res x1) -> (StarBw c (x2 x)) -> StarBw c (More x1 x2)
Definition
The Kleene star on containers
public exportStar : Container -> ContainerStar c = (x : StarFw c) !> StarBw c x
public exportsingleton : c.req -> StarFw csingleton x = More x (\_ => Done)