Skip to content

Add hayoo backend for suggesting imports. #358

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

Closed

Conversation

alexanderkjeldaas
Copy link
Contributor

NixOS doesn't seem to have a working hoogle, so hayoo is the better option. Added a hayoo backend.

@alexanderkjeldaas alexanderkjeldaas force-pushed the add-hayoo-ident branch 2 times, most recently from 73821ab to 4e9e538 Compare October 14, 2014 23:15
;; TODO: gather packages as well, and when we choose a
;; given import, check that we have the package in the
;; cabal file as well.
(modules-l (cl-mapcar (lambda (r) (cl-mapcar 'identity (assoc-default 'resultModules r))) results))
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't the standard mapcar be equivalent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can use cl-mapcan, but I also need to convert from vector to list (using append x nil).

However, I see another problem here. There is no queuing when asking the user for a response, so when multiple symbols are missing, they seem to be all over each other asking whether to add an import statement.

Some kind of explicit queuing seems to be needed when the prompt is called asyncronously.

(defun haskell-process-hayoo-ident (session file ident callback)
"Hayoo for IDENT, returns a list of modules asyncronously through CALLBACK."
;; This is a bit mysterious, but otherwise these are all unset
(setq haskell-process-hayoo-ident--session session
Copy link
Member

Choose a reason for hiding this comment

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

lexical-let might be an option here, right, since these vars are local to this function and its nested lambdas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that seems to work. Thanks!

@purcell
Copy link
Member

purcell commented Oct 16, 2014

There's a build failure with the current version of this PR:

In toplevel form:

haskell-process.el:935:56:Error: `(session session)' is a malformed function

make: *** [check-haskell-process] Error 1

You can run make check locally to reproduce this, or make check EMACS=/my/path/to/emacs if necessary.

@alexanderkjeldaas
Copy link
Contributor Author

Fixed. And thanks for the 'make check' tip.

We now require 'cl during compilation until the code is converted to use
lexical bindings by default (Emacs 24.1+)

On Thu, Oct 16, 2014 at 10:11 AM, Steve Purcell [email protected]
wrote:

There's a build failure with the current version of this PR:

In toplevel form:

haskell-process.el:935:56:Error: `(session session)' is a malformed function

make: *** [check-haskell-process] Error 1

You can run make check locally to reproduce this, or make check
EMACS=/my/path/to/emacs if necessary.


Reply to this email directly or view it on GitHub
#358 (comment).

@purcell
Copy link
Member

purcell commented Oct 16, 2014

We only just removed 'cl everywhere: I think we can keep things simple and just fetch the hayoo results synchronously in this case. I made a couple of further commits on a branch of my own to show what I mean: https://github.com/purcell/haskell-mode/compare/hayoo?expand=1

Let me know if that makes sense, and I'll go ahead and squash then apply everything here.

@alexanderkjeldaas
Copy link
Contributor Author

Looks good to me.

@purcell
Copy link
Member

purcell commented Oct 17, 2014

Squashed and merged! Thanks for all your work on this.

@gracjan
Copy link
Contributor

gracjan commented Feb 27, 2015

@purcell: close?

@purcell purcell closed this Feb 27, 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

Successfully merging this pull request may close these issues.

3 participants