-
-
Notifications
You must be signed in to change notification settings - Fork 392
Document exception handling in Actions/Rules #3407
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
Changes from 1 commit
b0f3694
205adc1
4c404cf
4f2c160
fab9c2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -54,8 +54,13 @@ unwrapDynamic x = fromMaybe (error msg) $ fromDynamic x | |||||
|
||||||
type TheRules = Map.HashMap TypeRep Dynamic | ||||||
|
||||||
-- | A computation that defines all the rules that form part of the computation graph. | ||||||
-- | ||||||
-- 'Rules' has access to 'IO' through 'MonadIO'. Use of 'IO' is at your own risk: if | ||||||
-- you write 'Rules' that thow exceptions, then you need to make sure to handle them | ||||||
-- yourself when you run the resulting 'Rules'. | ||||||
newtype Rules a = Rules (ReaderT SRules IO a) | ||||||
deriving newtype (Monad, Applicative, Functor, MonadIO, MonadFail) | ||||||
deriving newtype (Monad, Applicative, Functor, MonadIO) | ||||||
|
||||||
data SRules = SRules { | ||||||
rulesExtra :: !Dynamic, | ||||||
|
@@ -67,6 +72,12 @@ data SRules = SRules { | |||||
--------------------------------------------------------------------- | ||||||
-- ACTIONS | ||||||
|
||||||
-- | An action representing something that can be run as part of a 'Rule'. | ||||||
-- | ||||||
-- 'Action's can be pure functions but also have access to 'IO' via 'MonadIO' and 'MonadUnliftIO. | ||||||
-- It should be assumed that actions can throw exceptions, these can be caught with | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for nitpicking, but who assumes these actions can throw exceptions? The user, or the Rules engine? Or both? E.g., are exceptions always caught or may they bubble up and eventually crash HLS? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unclear! I'm writing this for the "user of Conceivably some other user of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, then slightly adapting the beginning of the sentence seems fine by me.
Suggested change
|
||||||
-- 'Development.IDE.Graph.Internal.Action.actionCatch'. In particular, it is | ||||||
-- permissible to use the 'MonadFail' instance, which will lead to an 'IOException'. | ||||||
newtype Action a = Action {fromAction :: ReaderT SAction IO a} | ||||||
deriving newtype (Monad, Applicative, Functor, MonadIO, MonadFail, MonadThrow, MonadCatch, MonadMask, MonadUnliftIO) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.