Skip to content
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

Limit the number of valid hole fits #1914

Closed
wants to merge 14 commits into from

Conversation

expipiplus1
Copy link
Contributor

@expipiplus1 expipiplus1 commented Jun 13, 2021

Originally haskell/ghcide#888

@jneira
Copy link
Member

jneira commented Jun 13, 2021

@pepeiborra commented in the original pr

I think the limit (be it 5 or 15) should be moved to the GHC flags that we set in GHC.Compat, and make sure we don't override a user value.

I think we should take in account the ghc flag in some way, at least to honour it if the user has set it on purpose.
I would be a little bit surprised if i set 20 and only see 10 in the editor.

So i think that maybe we should follow the recommendation and set the flag auto for the specific ghc session for hls if users didnt set it explicitly.

@pepeiborra
Copy link
Collaborator

Thanks Joe!

@Ailrun Ailrun added the merge me Label to trigger pull request merge label Jun 14, 2021
@Ailrun
Copy link
Member

Ailrun commented Jun 26, 2021

@expipiplus1 Tests from

, testSession "postfix hole uses postfix notation of infix operator" $ do
let mkDoc x = T.unlines
[ "module Testing where"
, "test :: Int -> Int -> Int"
, "test a1 a2 = " <> x <> " a1 a2"
]
doc <- createDoc "Test.hs" "haskell" $ mkDoc "_"
_ <- waitForDiagnostics
actions <- getCodeActions doc (Range (Position 2 13) (Position 2 14))
chosen <- liftIO $ pickActionWithTitle "replace _ with (+)" actions
executeCodeAction chosen
modifiedCode <- documentContents doc
liftIO $ mkDoc "(+)" @=? modifiedCode
, testSession "filling infix type hole uses infix operator" $ do
let mkDoc x = T.unlines
[ "module Testing where"
, "test :: Int -> Int -> Int"
, "test a1 a2 = a1 " <> x <> " a2"
]
doc <- createDoc "Test.hs" "haskell" $ mkDoc "`_`"
_ <- waitForDiagnostics
actions <- getCodeActions doc (Range (Position 2 16) (Position 2 19))
chosen <- liftIO $ pickActionWithTitle "replace _ with (+)" actions
executeCodeAction chosen
modifiedCode <- documentContents doc
liftIO $ mkDoc "+" @=? modifiedCode

use filtered actions, so these keep failing.

@expipiplus1
Copy link
Contributor Author

hmm, the tests don't run for me locally. Would it be possible for someone else to take over this PR, please?

❯ cabal run test:ghcide-tests -- --pattern "postfix hole"
Up to date
ghcide
  code actions
    fill typed holes
      postfix hole uses postfix notation of infix operator: FAIL
        Exception: ghcide: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

@isovector

This comment has been minimized.

@jneira
Copy link
Member

jneira commented Sep 2, 2021

tests failing:

 Test suite ghcide-tests: RUNNING...
ghcide
  code actions
    fill typed holes
      postfix hole uses postfix notation of infix operator: FAIL (1.82s)
        test/exe/Main.hs:5546:
        Found no matching actions for "replace _ with (+)" in ["replace _ with test","replace _ with (-)","replace _ with (*)","replace _ with asTypeOf","replace _ with const","replace _ with pure","replace _ with (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits)","replace _ with curry _","replace _ with ($) _","replace _ with ($!) _","replace _ with const _","replace _ with flip _","replace _ with id _"]
        Use -p '/postfix hole uses postfix notation of infix operator/' to rerun this test only.
      filling infix type hole uses infix operator:          FAIL (1.83s)
        test/exe/Main.hs:5546:
        Found no matching actions for "replace _ with (+)" in ["replace _ with test","replace _ with (-)","replace _ with (*)","replace _ with asTypeOf","replace _ with const","replace _ with pure","replace _ with (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits)","replace _ with curry _","replace _ with ($) _","replace _ with ($!) _","replace _ with const _","replace _ with flip _","replace _ with id _"]
        Use -p '/filling infix type hole uses infix operator/' to rerun this test only.
  cradle
    dependencies

@Tritlo
Copy link

Tritlo commented Oct 6, 2021

Note! Valid hole-fits are a lot faster now on HEAD, so this might not be required anymore.

@expipiplus1
Copy link
Contributor Author

expipiplus1 commented Oct 6, 2021 via email

@jneira jneira removed the merge me Label to trigger pull request merge label Nov 28, 2021
@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Dec 21, 2021

Hole fitting solving would always be costly for the foreseeable futuristic future.

I consider 10 as a sane default (which would terminate mostly in the sane time & not clutter much, which I would prefer).

Lets not bikeshed - don't let the ideal be the enemy of the good.


@expipiplus1 would you be kind to push it over the last bump? ❤️

@Anton-Latukha Anton-Latukha marked this pull request as draft December 21, 2021 04:10
@expipiplus1
Copy link
Contributor Author

Sorry, I won't be able to get to this in a timely manner. Happy for someone else to take over though.

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Dec 21, 2021

Yep. Looked into commits.

Rebasing for this diff was a bit excessive 🤣


Ok then somebody from us would finish this.

@dnikolovv
Copy link

Hey all.

What's left for this one to get in?

@michaelpj michaelpj added the status: unfinished Status for PRs that have been semi-abandoned label Nov 2, 2022
@michaelpj
Copy link
Collaborator

This continues to be desirable but this implementation seems dead. Does anyone want to pick it up?

@michaelpj
Copy link
Collaborator

Superseded.

@michaelpj michaelpj closed this Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: unfinished Status for PRs that have been semi-abandoned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants