{-# LANGUAGE CPP #-} module RIO where #if __GLASGOW_HASKELL__ < 710 import Control.Applicative #endif -- THE REST OF THIS FILE IS SAFE; just adding this to trigger an error to appease the "neg" gods. {-@ silly_buggy_incr :: Nat -> Nat @-} silly_buggy_incr :: Int -> Int silly_buggy_incr x = x - 1 {-@ data RIO a

Bool, q :: World -> a -> World -> Bool> = RIO (rs :: (xxx:World

-> (a, World)<\w -> {v:World | true}>)) @-} data RIO a = RIO {runState :: World -> (a, World)} {-@ runState :: forall

Bool, q :: World -> a -> World -> Bool>. RIO a -> xyy:World

-> (a, World)<\w -> {v:World | true}> @-} data World = W -- | RJ: Putting these in to get GHC 7.10 to not fuss instance Functor RIO where fmap = undefined -- | RJ: Putting these in to get GHC 7.10 to not fuss instance Applicative RIO where pure = undefined (<*>) = undefined instance Monad RIO where {-@ instance Monad RIO where >>= :: forall < p :: World -> Bool , p2 :: a -> World -> Bool , r :: a -> Bool , q1 :: World -> a -> World -> Bool , q2 :: a -> World -> b -> World -> Bool , q :: World -> b -> World -> Bool>. {x::a, w::World

|- World <: World} {y::a, w::World

, w2::World, x::b, y::a |- World <: World} {x::a, w::World, w2::World|- {v:a | v = x} <: a} RIO a -> (x:a -> RIO <{v:World | true}, \w1 y -> {v:World | true}> b) -> RIO b ; >> :: forall < p :: World -> Bool , p2 :: World -> Bool , q1 :: World -> a -> World -> Bool , q2 :: World -> b -> World -> Bool , q :: World -> b -> World -> Bool>. {x::a, w::World

|- World <: World} {w::World

, w2::World, x::b, y::a |- World <: World} RIO a -> RIO b -> RIO b ; return :: forall

Bool>. x:a -> RIO {w1:World | w0 == w1 && y == x}> a @-} (RIO g) >>= f = RIO $ \x -> case g x of {(y, s) -> (runState (f y)) s} (RIO g) >> f = RIO $ \x -> case g x of {(y, s) -> (runState f ) s} return w = RIO $ \x -> (w, x) {-@ qualif Papp4(v:a, x:b, y:c, z:d, p:Pred a b c d) : papp4(p, v, x, y, z) @-} -- Test Cases: -- * TestM (Basic) -- * TwiceM -- * IfM -- * WhileM