module Compose where import Prelude hiding (Functor, Monad) data ST s a = ST {runState :: s -> (a,s)} {-@ data ST s a

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

-> (a, s)) @-} {-@ runState :: forall

Prop, q :: s -> s -> Prop, r :: s -> a -> Prop>. ST s a -> x:s

-> (a, s) @-} class Functor f where fmap :: (a -> b) -> f a -> f b instance Functor (ST s) where fmap f (ST g) = ST (\s -> let (a, s') = g s in (f a, s')) class Functor m => Monad m where (>>) :: m a -> m b -> m b instance Monad (ST s) where {-@ instance Monad ST s where >> :: forall s a b < pref :: s -> Prop, postf :: s -> s -> Prop , pre :: s -> Prop, postg :: s -> s -> Prop , post :: s -> s -> Prop , rg :: s -> a -> Prop , rf :: s -> b -> Prop , r :: s -> b -> Prop >. {x::s

, y::s |- b <: b}
       {xx::s
, w::s |- s <: s}
       {ww::s
 |- s <: s}
       (ST  s a)
    -> (ST  s b)
    -> (ST  s b)
    @-}
  (ST g) >>  f = ST (\x -> case g x of {(y, s) -> (runState f) s})