Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] [ANN] The Missing Library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yamagata Yoriyuki <yoriyuki@m...>
Subject: Common IO structure (was Re: [Caml-list] [ANN] The Missing Library)
From: "Nicolas Cannasse" <warplayer@free.fr>
Subject: Re: [Caml-list] [ANN] The Missing Library
Date: Sat, 24 Apr 2004 11:28:19 +0200

> There is a beginning of answer in the ExtLib : it's the new IO module that
> is enabling high-level abstracts inputs/ouputs. http://ocaml-lib.sf.net as
> usual :-)

While we are at it...

Several libraries (Cryptokit, ocamlnet, and Camomile, as far as I
know) have their own I/O modules.  Could we unify these interfaces?
IO module of SF Extlib might be a contender, but its channels are
abstract types, which I think problematic.

>From Camomile perspective, I want channels

1) Polymorphic, so that channels can handle Unicode characters
   directly.

2) Based on Objects, so that each library can make an extension of
   channels while remain compatible with the common interface.

3) Light weight.

Using objects has the extra plus that what we really have to in this
case is only using the same method name.  We do not need to introduce
a dependency to the common I/O library.

Just for the reference, I put Camomile OOChannel interface in the
last.  I'd like to hear the opinion of library developpers.

(** Generic input/output channel *)
class type ['a] obj_input_channel = 
  object 
    method close : unit 

	(** If the channel is already terminated, raise End_of_file *)
    method get : 'a 
  end

class type ['a] obj_output_channel = 
  object
    method close : unit
    method flush : unit
    method put : 'a -> unit
  end

class ['a] channel_of_stream : 'a Stream.t -> ['a] obj_input_channel

val stream_of_channel : 'a #obj_input_channel -> 'a Stream.t

class ['a, 'b] filter_in : 
    ('b obj_output_channel -> 'a obj_output_channel) ->
      'a obj_input_channel -> 
	['b] obj_input_channel

class ['a] unget : 'a #obj_input_channel ->
    object
      inherit ['a] obj_input_channel
      method unget : 'a -> unit
    end

class type char_input_channel =
  object
    inherit [char] obj_input_channel
    method input : string -> int -> int -> int
    method really_input : string -> int -> int -> unit
  end

class type char_output_channel =
  object
    inherit [char] obj_output_channel
    method output : string -> int -> int -> unit
  end

class char_input_channel_of : char obj_input_channel -> char_input_channel
class char_output_channel_of : char obj_output_channel -> char_output_channel

class of_in_channel : Pervasives.in_channel -> char_input_channel
class of_out_channel : Pervasives.out_channel -> char_output_channel

-------------------
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