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

Eval plugin: proper multilined results handling and command-name abbreviations #413

Merged
merged 5 commits into from
Sep 23, 2020
Merged

Eval plugin: proper multilined results handling and command-name abbreviations #413

merged 5 commits into from
Sep 23, 2020

Conversation

konn
Copy link
Collaborator

@konn konn commented Sep 19, 2020

This pull-request consists of two changes to Eval plugin:

  1. Bugfix: a proper treatment of multilined results.

    Previously, GHCi-like commands in Eval plugin doesn't treat multilined results properly.

    For example, with the current Eval plugin we get:

    f :: forall k n a. (KnownNat k, KnownNat n, Typeable a)
      => Proxy k -> Proxy n -> Proxy a -> ()
    f _ _ _ = ()
    
    -- >>> :type f
    -- f :: forall k1 (k2 :: Nat) (n :: Nat) (a :: k1).
    (KnownNat k2, KnownNat n, Typeable a) =>
    Proxy k2 -> Proxy n -> Proxy a -> ()

    Apparlently, the last two lines must be prefixed with --.
    This pull request addresses this issue and now it seems that the plugin returns the same result as GHCi:

    -- >>> :type f
    -- f :: forall k1 (k2 :: Nat) (n :: Nat) (a :: k1).
    --      (KnownNat k2, KnownNat n, Typeable a) =>
    --      Proxy k2 -> Proxy n -> Proxy a -> ()

    It tries to use Outputable.SDoc to generate the same alignment as the GHCi.

  2. New feature: abbreviation for GHCi commands.

    Eval plugin now lookups GHCi-like commands first by exact match, then fallbacks to the first element in the dictionary with the given prefix.
    Since there are just three commands currently, I just used lists to implement command dictionary; perhaps we should use some kind of trie in a future?

Copy link
Member

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style comments

plugins/default/src/Ide/Plugin/Eval.hs Outdated Show resolved Hide resolved
plugins/default/src/Ide/Plugin/Eval.hs Outdated Show resolved Hide resolved
@konn
Copy link
Collaborator Author

konn commented Sep 21, 2020

I've forgotten to fix the pragma styles in functional tests. Now they must be accord with the existing codebase's LANGUAGE pragma style.

@pepeiborra pepeiborra merged commit 8a71972 into haskell:master Sep 23, 2020
@pepeiborra
Copy link
Collaborator

Thank you!

pepeiborra added a commit that referenced this pull request Dec 27, 2020
* Refactor getDocumentation to work with parsed modules

* Fix names to express semantic rather than type information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants