home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 876 / hugs.sis / AnsiDemo.hs < prev    next >
Encoding:
Text File  |  2000-09-21  |  1.1 KB  |  29 lines

  1. -- This program is a simple example of the kind of thing that you can do with
  2. -- ANSI escape character sequences.  But, of course, it will only work on
  3. -- machines that support those character sequences (xterms and PCs with
  4. -- ansi.sys installed, for example).
  5. --
  6. -- Type `interact program' to run the program.
  7.  
  8. module AnsiDemo( program ) where
  9. import AnsiInteract
  10.  
  11. writes  = writeStr . concat
  12. program = writes [ cls,
  13.                    at (17,5)  (highlight "Demonstration program"),
  14.                    at (48,5)  "Version 1.0",
  15.                    at (17,7)  "This program illustrates a simple approach",
  16.                    at (17,8)  "to screen-based interactive programs using",
  17.                    at (17,9)  "the Hugs functional programming system.",
  18.                    at (17,11) "Please press any key to continue ..."
  19.                  ]
  20.           (pressAnyKey
  21.           (promptReadAt (17,15) 18 "Please enter your name: " (\name ->
  22.           (let reply = "Hello " ++ name ++ "!" in
  23.            writeAt (40-(length reply`div` 2),18) reply
  24.           (moveTo (1,23)
  25.           (writeStr "I'm waiting...\n"
  26.           (pressAnyKey
  27.           end)))))))
  28.  
  29.