{-@ LIQUID "--no-termination" @-} {-@ LIQUID "--short-names" @-} module Foo () where import Language.Haskell.Liquid.Prelude (liquidAssert) import Data.IORef {-@ type Upto N = {v:Nat | v < N} @-} {-@ job :: IO () @-} job = do p <- newIORef (0 :: Int) writeIORef p 10 v <- readIORef p liquidAssert (v == 0) $ return () {-@ bob :: Nat -> IO () @-} bob n = do t <- newIO (n+1) (\_ -> 0) setIO t 0 100 r <- getIO t 0 liquidAssert (r == 0) $ return () data IOArr a = IOA { size :: Int , pntr :: IORef (Arr a) } data Arr a = A { alen :: Int , aval :: Int -> a } {-@ data IOArr a
a -> Prop> = IOA { size :: Nat , pntr :: IORef ({v:Arr
a | alen v = size}) } @-} {-@ data Arr a
a -> Prop> = A { alen :: Nat , aval :: i:Upto alen -> a
} @-} {-@ newIO :: forall
a -> Prop>. n:Nat -> (i:Upto n -> a
) -> IO ({v: IOArr
a | size v = n}) @-} newIO :: Int -> (Int -> a) -> IO (IOArr a) newIO n f = undefined {-@ getIO :: forall
a -> Prop>. a:IOArr
a -> i:Upto (size a) -> IO (a
) @-} getIO :: IOArr a -> Int-> IO a getIO a@(IOA sz p) i = undefined {-@ setIO :: forall
a -> Prop>. a:IOArr
a -> i:Upto (size a) -> a
-> IO () @-} setIO :: IOArr a -> Int -> a -> IO () setIO a@(IOA sz p) i v = undefined