diff --git a/lib/StackAction.ml b/lib/StackAction.ml index d6e0e85..b18c937 100644 --- a/lib/StackAction.ml +++ b/lib/StackAction.ml @@ -14,3 +14,5 @@ let merge lhs rhs = { pop = lhs.pop + pop; push = List.append push rhs.push; } let empty = { pop = 0; push = []; } + +let map f sta = { pop = sta.pop; push = List.map f sta.push; } diff --git a/lib/StackAction.mli b/lib/StackAction.mli new file mode 100644 index 0000000..3da10cd --- /dev/null +++ b/lib/StackAction.mli @@ -0,0 +1,11 @@ +(** A stack action (pop is run first, then push sequentially) *) +type 'a t = + { pop : int + ; push : 'a list + } + +val merge : 'a t -> 'a t -> 'a t + +val empty : 'a t + +val map : ('a -> 'b) -> 'a t -> 'b t