Skip to content

Instantly share code, notes, and snippets.

@fendor
Created August 16, 2020 12:55
Show Gist options
  • Save fendor/73692b6d132e754f93ddd0c63410024a to your computer and use it in GitHub Desktop.
Save fendor/73692b6d132e754f93ddd0c63410024a to your computer and use it in GitHub Desktop.
let
workRun :: (IO ([()], [IO ()]) -> IO ([()], [IO ()])) -> IO (IO ())
workRun restore = do
let systemActs' = pumpAction : map getAction systemActs
res <- try @SomeException
(restore $ (shakeRunDatabase shakeDb systemActs' :: IO ([()], [IO ()])))
let res' = case res of
Left e -> "exception: " <> displayException e
Right _ -> "completed"
-- Wrap up in a thread to avoid calling interruptible
-- operations inside the masked section
let wrapUp = logDebug logger $ T.pack $ "Finishing build session(" ++ res' ++ ")"
return wrapUp
-- Do the work in a background thread
let myAsync :: ((IO ([()], [IO ()]) -> IO ([()], [IO ()])) -> IO (IO ())) -> IO (Async (IO (IO ())))
myAsync = asyncWithUnmask
workThread <- myAsync workRun
-- run the wrap up unmasked
_ <- async $ join $ wait workThread
[29 of 49] Compiling Development.IDE.Core.Shake ( src/Development/IDE/Core/Shake.hs, /home/munin/Documents/haskell/ghcide/dist-newstyle/build/x86_64-linux/ghc-8.11.0.20200814/ghcide-0.2.0/build/Development/IDE/Core/Shake.o )
src/Development/IDE/Core/Shake.hs:611:19: error:
• Couldn't match type: forall b. IO b -> IO b
with: IO ([()], [IO ()]) -> IO ([()], [IO ()])
Expected: ((IO ([()], [IO ()]) -> IO ([()], [IO ()]))
-> IO (IO ()))
-> IO (Async (IO (IO ())))
Actual: ((forall b. IO b -> IO b) -> IO (IO ()))
-> IO (Async (IO ()))
• In the expression: asyncWithUnmask
In an equation for ‘myAsync’: myAsync = asyncWithUnmask
In the expression:
do actionQueue :: TQueue DelayedActionInternal <- atomically
$ do q <- newTQueue
traverse_ (writeTQueue q) userActs
....
actionInProgress :: TVar (Maybe DelayedActionInternal) <- newTVarIO
Nothing
let pumpAction = forever $ ...
workRun :: (IO ([()], [IO ()]) -> IO ([()], [IO ()])) -> IO (IO ())
....
let myAsync ::
((IO ([()], [IO ()]) -> IO ([()], [IO ()])) -> IO (IO ()))
-> IO (Async (IO (IO ())))
myAsync = asyncWithUnmask
....
|
611 | myAsync = asyncWithUnmask
| ^^^^^^^^^^^^^^^
cabal: Failed to build ghcide-0.2.0 (which is required by exe:ghcide-bench
from ghcide-0.2.0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment