15

I would like to use a text-based UI in my Haskell program. I found some bindings for the ncurses library (see also hscurses or ncurses, which one to use?). The hscurses and nanocurses packages are just simple wrappers around the C library, while vty isn't very well documented and a bit ugly (for example mixing snake_case and CamelCase).

The ncurses library on Hackage looks much more pretty and provides API which nicely fits Haskell. The problem is that it doesn't seem to implement some crucial features, like resizing or refreshing the windows.

So my question is:

  • is there any other Haskell text UI library, either ncurses-based or not, which I missed?
  • if there isn't anyone, is it possible to extend the ncurses Haskell library to at least support window refreshing and resizing? (this should be probably consulted with the project owner, but I need the solution quickly)

EDIT:

I finally used nscurses without windows (and panels) to avoid the troubles with refreshing them. I had problems with output to bottom-right corner of a window (a very similar issue was reported for Python's ncurses binding). I solved it by not writing there :).

Community
  • 1
  • 1
Jan Špaček
  • 1,111
  • 1
  • 9
  • 24

3 Answers3

9

Have you looked at vty-ui? It has a very nice user manual with lots of examples. I believe it's essentially a wrapper around vty.

mhwombat
  • 8,026
  • 28
  • 53
3

I've used nanoncurses and hscurses succesfully, my hmp3 app has a binding that was the basis for nanocurses.

No matter what you probably will want a nice high level API. hscurses does have a box abstraction at least.

You'd be fine going with hscurses.

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
  • Well, the main goal of my program is to present Haskell and I thought I would use the abstractions in `ncurses` (like monad `Curses` and `Update`) to show that programming in Haskell is prettier than C. But `hscurses` is on the same "level" as pure C ncurses, so using it as a demonstration of Haskell doesn't have much sense. I'll try to extend `ncurses`; if I fail, I will use `hscurses` :). – Jan Špaček Mar 02 '13 at 18:49
  • The curses libraries are low level. I don't see a good way to present Haskell by showing terminal blitting :) You might have better luck with e.g. FRP guis or image processing... – Don Stewart Mar 02 '13 at 18:51
  • I wanted to use ncurses-based interactive interface as a part of a larger program (path finding in a maze with moving obstacles). For now, it just prints the found path to terminal, and I thought it would be cool to support also stepping through the found path :). – Jan Špaček Mar 02 '13 at 20:09
  • @honzasp: maybe you could use http://projects.haskell.org/diagrams/ to show the maze path -- that's very elegant Haskell – amindfv Mar 04 '13 at 05:37
  • 1
    In a previous project I was unable to use ncurses due to it's GPL licence. I used vty to good effect, without much effort. – timbod Mar 07 '13 at 11:47
3

There is another good choice for Text-based user interfaces in haskell;

Brick is written by jtdaugherty, the same person that developed vty-ui which is Deprecated now.

The API is Declarative, which is Better for Presenting a language like Haskell. also the Documentation was great and complete.

Community
  • 1
  • 1
pouya
  • 74
  • 1
  • 5