state.tri (728B)
1 !import io as IO 2 !export pure 3 !export bind 4 !export lift 5 !export current 6 !export replace 7 !export io 8 9 -- Sequential test-only state transformer over IO. Each action is a function 10 -- from explicit state to IO [value nextState]; no host state or concurrency. 11 pure value state = IO.pure [value state] 12 bind action next state = IO.bind (action state) (reply : case reply of 13 [value following] = next value following 14 _ = IO.fail "Invalid test state action") 15 lift action state = IO.bind action (value : IO.pure [value state]) 16 current state = IO.pure [state state] 17 replace value _ = IO.pure [t value] 18 io action = IO.io (IO.bind (action []) (reply : case reply of 19 [value _] = IO.pure value 20 _ = IO.fail "Invalid test state action"))