Skip to content

Add IO escape hatches #35

@tomjaguarpaw

Description

@tomjaguarpaw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions