Skip to content

Commit 30b3fec

Browse files
authored
Adjust rendering of error logs and drop unneeded MonadUnliftIO instance (#2755)
* drop unneeded MonadUnliftIO instance * Adjust error message * fixups
1 parent b7f37ad commit 30b3fec

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

exe/Main.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
module Main(main) where
66

77
import Data.Function ((&))
8+
import Data.Text (Text)
9+
import Development.IDE.Plugin.LSPWindowShowMessageRecorder (makeLspShowMessageRecorder)
810
import Development.IDE.Types.Logger (Priority (Debug, Info, Error),
911
WithPriority (WithPriority, priority),
1012
cfilter, cmapWithPrio,
@@ -15,11 +17,9 @@ import Ide.Arguments (Arguments (..),
1517
getArguments)
1618
import Ide.Main (defaultMain)
1719
import qualified Ide.Main as IdeMain
20+
import Ide.PluginUtils (pluginDescToIdePlugins)
1821
import qualified Plugins
19-
import Prettyprinter (Pretty (pretty), vcat)
20-
import Development.IDE.Plugin.LSPWindowShowMessageRecorder (makeLspShowMessageRecorder)
21-
import Data.Text (Text)
22-
import Ide.PluginUtils (pluginDescToIdePlugins)
22+
import Prettyprinter (Pretty (pretty), vsep)
2323

2424
data Log
2525
= LogIdeMain IdeMain.Log
@@ -59,8 +59,8 @@ main = do
5959
defaultMain (cmapWithPrio LogIdeMain recorder) args (pluginDescToIdePlugins [lspRecorderPlugin] <> plugins)
6060

6161
renderDoc :: Doc a -> Text
62-
renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vcat
63-
["Unhandled exception, please check your setup and/or the [issue tracker](" <> issueTrackerUrl <> "): "
62+
renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vsep
63+
["Error condition, please check your setup and/or the [issue tracker](" <> issueTrackerUrl <> "): "
6464
,d
6565
]
6666

ghcide/src/Development/IDE/Plugin/LSPWindowShowMessageRecorder.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
module Development.IDE.Plugin.LSPWindowShowMessageRecorder (makeLspShowMessageRecorder) where
44

55
import Control.Monad.IO.Class
6-
import Control.Monad.IO.Unlift (MonadUnliftIO)
76
import Data.Foldable (for_)
87
import Data.IORef
98
import Data.IORef.Extra (atomicModifyIORef'_)
@@ -24,8 +23,8 @@ makeLspShowMessageRecorder = do
2423
backLogRef <- newIORef []
2524
let recorder = Recorder $ \it -> do
2625
mbenv <- liftIO $ readIORef envRef
27-
case mbenv of
28-
Nothing -> liftIO $ atomicModifyIORef'_ backLogRef (it :)
26+
liftIO $ case mbenv of
27+
Nothing -> atomicModifyIORef'_ backLogRef (it :)
2928
Just env -> sendMsg env it
3029
-- the plugin captures the language context, so it can be used to send messages
3130
plugin =
@@ -35,11 +34,11 @@ makeLspShowMessageRecorder = do
3534
liftIO $ writeIORef envRef $ Just env
3635
-- flush the backlog
3736
backLog <- liftIO $ atomicModifyIORef' backLogRef ([],)
38-
for_ (reverse backLog) $ sendMsg env
37+
liftIO $ for_ (reverse backLog) $ sendMsg env
3938
}
4039
return (recorder, plugin)
4140

42-
sendMsg :: MonadUnliftIO m => LanguageContextEnv config -> WithPriority Text -> m ()
41+
sendMsg :: LanguageContextEnv config -> WithPriority Text -> IO ()
4342
sendMsg env WithPriority {..} =
4443
LSP.runLspT env $
4544
LSP.sendNotification

ghcide/src/Development/IDE/Types/Logger.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ data WithPriority a = WithPriority { priority :: Priority, callStack_ :: CallSta
9797
-- You shouldn't call warning/error if the user has caused an error, only
9898
-- if our code has gone wrong and is itself erroneous (e.g. we threw an exception).
9999
newtype Recorder msg = Recorder
100-
{ logger_ :: forall m. (MonadUnliftIO m) => msg -> m () }
100+
{ logger_ :: forall m. (MonadIO m) => msg -> m () }
101101

102-
logWith :: (HasCallStack, MonadUnliftIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m ()
102+
logWith :: (HasCallStack, MonadIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m ()
103103
logWith recorder priority msg = withFrozenCallStack $ logger_ recorder (WithPriority priority callStack msg)
104104

105105
instance Semigroup (Recorder msg) where

hls-graph/hls-graph.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ library
8181
, stm-containers
8282
, time
8383
, transformers
84-
, unliftio
8584
, unordered-containers
8685

8786
if flag(embed-files)

hls-graph/src/Development/IDE/Graph/Internal/Types.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import qualified ListT
3636
import StmContainers.Map (Map)
3737
import qualified StmContainers.Map as SMap
3838
import System.Time.Extra (Seconds)
39-
import UnliftIO (MonadUnliftIO)
4039

4140

4241
unwrapDynamic :: forall a . Typeable a => Dynamic -> a
@@ -63,7 +62,7 @@ data SRules = SRules {
6362
-- ACTIONS
6463

6564
newtype Action a = Action {fromAction :: ReaderT SAction IO a}
66-
deriving newtype (Monad, Applicative, Functor, MonadIO, MonadFail, MonadThrow, MonadCatch, MonadMask, MonadUnliftIO)
65+
deriving newtype (Monad, Applicative, Functor, MonadIO, MonadFail, MonadThrow, MonadCatch, MonadMask)
6766

6867
data SAction = SAction {
6968
actionDatabase :: !Database,

0 commit comments

Comments
 (0)