Skip to content

Provide runProcess' that returns allows returning a result?  #306

@teh

Description

@teh

I'm new to h-d so I'm rising an issue for discussion before starting to submit PRs. Maybe I missed something obvious.

I propose to add a new function runProcess' :: LocalNode -> Process a -> IO a.

My main use case is interacting with the h-d ecosystem from other places, e.g. I have wai Application that then runs call to call some stuff. In this specific case I use an MVar to get the result but, but I have this pattern repeating in a few other places as well.

result' <- newEmptyMVar @HttpResponse
runProcess node $ do
  ...
-- must never fail, we prefer exception over blocking handler that holds on to memory
Just (HttpResponse status body) <- tryTakeMVar result'
respond $ responseLBS status [] (BSL.fromStrict body)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions