You can subscribe to this list here.
2003 |
Jan
|
Feb
(81) |
Mar
(97) |
Apr
(88) |
May
(80) |
Jun
(170) |
Jul
(9) |
Aug
|
Sep
(18) |
Oct
(58) |
Nov
(19) |
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(22) |
Feb
(9) |
Mar
(28) |
Apr
(164) |
May
(186) |
Jun
(101) |
Jul
(143) |
Aug
(387) |
Sep
(69) |
Oct
(14) |
Nov
(8) |
Dec
(99) |
2005 |
Jan
(10) |
Feb
(34) |
Mar
(24) |
Apr
(7) |
May
(41) |
Jun
(20) |
Jul
(3) |
Aug
(23) |
Sep
(2) |
Oct
(26) |
Nov
(41) |
Dec
(7) |
2006 |
Jan
(6) |
Feb
(3) |
Mar
(11) |
Apr
|
May
|
Jun
(5) |
Jul
(8) |
Aug
(20) |
Sep
|
Oct
(6) |
Nov
(5) |
Dec
|
2007 |
Jan
|
Feb
(1) |
Mar
|
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
(7) |
Oct
(6) |
Nov
(19) |
Dec
(11) |
2008 |
Jan
|
Feb
(7) |
Mar
(9) |
Apr
(21) |
May
(42) |
Jun
(27) |
Jul
(28) |
Aug
(26) |
Sep
(16) |
Oct
(32) |
Nov
(49) |
Dec
(65) |
2009 |
Jan
(35) |
Feb
(20) |
Mar
(36) |
Apr
(42) |
May
(111) |
Jun
(99) |
Jul
(70) |
Aug
(25) |
Sep
(15) |
Oct
(29) |
Nov
(3) |
Dec
(18) |
2010 |
Jan
(10) |
Feb
(4) |
Mar
(57) |
Apr
(63) |
May
(71) |
Jun
(64) |
Jul
(30) |
Aug
(49) |
Sep
(11) |
Oct
(4) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2024 |
Jan
(1) |
Feb
(3) |
Mar
(6) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Amit D. <ad...@Co...> - 2003-02-28 16:53:43
|
Hi Everyone, Sorry for not participation in the discussion earlier, as I had a fairly tight deadline to work towards. I apologize if some of my comments (to come in the next few emails) may have already been discussed and decided against, as I haven't been able to read all of the messages this week. Thanks, Nicolas, for putting everyone's suggestions together. I have a couple of additions that I would like to suggest. To keep the discussion easy to follow for people who are new, or coming back after a bit (like me :), I'll reply to each module separately. -Amit |
From: Fernando A. <fer...@cc...> - 2003-02-28 15:14:36
|
> > let default x = function > > | None -> x > > | Some v -> v > > Hum sorry :) > It was in the same thread so I messed up... > Theses are nices, but what package would they belong to ? These functions extend the Pervasives module, so they belong under ExtLib (no sub-module) or maybe ExtLib.Pervasives (not sure about that) Fernando |
From: Stefano Z. <za...@bo...> - 2003-02-28 13:16:09
|
On Fri, Feb 28, 2003 at 12:38:12PM +0900, Nicolas Cannasse wrote: > > (* like perl's chomp function, remove trailing newline characters *) > > - val String.chomp : string -> string > Uhm, why not, but this need some discuss on implementation since newline is > "\r\n" under windows and "\n" under *nix.... Yes, but I'm almost sure that somewhere this information is already available in the standard library. Think for example at the input_line function that read a line from an input channel without trailing "newline", on *nix it removes the trailing "\n" but I'm almost sure that under win it removes trailing "\r\n" and so on on mac. > perhaps : > val iter_in : (string -> unit) -> in_channel -> unit > val map_in : (string -> 'a) -> in_channel -> 'a list > val fold_in : ('a -> string -> 'a) -> 'a -> in_channel -> 'a > > are better so it can work on many kind of descriptors and does not have to > handle the "file not found" problems Agreed. > I propose also : > val read_lines : in_channel -> string list Better "input_lines" for coherence with Pervasives.input_line > val read_all : in_channel -> string Better "input_all", "read_*" prefixed functions in Pervasives act on stdin only and not on generic input channels. Therefore I also suggest "read_lines" which is a "input_lines" working on stdint and "read_all", the same for "input_all". Anyway is probably worthwhile to think at something like: val input_lines: ?inchan:in_channel -> string list val input_line: ?inchan:in_channel -> string with optional argument "inchan" defaulting to "stdin". This makes standard library more compact. > > - val Dbm.fold_left > Uh, never used Dbm... Ok, but trust me, a fold function is always useful! :-) > > - val Hashtbl.sorted_fold: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> > > - val Hashtbl.sorted_iter: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> > Aren't theses strange and very particular ones ?? Probably you are right, they are uncommon also in other standard libraries ... not really useful indeed. > All theses cannot be part of the ExtLib, since we're only focusing right now > on the StdLib Extension ( and Unix is not part of the StdLib altought it's > part of the standard distribution ) and also theses function need some C > code to work. Ok, we probably disagree on the idea of "standard library", I was thinking at it like "all the libraries that are part of the ocaml distribution". If you are looking only at Pervasives module remember that also Dbm isn't part of it ... > > - val Random.char: unit -> char > > - val Random.string: int -> char (* argument is string length *) > Don't like theses Why? > > - val non: ('a -> bool) -> ('a -> bool) > Since there is some need for such basic functions, let's put that in a > module Logic Is it worth the effort? Have you find many other functions for this module? > > - val unsome : 'a option -> 'a > Global is much more complete Uh? Cheers. -- Stefano Zacchiroli - Undergraduate Student of CS @ Uni. Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} - http://www.bononia.it/zack/ " I know you believe you understood what you think I said, but I am not sure you realize that what you heard is not what I meant! " -- G.Romney |
From: Nicolas C. <war...@fr...> - 2003-02-28 10:27:05
|
> >The last point is about compilation and module linkage. > >If you want to do "open ExtLib" and then "open List" for exemple, then > >ExtLib have to be ONE big module (perhaps several files linked together with > >the -pack option, but still one big cmo ) and so will always be entirely > >linked with your bytecode if you're using only one function of it... so > >that'll prevent us from adding new modules since each time it will get > >bigger and bigger. If you have another structure/compilation proposal.... > > > > I recall the question about namespaces in the COAN thread and X. Leroy > saying that the -pack option was still unstable... Could we ask for it > to "drift" so that the support would be merely "namespatial" in the > sense that no big cmo file got build out of the multiple cmo's being > packed... Or at least that cmos generated with -pack were rather stubs > for the modules being assembled so that they didn't have to be loaded as > a *whole*. I'm not into compiler/linker construction so I don't know > about the complexity of this but it doesn't look altogether unreasonable > to me... It's for the benefit of the generated code to be lean! I don't think this kind of hack will be done by the caml team like this. It takes time to find a good way to do it, and might not be done for the 3.07 release. So we cannot rely on it, and have to find our own packaging way. Nicolas Cannasse |
From: Nicolas C. <war...@fr...> - 2003-02-28 10:24:23
|
> > > (* given a 'a option returns the 'a value if it's Some _ or raise an > > > exception, find a better name! *) > > > - val unsome : 'a option -> 'a > > > > Global is much more complete > > Huh ?? that's not the same thing at all ... This kind of function is > useful when dealing with optional arguments. > > There's more of this kind of fonctions (manipulating 'a option values) : > > let may f = function > | None -> () > | Some v -> f v > > let may_map f = function > | None -> None > | Some v -> Some (f v) > > let is = function > | None -> false > | Some _ -> true > > let default x = function > | None -> x > | Some v -> v Hum sorry :) It was in the same thread so I messed up... Theses are nices, but what package would they belong to ? Nicolas Cannasse |
From: fva <fv...@ts...> - 2003-02-28 10:20:53
|
Nicolas Cannasse wrote: >>>That would help. Thanks. >>> >>> >>- val String.explode : string -> char list >>- val String.implode : char list -> string >> >> > >Agree > Agree. >> (* like perl's chomp function, remove trailing newline characters *) >>- val String.chomp : string -> string >> >> > >Uhm, why not, but this need some discuss on implementation since newline is >"\r\n" under windows and "\n" under *nix.... > Agree with the consideration for the this double character ending quirks & so. >> (* fold left on file lines (without trailing newline), I don't know in >> which module this functions should go, maybe Sys? *) >>- val fold_file : ('a -> string -> 'a) -> 'a -> string -> 'a >> (* iter on file lines *) >>- val iter_file : (string -> unit) -> string -> unit >> >> > >perhaps : > >val iter_in : (string -> unit) -> in_channel -> unit >val map_in : (string -> 'a) -> in_channel -> 'a list >val fold_in : ('a -> string -> 'a) -> 'a -> in_channel -> 'a > >are better so it can work on many kind of descriptors and does not have to >handle the "file not found" problems > >I propose also : > >val read_lines : in_channel -> string list >val read_all : in_channel -> string > I like better the "in_channel" typed functions. I also use iteri, fold and iter on directories filtering out "." and ".." for doing experiments on many files (based in Unix.opendir, closedir). Haven't looked if the stdlib opted them in for ages... BTW doesn't this look like a pattern on an abstract structure with sequential access? Wouldn't a single signature and a number of structure instantiations be in order here... Ease of use & all that... >that returns all the contents ( up to End_of_file ) > > > >>- val Dbm.fold_left >> >> > >Uh, never used Dbm... > Me neither. Can't judge. >>- val Hashtbl.keys : ('a, 'b) Hashtbl.t -> 'a list >>- val Hashtbl.values : ('a, 'b) Hashtbl.t -> 'b list >> (* remove all bindings of a given keys *) >>- val Hashtbl.remove_all : ('a, 'b) Hashtbl.t -> 'a -> unit >> >> > >Agree > Yes. I also miss those when I've been perling for some time... >> (* like Hashtbl.fold but working on ordered key list. Find a better >> name!, compare defaults to Pervasives.compare *) >>- val Hashtbl.sorted_fold: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> >> >> >'c -> 'c) -> ('a, 'b) Hashtbl.t -> 'c -> 'c > >> (* as above for iter *) >>- val Hashtbl.sorted_iter: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> >> >> >unit) -> ('a, 'b) Hashtbl.t -> unit > >Aren't theses strange and very particular ones ?? > I see the perlmania here as well, but they are worth, for me at least, in *very particular contexts* (text processing). >> (* return all bindings of a given key *) >>- val List.assoc_all: 'a -> ('a * 'b) list -> 'b list >> (* as above but use physical equality *) >>- val List.assq_all: 'a -> ('a * 'b) list -> 'b list >> Yes. I have these in the more general context of "maps". >>- val Sys.copy: src:string -> dst:string -> unit >> >> (* add support for recursive directory creation for Unix.mkdir *) >>- support for "-p" to Unix.mkdir >>- Unix.is_directory : ?follow_sym_link: bool -> string -> bool >>- Unix.is_regular >>- Unix.is_symlink >>- ... (* predicates over filenames, optional argument defaults to false, >> if it is true predicate are over symlink target *) >> (* return size of a given file; maybe Sys.filesize? *) >>- Unix.filesize : string -> bool >> (* "/ls" command interface *) >>- Unix.ls : string -> string list >> >> > >All theses cannot be part of the ExtLib, since we're only focusing right now >on the StdLib Extension ( and Unix is not part of the StdLib altought it's >part of the standard distribution ) and also theses function need some C >code to work. > So no using of Unix, uh? I see: standalone and all that. >>- val Random.char: unit -> char >>- val Random.stringi: int -> char (* argument is string length *) >> >> > >Don't like theses > Don't see the point either, really. >> (* predicate negation *) >>- val non: ('a -> bool) -> ('a -> bool) >> >> > >Since there is some need for such basic functions, let's put that in a >module Logic > Interesting. Agree. >> (* given a 'a option returns the 'a value if it's Some _ or raise an >> exception, find a better name! *) >>- val unsome : 'a option -> 'a >> >> > >Global is much more complete > Think so too. I liked the name "the" for this function, though. It also looks like the iota quantifier and perhaps should go into Logic? Regards, Fran Valverde |
From: fva <fv...@ts...> - 2003-02-28 10:08:37
|
Nicolas Cannasse wrote: >I also have mine, but in a different way ( that's "named" globals - better >debug & type abstraction ) >But since I hasn't used it much, I was wondering if it should be part of the >ExtLib, maybe ? > > >exception Global_not_initialized of string > >module Global : > sig > > type 'a t > > val empty : string -> 'a t (* returns an new named empty global *) > val name : 'a t -> string (* retrieve the name of a global *) > val set : 'a t -> 'a -> unit (* set the global value contents *) > val get : 'a t -> 'a (* get the global value contents - raise >Global_not_initialized if not defined *) > val undef : 'a t -> unit (* reset the global value contents to undefined *) > val isdef : 'a t -> bool (* tell if the global value has been set *) > > val opt : 'a t -> 'a option (* return None if the global is undefined, or >Some v where v is the current global value contents *) > > end > I've also something similar for generating new names, etc... I think it worth putting in an extended lib. Regards, Fva |
From: fva <fv...@ts...> - 2003-02-28 10:02:41
|
Nicolas Cannasse wrote: >The last point is about compilation and module linkage. >If you want to do "open ExtLib" and then "open List" for exemple, then >ExtLib have to be ONE big module (perhaps several files linked together with >the -pack option, but still one big cmo ) and so will always be entirely >linked with your bytecode if you're using only one function of it... so >that'll prevent us from adding new modules since each time it will get >bigger and bigger. If you have another structure/compilation proposal.... > I recall the question about namespaces in the COAN thread and X. Leroy saying that the -pack option was still unstable... Could we ask for it to "drift" so that the support would be merely "namespatial" in the sense that no big cmo file got build out of the multiple cmo's being packed... Or at least that cmos generated with -pack were rather stubs for the modules being assembled so that they didn't have to be loaded as a *whole*. I'm not into compiler/linker construction so I don't know about the complexity of this but it doesn't look altogether unreasonable to me... It's for the benefit of the generated code to be lean! Regards, Fran Valverde |
From: Olivier A. <ol...@us...> - 2003-02-28 08:57:44
|
> > (* given a 'a option returns the 'a value if it's Some _ or raise an > > exception, find a better name! *) > > - val unsome : 'a option -> 'a > > Global is much more complete Huh ?? that's not the same thing at all ... This kind of function is useful when dealing with optional arguments. There's more of this kind of fonctions (manipulating 'a option values) : let may f = function | None -> () | Some v -> f v let may_map f = function | None -> None | Some v -> Some (f v) let is = function | None -> false | Some _ -> true let default x = function | None -> x | Some v -> v -- Olivier |
From: Nicolas C. <war...@fr...> - 2003-02-28 06:07:01
|
> > > I'd prefer ExtLib.List.int > > > > > > That way, I can switch from StdLib.List to ExtLib.List by just > > > "opening" ExtLib in my sources. > > > > This way, you're supposing that ExtLib.List will be a reimplementation of > > the List module... I don't that's the purpose here. Let's just say that > > More than a reimplementation, I see it as a superset. > > ExtLib would pass through without change most StdLib functions, add a few > missing functions and shadow the bad guys in StdLib (incorrect functions > in List and so) > > It may also add a few sub-modules missing in StdLib, and maybe a few > functions missing in Pervasives. So, "open ExtLib" will give you an > enhanced OCaml environment. I would actually like to have that, but : - I don't really agree when you're qualifying "bad guys" some stdlib functions. and I don't think that the caml team will agree also :) - the only "bad guys" for me are the functions which are raising either Invalid_argument or Failure when users are supposed catch it to handle (for example, creating an Array with a negative size is a good "invalid_argument" raise case, while List.hd is not ) - we can't modify theses functions without giving them a different name ( for obvious stdlib compatibily reasons ) but when can provide different implementations ( such as stoi & stof in the ExtLib.String proposed in v0.1 as alternatives to int_of_string & float_of_string ) The last point is about compilation and module linkage. If you want to do "open ExtLib" and then "open List" for exemple, then ExtLib have to be ONE big module (perhaps several files linked together with the -pack option, but still one big cmo ) and so will always be entirely linked with your bytecode if you're using only one function of it... so that'll prevent us from adding new modules since each time it will get bigger and bigger. If you have another structure/compilation proposal.... Regards, Nicolas Cannasse |
From: Fernando A. <fer...@cc...> - 2003-02-28 04:10:54
|
On Fri, Feb 28, 2003 at 11:40:55AM +0900, Nicolas Cannasse wrote: > > I'd prefer ExtLib.List.int > > > > That way, I can switch from StdLib.List to ExtLib.List by just > > "opening" ExtLib in my sources. > > This way, you're supposing that ExtLib.List will be a reimplementation of > the List module... I don't that's the purpose here. Let's just say that More than a reimplementation, I see it as a superset. ExtLib would pass through without change most StdLib functions, add a few missing functions and shadow the bad guys in StdLib (incorrect functions in List and so) It may also add a few sub-modules missing in StdLib, and maybe a few functions missing in Pervasives. So, "open ExtLib" will give you an enhanced OCaml environment. Fernando |
From: Nicolas C. <war...@fr...> - 2003-02-28 03:39:04
|
> > That would help. Thanks. > > - val String.explode : string -> char list > - val String.implode : char list -> string Agree > (* like perl's chomp function, remove trailing newline characters *) > - val String.chomp : string -> string Uhm, why not, but this need some discuss on implementation since newline is "\r\n" under windows and "\n" under *nix.... > (* fold left on file lines (without trailing newline), I don't know in > which module this functions should go, maybe Sys? *) > - val fold_file : ('a -> string -> 'a) -> 'a -> string -> 'a > (* iter on file lines *) > - val iter_file : (string -> unit) -> string -> unit perhaps : val iter_in : (string -> unit) -> in_channel -> unit val map_in : (string -> 'a) -> in_channel -> 'a list val fold_in : ('a -> string -> 'a) -> 'a -> in_channel -> 'a are better so it can work on many kind of descriptors and does not have to handle the "file not found" problems I propose also : val read_lines : in_channel -> string list val read_all : in_channel -> string that returns all the contents ( up to End_of_file ) > - val Dbm.fold_left Uh, never used Dbm... > - val Hashtbl.keys : ('a, 'b) Hashtbl.t -> 'a list > - val Hashtbl.values : ('a, 'b) Hashtbl.t -> 'b list > (* remove all bindings of a given keys *) > - val Hashtbl.remove_all : ('a, 'b) Hashtbl.t -> 'a -> unit Agree > (* like Hashtbl.fold but working on ordered key list. Find a better > name!, compare defaults to Pervasives.compare *) > - val Hashtbl.sorted_fold: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> 'c -> 'c) -> ('a, 'b) Hashtbl.t -> 'c -> 'c > (* as above for iter *) > - val Hashtbl.sorted_iter: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> unit) -> ('a, 'b) Hashtbl.t -> unit Aren't theses strange and very particular ones ?? > (* return all bindings of a given key *) > - val List.assoc_all: 'a -> ('a * 'b) list -> 'b list > (* as above but use physical equality *) > - val List.assq_all: 'a -> ('a * 'b) list -> 'b list > - val Sys.copy: src:string -> dst:string -> unit > > (* add support for recursive directory creation for Unix.mkdir *) > - support for "-p" to Unix.mkdir > - Unix.is_directory : ?follow_sym_link: bool -> string -> bool > - Unix.is_regular > - Unix.is_symlink > - ... (* predicates over filenames, optional argument defaults to false, > if it is true predicate are over symlink target *) > (* return size of a given file; maybe Sys.filesize? *) > - Unix.filesize : string -> bool > (* "/ls" command interface *) > - Unix.ls : string -> string list All theses cannot be part of the ExtLib, since we're only focusing right now on the StdLib Extension ( and Unix is not part of the StdLib altought it's part of the standard distribution ) and also theses function need some C code to work. > - val Random.char: unit -> char > - val Random.stringi: int -> char (* argument is string length *) Don't like theses > (* predicate negation *) > - val non: ('a -> bool) -> ('a -> bool) Since there is some need for such basic functions, let's put that in a module Logic > (* given a 'a option returns the 'a value if it's Some _ or raise an > exception, find a better name! *) > - val unsome : 'a option -> 'a Global is much more complete Thanks, Nicolas Cannasse |
From: Nicolas C. <war...@fr...> - 2003-02-28 03:28:31
|
Hi list Here's most of the functions ( sorted by module ) that I been gathered from different mails here and there. There might me some mission functions but I tried to make the whole consisted and documented. You will see that I have included both Global and MList modules, since MList seems to be approved, and Global-like used by several people here. Please report any problem of understanding, naming convention, exception, usability.... on the list I think this is a good basis of work. Nicolas Cannasse |
From: Nicolas C. <war...@fr...> - 2003-02-28 02:45:30
|
> > > > (* given a 'a option returns the 'a value if it's Some _ or raise an > > > > exception, find a better name! *) > > > > - val unsome : 'a option -> 'a > > > > > > Isn't this called valOf in SML? But unsome sounds better to me. > > > > This might not be to everyone's tastes, but I often use a related > > function that I call "the": > > val the : 'a option ref -> 'a > > which fails with Failure "uninitialized variable" when the > > (dereferenced) option is None. > > I use something like this too : > I also have mine, but in a different way ( that's "named" globals - better debug & type abstraction ) But since I hasn't used it much, I was wondering if it should be part of the ExtLib, maybe ? exception Global_not_initialized of string module Global : sig type 'a t val empty : string -> 'a t (* returns an new named empty global *) val name : 'a t -> string (* retrieve the name of a global *) val set : 'a t -> 'a -> unit (* set the global value contents *) val get : 'a t -> 'a (* get the global value contents - raise Global_not_initialized if not defined *) val undef : 'a t -> unit (* reset the global value contents to undefined *) val isdef : 'a t -> bool (* tell if the global value has been set *) val opt : 'a t -> 'a option (* return None if the global is undefined, or Some v where v is the current global value contents *) end Nicolas Cannasse |
From: Nicolas C. <war...@fr...> - 2003-02-28 02:41:42
|
> > ok , let's call it ExtList.init ! > > I'd prefer ExtLib.List.int > > That way, I can switch from StdLib.List to ExtLib.List by just > "opening" ExtLib in my sources. This way, you're supposing that ExtLib.List will be a reimplementation of the List module... I don't that's the purpose here. Let's just say that ExtList contains additionnals functions using the List.t type ( aka 'a list ) and that you can use them just with "open ExtList". Don't you think ? > By the way, what if we propose to the caml team that the modules in the > standard library be all under a StdLib module? Same remarks. ExtLib is not a different implementation, so switching between StdLib and ExtLib does not make sense. Nicolas Cannasse |
From: Nicolas C. <war...@fr...> - 2003-02-28 02:31:38
|
> > How would you go about packaging these in the extlib so that they can be > > more or less seamlessly integrated with the stdlib. A single overarching > > file-module? > > As someone suggested earlier on this list, I'd favor something like: > > module Ext = > struct > module List = > struct > include List > ... <our extensions go here> > end > > module String = > struct > include String > ... <our extensions go here> > end > ... > end Linkage of binaries in bytecode application is made on a per-file basis ( and not per-module or per-function ). So in order to keep the bytecode size small, we'll have to use several files (that's just what's the stdlib is doing). Nicolas Cannasse |
From: Olivier A. <ol...@us...> - 2003-02-27 20:06:18
|
Eric C. Cooper [Thursday 27 February 2003] : > > On Thu, Feb 27, 2003 at 05:00:49PM +0100, Michal Moskal wrote: > > On Thu, Feb 27, 2003 at 02:51:58PM +0100, Stefano Zacchiroli wrote: > > > (* given a 'a option returns the 'a value if it's Some _ or raise an > > > exception, find a better name! *) > > > - val unsome : 'a option -> 'a > > > > Isn't this called valOf in SML? But unsome sounds better to me. > > This might not be to everyone's tastes, but I often use a related > function that I call "the": > val the : 'a option ref -> 'a > which fails with Failure "uninitialized variable" when the > (dereferenced) option is None. I use something like this too : ,----[ uref.ml ] | exception Uninitialised | type 'a uref = 'a option ref | let uref () = ref None | let (&=) r v = r := Some v | let is_init r = !r <> None | let (!!) r = | match !r with | | None -> raise Uninitialised | | Some v -> v `---- ,----[ uref.mli ] | exception Uninitialised | type 'a uref = 'a option ref | val uref : unit -> 'a uref | val ( &= ) : 'a uref -> 'a -> unit | val is_init : 'a uref -> bool | val ( !! ) : 'a uref -> 'a `---- -- Olivier |
From: Eric C. C. <ec...@cm...> - 2003-02-27 19:29:11
|
On Thu, Feb 27, 2003 at 07:51:43PM +0900, Nicolas Cannasse wrote: > > (* Generate the range of integers [a; a+1; ...; b] *) > > > > val range : int * int -> int list > > would prefer : > range : int -> int -> int list > since it's not causing any overhead due to the tuple allocation ( integer > are unboxed ) That's a reasonable argument. I like the suggestion of mathematical "interval notation" with range (1, 10), but don't feel strongly about it. > > (* Reverse assoc *) > > (* can also add rassq, mem_rassoc/rassq, remove_rassoc/rassq if needed *) > > > > val rassoc : 'b -> ('a * 'b) list -> 'a > > I reallly don't like theses. The usage of them are far from obvious My old Lisp habits are showing, I guess. > > (* String equivalents of Array.fold_left and Array.fold_right *) > > > > val string_fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a > > val string_fold_right : (char -> 'a -> 'a) -> 'a -> string -> 'a I really think these are useful. For example: let checksum data = string_fold_left (fun n c -> (n + Char.code c) mod 256) 0 data let explode string = string_fold_right (fun c list -> c :: list) [] string > > (* Convert between strings and lists of chars. *) > > > > val explode : string -> char list > > val implode : char list -> string > > Theses four are interesting, but I don't realy see the need of using Strings > as char list. Could you tell me about it ? This is another Lisp influence. I find it easier to write "functional" string manipulation with these operators (versus the Buffer module, which is more efficient for large strings, but also more imperative and less flexible -- you can't go back and insert data at the beginning or middle). Thanks for all the comments. -- Eric C. Cooper e c c @ c m u . e d u |
From: Eric C. C. <ec...@cm...> - 2003-02-27 19:11:51
|
On Thu, Feb 27, 2003 at 10:58:20AM +0100, fva wrote: > How would you go about packaging these in the extlib so that they can be > more or less seamlessly integrated with the stdlib. A single overarching > file-module? As someone suggested earlier on this list, I'd favor something like: module Ext = struct module List = struct include List ... <our extensions go here> end module String = struct include String ... <our extensions go here> end ... end -- Eric C. Cooper e c c @ c m u . e d u |
From: Eric C. C. <ec...@cm...> - 2003-02-27 19:02:50
|
On Thu, Feb 27, 2003 at 05:00:49PM +0100, Michal Moskal wrote: > On Thu, Feb 27, 2003 at 02:51:58PM +0100, Stefano Zacchiroli wrote: > > (* given a 'a option returns the 'a value if it's Some _ or raise an > > exception, find a better name! *) > > - val unsome : 'a option -> 'a > > Isn't this called valOf in SML? But unsome sounds better to me. This might not be to everyone's tastes, but I often use a related function that I call "the": val the : 'a option ref -> 'a which fails with Failure "uninitialized variable" when the (dereferenced) option is None. I typically use it with 'a option refs that represent global variables, like options set on the command line: let channel = open_in (the input_file) in ... etc. -- Eric C. Cooper e c c @ c m u . e d u |
From: Fernando A. <fer...@cc...> - 2003-02-27 17:52:25
|
On Thu, Feb 27, 2003 at 07:51:43PM +0900, Nicolas Cannasse wrote: > ok , let's call it ExtList.init ! I'd prefer ExtLib.List.int That way, I can switch from StdLib.List to ExtLib.List by just "opening" ExtLib in my sources. By the way, what if we propose to the caml team that the modules in the standard library be all under a StdLib module? Fernando |
From: Michal M. <mal...@pl...> - 2003-02-27 16:04:27
|
On Thu, Feb 27, 2003 at 02:51:58PM +0100, Stefano Zacchiroli wrote: > (* given a 'a option returns the 'a value if it's Some _ or raise an > exception, find a better name! *) > - val unsome : 'a option -> 'a Isn't this called valOf in SML? But unsome sounds better to me. -- : Michal Moskal ::::: malekith/at/pld-linux.org : GCS {C,UL}++++$ a? !tv : PLD Linux ::::::: Wroclaw University, CS Dept : {E-,w}-- {b++,e}>+++ h |
From: Stefano Z. <za...@bo...> - 2003-02-27 13:52:36
|
On Wed, Feb 26, 2003 at 09:36:54PM -0500, Manos Renieris wrote: > That would help. Thanks. - val String.explode : string -> char list - val String.implode : char list -> string (* like perl's chomp function, remove trailing newline characters *) - val String.chomp : string -> string (* fold left on file lines (without trailing newline), I don't know in which module this functions should go, maybe Sys? *) - val fold_file : ('a -> string -> 'a) -> 'a -> string -> 'a (* iter on file lines *) - val iter_file : (string -> unit) -> string -> unit - val Dbm.fold_left - val Hashtbl.keys : ('a, 'b) Hashtbl.t -> 'a list - val Hashtbl.values : ('a, 'b) Hashtbl.t -> 'b list (* remove all bindings of a given keys *) - val Hashtbl.remove_all : ('a, 'b) Hashtbl.t -> 'a -> unit (* like Hashtbl.fold but working on ordered key list. Find a better name!, compare defaults to Pervasives.compare *) - val Hashtbl.sorted_fold: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> 'c -> 'c) -> ('a, 'b) Hashtbl.t -> 'c -> 'c (* as above for iter *) - val Hashtbl.sorted_iter: ?compare: ('a -> 'a -> int) -> ('a -> 'b -> unit) -> ('a, 'b) Hashtbl.t -> unit (* return all bindings of a given key *) - val List.assoc_all: 'a -> ('a * 'b) list -> 'b list (* as above but use physical equality *) - val List.assq_all: 'a -> ('a * 'b) list -> 'b list - val Sys.copy: src:string -> dst:string -> unit (* add support for recursive directory creation for Unix.mkdir *) - support for "-p" to Unix.mkdir - Unix.is_directory : ?follow_sym_link: bool -> string -> bool - Unix.is_regular - Unix.is_symlink - ... (* predicates over filenames, optional argument defaults to false, if it is true predicate are over symlink target *) (* return size of a given file; maybe Sys.filesize? *) - Unix.filesize : string -> bool (* "/ls" command interface *) - Unix.ls : string -> string list - val Random.char: unit -> char - val Random.string: int -> char (* argument is string length *) (* predicate negation *) - val non: ('a -> bool) -> ('a -> bool) (* given a 'a option returns the 'a value if it's Some _ or raise an exception, find a better name! *) - val unsome : 'a option -> 'a Hope this helps, Cheers. -- Stefano Zacchiroli - Undergraduate Student of CS @ Uni. Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} - http://www.bononia.it/zack/ " I know you believe you understood what you think I said, but I am not sure you realize that what you heard is not what I meant! " -- G.Romney |
From: fva <fv...@ts...> - 2003-02-27 12:04:47
|
Stefano Zacchiroli wrote: >If you like I can sent you on the list (to which I'm _not_ subscribed) >the set of functions I've collected that I would like to see in the >ocaml standard library. > Yes of course... I think everybody would appreciate that. Regards, Fran Valverde |
From: Nicolas C. <war...@fr...> - 2003-02-27 10:52:29
|
> (* > * Additions to the List module. > *) > > (* Generate the range of integers [a; a+1; ...; b] *) > > val range : int * int -> int list would prefer : range : int -> int -> int list since it's not causing any overhead due to the tuple allocation ( integer are unboxed ) > (* List equivalent of Array.init *) > > val listi : int -> (int -> 'a) -> 'a list ok , let's call it ExtList.init ! and so you have let range a b = ExtList.init (b - a) (fun x -> x+a) and if I agree that List.init is missing, I don't think that the "range" is worth including in ExtList > (* List equivalent of Array.mapi *) > > val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list > val iteri : (int -> 'a -> unit) -> 'a list -> unit ok I buy it > (* Reverse assoc *) > (* can also add rassq, mem_rassoc/rassq, remove_rassoc/rassq if needed *) > > val rassoc : 'b -> ('a * 'b) list -> 'a I reallly don't like theses. The usage of them are far from obvious > (* Tail-recursively compute rev (map f list1) @ list2 *) > > val rev_map_append : ('a -> 'b) -> 'a list -> 'b list -> 'b list same : I don't see the point This function seems very particular, I haven't ever needed it (or perhaps I don't remember) And I would like something doing that, I think I wouln't even check in any StandardLibrary if it exists. > (* Split [x1; x2; ...; xN] into [x1; ...; x{n}] and [x{n+1}; ...; xN] *) > > val split_nth : int -> 'a list -> 'a list * 'a list Agree, Looks a little like the npop from MList > (* Tail-recursively split [x1; x2; ...; xN] into > [x{n}; ...; x1] and [x{n+1}; ...; xN] *) > > val rev_split_nth : int -> 'a list -> 'a list * 'a list Don't agree. If users wants tail-recusive calls for such functions, I think they have to implement it since we're not going to provide for all the non tail recursive functions a corresponding tail recursive one. > (* Return the last element of a list. *) > > val last : 'a list -> 'a Agree - need an exception :) > (* Insert x at position n in list. > Position 0 places x at the front; > position (length list) places x at the end. *) > > val insert : 'a -> int -> 'a list -> 'a list Agree > (* Remove first occurrence of x, if any, from list. *) > val remove_first : 'a -> 'a list -> 'a list > > (* Remove all occurrences of x from list. *) > val remove : 'a -> 'a list -> 'a list > > (* Remove a subset of elements from a list. *) > val remove_subset : 'a list -> 'a list -> 'a list Actually I wonder if when you're using theses, you're not actualy using somehow a mutable list... > (* Rotate each element of a list to the left, > so that the head becomes the last element. *) > > val rotate_left : 'a list -> 'a list Too much particular > (* Homogeneous version of List.fold_left. > Uses the head of the list as the initial value. *) > > val fold : ('a -> 'a -> 'a) -> 'a list -> 'a Same > (* Test whether the first list is a subset of the second. *) > > val subset : 'a list -> 'a list -> bool Agree, but I would add a functional comparator as first parameter. Perhaps when using such comparators, we could use an optional argument ?comp having a default of ( = ) > (* Return cartesian product of two lists. *) > > val product : 'a list -> 'b list -> ('a * 'b) list "join" is a better name. > (* Return all sublists of a list. *) > > val subsets : 'a list -> 'a list list Pfiouu You're doing strange things with Ocaml , aren't you ? :) Statistics, is it ? > (* Return all n-element sublists of a list. *) > > val choose : int -> 'a list -> 'a list list > > (* Return all sublists with up to n elements. *) > > val choose_up_to : int -> 'a list -> 'a list list Too particular > (* Remove duplicates from a sorted list, > using a sort-style comparison function that returns 0 for equality. *) > > val uniq : ('a -> 'a -> int) -> 'a list -> 'a list Why do not use a ('a -> 'a -> bool) on unsorted list ? complexity is the same > (* > * Additions to the String module. > *) > > (* String equivalents of Array.fold_left and Array.fold_right *) > > val string_fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a > val string_fold_right : (char -> 'a -> 'a) -> 'a -> string -> 'a > > (* Convert between strings and lists of chars. *) > > val explode : string -> char list > val implode : char list -> string Theses four are interesting, but I don't realy see the need of using Strings as char list. Could you tell me about it ? > (* Convert between strings and lists of ints in the range 0 .. 255 *) > > val explode_bytes : string -> int list > val implode_bytes : int list -> string > > (* Like [index_from] but searches at most [len] chars. *) > (* can also add bounded_rindex if needed *) > > val bounded_index : string -> pos:int -> len:int -> char -> int Same > (* > * Miscellaneous control structures. > *) > > (* Compute f (g x) *) > (* It would be nice to have a standard infix operator for this. *) > > val compose : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c Agree > (* Compute f^n x *) > > val iterate : ('a -> 'a) -> int -> 'a -> 'a Agree > (* Invoke (f ()) n times, for side effects. *) > > val repeat : int -> (unit -> unit) -> unit > > (* Apply f to 0 .. n-1, for side effects. *) > > val dotimes : int -> (int -> unit) -> unit Better with a "for" loop. Done. Nicolas Cannasse |