Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-04-25 (08:56)
From: Yamagata Yoriyuki <yoriyuki@m...>
Subject: Common IO structure (was Re: [Caml-list] [ANN] The Missing Library)
From: "Nicolas Cannasse" <>
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. 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

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 = 
    method close : unit 

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

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

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 ->
      inherit ['a] obj_input_channel
      method unget : 'a -> unit

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

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

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 Archives:
Bug reports: FAQ:
Beginner's list: