Skip to content

Instantly share code, notes, and snippets.

@abakst
Created July 8, 2016 16:44
Show Gist options
  • Save abakst/15ad76c4e337ff50ce8773695f54f44a to your computer and use it in GitHub Desktop.
Save abakst/15ad76c4e337ff50ce8773695f54f44a to your computer and use it in GitHub Desktop.
module Foo() where
{-@
data Message = Ping { pingPid :: Pid }
| Pong { pongPid :: Pid }
@-}
data Message = Ping Pid
| Pong Pid
data Process a = P a
data Pid = Pid Int
deriving Eq
instance Functor Process where
instance Applicative Process where
instance Monad Process where
{-@ send :: Pid -> m:m -> Process () @-}
send :: Pid -> m -> Process ()
send p m = undefined
{-@ recv :: Process m @-}
recv :: Process m
recv = undefined
{-@ measure msgPid @-}
{-@ msgPid :: x:Message -> {v:Pid | v = msgPid x} @-}
msgPid :: Message -> Pid
msgPid (Ping p) = p
msgPid (Pong p) = p
{-@ foo :: Process () @-}
foo :: Process ()
foo = do x <- recv
let p = case x of
Ping p -> p
Pong p -> p
send p x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment