caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matt Gushee <mgushee@havenrock.com>
To: caml-list@pauillac.inria.fr
Subject: [Caml-list] Seeking feedback on a project
Date: Thu, 10 Jul 2003 18:47:06 -0600	[thread overview]
Message-ID: <20030711004706.GB4031@swordfish> (raw)

I would like to hear your opinions about a project I have been working on
over the last few days.

The project is an OCaml library intended to provide a generic framework
for constructing interactive text-based programs. I see this as being
useful for applications such as configuration editors, expert system
shells, and data entry interfaces.

The way this came about is that I have been wanting such a library for
my own personal use for some time; and lately I have also been curious
about OCaml functors, but didn't quite understand how they worked. So it
occurred to me that it might be appropriate to code this library using
functors, and decided to go ahead and try it.

Now I've developed part of the library, and in so doing have
accomplished one goal: I now have a fairly good understanding of how
functors work. Meanwhile, it turns out that completing this project,
while not a huge undertaking, will be significantly more work than I
thought at first, so I'm wondering if I should really continue it.

I'd like to ask list members' opinions on the following:

 * Would you find something like this library useful, or do you know
   people who would?
 * Is my approach (see below for more details) a sensible one? Are there
   better ways to attack this problem in OCaml?
 * Does a library of this sort already exist?


To help you answer the above questions, here's a little bit more
information:

The library (tentatively called ShellKit) provides a type of low-level
component called a "shell." The shell is the basic unit of interaction,
and it has the following characteristics:

 - prints some text (usually a prompt, and depending on the type of
   shell, possibly a menu or a brief description), then accepts user
   input on STDIN.
 - has a 'run' function whose signature is:
     run : ?data -> unit -> result
   where 
     type result = signal * string option
 - has an associated data type
 - has a function to validate the input
 - can be supplied a default value
 - in addition to handling a specific type of input, can have hooks for
   special global commands such as "help" and "quit."

The basic process for creating a shell looks like:

   configuration -> functor -> shell driver -> functor -> shell

Here's a concrete example:

module BShell = MkShell(
  MkBooleanDriver(
    struct
      type t = bool
      let help = None
      let default = None
      let prompt_msg = "Do you like ShellKit?"
      let common = default_shell_options
    end
  )
);;

When you invoke BShell.run (), it produces a prompt like this:

  Do you like ShellKit? [y/n] >

... then, of course, captures the user's input.


NOTE: If I continue this work, the final product will include structures
for assembling shells into programs, but so far those exist only in
skeleton form.

Anyway, thanks in advance for your comments.

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2003-07-11  0:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <D4DBD8568F05D511A1C20002A55C008C11AC05A4@uswaumsx03medge.med.ge.com>
2003-07-11  0:47 ` Matt Gushee [this message]
     [not found]   ` <001401c34788$19f1b0a0$9600a8c0@maison>
2003-07-11 17:06     ` Matt Gushee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030711004706.GB4031@swordfish \
    --to=mgushee@havenrock.com \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).