-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
For every effect I think it would be good to have one or more "IO escape hatches" for anyone who has some Bluefin effectful operation but doesn't know what to do with it. For example, we could have
escapeState ::
e1 :> es =>
IOE e1 ->
IORef s ->
(forall e. State s e -> Eff (e :& es) r) ->
Eff es r
escapeState io ref k = do
s <- readIORef ref
(r, s') <- runState s k
writeIORef ref r
pure s'
escapeIOException ::
e1 :> es =>
Control.Exception.Exception ex =>
IOE e1 ->
(forall e. Exception ex e -> Eff (e :& es) r) ->
Eff es r
escapeIOException io k =
handle (effIO io . throwIO) k
escapeErrorShow ::
e1 :> es =>
Show ex =>
IOE e1 ->
(forall e. Exception ex e -> Eff (e :& es) r) ->
Eff es r
escapeIOException io k =
handle (effIO io . error . show) kMetadata
Metadata
Assignees
Labels
No labels