Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
distributed-systems
machines-test
Commits
ca946ab7
Commit
ca946ab7
authored
Nov 04, 2018
by
Kevin Cotrone
Browse files
Add liftTImed and awaitTimeout
parent
b1ecd28d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Main.hs
View file @
ca946ab7
...
...
@@ -55,15 +55,14 @@ select ma m = MachineT $ runMachineT m >>= \v -> case v of
((
GetATimeOrAMessage
$
min
t
t'
))
.
select
fg
$
encased
v
-- selectTimeFirst :: UTCTime -> TimedT m UTCTime UTCTime
-- selectTimeFirst startTime = select
liftTimed
::
Monad
m
=>
ProcessT
m
a
b
->
TimedT
m
a
b
liftTimed
p
=
MachineT
$
runMachineT
p
>>=
\
v
->
case
v
of
Yield
o
k
->
return
$
Yield
o
(
liftTimed
k
)
Stop
->
return
Stop
Await
f
Refl
ff
->
return
$
Await
(
liftTimed
.
f
)
DefinitelyGetAMessage
(
liftTimed
ff
)
-- test :: IO ()
-- test = run $ cap $ select (source [1..5]) (construct $ do
-- t <- liftIO $ getCurrentTime
-- r <- await (GetATimeOrAMessage $ t `addUtcTime` 10)
-- liftIO $ print r
-- )
awaitTimeout
::
UTCTime
->
PlanT
(
Select
a
)
o
m
(
Either
UTCTime
a
)
awaitTimeout
=
awaits
.
GetATimeOrAMessage
echoT
::
TimedT
m
a
a
echoT
=
undefined
echoT
::
Monad
m
=>
TimedT
m
a
a
echoT
=
liftTimed
echo
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment