If an extension (LambdaCase in my case) is enabled using default-extensions in the cabal file and a module is using the extension, using the "Apply hint" code action fails with an error like this:
LSP :: Please open an issue in lsp-mode for implementing `98488:hlint:applyAll'.
(error "hlint:applyAll: \"\\\"(RealSrcSpan SrcSpanOneLine \\\\\\\"/tmp/Update98488-114.hs\\\\\\\" 148 23 27,\\\\\\\"Illegal lambda-case (use -XLambdaCase)\\\\\\\")\\\\nCallStack (from HasCallStack):\\\\n error, called at src/Refact/Internal.hs:84:13 in apply-refact-0.8.2.1-e5ada769d1ed74b27020ceda163d33b8a75e91b8939fcd90cc77787a3840b289:Refact.Internal\\\"\"")
haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools
haskell-language-server version: 0.6.0.0 (GHC: 8.8.4) (PATH: /home/axeman/.local/bin/haskell-language-server-8.8.4)
Tool versions found on the $PATH
cabal: 3.2.0.0
stack: 2.3.3
ghc: 8.8.4
hie.yamlcradle:
stack:
- path: ./libs/api-bot/src
component: api-bot:lib
- path: ./libs/api-client/src
component: api-client:lib
- path: ./tools/api-simulations/lib/src
component: api-simulations:lib
- path: ./tools/api-simulations/loadtest/src
component: api-simulations:exe:api-loadtest
- path: ./tools/api-simulations/smoketest/src
component: api-simulations:exe:api-smoketest
- path: ./tools/db/auto-whitelist/src
component: auto-whitelist:exe:auto-whitelist
- path: ./libs/bilge/src
component: bilge:lib
- path: ./tools/db/billing-team-member-backfill/src
component: billing-team-member-backfill:exe:billing-team-member-backfill
- path: ./tools/bonanza/src
component: bonanza:lib
- path: ./tools/bonanza/main/Main.hs
component: bonanza:exe:bonanza
- path: ./tools/bonanza/main/KibanaRaw.hs
component: bonanza:exe:kibana-raw
- path: ./tools/bonanza/main/Kibanana.hs
component: bonanza:exe:kibanana
- path: ./tools/bonanza/test/unit
component: bonanza:test:bonanza-tests
- path: ./services/brig/src
component: brig:lib
- path: ./services/brig/src/Main.hs
component: brig:exe:brig
- path: ./services/brig/index/src/Main.hs
component: brig:exe:brig-index
- path: ./services/brig/test/integration
component: brig:exe:brig-integration
- path: ./services/brig/schema/src
component: brig:exe:brig-schema
- path: ./services/brig/test/unit
component: brig:test:brig-tests
- path: ./libs/brig-types/src
component: brig-types:lib
- path: ./libs/brig-types/test/unit
component: brig-types:test:brig-types-tests
- path: ./services/cannon/src
component: cannon:lib
- path: ./services/cannon/src/Main.hs
component: cannon:exe:cannon
- path: ./services/cannon/test
component: cannon:test:cannon-tests
- path: ./services/cargohold/src
component: cargohold:lib
- path: ./services/cargohold/src/Main.hs
component: cargohold:exe:cargohold
- path: ./services/cargohold/test/integration
component: cargohold:exe:cargohold-integration
- path: ./libs/cargohold-types/src
component: cargohold-types:lib
- path: ./libs/cassandra-util/src
component: cassandra-util:lib
- path: ./libs/dns-util/src
component: dns-util:lib
- path: ./libs/dns-util/test
component: dns-util:test:spec
- path: ./libs/extended/src
component: extended:lib
- path: ./services/federator/src
component: federator:lib
- path: ./services/federator/exec
component: federator:exe:federator
- path: ./tools/db/find-undead/src
component: find-undead:exe:find-undead
- path: ./services/galley/src
component: galley:lib
- path: ./services/galley/src/Main.hs
component: galley:exe:galley
- path: ./services/galley/test/integration
component: galley:exe:galley-integration
- path: ./services/galley/migrate-data/src
component: galley:exe:galley-migrate-data
- path: ./services/galley/schema/src
component: galley:exe:galley-schema
- path: ./services/galley/test/unit
component: galley:test:galley-types-tests
- path: ./libs/galley-types/src
component: galley-types:lib
- path: ./libs/galley-types/test/unit
component: galley-types:test:galley-types-tests
- path: ./services/gundeck/src
component: gundeck:lib
- path: ./services/gundeck/src/Main.hs
component: gundeck:exe:gundeck
- path: ./services/gundeck/test/integration
component: gundeck:exe:gundeck-integration
- path: ./services/gundeck/schema/src
component: gundeck:exe:gundeck-schema
- path: ./services/gundeck/test/unit
component: gundeck:test:gundeck-tests
- path: ./services/gundeck/test/unit
component: gundeck:bench:gundeck-bench
- path: ./libs/gundeck-types/src
component: gundeck-types:lib
- path: ./libs/hscim/src
component: hscim:lib
- path: ./libs/hscim/server
component: hscim:exe:hscim-server
- path: ./libs/hscim/test
component: hscim:test:spec
- path: ./libs/imports/src
component: imports:lib
- path: ./tools/makedeb/src
component: makedeb:lib
- path: ./tools/makedeb/src/Main.hs
component: makedeb:exe:makedeb
- path: ./libs/metrics-core/src
component: metrics-core:lib
- path: ./libs/metrics-wai/src
component: metrics-wai:lib
- path: ./tools/db/migrate-sso-feature-flag/src
component: migrate-sso-feature-flag:exe:migrate-sso-feature-flag
- path: ./services/proxy/src
component: proxy:lib
- path: ./services/proxy/src/Main.hs
component: proxy:exe:proxy
- path: ./libs/ropes/src
component: ropes:lib
- path: ./tools/db/service-backfill/src
component: service-backfill:exe:service-backfill
- path: ./libs/sodium-crypto-sign/src
component: sodium-crypto-sign:lib
- path: ./services/spar/src
component: spar:lib
- path: ./services/spar/exec
component: spar:exe:spar
- path: ./services/spar/test-integration
component: spar:exe:spar-integration
- path: ./services/spar/schema/src
component: spar:exe:spar-schema
- path: ./services/spar/test
component: spar:test:spec
- path: ./libs/ssl-util/src
component: ssl-util:lib
- path: ./tools/stern/src
component: stern:lib
- path: ./tools/stern/src/Main.hs
component: stern:exe:stern
- path: ./libs/tasty-cannon/src
component: tasty-cannon:lib
- path: ./libs/types-common/src
component: types-common:lib
- path: ./libs/types-common/test
component: types-common:test:tests
- path: ./libs/types-common-aws/src
component: types-common-aws:lib
- path: ./libs/types-common-journal/src
component: types-common-journal:lib
- path: ./libs/wai-utilities/src
component: wai-utilities:lib
- path: ./libs/wire-api/src
component: wire-api:lib
- path: ./libs/wire-api/test/unit
component: wire-api:test:wire-api-tests
- path: ./libs/zauth/src
component: zauth:lib
- path: ./libs/zauth/main
component: zauth:exe:zauth
- path: ./libs/zauth/test
component: zauth:test:zauth-unit
LambdaCase to default-extensions in the cabal file.do.The hlint hint should get applied
hlint complains about LambdaCase.
LSP logs:
Found "/home/axeman/workspace/wire-server/hie.yaml" for "/home/axeman/workspace/wire-server/a"
Module "/home/axeman/workspace/wire-server/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/axeman/workspace/wire-server", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.6.0.0, Git revision 372a12e797069dc3ac4fa33dcaabe3b992999d7c (dirty) x86_64 ghc-8.10.1
Current directory: /home/axeman/workspace/wire-server
Operating system: linux
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /home/axeman/workspace/wire-server
Cradle type: Stack
Tool versions found on the $PATH
cabal: 3.0.0.0
stack: 2.3.3
ghc: 8.8.4
Consulting the cradle to get project GHC version...
Project GHC version: 8.8.4
haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server-8.8","haskell-language-server"]
Launching haskell-language-server exe at:/home/axeman/.local/bin/haskell-language-server-8.8.4
haskell-language-server version: 0.6.0.0 (GHC: 8.8.4) (PATH: /home/axeman/.local/bin/haskell-language-server-8.8.4)
Starting (haskell-language-server)LSP server...
with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "hlint",PluginId "importLens",PluginId "moduleName",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell",PluginId "tactic"]
in directory: /home/axeman/workspace/wire-server
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
Started LSP server in 0.00s
Output from setting up the cradle Cradle {cradleRootDir = "/home/axeman/workspace/wire-server", cradleOptsProg = CradleAction: Stack}
> galley> configure (lib)
> Configuring galley-0.83.0...
> galley> initial-build-steps (lib)
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: galley
> /home/axeman/workspace/wire-server/.stack-work/install/x86_64-linux-nix/730229c219acc762949b1a7da64c266b88463ab6c391a6a622e0cbcb64fca603/8.8.4/pkgdb:/home/axeman/.stack/snapshots/x86_64-linux-nix/730229c219acc762949b1a7da64c266b88463ab6c391a6a622e0cbcb64fca603/8.8.4/pkgdb:/nix/store/w30rhw13ji6vkv0zksms5h7897cxvl90-ghc-8.8.4/lib/ghc-8.8.4/package.conf.d
@akshaymankar thanks for the detailed bug report.
is the log including the try to use hlint? i would expect see within entries like hlint:getIdeas:setExtensions:<list of actual extensions used by hlint> that may help for trace it.
Oh no, I forgot to paste logs from the debug logs! The logs in the description are from stderr.
Here is the relevant portion of the debug logs, it seems to have missed LambdaCase somehow.
2020-11-12 09:20:56.554454946 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"},"range":{"start":{"line":604,"character":0},"end":{"line":604,"character":0}},"context":{"diagnostics":[{"severity":3,"range":{"start":{"line":604,"character":0},"end":{"line":605,"character":52}},"code":"refact:Eta reduce","source":"hlint","message":"/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n"}]}},"id":20}
2020-11-12 09:20:56.555862502 [ThreadId 1566] - finish: CodeAction (took 0.00s)
2020-11-12 09:20:56.556244385 [ThreadId 1568] - finish: CodeAction:PackageExports (took 0.00s)
2020-11-12 09:20:56.557310719 [ThreadId 1570] - finish: importLens (took 0.00s)
2020-11-12 09:20:56.557957429 [ThreadId 1572] - finish: retrie (took 0.00s)
2020-11-12 09:20:56.55858729 [ThreadId 1574] - finish: tactic (took 0.00s)
2020-11-12 09:20:56.558827878 [ThreadId 1576] - finish: tactic (took 0.00s)
2020-11-12 09:20:56.559084789 [ThreadId 1578] - finish: tactic (took 0.00s)
2020-11-12 09:20:56.563575973 [ThreadId 7] - <--2--{"result":[{"command":{"command":"178614:hlint:applyAll","arguments":["file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"title":"Apply all hints"},"kind":"quickfix","title":"Apply all hints"},{"command":{"command":"178614:hlint:applyOne","arguments":[{"hintTitle":"Eta reduce","start_pos":{"line":604,"character":0},"file":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"}],"title":"Apply hint: Eta reduce"},"kind":"quickfix","diagnostics":[{"severity":3,"range":{"start":{"line":604,"character":0},"end":{"line":605,"character":52}},"code":"refact:Eta reduce","source":"hlint","message":"/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n"}],"title":"Apply hint: Eta reduce"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"Unfold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Unfold postOtrMessage"}],"title":"Unfold postOtrMessage"},"kind":"refactor.inline","title":"Unfold postOtrMessage"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"Unfold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Unfold postOtrMessage in current file"}],"title":"Unfold postOtrMessage in current file"},"kind":"refactor.inline","title":"Unfold postOtrMessage in current file"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"Fold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Fold postOtrMessage"}],"title":"Fold postOtrMessage"},"kind":"refactor.extract","title":"Fold postOtrMessage"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"Fold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Fold postOtrMessage in current file"}],"title":"Fold postOtrMessage in current file"},"kind":"refactor.extract","title":"Fold postOtrMessage in current file"}],"jsonrpc":"2.0","id":20}
2020-11-12 09:20:57.335792723 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"},"range":{"start":{"line":604,"character":0},"end":{"line":604,"character":0}},"context":{"diagnostics":[{"severity":3,"range":{"start":{"line":604,"character":0},"end":{"line":605,"character":52}},"code":"refact:Eta reduce","source":"hlint","message":"/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n"}]}},"id":21}
2020-11-12 09:20:57.337070187 [ThreadId 1584] - finish: CodeAction (took 0.00s)
2020-11-12 09:20:57.337370882 [ThreadId 1586] - finish: CodeAction:PackageExports (took 0.00s)
2020-11-12 09:20:57.338617878 [ThreadId 1588] - finish: importLens (took 0.00s)
2020-11-12 09:20:57.33932138 [ThreadId 1590] - finish: retrie (took 0.00s)
2020-11-12 09:20:57.340101189 [ThreadId 1592] - finish: tactic (took 0.00s)
2020-11-12 09:20:57.34040297 [ThreadId 1594] - finish: tactic (took 0.00s)
2020-11-12 09:20:57.340620704 [ThreadId 1596] - finish: tactic (took 0.00s)
2020-11-12 09:20:57.345648332 [ThreadId 7] - <--2--{"result":[{"command":{"command":"178614:hlint:applyAll","arguments":["file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"title":"Apply all hints"},"kind":"quickfix","title":"Apply all hints"},{"command":{"command":"178614:hlint:applyOne","arguments":[{"hintTitle":"Eta reduce","start_pos":{"line":604,"character":0},"file":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"}],"title":"Apply hint: Eta reduce"},"kind":"quickfix","diagnostics":[{"severity":3,"range":{"start":{"line":604,"character":0},"end":{"line":605,"character":52}},"code":"refact:Eta reduce","source":"hlint","message":"/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n"}],"title":"Apply hint: Eta reduce"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"Unfold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Unfold postOtrMessage"}],"title":"Unfold postOtrMessage"},"kind":"refactor.inline","title":"Unfold postOtrMessage"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"Unfold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Unfold postOtrMessage in current file"}],"title":"Unfold postOtrMessage in current file"},"kind":"refactor.inline","title":"Unfold postOtrMessage in current file"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"Fold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Fold postOtrMessage"}],"title":"Fold postOtrMessage"},"kind":"refactor.extract","title":"Fold postOtrMessage"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"Fold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Fold postOtrMessage in current file"}],"title":"Fold postOtrMessage in current file"},"kind":"refactor.extract","title":"Fold postOtrMessage in current file"}],"jsonrpc":"2.0","id":21}
2020-11-12 09:20:59.595638679 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"command":"178614:hlint:applyOne","arguments":[{"hintTitle":"Eta reduce","start_pos":{"line":604,"character":0},"file":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"}]},"id":22}
2020-11-12 09:20:59.596380223 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"token":1},"method":"window/workDoneProgress/create","id":3}
2020-11-12 09:20:59.596293361 [ThreadId 1602] - hlint:applyOneCmd:file=NormalizedFilePath "/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"
2020-11-12 09:20:59.596690722 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":true,"title":"Applying hint: Eta reduce"},"token":1},"method":"$/progress"}
2020-11-12 09:20:59.596928178 [ThreadId 1603] - hlint:getIdeas:file:NormalizedFilePath "/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"
2020-11-12 09:20:59.597406756 [ThreadId 1603] - hlint:getIdeas:setExtensions:[Cpp,OverlappingInstances,UndecidableInstances,IncoherentInstances,UndecidableSuperClasses,MonomorphismRestriction,MonoPatBinds,MonoLocalBinds,RelaxedPolyRec,ExtendedDefaultRules,ForeignFunctionInterface,UnliftedFFITypes,InterruptibleFFI,CApiFFI,GHCForeignImportPrim,JavaScriptFFI,ParallelArrays,TemplateHaskell,TemplateHaskellQuotes,ImplicitParams,ImplicitPrelude,ScopedTypeVariables,AllowAmbiguousTypes,UnliftedNewtypes,BangPatterns,TypeFamilies,TypeFamilyDependencies,TypeInType,OverloadedStrings,OverloadedLists,NumDecimals,DisambiguateRecordFields,RecordWildCards,RecordPuns,ViewPatterns,GADTs,GADTSyntax,NPlusKPatterns,DoAndIfThenElse,BlockArguments,RebindableSyntax,ConstraintKinds,PolyKinds,DataKinds,InstanceSigs,ApplicativeDo,StandaloneDeriving,DeriveDataTypeable,AutoDeriveTypeable,DeriveFunctor,DeriveTraversable,DeriveFoldable,DeriveGeneric,DefaultSignatures,DeriveAnyClass,DeriveLift,DerivingStrategies,DerivingVia,TypeSynonymInstances,FlexibleContexts,FlexibleInstances,ConstrainedClassMethods,MultiParamTypeClasses,NullaryTypeClasses,FunctionalDependencies,UnicodeSyntax,ExistentialQuantification,MagicHash,EmptyDataDecls,KindSignatures,RoleAnnotations,ParallelListComp,MonadComprehensions,GeneralizedNewtypeDeriving,PostfixOperators,TupleSections,PatternGuards,LiberalTypeSynonyms,RankNTypes,ImpredicativeTypes,TypeOperators,ExplicitNamespaces,PackageImports,ExplicitForAll,AlternativeLayoutRuleTransitional,DatatypeContexts,NondecreasingIndentation,RelaxedLayout,TraditionalRecordSyntax,LambdaCase,MultiWayIf,BinaryLiterals,HexFloatLiterals,DuplicateRecordFields,OverloadedLabels,EmptyCase,PatternSynonyms,PartialTypeSignatures,NamedWildCards,TypeApplications,Strict,StrictData,MonadFailDesugaring,EmptyDataDeriving,NumericUnderscores,QuantifiedConstraints,ImportQualifiedPost,CUSKs,StandaloneKindSignatures,QuasiQuotes,StarIsType]
2020-11-12 09:20:59.599532625 [ThreadId 5] - ---> {"jsonrpc":"2.0","id":3,"result":null}
2020-11-12 09:20:59.599739755 [ThreadId 5] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":3,\"result\":null}\n"
2020-11-12 09:20:59.647430226 [ThreadId 1603] - finish: applyHint (took 0.05s)
2020-11-12 09:20:59.647464738 [ThreadId 1602] - applyHint:apply=[("/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n",[Replace {rtype = Decl, pos = SrcSpan {startLine = 605, startCol = 1, endLine = 606, endCol = 53}, subts = [("body",SrcSpan {startLine = 606, startCol = 3, endLine = 606, endCol = 37}),("a",SrcSpan {startLine = 605, startCol = 16, endLine = 605, endCol = 20}),("b",SrcSpan {startLine = 605, startCol = 21, endLine = 605, endCol = 25})], orig = "postOtrMessage a b = body"}])]
2020-11-12 09:21:00.325629372 [ThreadId 1606] - finish: hlint (took 0.00s)
2020-11-12 09:21:00.361357458 [ThreadId 1602] - hlint:applyOneCmd:res=Left "\"(RealSrcSpan SrcSpanOneLine \\\"/tmp/Update178614-91.hs\\\" 148 23 27,\\\"Illegal lambda-case (use -XLambdaCase)\\\")\\nCallStack (from HasCallStack):\\n error, called at src/Refact/Internal.hs:84:13 in apply-refact-0.8.2.1-e5ada769d1ed74b27020ceda163d33b8a75e91b8939fcd90cc77787a3840b289:Refact.Internal\""
2020-11-12 09:21:00.362100071 [ThreadId 7] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":1},"method":"$/progress"}
2020-11-12 09:21:00.362578405 [ThreadId 7] - <--2--{"error":{"code":-32602,"message":"hlint:applyOne: \"\\\"(RealSrcSpan SrcSpanOneLine \\\\\\\"/tmp/Update178614-91.hs\\\\\\\" 148 23 27,\\\\\\\"Illegal lambda-case (use -XLambdaCase)\\\\\\\")\\\\nCallStack (from HasCallStack):\\\\n error, called at src/Refact/Internal.hs:84:13 in apply-refact-0.8.2.1-e5ada769d1ed74b27020ceda163d33b8a75e91b8939fcd90cc77787a3840b289:Refact.Internal\\\"\""},"jsonrpc":"2.0","id":22}
2020-11-12 09:21:00.940314386 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"},"range":{"start":{"line":604,"character":0},"end":{"line":604,"character":0}},"context":{"diagnostics":[{"severity":3,"range":{"start":{"line":604,"character":0},"end":{"line":605,"character":52}},"code":"refact:Eta reduce","source":"hlint","message":"/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n"}]}},"id":23}
2020-11-12 09:21:00.941763218 [ThreadId 1612] - finish: CodeAction (took 0.00s)
2020-11-12 09:21:00.942085644 [ThreadId 1614] - finish: CodeAction:PackageExports (took 0.00s)
2020-11-12 09:21:00.943267806 [ThreadId 1616] - finish: importLens (took 0.00s)
2020-11-12 09:21:00.944133219 [ThreadId 1618] - finish: retrie (took 0.00s)
2020-11-12 09:21:00.944994586 [ThreadId 1620] - finish: tactic (took 0.00s)
2020-11-12 09:21:00.945288517 [ThreadId 1622] - finish: tactic (took 0.00s)
2020-11-12 09:21:00.945553769 [ThreadId 1624] - finish: tactic (took 0.00s)
2020-11-12 09:21:00.951293759 [ThreadId 7] - <--2--{"result":[{"command":{"command":"178614:hlint:applyAll","arguments":["file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"title":"Apply all hints"},"kind":"quickfix","title":"Apply all hints"},{"command":{"command":"178614:hlint:applyOne","arguments":[{"hintTitle":"Eta reduce","start_pos":{"line":604,"character":0},"file":"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"}],"title":"Apply hint: Eta reduce"},"kind":"quickfix","diagnostics":[{"severity":3,"range":{"start":{"line":604,"character":0},"end":{"line":605,"character":52}},"code":"refact:Eta reduce","source":"hlint","message":"/home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs:(605,1)-(606,52): Warning: Eta reduce\nFound:\n postOtrMessage zusr zcon cnv val message\n = postNewOtrMessage zusr (Just zcon) cnv val message\nPerhaps:\n postOtrMessage zusr zcon = postNewOtrMessage zusr (Just zcon)\n"}],"title":"Apply hint: Eta reduce"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"Unfold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Unfold postOtrMessage"}],"title":"Unfold postOtrMessage"},"kind":"refactor.inline","title":"Unfold postOtrMessage"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"Unfold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Unfold postOtrMessage in current file"}],"title":"Unfold postOtrMessage in current file"},"kind":"refactor.inline","title":"Unfold postOtrMessage in current file"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":false,"rewrites":[{"tag":"Fold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Fold postOtrMessage"}],"title":"Fold postOtrMessage"},"kind":"refactor.extract","title":"Fold postOtrMessage"},{"command":{"command":"178614:retrie:retrieCommand","arguments":[{"restrictToOriginatingFile":true,"rewrites":[{"tag":"Fold","contents":"Galley.API.Update.postOtrMessage"}],"originatingFile":[-6523771766798299113,"file:///home/axeman/workspace/wire-server/services/galley/src/Galley/API/Update.hs"],"description":"Fold postOtrMessage in current file"}],"title":"Fold postOtrMessage in current file"},"kind":"refactor.extract","title":"Fold postOtrMessage in current file"}],"jsonrpc":"2.0","id":23}
Thanks, it seems we are not honouring the default-extensions cabal stanza (so you will not see other extensions put there if they are not included in the default ones).
I can think of in some workarounds that might work, while we fix that:
EDIT: but not sure if apply-refact would work including it, could you confirm if any of both works for you?
- set the extension as a pragma in the file
This works.
- add the extension using hlint configuration: https://github.com/ndmitchell/hlint/blob/master/README.md#language-extensions
This doesn't work.
I've opened an issue upstream to prepare the possible fix for when we would able to get default-extensions from .cabal: https://github.com/mpickering/apply-refact/issues/91
@akshaymankar Just in case, did you try to apply the refactoring using hlint executable in the shell?
I didn't. I tried to do it just now, but the version of hlint and apply-refact in nix-unstable don't seem to be compatible and installing apply-refact_0_8_0_0 fails on my computer. I will not be able to do this today at least. I will try it tomorrow and let you know, if you (or someone else) haven't already figured it out.
I installed apply-refact from the master branch and now running hlint <file> --refactor works.
@akshaymankar thanks for confirming it, i'll take a look to how hlint executable is calling apply-refact, to honour the same default extensions
I note that HLint the library doesn't have any way to invoke apply-refact, so I guess you are using HLint the binary? That seems like an unnecessary runtime dependency - I'd consider whether the IDE should call apply-refact directly. What HLint does is pass along its extensions to apply-refact, but to a large extent using HLint the binary its just guessing as to which extension are in scope, so it turns on most of them. However, I think that changed in the last 9 months, so it could be inconsistent based on HLint version.
@ndmitchell we are calling directly the apply-refact api, via applyRefactoring. We pass the file name and it does not support any parsing options.
I've asked in apply-refact for two new additions:
ParsedModule, cause we already have the module parsed with ghc-8.10Ah cool, so nothing to do with me :) - that all makes sense.
I've been using a patch like this for some time (it adds a heap of extensions to be on by default in ghc-exactprint). I think it causes a couple of tests to break in apply-refact but I've not looked into that.
We added a pair of tests over the handling of extension by apply-refact: https://github.com/haskell/haskell-language-server/blob/master/test/functional/FunctionalCodeAction.hs#L112-L119
From the tests we can infer that applying hints with default extensions should work with ghc-8.10
Most helpful comment
I've opened an issue upstream to prepare the possible fix for when we would able to get
default-extensionsfrom.cabal: https://github.com/mpickering/apply-refact/issues/91