Skip to content

Run hs2hs on .hsc-files before loading #1238

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
wants to merge 11 commits into from

Conversation

unhammer
Copy link
Contributor

Disable by setting haskell-process-do-hsc2hs to nil.

Tests only work interactively, TODO.

Fixes #1012.

Disable by setting haskell-process-do-hsc2hs to nil.

Tests only work interactively, TODO
@unhammer unhammer mentioned this pull request Mar 29, 2016
file-name)))


(defvar haskell-process-do-hsc2hs t
Copy link
Contributor

Choose a reason for hiding this comment

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

We would not want to push the burden on users with this variable due to cost described in https://github.com/haskell/haskell-mode/wiki/Customizable-variables

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gracjan
Copy link
Contributor

gracjan commented Mar 29, 2016

Note that on our build server there is no hsc installed and in general we would love to not depend on hsc. Lets do this:

  1. Add a variable that is hsc-exec-path (with more proper name).
  2. In tests customize this variable to a shell script that pretends to be a hsc compiler.

So basically we mock hsc on shell level. What do you think?

@gracjan gracjan changed the title run hs2hs on .hsc-files before loading (#1012) Run hs2hs on .hsc-files before loading (#1012) Mar 29, 2016
@unhammer
Copy link
Contributor Author

1 Add a variable that is hsc-exec-path (with more proper name).
2 In tests customize this variable to a shell script that pretends to
be a hsc compiler.

So basically we mock hsc on shell level. What do you think?

Sounds good to me. Do we customise test variables in haskell-hs2hs-tests.el, or is there a central file?

@gracjan
Copy link
Contributor

gracjan commented Mar 29, 2016

In haskell-hs2hs-tests.el. Actually you could use dynamic binding so that customization is done per test.

@unhammer
Copy link
Contributor Author

Added a fake script now; how does it look? I still get Wrong type argument: stringp, ("ghci" "-ferror-spans") as in #1012 (comment) both in my terminal and from travis though. Are there any other tests that load the REPL that I could look at?

}
")

(defmacro with-hsc2hs (contents &rest body)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should always use the hsc2hs.sh script. I do not want reports from people that accidentally have something strange in their paths and therefore tests accidentally pass or fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@gracjan
Copy link
Contributor

gracjan commented Mar 30, 2016

This Wrong type argument: stringp, ("ghci" "-ferror-spans") indicates a couple of things:

  1. Something in there should compose cmd line invocation even given list of strings. See Improve error handling of exec of external programs if they are absent and handle list of params #975.
  2. On Travis we do not want ghci so there is a need for another awk script fake-ghci.sh just like the one you did for hsc2hs.
  3. In general when executables aren't found the information should be much more user friendly.

@gracjan
Copy link
Contributor

gracjan commented Mar 30, 2016

And also note that this whole external program execution testing is tracked by issue #1206.

@gracjan
Copy link
Contributor

gracjan commented Mar 30, 2016

Nice!

@gracjan gracjan changed the title Run hs2hs on .hsc-files before loading (#1012) Run hs2hs on .hsc-files before loading Mar 30, 2016
@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2016

How about inlining the contents of hsc2hs.sh in a function that will create this script on the fly, add executable bit and setup the path, I mean:

     (with-script-path ' haskell-process-path-hsc2hs
      "#!/bin/awk
      /END/ { the script here }"
      (body-of-function))

So this will create a new file with contents given, add executable bit, and set the given variable to the path of what was created. What do you think?

@unhammer
Copy link
Contributor Author

unhammer commented Apr 6, 2016

That'd work, but the macro can't clean up the file because it's running async now. Does
https://github.com/unhammer/haskell-mode/compare/hsc2hs-1012...unhammer:hsc2hs-1012-tempscript?expand=1 seem OK?

@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2016

Yes.

No cleanup is okay, we might fix that later as low priority.

@gracjan
Copy link
Contributor

gracjan commented Apr 6, 2016

You need to create a script that plays the role of GHCi.

process seems to just die, although it works fine interactively on the
command line
@unhammer
Copy link
Contributor Author

unhammer commented Apr 7, 2016

I haven't been able to get that to work; the process seems to just die before it sends any output at all.

Does haskell-repl send any signals or such before interaction happens? Should the output be different from running ghci on the command line?

@gracjan
Copy link
Contributor

gracjan commented Apr 7, 2016

I do not think there are any signals involved. If there is an async communication isn't that the tests ends up before fake-ghc?

@unhammer
Copy link
Contributor Author

unhammer commented Apr 7, 2016

I was checking (process-status (get-buffer-process "*haskell*")), but now I see there is never any process associated with the REPL buffer; doing (process-status (cdr (assoc 'inferior-process (haskell-process)))) actually checks the status, so it is running after all.

I'm just not getting the output in the REPL. I see the output in the haskell-process-log of the fake-ghci if I, instead of (insert ":t unNUMBERS rand_max") (haskell-interactive-handle-expr) do (haskell-process-send-string (haskell-session-process haskell-session) ":t unNUMBERS rand_max") (is that just for "internal" communication?), but it doesn't end up in the REPL.

@gracjan
Copy link
Contributor

gracjan commented Apr 7, 2016

Interesting. Communication is somehow preprocessed, maybe something is eating your output?

@gracjan
Copy link
Contributor

gracjan commented Apr 25, 2016

Ping? Anything happening here?

I find this idea really good, so would be lovely to see this pushed forward!

@unhammer
Copy link
Contributor Author

Hey; I never figured out how to fix this :( (also, I haven't actually had use for hsc2hs in some months months).

I'd love to get it working though. Could you explain what happen (or is supposed to happen) between the haskell-process-log and the REPL? I see haskell-mode at least puts the lambda character in the prompt, presumably some other things happen there as well. Since the log shows the expected output, I'm guessing whatever is parsing my fake-ghci is not seeing what it expects.

@gracjan
Copy link
Contributor

gracjan commented Apr 26, 2016

Well, I do know as much as you do at this point.

A fake-ghci would be great to test other things in haskell-interactive-mode.

@gracjan
Copy link
Contributor

gracjan commented May 17, 2016

Anyway I plan to steal the part with awk, make it more general and use it for some other tests.

@unhammer
Copy link
Contributor Author

Cool; it'd be great if something useful comes of this :)

@gracjan
Copy link
Contributor

gracjan commented May 18, 2016

I've remade the testing parts in #1331, no awk, just pure elisp :)

If you happen to need hsc again then please use my testing functionality.

Thanks for inspiration!

@gracjan gracjan closed this May 18, 2016
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.

2 participants