Skip to content

Retrie does not apply forward rule in Windows (revisit after facebookincubator/retrie#30) #533

Closed
@jneira

Description

@jneira

With a simple example took from retrie readme:

module MyModule2 where

myMaybe :: b -> (a -> b) -> Maybe a -> b
myMaybe d f mb = case mb of
  Nothing -> d
  Just x -> f x

type MyMaybe = Maybe Int

{-# RULES "myRule" forall x. myMaybe Nothing Just x = x #-}

foo :: Maybe Int
foo = myMaybe Nothing Just (Just 5)

First minor thing: code actions are duplicated:

2020-10-23 22:38:44.2079688 [ThreadId 6] - <--2--{"result":[{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward in current file"}],"title":"Apply rule myRule forward in current file"},"kind":"refactor","title":"Apply rule myRule forward in current file"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward"}],"title":"Apply rule myRule forward"},"kind":"refactor","title":"Apply rule myRule forward"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}],"title":"Apply rule myRule backwards"},"kind":"refactor","title":"Apply rule myRule backwards"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}],"title":"Apply rule myRule backwards"},"kind":"refactor","title":"Apply rule myRule backwards"}],"jsonrpc":"2.0","id":65}

Moreover the forward rules are not applied:

log
2020-10-23 22:41:53.4139426 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":66,"method":"workspace/executeCommand","params":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward"}]}}
2020-10-23 22:41:53.4159422 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"token":4},"method":"window/workDoneProgress/create","id":9}
2020-10-23 22:41:53.4169457 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":true,"title":"Apply rule myRule forward"},"token":4},"method":"$/progress"}
2020-10-23 22:41:53.4189455 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":9,"result":null}
2020-10-23 22:41:53.4189455 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":9,\"result\":null}"
2020-10-23 22:41:53.4199429 [ThreadId 2454] - finish: Retrie.GhcSessionDeps (took 0.00s)
2020-10-23 22:41:53.4209446 [ThreadId 2456] - finish: Retrie.getBinds (took 0.00s)
fromList [NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build\\autogen\\Paths_cabal_test.hs",NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs",NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\MyModule2.hs"]
2020-10-23 22:41:53.4349456 [ThreadId 2458] - finish: C:GetParsedModule (took 0.00s)
2020-10-23 22:41:53.435946 [ThreadId 2460] - finish: C:GetModIface (took 0.00s)
hgIgnorePred: hg: readCreateProcessWithExitCode: does not exist (No such file or directory)
gitIgnorePred: fatal: not a git repository (or any of the parent directories): .git

Reading VCS ignore failed! Continuing without ignoring.
stdin:
D:\dev\ws\haskell\cabal-test\dist-newstyle\build\x86_64-windows\ghc-8.10.1\cabal-test-0.1.0.0\build\autogen\Paths_cabal_test.hs
D:\dev\ws\haskell\cabal-test\src\Lib.hs
D:\dev\ws\haskell\cabal-test\src\MyModule2.hs

shellCmd:
xargs grep -l 'myMaybe[[:space:]]\+Nothing[[:space:]]\+Just'
Files:
2020-10-23 22:41:53.7249543 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":4},"method":"$/progress"}
2020-10-23 22:41:53.7259457 [ThreadId 6] - <--2--{"result":null,"jsonrpc":"2.0","id":66}
2020-10-23 22:41:53.7259457 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"edit":{"changes":{}}},"method":"workspace/applyEdit","id":10}
2020-10-23 22:41:53.7319428 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":67,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/MyModule2.hs"},"range":{"start":{"line":9,"character":33},"end":{"line":9,"character":33}},"context":{"diagnostics":[]}}}
2020-10-23 22:41:53.7319428 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":10,"result":{"applied":true}}
2020-10-23 22:41:53.7319428 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":10,\"result\":{\"applied\":true}}"
2020-10-23 22:41:53.7329422 [ThreadId 2472] - finish: CodeAction (took 0.00s)
2020-10-23 22:41:53.7329422 [ThreadId 2474] - finish: CodeAction:PackageExports (took 0.00s)
2020-10-23 22:41:53.7339438 [ThreadId 2476] - finish: importLens (took 0.00s)
2020-10-23 22:41:53.7349425 [ThreadId 2478] - finish: retrie (took 0.00s)
2020-10-23 22:41:53.7359426 [ThreadId 2480] - finish: tactic (took 0.00s)
2020-10-23 22:41:53.7359426 [ThreadId 2482] - finish: tactic (took 0.00s)
2020-10-23 22:41:53.7359426 [ThreadId 2484] - finish: tactic (took 0.00s)
2020-10-23 22:41:53.7389453 [ThreadId 6] - <--2--{"result":[{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward in current file"}],"title":"Apply rule myRule forward in current file"},"kind":"refactor","title":"Apply rule myRule forward in current file"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward"}],"title":"Apply rule myRule forward"},"kind":"refactor","title":"Apply rule myRule forward"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}],"title":"Apply rule myRule backwards"},"kind":"refactor","title":"Apply rule myRule backwards"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}],"title":"Apply rule myRule backwards"},"kind":"refactor","title":"Apply rule myRule backwards"}],"jsonrpc":"2.0","id":67}

But the backwards one is:

log
2020-10-23 22:43:46.2784787 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":68,"method":"workspace/executeCommand","params":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}]}}
2020-10-23 22:43:46.2834808 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"token":5},"method":"window/workDoneProgress/create","id":11}
2020-10-23 22:43:46.2844817 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":true,"title":"Apply rule myRule backwards"},"token":5},"method":"$/progress"}
2020-10-23 22:43:46.2844817 [ThreadId 2491] - finish: Retrie.GhcSessionDeps (took 0.00s)
2020-10-23 22:43:46.2854818 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":11,"result":null}
2020-10-23 22:43:46.2854818 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":11,\"result\":null}"
2020-10-23 22:43:46.287479 [ThreadId 2493] - finish: Retrie.getBinds (took 0.00s)
fromList [NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build\\autogen\\Paths_cabal_test.hs",NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\Lib.hs",NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\MyModule2.hs"]
2020-10-23 22:43:46.2924834 [ThreadId 2495] - finish: C:GetParsedModule (took 0.00s)
2020-10-23 22:43:46.2924834 [ThreadId 2497] - finish: C:GetModIface (took 0.00s)
hgIgnorePred: hg: readCreateProcessWithExitCode: does not exist (No such file or directory)
gitIgnorePred: fatal: not a git repository (or any of the parent directories): .git

Reading VCS ignore failed! Continuing without ignoring.
Files:
D:\dev\ws\haskell\cabal-test\src\MyModule2.hs
2020-10-23 22:43:46.5034776 [ThreadId 2503] - finish: Retrie.GetFileContents (took 0.00s)
2020-10-23 22:43:46.5034776 [ThreadId 2505] - finish: C:GetParsedModule (took 0.00s)
2020-10-23 22:43:46.50448 [ThreadId 2507] - finish: C:GetModIface (took 0.00s)
2020-10-23 22:43:46.5204788 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":5},"method":"$/progress"}
2020-10-23 22:43:46.5204788 [ThreadId 6] - <--2--{"result":null,"jsonrpc":"2.0","id":68}
2020-10-23 22:43:46.5244798 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":69,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/MyModule2.hs"},"range":{"start":{"line":9,"character":33},"end":{"line":9,"character":33}},"context":{"diagnostics":[]}}}
2020-10-23 22:43:46.52548 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"edit":{"changes":{"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs":[{"range":{"start":{"line":9,"character":29},"end":{"line":9,"character":51}},"newText":"myMaybe Nothing Just (myMaybe Nothing Just x)"},{"range":{"start":{"line":12,"character":6},"end":{"line":12,"character":35}},"newText":"myMaybe Nothing Just (myMaybe Nothing Just (Just 5))"}]}}},"method":"workspace/applyEdit","id":12}
2020-10-23 22:43:46.52548 [ThreadId 2513] - finish: CodeAction (took 0.00s)
2020-10-23 22:43:46.52548 [ThreadId 2515] - finish: CodeAction:PackageExports (took 0.00s)
2020-10-23 22:43:46.5264816 [ThreadId 2517] - finish: importLens (took 0.00s)
2020-10-23 22:43:46.5274806 [ThreadId 2519] - finish: retrie (took 0.00s)
2020-10-23 22:43:46.5274806 [ThreadId 2521] - finish: tactic (took 0.00s)
2020-10-23 22:43:46.5274806 [ThreadId 2523] - finish: tactic (took 0.00s)
2020-10-23 22:43:46.5284799 [ThreadId 2525] - finish: tactic (took 0.00s)
2020-10-23 22:43:46.5294808 [ThreadId 6] - <--2--{"result":[{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward in current file"}],"title":"Apply rule myRule forward in current file"},"kind":"refactor","title":"Apply rule myRule forward in current file"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleForward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule forward"}],"title":"Apply rule myRule forward"},"kind":"refactor","title":"Apply rule myRule forward"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}],"title":"Apply rule myRule backwards"},"kind":"refactor","title":"Apply rule myRule backwards"},{"command":{"command":"7784:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"RuleBackward","contents":"MyModule2.myRule"}],"originatingFile":[-968851223,"file:///D:/dev/ws/haskell/cabal-test/src/MyModule2.hs"],"description":"Apply rule myRule backwards"}],"title":"Apply rule myRule backwards"},"kind":"refactor","title":"Apply rule myRule backwards"}],"jsonrpc":"2.0","id":69}
2020-10-23 22:43:46.6004841 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/MyModule2.hs","version":23},"contentChanges":[{"range":{"start":{"line":12,"character":34},"end":{"line":12,"character":34}},"rangeLength":0,"text":")"},{"range":{"start":{"line":12,"character":28},"end":{"line":12,"character":28}},"rangeLength":0,"text":"myMaybe Nothing Just ("},{"range":{"start":{"line":9,"character":51},"end":{"line":9,"character":51}},"rangeLength":0,"text":")"},{"range":{"start":{"line":9,"character":50},"end":{"line":9,"character":50}},"rangeLength":0,"text":"(myMaybe Nothing Just "}]}}
2020-10-23 22:43:46.6014847 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":12,"result":{"applied":true}}
2020-10-23 22:43:46.6014847 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":12,\"result\":{\"applied\":true}}"
2020-10-23 22:43:46.6024843 [ThreadId 13] - Set files of interest to: [(NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\MyModule2.hs",Modified)]
2020-10-23 22:43:46.603483 [ThreadId 13] - Restarting build session (aborting the previous one took 0.00s)
2020-10-23 22:43:46.603483 [ThreadId 2263] - Finishing build session(exception: AsyncCancelled)
2020-10-23 22:43:46.6054836 [ThreadId 13] - Modified text document: file:///d%3A/dev/ws/haskell/cabal-test/src/MyModule2.hs
2020-10-23 22:43:46.6134843 [ThreadId 2568] - getClientConfigAction:clientSettings:Just (Object (fromList [("haskell",Object (fromList [("logFile",String ""),("updateBehavior",String "keep-up-to-date"),("hlintOn",Bool True),("formatOnImportOn",Bool True),("indentationRules",Object (fromList [("enabled",Bool True)])),("liquidOn",Bool True),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "ormolu"),("trace",Object (fromList [("server",String "messages")]))]))]))
2020-10-23 22:43:46.6144797 [ThreadId 2568] - hlint:rules:hlintOn=True
2020-10-23 22:43:46.6144797 [ThreadId 2568] - hlint:getIdeas:file:NormalizedFilePath "D:\\dev\\ws\\haskell\\cabal-test\\src\\MyModule2.hs"
2020-10-23 22:43:46.6254793 [ThreadId 2595] - finish: kick (took 0.02s)
2020-10-23 22:43:49.0608374 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":70,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/cabal-test/src/MyModule2.hs"}}}
2020-10-23 22:43:49.0608374 [ThreadId 2599] - Plugin.makeCodeLens (ideLogger)
2020-10-23 22:43:49.0618379 [ThreadId 2600] - finish: codeLens (took 0.00s)
2020-10-23 22:43:49.0628388 [ThreadId 2605] - finish:  (took 0.00s)
2020-10-23 22:43:49.0638401 [ThreadId 2606] - finish: ModuleName.ghcSession (took 0.00s)
2020-10-23 22:43:49.0638401 [ThreadId 2599] - Plugin ModuleName  import paths ["d:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build","d:\\dev\\ws\\haskell\\cabal-test\\common-src","d:\\dev\\ws\\haskell\\cabal-test\\src","d:\\dev\\ws\\haskell\\cabal-test\\win-src","d:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build\\autogen","d:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build\\global-autogen"]
2020-10-23 22:43:49.0718355 [ThreadId 2599] - Plugin ModuleName  canonic paths ["D:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build","D:\\dev\\ws\\haskell\\cabal-test\\common-src","D:\\dev\\ws\\haskell\\cabal-test\\src","D:\\dev\\ws\\haskell\\cabal-test\\win-src","D:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build\\autogen","D:\\dev\\ws\\haskell\\cabal-test\\dist-newstyle\\build\\x86_64-windows\\ghc-8.10.1\\cabal-test-0.1.0.0\\build\\global-autogen"] mdlPath D:\dev\ws\haskell\cabal-test\src\MyModule2.hs
2020-10-23 22:43:49.0728367 [ThreadId 2599] - Plugin ModuleName  prefix Just "D:\\dev\\ws\\haskell\\cabal-test\\src"
2020-10-23 22:43:49.0728367 [ThreadId 2599] - Plugin ModuleName  mdlName Just "MyModule2"
2020-10-23 22:43:49.0728367 [ThreadId 2608] - finish: ModuleName.GetParsedModule (took 0.00s)
2020-10-23 22:43:49.0728367 [ThreadId 2599] - Plugin ModuleName  correct Just "MyModule2" stated Just (Range {_start = Position {_line = 0, _character = 7}, _end = Position {_line = 0, _character = 16}},"MyModule2")
2020-10-23 22:43:49.0738401 [ThreadId 2599] - Plugin ModuleName  actions []
2020-10-23 22:43:49.0748378 [ThreadId 6] - <--2--{"result":[],"jsonrpc":"2.0","id":70}

Maybe the output of grep could be significative:

shellCmd:
xargs grep -l 'myMaybe[[:space:]]\+Nothing[[:space:]]\+Just'
Files:

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-retrie-pluginos: windowsstatus: blockedNot actionable, because blocked by upstream/GHC etc.type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions