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

Code duplication between haskell-process-do-type, haskell-process-insert-type #989

Closed
bergey opened this issue Nov 12, 2015 · 8 comments
Closed

Comments

@bergey
Copy link
Contributor

bergey commented Nov 12, 2015

haskell-process-do-type has two code paths, one to insert a type, one to show it in the minibuffer. They share no code, and for example use different rules to decide what string to pass to ghci.

I'm happy to make a PR refactoring the common code into a single function, if the maintainers agree that this would be an improvement.

@gracjan
Copy link
Contributor

gracjan commented Nov 12, 2015

Hmm, interesting.

I remember Artur working on this and it proved problematic to merge those code paths. I'm not sure what the problem was, though.

If you can merge it then great, go ahead!

@geraldus
Copy link
Contributor

I'll be able to have a look tommorow.

@geraldus
Copy link
Contributor

Oh, guys, I'm a greatest lier, apologizes, I have not looked at this yet. Maybe on Thuesday...

@bergey
Copy link
Contributor Author

bergey commented Nov 15, 2015

No rush, I have plenty of other projects. =)

@geraldus
Copy link
Contributor

Ok, the difference is if user just wants to see a type, do-type shows result in the minibuffer or in popup window depending on presentation mode configuration. If user wants to insert a type, it is not necessary to show result, because it will be inserted anyway. So there is two diffrents ways of functionallity. Does it makes some sense? Or do you have other questions?

@bergey
Copy link
Contributor Author

bergey commented Nov 17, 2015

I understand the difference in output. I was surprised that this leads to different regexen to match the Haskell identifier, and to decide whether to add parens in the ghci query. I jumped to the conclusion that the two functions should do the same thing up to the point where they output the type differently. Looking now, that may be wrong.

Is it documented anywhere that haskell-process-do-type will message the type of the expression in region, but haskell-process-insert-type will ignore the active region and pick the identifier at point? Or that neither will give the type of an operator?

I thought that merging the code up to the point of display might be the first step towards documenting, and possibly expanding, their functionality. If you think they're better off separate, feel free to close this issue, and I'll take a stab at documenting the current behavior, at least.

@gracjan gracjan changed the title code duplication between haskell-process-do-type, haskell-process-insert-type Code duplication between haskell-process-do-type, haskell-process-insert-type Nov 17, 2015
@gracjan
Copy link
Contributor

gracjan commented Nov 17, 2015

Thinking about this issue again it might be more productive for you to contribute to Haskell IDE Engine because it is supposed to fix this and many other problems.

@bergey
Copy link
Contributor Author

bergey commented Nov 17, 2015

Yes, that makes sense. Thanks for the advice.

@bergey bergey closed this as completed Nov 25, 2015
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

No branches or pull requests

3 participants