From: Nicolas C. <war...@fr...> - 2004-02-01 10:17:26
|
Just a little additionnal suggestion about SysUtil : SysUtil is heavily relying on the Unix module for its implementation, and that's ok. But only one feature ( the Match pattern to match the filename using a regexp) is using the Str module. In order to reduce dependencies, I think you should abstract the Match, using an user define regexp matching. For exemple : in SysUtil.mli : --- val configure_regexp : make:(string -> 'a) -> test:('a -> bool) -> unit in SysUtil.ml : ----- let regexp_make= ref (fun _ -> failwith "Regexp is not configured") let regexp_test = ref (fun x _ -> failwith "Regexp is not configured"; x = 0) (* we need to give a type here for ungeneralized variables *) let configure_regexp ~make ~test = regexp_make := Obj.magic make; (* we need to cast here because the type we need is slighty different *) regexp_test := Obj.magic test * and in testing Match : let reg = !regexp_make str in fun x -> !regexp_test reg x Then the user could write : SysUtil.configure_regexp Str.regexp Str.string_match before making any Match ( we can also use only one function with currying trick : SysUtil.configure_regexp (fun reg -> let reg = Str.regexp reg in (Str.String.match reg)) but it's then less comprehensible for the user ) Regards, Nicolas Cannasse |