-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement "split" tactic #521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. The test failures have me concerned though! I think I might know what's going wrong, so I'll try to fix that today.
stack.yaml
Outdated
@@ -4,6 +4,7 @@ packages: | |||
- . | |||
- ./ghcide/ | |||
- ./hls-plugin-api | |||
- ./plugins/tactics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Not sure how I missed this.
I suspect the following diff will fix the tests: diff --git a/plugins/tactics/src/Ide/Plugin/Tactic/Debug.hs b/plugins/tactics/src/Ide/Plugin/Tactic/Debug.hs
index ba91a7c..6c528da 100644
--- a/plugins/tactics/src/Ide/Plugin/Tactic/Debug.hs
+++ b/plugins/tactics/src/Ide/Plugin/Tactic/Debug.hs
@@ -1,3 +1,7 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE TypeApplications #-}
+
module Ide.Plugin.Tactic.Debug
( unsafeRender
, unsafeRender'
@@ -9,17 +13,36 @@ module Ide.Plugin.Tactic.Debug
, traceMX
) where
+import Control.DeepSeq
+import Control.Exception
import Debug.Trace
import DynFlags (unsafeGlobalDynFlags)
import Outputable hiding ((<>))
+import System.IO.Unsafe (unsafePerformIO)
+
+#if __GLASGOW_HASKELL__ >= 808
+import PlainPanic (PlainGhcException)
+type GHC_EXCEPTION = PlainGhcException
+#else
+import Panic (GhcException)
+type GHC_EXCEPTION = GhcException
+#endif
+
------------------------------------------------------------------------------
-- | Print something
unsafeRender :: Outputable a => a -> String
unsafeRender = unsafeRender' . ppr
+
unsafeRender' :: SDoc -> String
-unsafeRender' = showSDoc unsafeGlobalDynFlags
+unsafeRender' sdoc = unsafePerformIO $ do
+ let z = showSDoc unsafeGlobalDynFlags sdoc
+ -- We might not have unsafeGlobalDynFlags (like during testing), in which
+ -- case GHC panics. Instead of crashing, let's just fail to print.
+ !res <- try @GHC_EXCEPTION $ evaluate $ deepseq z z
+ pure $ either (const "<unsafeRender'>") id res
+{-# NOINLINE unsafeRender' #-}
traceMX :: (Monad m, Show a) => String -> a -> m ()
traceMX str a = traceM $ mappend ("!!!" <> str <> ": ") $ show a
diff --git a/plugins/tactics/hls-tactics-plugin.cabal b/plugins/tactics/hls-tactics-plugin.cabal
index 9abb2b5..7fecc86 100644
--- a/plugins/tactics/hls-tactics-plugin.cabal
+++ b/plugins/tactics/hls-tactics-plugin.cabal
@@ -75,6 +75,28 @@ library
, syb
, text
, transformers
+ , deepseq |
I wonder what exactly is the difference now between the circle ci and the github tests, seeing that the latter worked fine, and only the former failed before? |
Yeah, I have no idea. We're in #haskell-ide-engine on freenode trying to suss out wtf. |
We were not able to come to a conclusion in irc, summarizin some facts:
|
Ok, i've tried to add |
f41f88f
to
ae68d4a
Compare
Progress! Thank you @jneira that seems to have at least fixed stack-ghc-8.10. Locally stack-8.8.x is also no problem. The github action fail for windows-ghc-8.10.1 looks suspicious, although probably not connected to the PR. |
@jneira uh oh. Now |
i've hit it another one in hlint pr too, after rebasing |
@WorldSEnder everything should be cleared up if you merge master. |
ae68d4a
to
ea3847c
Compare
One code action per datatype constructor is produced. test cases for splitting don't suggest constructors with hash by default suggesting I# for Int probably is not what you want 99% of the time also reuse tyDataCons, tacname use 'algebraicTyCon' as filter for now
ea3847c
to
e2cc325
Compare
Rerunning circleci failed jobs |
66ada8c
to
d4f5d43
Compare
I'd like to get this merged. Mind if I take over, @WorldSEnder ? |
Go ahead, the branch is set to accept commits from maintainers. |
I guess this PR is not relevant anymore, as succeeded by #1379. If not, feel free to reopen this. |
Different meaning of "split", I'm afraid! |
Implemented in #1461 |
Originated as isovector#30 this implements a split tactic for introducing specific constructors in holes on the user's request. For more details also see the linked PR.