-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with the logging API #55
Comments
Hi, Harendra
I had this problen, that's is why I created the Cloud monad, to force
logging.. The solution is to promote logged to the Cloud Monad, and rename
the cloud monad to something more general that includes logging/recovery
for any purpose.
2017-05-13 22:00 GMT+02:00 Harendra Kumar <[email protected]>:
… With the current design of the logging primitives, it is possible to
easily run into inconsistent behavior. For example:
main = keep $ restore $ do
r <- choose [1..5 :: Int]
logged $ liftIO $ print ("A",r)
suspend ()
liftIO $ print ("B",r)
Here, the programmer forgot to add logged to the choose primitive. This
results in an incorrect output. Another example, if we use suspend
without logging, the program always suspends:
main = keep $ do
r <- choose [1..5 :: Int]
liftIO $ print ("A",r)
suspend ()
liftIO $ print ("B",r)
Instead we should either throw an error or ignore the suspend since we are
not logging.
A potential solution to these problems is to design the API such that we
use the logged primitive one level above the suspend. If the parent is
logged then logging is inherited by all the child computations and we can
suspend a child. Since we know the logged/not logged state we can change
the behavior of suspend based on that. Also, the logged primitive itself
can do the job of restore as well. The code will look like:
main = keep $ logged $ do
r <- choose [1..5 :: Int]
liftIO $ print ("A",r)
suspend ()
liftIO $ print ("B",r)
I have not thought much about it, so I am not sure if this solution has
any inherent problems.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#55>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAf5ivoZjxm72on5mj3iUaPYJMMHjuh-ks5r5gvYgaJpZM4NaLVi>
.
--
Alberto.
|
Yeah, I figured that when I later looked at the Cloud monad. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the current design of the logging primitives, it is possible to easily run into inconsistent behavior. For example:
Here, the programmer forgot to add
logged
to thechoose
primitive. This results in an incorrect output. Another example, if we usesuspend
without logging, the program always suspends:Instead we should either throw an error or ignore the suspend since we are not logging.
A potential solution to these problems is to design the API such that we use the
logged
primitive one level above thesuspend
. If the parent is logged then logging is inherited by all the child computations and we can suspend a child. Since we know the logged/not logged state we can change the behavior ofsuspend
based on that. Also, the logged primitive itself can do the job of restore as well. The code will look like:I have not thought much about it, so I am not sure if this solution has any inherent problems.
The text was updated successfully, but these errors were encountered: