Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does EasyPlot make commands invisible in GHCi?

Tags:

haskell

Minimal working example:

  1. Start GHCi
  2. import Graphics.EasyPlot
  3. plot X11 sin

On my system, as expected, a plot of the sine function appears in a window, GHCi displays True (the value of the IO Bool that plot returned, indicating a successful plot) and a fresh command prompt appears.

Unexpectedly, when I type, no text appears at the command prompt until I hit enter. Then the text I typed becomes visible, and GHCi reacts as expected to whatever command I entered. When I type at the next command prompt, the same thing happens. So far, I've found two ways to get GHCi back to normal:

  • Running :l to load a file.
  • Quitting and restart.

Why does this happen, and how can I prevent it?


Things that don't prevent the behavior:

  • Calling plot from the main function in a file and running it using the :main command in GHCi.
  • Plotting to a file, using the PNG terminal, instead of to a window.
  • Using plot' instead of plot.

Things that don't get GHCi back to normal:

  • Running :m to unload all modules.
like image 392
Vectornaut Avatar asked Sep 29 '22 12:09

Vectornaut


1 Answers

I can reproduce what you describe (ghc-7.8.4, fedora 21, x86_64, xmonad).

It is not a ghci feature, you get the same behaviour in a shell.

gnuplot -e "set terminal x11 persist ; plot sin(x)"

(This is (roughly) the command that is sent to the shell by EasyPlot, cf. https://hackage.haskell.org/package/easyplot-1.0/docs/src/Graphics-EasyPlot.html#exec )

Plot window appears, shell prompt appears, but shell does not (seem to) work.

You can just move the mouse pointer to the plot window, then back to the shell - this seems to make it work.

like image 64
d8d0d65b3f7cf42 Avatar answered Nov 01 '22 21:11

d8d0d65b3f7cf42