pqwy / notty

Declarative terminal graphics for OCaml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I can't get any of the examples to work

kdvolder opened this issue · comments

Installed notty from opam. Then tried to follow the 'Basics' instructions.

For example here's what I tried:

─( 19:49:50 )─< command 0 >───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # #require "notty";;
─( 19:49:52 )─< command 1 >───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # #require "notty.top";;
─( 19:50:03 )─< command 2 >───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # I.string A.empty "Rad!";;
- : image = Rad!
─( 19:51:22 )─< command 3 >───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # I.string A.empty "Rad!" |> Notty_unix.output_image;;
Line 1:
Error: Reference to undefined global `Notty_unix'
─( 19:51:52 )─< command 4 >───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─

It seems to create images alright, but I'm not really sure how you can make it show anything on the screen at all. Every time I have tried someImage |> Notty_unix.output_image;;. I always get

   Error: Reference to undefined global `Notty_unix`.

I'm relatively new to Ocaml, so perhaps I am doing something obviously wrong because I don't understand it. But if so, the 'basics' could do with some more 'basic' explanation of how you install the library properly and how you actually get it to a point where a basic example actually displays something on the screen.

Okay, so I figured what I was missing. Apparantly it was #require "notty.unix";;.

So FYI: the full sequence of 'stuff' needed in front of 'the basics':

#require "notty";;
#require "notty.top";;
#require "notty.unix";;
open Notty;;
(* after all that, the example from https://pqwy.github.io/notty/doc/Notty.html#basics works *)
let wow = I.string A.(fg red ++ bg black) "Wow!" in
I.(wow <-> (void 2 0 <|> wow)) |> Notty_unix.output_image