From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA02335; Fri, 11 Jul 2003 02:47:06 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA10618 for ; Fri, 11 Jul 2003 02:47:05 +0200 (MET DST) Received: from mz2.forethought.net (mzpi4.forethought.net [216.241.36.13]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h6B0l3T14672 for ; Fri, 11 Jul 2003 02:47:04 +0200 (MET DST) Received: from [216.241.35.41] (helo=swordfish) by mz2.forethought.net with esmtp (Exim 4.14) id 19am3y-0008MH-JV for caml-list@pauillac.inria.fr; Thu, 10 Jul 2003 18:47:02 -0600 Received: from matt by swordfish with local (Exim 3.35 #1 (Debian)) id 19am42-0002XT-00 for ; Thu, 10 Jul 2003 18:47:06 -0600 Date: Thu, 10 Jul 2003 18:47:06 -0600 From: Matt Gushee To: caml-list@pauillac.inria.fr Subject: [Caml-list] Seeking feedback on a project Message-ID: <20030711004706.GB4031@swordfish> Reply-To: Matt Gushee Mail-Followup-To: caml-list@pauillac.inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.27i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; gushee:01 mgushee:01 havenrock:01 generic:01 functors:01 low-level:01 stdin:01 hooks:01 functor:01 struct:01 englewood:01 manure:01 ignores:01 --lao:01 merel:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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