module Compose where data ST s a = ST {runState :: s -> s} {-@ data ST s a

Prop, q :: s -> s -> Prop> = ST (runState :: x:s

-> s) @-} {-@ cmp :: forall < pref :: s -> Prop, postf :: s -> s -> Prop , pre :: s -> Prop, postg :: s -> s -> Prop , post :: s -> s -> Prop >. {y:s -> s -> s} {x:s

 -> z:s -> s -> s }
       f:(ST  s a)
    -> g:(ST 
 s b)
    ->   (ST 
 s b)
@-}

cmp :: ST s a
    -> ST s b
    -> ST s b

cmp (ST f) (ST g) = ST $ \s -> f (g s)


{-@ incr :: ST <{\x -> x >= 0}, {\x v -> v = x + 1}> Nat Int @-}
incr :: ST Int Int 
incr = ST $ \x -> x + 1

{-@ incr2 :: ST <{\x -> x >= 0}, {\x v -> v = x + 4}> Nat Int @-}
incr2 :: ST Int Int 
incr2 = cmp incr incr