0

In python, there exists many IDEs which let you do this.

>>> if (a==5):
      print "Yes"
else:
      print "No"

But in haskell's GHCi:

Prelude> do

<interactive>:2:1: Empty 'do' block

It does not work. Is there any IDE which lets you do multiline commands in interactive mode.

Note: I am aware of the :{ and :} commands, but you then can not edit upper lines after entering them.

bheklilr
  • 53,530
  • 6
  • 107
  • 163
PyRulez
  • 10,513
  • 10
  • 42
  • 87
  • 1
    AFAIK you can't edit the upper lines after entering them in IPython either. It's essentially the same as IPython's readline functionality, except you have to manually start it – bheklilr Dec 03 '13 at 22:11
  • Yes, but I haven't found any haskell ide that can do it. Python's IDLE can. – PyRulez Dec 03 '13 at 22:13
  • First of all, I wouldn't really consider IDLE to be an IDE. Second, few people actually use IDLE for significant python development. Most will use IPython and it's huge, awesome feature set. Like GHCi, IPython is a REPL, but IDLE is not. IDLE is built using a GUI toolkit called Tkinter, so it's theoretically possible to write something similar for Haskell, but to my knowledge no one has. You aren't going to get that functionality very easily in a REPL. – bheklilr Dec 03 '13 at 22:21

2 Answers2

5

Enter

Prelude> :set +m
Prelude> do
Prelude|   x <- getLine
Prelude|   putStrLn $ "yay: " ++ x
Prelude|
hi!
yay: hi!

The :set +m part enables multi-line input like in Python. This works like the :{ :} though so you won't be able to edit upper lines there either. If you want to do that, I recommend writing in a file instead and loading it in the interpreter. (This can be done really quickly with the correct Vim or Emacs setup.)

If you're not into the command-line editors, you can probably look at some of the actual Haskell IDEs out there. I know FP Complete has a web-based one that's free for education purposes. There has been some attempts at building IDEs in Haskell as well.

kqr
  • 14,791
  • 3
  • 41
  • 72
2

Try ihaskell, https://github.com/gibiansky/IHaskell, which is a Haskell kernel for ipython. It's a young project and not on hackage yet. Let us know how it goes!

GarethR
  • 724
  • 5
  • 7