Closed kindaro closed 3 years ago
Of course, I can copy some code from RIO.Prelude.Simple
and have this:
runApp ∷ RIO App α → IO α
runApp action = do
verbose <- isJust <$> lookupEnv "RIO_VERBOSE"
lo <- logOptionsHandle stderr verbose
withLogFunc lo $ \lf -> do
simpleApp <- mkSimpleApp lf Nothing
temporaryDirectory ← getTempDir
runRIO App {..} action
But what is the point of depending on a library if I still have to borrow code from it? Also, it is very technical and I do not really want to trust myself with this sort of things.
This bit of code looks incorrect to me:
runApp ∷ RIO App α → IO α
runApp action = do
simpleApp ← runSimpleApp ask
temporaryDirectory ← getTempDir
runRIO App {..} action
Instead of using runSimpleApp
and then allowing the result of ask
to escape, something like the following would be preferable:
runApp ∷ RIO App α → IO α
runApp action = runSimpleApp $ do
simpleApp ← ask
temporaryDirectory ← getTempDir
runRIO App {..} action
For the rest of the code: to be honest, I'm not that comfortable with all of the language extensions employed to make that work, so it's possible something is slipping past me.
This works, thanks!
I like
SimpleApp
, but I want to add some more information to the environment. This is how I thought I should go:However, this gives me
thread blocked indefinitely in an MVar operation
. I have noMVar
values in my code, and it works withrunSimpleApp
. So, I suppose the failure arises from my invokingrumSimpleApp ask
to extract the environment.Is this behaviour expected? Can it be fixed? Is there a better way to go about this?