Skip to content
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

Add IO escape hatches #35

Open
tomjaguarpaw opened this issue Jan 7, 2025 · 0 comments
Open

Add IO escape hatches #35

tomjaguarpaw opened this issue Jan 7, 2025 · 0 comments

Comments

@tomjaguarpaw
Copy link
Owner

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) k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant