packages feed

cornelis-0.2.0.1 / src / Cornelis / Debug.hs

module Cornelis.Debug whereimport Control.Exception (catch, throw)import Control.Monad.IO.Classimport System.IO.Error (isAlreadyInUseError)import Neovimimport Neovim.API.String (vim_report_error)reportExceptions :: Neovim env () -> Neovim env ()reportExceptions =  flip catchNeovimException $ vim_report_error . mappend "UNHANDLED EXCEPTION " . showtraceMX :: Show a => String -> a -> Neovim env ()traceMX herald a =  vim_report_error $ "!!!" <> herald <> ": " <> show adebug :: (Show a, MonadIO m) => a -> m ()debug x = liftIO $ go 100  where    go 0 = pure ()    go n =      catch       (appendFile  "/tmp/agda.log" (show x <> "\n"))       (\e -> if isAlreadyInUseError e then go (n-1 :: Int) else throw e)