Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Documenting authors.

git-svn-id: svn+ssh://svn.forge.ocamlcore.org/svnroot/batteries@138 b9ea8324-641f-426b-95ce-2518f2e44cc5
  • Loading branch information...
commit 8eddc9b28829bcfd52c48a626953c8d2c4c95d6c 1 parent 2b08593
yoric authored
Showing with 1,134 additions and 239 deletions.
  1. +12 −1 trunk/batteries/ChangeLog
  2. +8 −7 trunk/batteries/Makefile
  3. +24 −6 trunk/batteries/README
  4. +2 −2 trunk/batteries/{build/GODI/batteries.spec → batteries.godiva}
  5. +13 −1 trunk/batteries/build/META
  6. +2 −0  trunk/batteries/build/README
  7. +3 −4 trunk/batteries/build/import.ml
  8. +0 −43 trunk/batteries/build/minimal.ml
  9. +83 −0 trunk/batteries/build/odoc_extract_mli.ml
  10. +14 −9 trunk/batteries/build/odoc_generator_batlib.ml
  11. +2 −0  trunk/batteries/build/packdoc.ml
  12. +4 −0 trunk/batteries/build/tools.ml
  13. +371 −0 trunk/batteries/doc/batteries/html/about.html
  14. +18 −1 trunk/batteries/doc/batteries/html/extensions.html
  15. +41 −0 trunk/batteries/doc/batteries/html/style.css
  16. +5 −3 trunk/batteries/doc/batteries/myocamlbuild.ml
  17. +5 −0 trunk/batteries/examples/README
  18. +2 −0  trunk/batteries/examples/examples.itarget
  19. +5 −0 trunk/batteries/src/README
  20. +1 −1  trunk/batteries/src/core/batteries_core.ml
  21. +2 −1  trunk/batteries/src/core/extlib/IO.ml
  22. +2 −0  trunk/batteries/src/core/extlib/base64.mli
  23. +5 −1 trunk/batteries/src/core/extlib/bitSet.mli
  24. +26 −1 trunk/batteries/src/core/extlib/charParser.mli
  25. +4 −0 trunk/batteries/src/core/extlib/dllist.mli
  26. +7 −3 trunk/batteries/src/core/extlib/dynArray.mli
  27. +11 −7 trunk/batteries/src/core/extlib/enum.mli
  28. +10 −6 trunk/batteries/src/core/extlib/enumLabels.mli
  29. +15 −0 trunk/batteries/src/core/extlib/extArray.ml
  30. +12 −3 trunk/batteries/src/core/extlib/extArray.mli
  31. +11 −8 trunk/batteries/src/core/extlib/extBig_int.mli
  32. +5 −1 trunk/batteries/src/core/extlib/extBool.mli
  33. +5 −1 trunk/batteries/src/core/extlib/extChar.mli
  34. +6 −1 trunk/batteries/src/core/extlib/extComplex.mli
  35. +37 −0 trunk/batteries/src/core/extlib/extFloat.ml
  36. +118 −1 trunk/batteries/src/core/extlib/extFloat.mli
  37. +3 −0  trunk/batteries/src/core/extlib/extGenlex.mli
  38. +11 −4 trunk/batteries/src/core/extlib/extHashtbl.mli
  39. +4 −2 trunk/batteries/src/core/extlib/extInt.mli
  40. +8 −1 trunk/batteries/src/core/extlib/extInt32.mli
  41. +23 −0 trunk/batteries/src/core/extlib/extInt64.mli
  42. +23 −2 trunk/batteries/src/core/extlib/extList.mli
  43. +19 −15 trunk/batteries/src/core/extlib/extNativeint.mli
  44. +9 −4 trunk/batteries/src/core/extlib/extNum.mli
  45. +7 −1 trunk/batteries/src/core/extlib/extRandom.mli
  46. +12 −1 trunk/batteries/src/core/extlib/extStream.mli
  47. +6 −1 trunk/batteries/src/core/extlib/extString.mli
  48. +3 −0  trunk/batteries/src/core/extlib/extUChar.mli
  49. +4 −4 trunk/batteries/src/core/extlib/extUTF8.mli
  50. +2 −0  trunk/batteries/src/core/extlib/extUnit.mli
  51. +6 −0 trunk/batteries/src/core/extlib/file.mli
  52. +7 −3 trunk/batteries/src/core/extlib/global.mli
  53. +2 −0  trunk/batteries/src/core/extlib/labels.mli
  54. +17 −11 trunk/batteries/src/core/extlib/lazyList.mli
  55. +22 −15 trunk/batteries/src/core/extlib/lazyListLabels.mli
  56. +2 −0  trunk/batteries/src/core/extlib/monad.mli
  57. +3 −0  trunk/batteries/src/core/extlib/number.mli
  58. +4 −1 trunk/batteries/src/core/extlib/optParse.mli
  59. +7 −4 trunk/batteries/src/core/extlib/option.mli
  60. +2 −0  trunk/batteries/src/core/toolchain/batlib_Findlib_Findlib.mli
  61. +3 −0  trunk/batteries/src/core/toolchain/batlib_Sexp_Conv.mli
  62. +12 −19 trunk/batteries/src/syntax/pa_batteries/pa_batteries.ml
  63. +1 −0  trunk/batteries/src/syntax/pa_mainfun/_tags
  64. +11 −24 trunk/batteries/src/syntax/{pa_batteries.ml → pa_mainfun/pa_mainfun.ml}
  65. +0 −7 trunk/batteries/test/syntax/_tags
  66. +0 −1  trunk/batteries/test/syntax/test_openin.ml
  67. +5 −3 trunk/tests/myocamlbuild.ml
  68. +3 −1 trunk/tests/test_random.ml
  69. +2 −3 trunk/tests/test_where.ml
13 trunk/batteries/ChangeLog
View
@@ -1,4 +1,15 @@
-10/08/2008 David Teller <David.Teller@univ-orleans.fr>:
+10/10/2008 David Teller <David.Teller@univ-orleans.fr>:
+ * about.html: created
+ * extFloat.ml*: [exp], [log], [log10], [cos], [sin], [tan], [acos], [asin], [atan], [atan2], [cosh], [sinh], [tanh], [ceil], [floor], [infinity], [neg_infinity], [nan], [epsilon], [pi], [frexp], [ldexp], [modf], [fpclass], [classify] added
+ * batteries_core.ml: now use [ExtStream.Stream] instead of [Batlib_baselib_Stream]
+ * extArray.ml?: [print] added
+ * IO.ml: [identity] created
+ * pa_mainfun.ml: created
+ * META: [pa_mainfun] added
+ * Makefile: [install], [syntax] now handle [pa_mainfun]
+ * extList.mli: [t_of_sexp], [sexp_of_t] added to [ExtList.List]
+
+10/09/2008 David Teller <David.Teller@univ-orleans.fr>:
* batlib_Baselib_Buffer.mli:
* batlib_Baselib_Digest.mli:
* batlib_Baselib_Lazy.mli:
15 trunk/batteries/Makefile
View
@@ -35,7 +35,7 @@ _build/build/odoc_generator_batlib.cmo: build/odoc_generator_batlib.ml
byte:
- ocamlbuild src/main/threads/batteries.cma &&\
+ ocamlbuild -classic-display src/main/threads/batteries.cma &&\
ocamlbuild src/main/nothreads/batteries.cma
opt:
@@ -43,10 +43,11 @@ opt:
ocamlbuild src/main/nothreads/batteries.cmxa
syntax:
- ocamlbuild src/syntax/pa_openin/pa_openin.cmo &&\
- ocamlbuild src/syntax/pa_openin/pa_openin_r.cmo &&\
- ocamlbuild src/syntax/pa_where/pa_where.cmo &&\
- ocamlbuild src/syntax/pa_batteries/pa_batteries.cmo
+ ocamlbuild src/syntax/pa_openin/pa_openin.cmo &&\
+ ocamlbuild src/syntax/pa_openin/pa_openin_r.cmo &&\
+ ocamlbuild src/syntax/pa_where/pa_where.cmo &&\
+ ocamlbuild src/syntax/pa_batteries/pa_batteries.cmo &&\
+ ocamlbuild src/syntax/pa_mainfun/pa_mainfun.cmo
batteries.mllib:
# echo $(foreach i, $(basename $(notdir $(shell find src/ -name "*.ml" -o -name "*.mlpack"))), $(shell ocaml build/tools.ml --capit $i)) > batteries.mllib &&\
@@ -69,7 +70,7 @@ batteries.mllib:
# cp batteries.mllib src/main/nothreads
install: syntax
- ocamlfind install batteries build/META _build/src/syntax/pa_openin/pa_openin.cmo _build/src/syntax/pa_openin/pa_openin_r.cmo _build/src/syntax/pa_where/pa_where.cmo _build/src/syntax/pa_batteries/pa_batteries.cmo &&\
+ ocamlfind install batteries build/META _build/src/syntax/pa_openin/pa_openin.cmo _build/src/syntax/pa_openin/pa_openin_r.cmo _build/src/syntax/pa_where/pa_where.cmo _build/src/syntax/pa_batteries/pa_batteries.cmo _build/src/syntax/pa_mainfun/pa_mainfun.cmo &&\
ocamlfind install batteries_threads build/threaded/META _build/src/main/threads/batteries.cmi -optional _build/src/main/threads/batteries.cma _build/src/main/threads/batteries.cmxa _build/src/main/threads/batteries.a &&\
ocamlfind install batteries_nothreads build/nothreads/META _build/src/main/nothreads/batteries.cmi -optional _build/src/main/nothreads/batteries.cma _build/src/main/nothreads/batteries.cmxa _build/src/main/nothreads/batteries.a
@@ -89,7 +90,7 @@ doc/api.odocl:
examples:
@echo Note: to build the examples, you must first have installed Batteries &&\
- echo If you haven't installed Batteries yet, please use make byte install &&\
+ echo If you haven\'t installed Batteries yet, please use make byte opt install &&\
cd examples &&\
ocamlbuild examples.otarget
30 trunk/batteries/README
View
@@ -1,20 +1,38 @@
+*** Welcome to Batteries Included ***
+
+Batteries Included: standard OCaml development platform.
+
+Batteries Included serves the following purposes:
+* define a standard set of libraries which may be
+ expected on every compliant installation of OCaml
+* organize these libraries into a hierarchy of modules,
+ with one source of documentation
+* define a standard set of language extensions which
+ may be expected on every compliant installation of OCaml
+* provide a consistent API for otherwise independent
+ libraries.
+
*** Building Batteries Included ***
You will need
* OCaml >= 3.10.2
* Findlib
+* Type-conv
+* Camomile >= 0.7
+* Sexplib
* GNU Make
-Run make byte opt doc install
-to install the full version of batteries included.
-Be patient, documentation generation takes several
-minutes.
+To install the full version of OCaml Batteries Included, execute
+
+ make byte opt doc install
+
+Be patient, documentation generation takes several minutes.
*** Using Batteries Included ***
-See doc/USAGE
+See doc/batteries/html/index.html
*** Extending Batteries Included ***
-See doc/GUIDELINES
+See doc/batteries/GUIDELINES
4 trunk/batteries/build/GODI/batteries.spec → trunk/batteries/batteries.godiva
View
@@ -1,6 +1,6 @@
Package: godi-batteries
-Version: 0.1
-Revision: 9
+Version: 0.20081010
+Revision: 1
Depends: godi-ocaml (>= 3.10.2), godi-findlib (>= 1.2), type-conv, camomile (>= 0.7), sexplib (>= 3.7.0)
Build-Depends: godi-findlib (>= 1.2), type-conv, sexplib (>= 3.7.0)
Sources: http://www.univ-orleans.fr/lifo/Members/David.Teller/software/batteries/batteries-0.1.tgz
14 trunk/batteries/build/META
View
@@ -52,6 +52,17 @@ package "pa_batteries" (
)
)
+package "pa_mainfun" (
+ description = "simplify syntax of main program (container)"
+ version = "20081008"
+ package "syntax" (
+ description = "simplify syntax of main program (syntax extension)"
+ version = "20081010"
+ archive(syntax, preprocessor) = "pa_mainfun.cmo"
+ archive(syntax, toploop) = "pa_mainfun.cmo"
+ )
+)
+
#
# Doesn't work, for some reason -- calling "sexplib.syntax" directly works, though.
#
@@ -79,10 +90,11 @@ package "bin_prot" (
#
# Doesn't work, for some reason.
+# The feature is actually implemented in myocamlbuild.ml
#
package "syntax" (
version = "20081007"
description = "Standard syntax extensions to the OCaml language, full package (requires Camlp4 >= 3.10)"
- requires = "batteries.pa_openin.syntax,batteries.pa_where.syntax,batteries.pa_batteries.syntax"
+ requires = "batteries.pa_openin.syntax,batteries.pa_where.syntax,batteries.pa_batteries.syntax,batteries.pa_mainfun.syntax"
requires(boilerplate) = "type-conv.syntax,bin_prot.syntax"
)
2  trunk/batteries/build/README
View
@@ -0,0 +1,2 @@
+This directory contains tools used during the compilation
+of Batteries Included.
7 trunk/batteries/build/import.ml
View
@@ -1,7 +1,6 @@
(*
- Import a set of files from library lib
+ Placeholder for a future tool.
- import file lib
-
- * write
+ This tool will import a set of interfaces from a library for quick
+ initialization of layer code.
*)
43 trunk/batteries/build/minimal.ml
View
@@ -1,43 +0,0 @@
-(*
- * Odoc_generator_batlib - custom documentation generator for Batteries
- * Copyright (C) 2008 Maxence Guesdon
- * Copyright (C) 2008 David Teller, LIFO, Universite d'Orleans
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version,
- * with the special exception on linking described in file LICENSE.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *)
-open Odoc_info;;
-open Module;;
-open List;;
-open Odoc_info
-module Naming = Odoc_html.Naming
-open Odoc_info.Value
-open Odoc_info.Module
-
-
-class bug_generator =
- object(self)
- inherit Odoc_html.html as super
-
- method generate modules =
- warning "GENERATION STARTED";
- super#generate modules
- end;;
-
-let doc_generator = ((new bug_generator) :> Args.doc_generator);;
-let _ = Args.set_doc_generator (Some doc_generator) in
- Odoc_args.add_option ("-force-generator", Arg.Unit (fun _ ->
- Args.set_doc_generator (Some doc_generator)),
- "Force the use of a generator (bug in OCamlDoc?)")
83 trunk/batteries/build/odoc_extract_mli.ml
View
@@ -0,0 +1,83 @@
+(*
+ * Odoc_generator_batlib - custom documentation generator for Batteries
+ * Copyright (C) 2008 David Teller, LIFO, Universite d'Orleans
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version,
+ * with the special exception on linking described in file LICENSE.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *)
+
+(* Incomplete *)
+
+
+(*From OCamlDoc*)
+open Odoc_info;;
+module Naming = Odoc_html.Naming
+module Name = Odoc_name
+open Odoc_info.Value
+open Odoc_info.Module
+open Odoc_info.Type
+open Odoc_info.Class
+open Odoc_info.Exception
+
+(*From the base library*)
+open List
+
+let o out = Printf.fprintf out "%s\n"
+let p out f = Printf.fprintf out f
+
+class mli_generator = object(self)
+
+ method generate modules =
+ List.iter self#generate_for_toplevel_module modules
+
+ method handle_toplevel_module modu =
+ if m.m_is_interface then () (*We're only generating stuff for modules which are not read from interfaces.*)
+ else (*For the moment, always print to stdout*)
+ begin
+ o out (info_string_of_info m.m_info);
+ handle_module m
+ end
+
+ method handle_module out m =
+ o out (info_string_of_info m.m_info);
+
+ method handle_module_kind out = function
+ | Module_struct l -> List.iter (self#handle_module_element out) l
+ | Module_alias a ->
+ (*method handle_module out modu =
+
+ o out (info_string_of_info m.m_info);
+ self#handle_module_type out m.m_type*)
+
+ method handle_module_type_kind out = function
+ Module_type_struct tl) -> List.iter2 (self#handle_module_element2 out) kl tl
+ | (Module_alias ka, Module_type_alias ta) ->
+ begin
+ p out "module %s : %a\n" a.ma_name;
+ match a.mta_module with
+ | None -> o out "??"
+ | Some mt -> self#handle_module_type out mt
+ end
+ | (_, k) -> self#handle_module_type_kind out k
+
+ method handle_module_type_kind out = function
+ | Module_type_struct l -> List.iter (self#handle_module_element out) k
+ | Module_type_functor pt tt ->
+ p out "functor(%a) -> %a" (self#handle_module_parameter out) pt (self#handle_module_type_kind out) tt
+end
+
+let _ =
+ Odoc_args.verbose := false;
+ Args.set_doc_generator (Some (new mli_generator :> Args.doc_generator))
23 trunk/batteries/build/odoc_generator_batlib.ml
View
@@ -607,14 +607,17 @@ class batlib_generator =
self#html_of_module_kind b father ~modu: m m.m_kind;
bs b "</pre>";
if info then
- (
- if complete then
- self#html_of_info ~indent: false
- else
- self#html_of_info_first_sentence
- ) b m.m_info
+ begin
+ verbose ("Printing information of module "^m.m_name^":\n"^(string_of_info_opt m.m_info));
+ if complete then
+ self#html_of_info ~indent: false
+ else
+ self#html_of_info_first_sentence
+ end b m.m_info
else
- ()
+ begin
+ warning ("Module "^m.m_name^" has no associated information")
+ end
with _ -> assert false
@@ -855,10 +858,12 @@ class batlib_generator =
bs b "</ul></div><hr />"
- method html_of_custom_tag_documents text = ""
+(* method html_of_custom_tag_author text =
+ verbose ("Generating author name "^text);
+ "<div><span style ='author'>author</span>"^text^"</span></div>"*)
initializer
- tag_functions <- ("documents", self#html_of_custom_tag_documents) :: tag_functions;
+(* tag_functions <- ("author", self#html_of_custom_tag_author) :: tag_functions;*)
default_style_options <- default_style_options@
["li.index_of {display:inline}";
"ul.indices {display:inline;font-variant:small-caps;list-style-position: inside;list-style-type:none;padding:0px}";
2  trunk/batteries/build/packdoc.ml
View
@@ -1,3 +1,5 @@
+(* Obsolete. Now integrated into myocamlbuild.ml*)
+
(** Imported from {!List} to avoid weird dependencies during compilation*)
module List =
struct
4 trunk/batteries/build/tools.ml
View
@@ -1,3 +1,7 @@
+(* Command-line utilities.
+
+ Probably obsolete now that we have moved towards a ocamlbuild build system.*)
+
let _ = Arg.parse [("--capit", Arg.String (fun x -> print_endline (String.capitalize x)), "Capitalize letter");
("--uncapit", Arg.String (fun x -> print_endline (String.uncapitalize x)), "Uncapitalize letter")]
ignore "Miscellaneous compile-time tools"
371 trunk/batteries/doc/batteries/html/about.html
View
@@ -0,0 +1,371 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta name="generator" content=
+"HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
+<link rel="stylesheet" href="style.css" type="text/css" />
+<style type="text/css">
+/*<![CDATA[*/
+ body {
+ padding: 3cm;
+ text-align:justify;
+ }
+/*]]>*/
+</style>
+<meta content="text/html; charset=us-ascii" http-equiv=
+"Content-Type" />
+<link rel="Start" href="root.html" />
+<link title="Index of modules" rel="Appendix" href=
+"root_modules.html" />
+<link title="Batteries" rel="Chapter" href="Batteries.html" />
+<title>OCaml Batteries Included</title>
+</head>
+<body>
+<h1>What is OCaml Batteries Included?</h1>
+
+<p>
+Twenty years ago, a language was just a compiler. You could measure
+the quality of a language from the beauty of its semantics, the
+clarity of its syntax, the speed of generated code. That was then. In
+the meantime, the Java and .Net nuclear plants have been built, while
+the Python and Ruby communities have gradually developed their own
+powerhouses. All these platforms have amply demonstrated that a
+language can only be as beautiful, clear and fast as the libraries
+which developers are actually going to use for their work. In
+other words, it's not about the language anymore, it's about
+the platform.
+</p>
+
+<p>
+At this point in time, out-of-the-box, OCaml isn't a usable platform.
+There is no Unicode, there are no modern user interface toolkits, no
+distributed programming infrastructures, no network services, no
+type-safe communications, no analysis of other languages, no
+interfacing with industrial platforms, no XML, non modern two- or
+three-dimensional drawing engine, etc. This would not be too much of a
+problem if OCaml provided an easy way of installing new libraries and
+of using these libraries once they are installed. This would also not
+be too much of a problem if OCaml could somehow guarantee that trivial
+data structures didn't need to be reinvented by most projects and that
+communication between libraries happened flawlessly.
+</p>
+
+<p>
+So no, out of the box, OCaml isn't a usable platform. However, no
+matter what you're trying to do, chances are that the community has
+already developed or adapted a tool to make your life easier. Easy
+installation of OCaml packages is quite possible, if you are using
+Debian or Ubuntu (apt-get), Fedora or Red Hat (yum) or actually, any
+Unix-compatible platform, including MacOS X and Windows (GODI). Simple and
+reliable usage of installed libraries can be done with Findlib. A
+comprehensive Unicode library is available (Camomile), as well as a
+modern user interface toolkit or two (LablGtk, OCamlRT), a number of
+distributed programming infrastructures (OCamlMPI, BSML, Opis,
+Camlp3l, OCamlNAE), libraries to interface with industrial platforms
+(OCamlJava, SpiderCaml, ...), to analyse other
+languages (CIL, Dalton/FlowCaml, ...), to read or write
+XML (PXP, Expat, ...), to draw in two or three dimensions (Cairo,
+OpenGL), to test your programs (OUnit), etc. OCaml even offers a
+built-in tool to customize the language itself (Camlp4).
+</p>
+
+<p>
+What's missing? A few things. For now, not all important libraries are
+available as simple-to-install packages. That problem is being
+addressed by the devoted packagers of Debian, Fedora and GODI, while
+the possibility exists that the recently announced Symbiosis will also
+help address the issue. The other missing part is a standard set of
+libraries, language extensions and data structures which developers
+could be assured to find on every OCaml installation, and which would
+let them write programs without having to endlessly reinvent the same
+basic wheels, and without spending their time writing adapters between
+libraries which should work well together but don't use the same
+conventions. OCaml Batteries is one possible answer to this problem
+</p>
+
+<p>
+OCaml Batteries Included consists in
+<ul>
+ <li>A core set of libraries, designed to define the basic standard
+ data structures. This set, largely based on both the Base library
+ of OCaml and ExtLib, extends the basic strings, arrays,
+ lists... provided with OCaml and introduces numerous data
+ structures, including enumerations, lazy lists, extendable inputs
+ and outputs, dynamic arrays, unicode ropes...</li>
+ <li>A uniformization layer, the glue, on top of chosen existing
+ libraries. Note that we are not forking any of these libraries,
+ only providing an additional layer on top of them. The libraries
+ may be installed manually by the user or, preferably, by automatic
+ dependency resolution thanks to apt-get, yum, GODI or some other
+ packaging tool. The uniformization layer serves to guarantee that
+ libraries play together nicely, that only one manner of reading
+ from a file or writing to the output is necessary, that every data
+ provided by a library may be decoded by another, etc.
+ </li>
+ <li>Additional documentation for whichever library for which we
+ provide glue, including both low-level documentation ("what the
+ heck does this function do?"), mid-level documentation ("why
+ should I use that function?") and high-level documentation ("ok,
+ I'm new here, where do I start?")</li>
+ <li>A handful of language extensions, provided as Camlp4 modules,
+ to solve common issues, automatically generate boilerplate code,
+ improve readability, ...</li>
+ <li>In the future, possibly a set of external tools.</li>
+ <li>Build tools to make all of this transparent.</li>
+ <li>And, of course, a logo.</li>
+</ul>
+
+
+<div style="text-align:center">
+<div>
+<img src="../../batteries_large.png" />
+</div>
+<span style="font-size:small">(Batteries courtesy of Benjamin Pavie, Camel courtesy of John Olsen, no animals injured)</a>
+</div>
+
+<p>
+OCaml Batteries Included depends on other packages. We are doing our
+best to avoid forking any project.
+
+
+<p> It is also a project maintained by
+the community, which means that it depends on you. If you have ideas,
+suggestions, complaints, bug reports, if you want to participate, to
+write code, documentation, tutorials, build tools, review code, have a
+word in policies, if you want a package to be included in the
+Batteries, or just to contact us, please
+use <a href="http://forge.ocamlcore.org/batteries">our website</a>.
+We provide bug trackers, request for features trackers, forums,
+etc. (courtesy of OCaml Core). We can also often be
+seen <a href="irc://irc.freenode.net/#ocaml">on irc, on server
+freenode, channel #ocaml</a>.
+</p>
+
+
+<p>
+OCaml Batteries Included is also a work-in-progress. The version you
+have in front of your eyes does not contain everything we want to put
+in it, nor even all the code we have written for it. But we'll get
+there. We intend to integrate additional libraries progressively, from
+minor release to minor release, with major milestones approximately
+twice per year. This policy is not written in stone and is largely
+subject to debate, so don't hesitate to comment on the subject.
+</p>
+
+<p>
+For more informations on the contents of OCaml Batteries Included,
+follow us towards <a href="api/index.html">the manual</a>.
+</p>
+
+<h1>Relations to other libraries</h1>
+<h2>Project Gallium's Base Library</h2>
+
+<p>
+First, a word on vocabulary. We call "Base
+library" <a href="http://caml.inria.fr">the library provided by INRIA
+with the default distribution of OCaml</a>. We don't call it "standard
+library" for the simple reason that there are several libraries vying
+for the status of standard, including Batteries Included.
+</p>
+<p>
+The relation between Batteries Included and the Base Library is
+simple: the Base Library is one of the libraries for which Batteries
+Included provides a uniformization layer. We are not forking the
+library, merely providing additional functions, additional
+documentation, boilerplate code...
+</p>
+<p>
+The complete Base Library is available in Batteries Included as
+module <code>Legacy</code>. Most modules are also available inside the
+Batteries module hierarchy, sometimes under different names, and
+usually completed by numerous new functions. A few modules are
+considered obsolete and appear only in <code>Legacy</code>.
+</p>
+
+<h2>Jane Street's Core</h2>
+<p>
+<a href="http://ocaml.janestcapital.com/">Jane Street's Core</a> is
+another library vying for the status of standard, this time produced
+by Jane Street Capital. This library is comparable in purpose and
+design to the core of Batteries Included (actually, we draw some
+inspiration from them and we hope that they are going to draw some
+inspiration from us, too) but there is no code shared between
+Batteries Included and Jane Street's Core for the moment.
+</p>
+<p>
+In the future, Batteries Included may depend on Jane Street's Core.
+This is not the case yet as, according to one of Jane Street's Core's
+authors, this library may change quite a lot, and in what we interpret
+as possibly incompatible ways, before reaching version 1.0.
+</p>
+<p>
+We already depend on two components of Jane Street's Core: Type-Conv
+(a general infrastructure which may be used to generate Boilerplate
+code) and Sexplib (an instance of Type-Conv used to generate
+code for serializating to/deserializing from human-readable S-Expressions).
+We intend to extend this to a third component of Jane Street's Core:
+Bin-Prot, another instance of Type-Conv, used this time to generate
+serialization to/from binary protocols.
+</p>
+
+<h2>ExtLib</h2>
+<p>
+<a href="http://code.google.com/p/ocaml-extlib/">ExtLib</a> is another
+extension of the OCaml Base Library. ExtLib was designed as a
+relatively small addition, with the idea of fitting nicely within the
+OCaml Base Library. Since 2005, ExtLib has essentially stopped growing,
+following a conscious choice from the maintainers.
+</p>
+<p>
+OCaml Batteries Included is largely based on ExtLib. Indeed, the core
+of Batteries is essentially a fork of ExtLib. We intend to maintain
+ascending compatibility with ExtLib (with the exception of changes in
+module names), although we have added a great number of features,
+fixed bugs, split code, etc. For most purposes, OCaml Batteries
+Included contains ExtLib and, in our mind, superseeds this library. We
+hope that the maintainers and developers of ExtLib will consider
+migrating to OCaml Batteries Included.
+</p>
+
+<h2>Community OCaml</h2>
+<p>
+<a href="http://github.com/thelema/ocaml-community/tree/master">Community
+OCaml</a> is an attempt to turn OCaml into an out-of-the-box complete
+development platform, including numerous libraries.
+</p>
+<p>
+We have joined forces with the developers of Community OCaml and
+we share most of our code. Although the design of Community OCaml is
+not completely decided yet, it is quite possible that this will be a
+distribution consisting in OCaml + Batteries Included + some package
+manager.
+</p>
+
+<h2>OCamlNet</h2>
+<p>
+<a href="http://projects.camlcity.org/projects/ocamlnet.html">OCamlNet</a>
+is an implementation of numerous Internet protocols for OCaml, along
+with so many utilities that it almost consists in a complete
+general-purpose development library for OCaml.
+</p>
+<p>
+OCaml Batteries Included will depend on OCamlNet and incorporate
+OCamlNet into its hierarchy. In particular, for the moment, OCaml
+Batteries Included provides little in the way of libraries for
+interacting with the operating system, as we intend to use OCamlNet
+for that purpose.
+</p>
+
+<h2>Caml Development Kit</h2>
+<p>
+The <a href="http://pauillac.inria.fr/cdk/">Caml Development Kit</a>,
+or CDK, was another attempt to build a development platform around
+OCaml by bundling together OCaml itself and a number of interesting
+libraries and tools. By opposition to Batteries Included, this was a
+monolithic distribution, with a custom compiler and very little documentation.
+Development on CDK seems to have died around 2001.
+</p>
+<p>
+There is no relation between CDK and Batteries Included other than the
+common goal. Any feedback from former CDK users or developers is
+welcome, though.
+</p>
+
+<h2>GODI, Apt, Yum</h2>
+<p>
+<a href="http://godi.camlcity.org/godi/index.html">GODI</a>,
+<a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool">Apt</a>
+and <a href="http://docs.fedoraproject.org/yum/en/">Yum</a> are the three main
+package managers available for OCaml users. The first one is
+OCaml-specific, the second one lives in Debian/Ubuntu/Knoppix world
+and the third one in the Red Hat/Fedora world.
+</p>
+<p>
+OCaml Batteries Included has no direct relation with either package
+manager, nor does it replicate the work of any of these
+managers. However, as Batteries relies on numerous external libraries,
+use of a package manager is strongly recommended.
+</p>
+
+
+<h2>Findlib</h2>
+<p>
+<a href="http://www.camlcity.org/archive/programming/findlib.html">Findlib</a>
+is a compile-time package manager for OCaml. It lets developers easily specify
+which libraries are required and manages compile-time dependencies between
+installed libraries.
+</p>
+<p>
+OCaml Batteries Included uses Findlib extensively.
+</p>
+
+<h1>Comparable projects, somewhere else</h1>
+<h2>Python Batteries Included</h2>
+<p>
+To the best of our knowledge, the term "Batteries Included" was first
+coined by the Python community to describe the standard distribution
+of Python, which in addition to usual data structures, contains
+modules for handling databases, compression, a number of file format
+(de)coders including JSON, (X)HTML, XML, CSV, cryptography, logging,
+text interfaces, threading, inter-process communication,
+implementation of client and server protocols from SMTP to HTTP,
+communication with external webbrowsers, image and sound manipulation,
+internationalization, lexing and parsing, graphical interfaces, unit
+testing, sandboxing, reflexivity, OS-specific services, ... This
+massive number of out-of-the-box features, along with the conciseness
+of the language, are probably the two main reasons of the success of
+Python: simple tasks, even those which require complex libraries, may
+often be programmed with only a few lines and in a few minutes.
+</p>
+<p>
+Well, obviously, we're trying to provide something as useful with
+OCaml Batteries Included, but with the added safety and speed of OCaml.
+</p>
+
+<h2>Haskell Batteries Included</h2>
+<p>
+The <a href="http://www.haskell.org/haskellwiki/Haskell_Platform">Haskell
+Platform</a> (although known as "Haskell Batteries Included") is a
+recent project undertaken by the Haskell community with objectives
+comparable to OCaml Batteries Included: "provides a comprehensive,
+stable and quality tested base for Haskell projects to work from." At
+the time of this writing, the Haskell Platform has not released any
+software, although a first release is expected within a few weeks.
+</p>
+<p>
+As OCaml Batteries, the Haskell Platform is community-led and relies
+on a number of decentralized libraries. As OCaml Batteries, the
+Haskell Platform requires package management. There are a number of
+differences in the methods, though.
+</p>
+<p>
+Some differences are probably trivial: where we strive to work with
+any of the major package management systems, the Haskell Platform is
+based solely on Cabal, which may allow them a better integration.
+Where OCaml Batteries attempts to reclassify existing libraries into
+one uniform hierarchy of modules, the Haskell Platform keeps the
+original module names, as decided by their original authors,
+pre-Platform.
+</p>
+<p>
+Others are quite far-reaching: OCaml Batteries provides an extended
+core of libraries to serve as support for standardization and
+uniformization, while the Haskell Platform doesn't. Similarly, the
+Haskell Platform doesn't add any uniformization layer, which means
+that the task of getting libraries to work together lies upon the
+end-user. Some Haskell libraries may be patched into compliance and
+uniformization, but this is not always possible, short of creating
+cyclic dependencies between libraries which should work together but
+don't. Finally, the Haskell Platform has much stricter guidelines
+regarding libraries which can or can't make it into the Platform.
+This is a good thing if library authors are willing to fix whichever
+problems prevent the inclusion of their work -- something which we
+don't assume for OCaml Batteries, at least not yet.
+</p>
+<p>
+Despite these differences, both projects seem based on solid
+foundations. And hopefully, both will achieve large success.
+</p>
+</body>
+</html>
19 trunk/batteries/doc/batteries/html/extensions.html
View
@@ -106,7 +106,24 @@
<dt>Precedence</dt><dd> <code>let a = b where c and d</code> is equivalent to <code>let a = (b where c and d)</code></dd>
</dl>
-<center><h2>Boiler-plate construction</h2></center>
+<center><h2>Toplevel evaluations</h2></center>
+<center>(activated by default, implemented as findlib package <code>batteries.pa_mainfun.syntax</code>)</center>
+<center>(designed for Batteries)</center>
+<p>
+As a convenience, you may evaluate top-level expressions without having to bind them. Consider a module
+consisting only in the following line:
+<pre>
+print_endline "done"
+</pre>
+
+This extract is equivalent to
+<pre>
+let _ = print_endline "done"
+</pre>
+
+This lightweight syntax for toplevel is meant to render toplevel evaluations more concise and readable.
+</p>
+<center><h2>Boilerplate construction</h2></center>
<center>(<i>de</i>activated by default, implemented as findlib package <code>sexplib.syntax</code>)</center>
<center><h3>Serialization to S-Expressions</h3></center>
41 trunk/batteries/doc/batteries/html/style.css
View
@@ -0,0 +1,41 @@
+a:visited {color : #416DFF; text-decoration : none; }
+a:link {color : #416DFF; text-decoration : none;}
+a:hover {color : Red; text-decoration : none; background-color: #5FFF88}
+a:active {color : Red; text-decoration : underline; }
+.keyword { font-weight : bold ; color : Red }
+.keywordsign { color : #C04600 }
+.superscript { font-size : 4 }
+.subscript { font-size : 4 }
+.comment { color : Green }
+.constructor { color : Blue }
+.type { color : #5C6585 }
+.string { color : Maroon }
+.warning { color : Red ; font-weight : bold }
+.info { margin-left : 3em; margin-right : 3em }
+.param_info { margin-top: 4px; margin-left : 3em; margin-right : 3em }
+.code { color : #465F91 ; }
+h1 { font-size : 20pt ; text-align: center; margin-top : 3em; margin-bottom: 2em }
+h2 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90BDFF ;padding: 2px; }
+h3 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90DDFF ;padding: 2px; }
+h4 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90EDFF ;padding: 2px; }
+h5 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90FDFF ;padding: 2px; }
+h6 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #C0FFFF ; padding: 2px; }
+div.h7 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #E0FFFF ; padding: 2px; }
+div.h8 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #F0FFFF ; padding: 2px; }
+div.h9 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #FFFFFF ; padding: 2px; }
+.typetable { border-style : hidden }
+.indextable { border-style : hidden }
+.paramstable { border-style : hidden ; padding: 5pt 5pt}
+body { background-color : White }
+tr { background-color : White }
+td.typefieldcomment { background-color : #FFFFFF ; font-size: smaller ;}
+pre { margin-bottom: 4px }
+div.sig_block {margin-left: 2em}
+li.index_of {display:inline}
+ul.indices {display:inline;font-variant:small-caps;list-style-position: inside;list-style-type:none;padding:0px}
+div.indices {text-align:center}
+.index_entry{font-size:x-small}
+ul.index_entry {list-style-type:none;padding:0px; margin-left:none; text-ident:-1em}
+li.index_entry_entry div.info {margin-left:1em}
+pre {background-color:rgb(250,250,250);margin-top:2em}
+pre.example {margin-top:2px; margin-bottom:2em}
8 trunk/batteries/doc/batteries/myocamlbuild.ml
View
@@ -101,14 +101,16 @@ struct
(*The command-line for [use_batteries] and [use_batteries_r]*)
- let cl_use_boilerplate = [A"-package"; A"batteries,sexplib.syntax"]
- and cl_use_batteries = [A"-package"; A "batteries.pa_openin.syntax,batteries.pa_type_conv.syntax,batteries.pa_where.syntax,batteries.bin_prot.syntax,batteries.pa_batteries.syntax"; A "-package"; A "batteries"]
+ let cl_use_boilerplate = [A"-package"; A "batteries.pa_type_conv.syntax,batteries,sexplib.syntax"]
+ and cl_use_batteries = [A"-package"; A "batteries.pa_openin.syntax,batteries.pa_where.syntax,batteries.pa_batteries.syntax"; A "-package"; A "batteries"]
+ and cl_use_batteries_o = [A"-package"; A"batteries.pa_mainfun.syntax" ]
+ (*[cl_use_batteries_o]: extensions which only make sense in original syntax*)
and cl_camlp4o = [A"-syntax"; A "camlp4o"]
and cl_camlp4r = [A"-syntax"; A "camlp4r"] in
let cl_boilerplate_original = cl_use_boilerplate @ cl_camlp4o
and cl_boilerplate_revised = cl_use_boilerplate @ cl_camlp4r
- and cl_batteries_original = cl_use_batteries @ cl_camlp4o
+ and cl_batteries_original = cl_use_batteries @ cl_use_batteries_o @ cl_camlp4o
and cl_batteries_revised = cl_use_batteries @ cl_camlp4r in
(** Tag [use_boilerplate] provides boilerplate syntax extensions,
5 trunk/batteries/examples/README
View
@@ -0,0 +1,5 @@
+A few examples of short programs written using OCaml Batteries Included.
+
+To build all these programs, run
+ make examples
+from the top-level directory.
2  trunk/batteries/examples/examples.itarget
View
@@ -2,3 +2,5 @@ cat.byte
cat.native
cat2.byte
cat2.native
+shuffle.byte
+shuffle.native
5 trunk/batteries/src/README
View
@@ -0,0 +1,5 @@
+Overview of the source code.
+
+* core/ contains the core of Batteries Included
+* main/threaded
+* main/nothreads
2  trunk/batteries/src/core/batteries_core.ml
View
@@ -49,7 +49,7 @@ module Data = struct
module Queue = Batlib_Baselib_Queue (*TODO:build from enum?*)
module RefList = Extlib.RefList
module Stack = Batlib_Baselib_Stack (*TODO:build from enum*)
- module Stream = Batlib_Baselib_Stream (*TODO:replace with latest version*)
+ module Stream = Extlib.ExtStream.Stream
end
(** Persistent containers (lists, sets...) *)
3  trunk/batteries/src/core/extlib/IO.ml
View
@@ -1499,6 +1499,7 @@ let mkprintf k out fmt =
in let kpr = pr k (Sformat.index_of_int 0) in
kapr kpr fmt;;
+external identity : 'a -> 'a = "%identity"(*Inlined from [Std] to avoid cyclic dependencies*)
let fprintf out fmt = mkprintf ignore out fmt
let printf fmt = fprintf stdout fmt
let eprintf fmt = fprintf stderr fmt
@@ -1509,7 +1510,7 @@ let ksprintf2 k fmt =
let kbprintf2 k buf fmt =
let out = output_buffer buf in
mkprintf (fun out -> k buf) out fmt
-let sprintf2 fmt = ksprintf2 (Std.identity) fmt
+let sprintf2 fmt = ksprintf2 (identity) fmt
let bprintf2 buf fmt = kbprintf2 ignore buf fmt
(**
Other possible implementation of [sprintf2],
2  trunk/batteries/src/core/extlib/base64.mli
View
@@ -25,6 +25,8 @@
(in that order).
@documents Base64
+
+ @author Nicolas Cannasse
*)
(** This exception is raised when reading an invalid character
6 trunk/batteries/src/core/extlib/bitSet.mli
View
@@ -23,7 +23,11 @@
A bitset is an array of boolean values that can be accessed with indexes
like an array but provides a better memory usage (divided by 8) for a
- very small speed trade-off. *)
+ very small speed trade-off.
+
+ @author Nicolas Cannasse
+ @author David Teller (Boilerplate code)
+*)
type t
27 trunk/batteries/src/core/extlib/charParser.mli
View
@@ -1,5 +1,30 @@
+(*
+ * CharParser - Parsing character strings
+ * Copyright (C) 2008 David Teller (contributor)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version,
+ * with the special exception on linking described in file LICENSE.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *)
+
+(** Parsing character strings.
+
+ @author David Teller
+*)
+
open ParserCo
-(** Parsing character strings *)
+
(** The position inside one file or one stream. *)
type position =
4 trunk/batteries/src/core/extlib/dllist.mli
View
@@ -23,6 +23,10 @@
This module implements a doubly linked list in a mutable or imperitive
style (changes to the list are visible to all copies of the list).
+
+ @author Brian Hurt
+ @author Jesse Guardiani
+ @author David Teller
*)
10 trunk/batteries/src/core/extlib/dynArray.mli
View
@@ -22,9 +22,13 @@
(** Dynamic arrays.
- A dynamic array is equivalent to a OCaml array that will resize itself
- when elements are added or removed, except that floats are boxed and
- that no initialization element is required.
+ A dynamic array is equivalent to a OCaml array that will resize itself
+ when elements are added or removed, except that floats are boxed and
+ that no initialization element is required.
+
+ @author Brian Hurt
+ @author Nicolas Cannasse
+ @author David Teller (boilerplate code)
*)
type 'a t
18 trunk/batteries/src/core/extlib/enum.mli
View
@@ -18,13 +18,17 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
-(** Enumeration over abstract collection of elements.
-
- Enumerations are entirely functional and most of the operations do not
- actually require the allocation of data structures. Using enumerations
- to manipulate data is therefore efficient and simple. All data structures in
- ExtLib such as lists, arrays, etc. have support to convert from and to
- enumerations.
+(**
+ Enumeration over abstract collection of elements.
+
+ Enumerations are entirely functional and most of the operations do not
+ actually require the allocation of data structures. Using enumerations
+ to manipulate data is therefore efficient and simple. All data structures in
+ ExtLib such as lists, arrays, etc. have support to convert from and to
+ enumerations.
+
+ @author Nicolas Cannasse
+ @author David Teller
*)
16 trunk/batteries/src/core/extlib/enumLabels.mli
View
@@ -18,13 +18,17 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
-(** Enumeration over abstract collection of elements.
- Enumerations are entirely functional and most of the operations do not
- actually require the allocation of data structures. Using enumerations
- to manipulate data is therefore efficient and simple. All data structures in
- ExtLib such as lists, arrays, etc. have support to convert from and to
- enumerations.
+(** Enumeration over abstract collection of elements.
+
+ Enumerations are entirely functional and most of the operations do not
+ actually require the allocation of data structures. Using enumerations
+ to manipulate data is therefore efficient and simple. All data structures in
+ ExtLib such as lists, arrays, etc. have support to convert from and to
+ enumerations.
+
+ @author Nicolas Cannasse
+ @author David Teller
*)
15 trunk/batteries/src/core/extlib/extArray.ml
View
@@ -221,6 +221,21 @@ let make_compare cmp a b =
else 1
in aux 0
+let print out print_a ?(first="") ?(last="") ?(sep="") t =
+ match length t with
+ | 0 ->
+ IO.nwrite out first;
+ IO.nwrite out last
+ | 1 ->
+ IO.Printf.fprintf out "%s%a%s" first print_a (unsafe_get t 0) last
+ | n ->
+ IO.nwrite out first;
+ print_a out (unsafe_get t 0);
+ for i = 1 to n - 1 do
+ IO.Printf.fprintf out "%s%a" sep print_a (unsafe_get t i)
+ done;
+ IO.nwrite out last
+
module Cap =
struct
(** Implementation note: in [('a, 'b) t], ['b] serves only as
15 trunk/batteries/src/core/extlib/extArray.mli
View
@@ -27,13 +27,18 @@
as a standalone module. It provides some additional functions.
*)
-(** Array operations.
- @documents Array
-*)
module Array :
sig
+ (** Array operations.
+
+ @documents Array
+ @author Xavier Leroy
+ @author Richard W.M. Jones
+ @author David Teller
+ *)
+
type 'a t = 'a array
(**{6 Base operations}*)
@@ -619,4 +624,8 @@ end
val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a t
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
+(** {7 Printing}*)
+
+val print : 'a IO.output -> ('a IO.output -> 'b -> unit) -> ?first:string -> ?last:string -> ?sep:string -> 'b t -> unit
+
end
19 trunk/batteries/src/core/extlib/extBig_int.mli
View
@@ -1,6 +1,6 @@
(*
- * IO - Abstract input/output
- * Copyright (C) 2003 Nicolas Cannasse
+ * ExtBig_int - Extended operations on big integers
+ * Copyright (C) 2008 Gabriel Scherer
* 2008 David Teller
*
* This library is free software; you can redistribute it and/or
@@ -23,12 +23,15 @@
module Big_int :
sig
-(** Operations on arbitrary-precision integers.
-
- Big integers (type [big_int]) are signed integers of arbitrary size.
-
- @documents Big_int
-*)
+ (** Operations on arbitrary-precision integers.
+
+ Big integers (type [big_int]) are signed integers of arbitrary size.
+
+ @documents Big_int
+ @author Valerie Menissier-Morain (base module)
+ @author Gabriel Scherer
+ @author David Teller
+ *)
open Nat
6 trunk/batteries/src/core/extlib/extBool.mli
View
@@ -21,7 +21,11 @@
module Bool :
sig
- (**Operations on booleans*)
+ (**Operations on booleans
+
+ @author Gabriel Scherer
+ @author David Teller
+ *)
type t = bool
(**The type of booleans. Formally, this is defined as [type t = true | false] *)
6 trunk/batteries/src/core/extlib/extChar.mli
View
@@ -21,7 +21,11 @@
module Char : sig
-(** Operations on characters. *)
+(** Operations on characters.
+
+ @author Xavier Leroy (base module)
+ @author David Teller
+*)
external code : char -> int = "%identity"
(** Return the ASCII code of the argument. *)
7 trunk/batteries/src/core/extlib/extComplex.mli
View
@@ -25,7 +25,12 @@ sig
This module provides arithmetic operations on complex numbers.
Complex numbers are represented by their real and imaginary parts
(cartesian representation). Each part is represented by a
- double-precision floating-point number (type [float]). *)
+ double-precision floating-point number (type [float]).
+
+ @author Xavier Leroy (base module)
+ @author Gabriel Scherer
+ @author David Teller
+ *)
type t = Complex.t = { re: float; im: float }
(** The type of complex numbers. [re] is the real part and [im] the
37 trunk/batteries/src/core/extlib/extFloat.ml
View
@@ -48,6 +48,43 @@ module BaseFloat = struct
external of_float : float -> float = "%identity"
external to_float : float -> float = "%identity"
+
+ let is_nan f = match classify_float f with
+ | FP_nan -> true
+ | _ -> false
+
+ external exp : float -> float = "caml_exp_float" "exp" "float"
+ external log : float -> float = "caml_log_float" "log" "float"
+ external log10 : float -> float = "caml_log10_float" "log10" "float"
+ external cos : float -> float = "caml_cos_float" "cos" "float"
+ external sin : float -> float = "caml_sin_float" "sin" "float"
+ external tan : float -> float = "caml_tan_float" "tan" "float"
+ external acos : float -> float = "caml_acos_float" "acos" "float"
+ external asin : float -> float = "caml_asin_float" "asin" "float"
+ external atan : float -> float = "caml_atan_float" "atan" "float"
+ external atan2 : float -> float -> float = "caml_atan2_float" "atan2" "float"
+ external cosh : float -> float = "caml_cosh_float" "cosh" "float"
+ external sinh : float -> float = "caml_sinh_float" "sinh" "float"
+ external tanh : float -> float = "caml_tanh_float" "tanh" "float"
+ external ceil : float -> float = "caml_ceil_float" "ceil" "float"
+ external floor : float -> float = "caml_floor_float" "floor" "float"
+ external frexp : float -> float * int = "caml_frexp_float"
+ external ldexp : float -> int -> float = "caml_ldexp_float"
+ external modf : float -> float * float = "caml_modf_float"
+ external classify : float -> fpclass = "caml_classify_float"
+
+ type fpclass = Pervasives.fpclass =
+ FP_normal
+ | FP_subnormal
+ | FP_zero
+ | FP_infinite
+ | FP_nan
+
+ let infinity = Pervasives.infinity
+ let neg_infinity = Pervasives.neg_infinity
+ let nan = Pervasives.nan
+ let epsilon = Pervasives.epsilon_float
+ let pi = 4. *. atan 1.
end
module Float = struct
119 trunk/batteries/src/core/extlib/extFloat.mli
View
@@ -23,9 +23,19 @@
module Float :
sig
- (**Operations on floating-point numbers*)
+ (**Operations on floating-point numbers
+
+ @author Gabriel Scherer
+ @author David Teller
+ @author Edgar Friendly
+ *)
type t = float
+
+ (**
+ {6 Usual operations}
+ *)
+
val zero : float
val one : float
val neg : float -> float
@@ -60,6 +70,113 @@ module Float :
val ( = ) : t -> t -> bool
val operations : t Number.numeric
+ (**
+ {6 Operations specific to floating-point numbers}
+ *)
+
+ external exp : float -> float = "caml_exp_float" "exp" "float"
+ (** Exponential. *)
+
+ external log : float -> float = "caml_log_float" "log" "float"
+ (** Natural logarithm. *)
+
+ external log10 : float -> float = "caml_log10_float" "log10" "float"
+ (** Base 10 logarithm. *)
+
+ external cos : float -> float = "caml_cos_float" "cos" "float"
+ (** See {!atan2}. *)
+
+ external sin : float -> float = "caml_sin_float" "sin" "float"
+ (** See {!atan2}. *)
+
+ external tan : float -> float = "caml_tan_float" "tan" "float"
+ (** See {!atan2}. *)
+
+ external acos : float -> float = "caml_acos_float" "acos" "float"
+ (** See {!atan2}. *)
+
+ external asin : float -> float = "caml_asin_float" "asin" "float"
+ (** See {!atan2}. *)
+
+ external atan : float -> float = "caml_atan_float" "atan" "float"
+ (** See {!atan2}. *)
+
+ external atan2 : float -> float -> float = "caml_atan2_float" "atan2" "float"
+ (** The usual trigonometric functions. *)
+
+ external cosh : float -> float = "caml_cosh_float" "cosh" "float"
+ (** See {!tanh}. *)
+
+ external sinh : float -> float = "caml_sinh_float" "sinh" "float"
+ (** See {!tanh}. *)
+
+ external tanh : float -> float = "caml_tanh_float" "tanh" "float"
+ (** The usual hyperbolic trigonometric functions. *)
+
+ external ceil : float -> float = "caml_ceil_float" "ceil" "float"
+ (** See {!floor}. *)
+
+ external floor : float -> float = "caml_floor_float" "floor" "float"
+ (** Round the given float to an integer value.
+ [floor f] returns the greatest integer value less than or
+ equal to [f].
+ [ceil f] returns the least integer value greater than or
+ equal to [f]. *)
+
+ val infinity : float
+ (** Positive infinity. *)
+
+ val neg_infinity : float
+ (** Negative infinity. *)
+
+ val nan : float
+ (** A special floating-point value denoting the result of an
+ undefined operation such as [0.0 /. 0.0]. Stands for
+ ``not a number''. Any floating-point operation with [nan] as
+ argument returns [nan] as result. As for floating-point comparisons,
+ [=], [<], [<=], [>] and [>=] return [false] and [<>] returns [true]
+ if one or both of their arguments is [nan]. *)
+
+ val is_nan : float -> bool
+ (** [is_nan f] returns [true] if [f] is [nan], [false] otherwise.*)
+
+ val epsilon : float
+ (** The smallest positive float [x] such that [1.0 +. x <> 1.0]. *)
+
+ val pi : float
+ (** The constant pi (3.14159...) *)
+
+ (** {6 Operations on the internal representation of floating-point numbers}*)
+
+ external frexp : float -> float * int = "caml_frexp_float"
+ (** [frexp f] returns the pair of the significant
+ and the exponent of [f]. When [f] is zero, the
+ significant [x] and the exponent [n] of [f] are equal to
+ zero. When [f] is non-zero, they are defined by
+ [f = x *. 2 ** n] and [0.5 <= x < 1.0]. *)
+
+ external ldexp : float -> int -> float = "caml_ldexp_float"
+ (** [ldexp x n] returns [x *. 2 ** n]. *)
+
+ external modf : float -> float * float = "caml_modf_float"
+ (** [modf f] returns the pair of the fractional and integral
+ part of [f]. *)
+
+ (** Classes of floating point numbers*)
+ type fpclass = Pervasives.fpclass =
+ FP_normal (** Normal number, none of the below *)
+ | FP_subnormal (** Number very close to 0.0, has reduced precision *)
+ | FP_zero (** Number is 0.0 or -0.0 *)
+ | FP_infinite (** Number is positive or negative infinity *)
+ | FP_nan (** Not a number: result of an undefined operation *)
+ (** The five classes of floating-point numbers, as determined by
+ the {!classify} function. *)
+
+ external classify : float -> fpclass = "caml_classify_float"
+ (** Return the class of the given floating-point number:
+ normal, subnormal, zero, infinite, or not a number. *)
+
+
(** {6 Boilerplate code}*)
(** {7 S-Expressions}*)
3  trunk/batteries/src/core/extlib/extGenlex.mli
View
@@ -27,6 +27,9 @@ module Genlex : sig
as a function from character streams to token streams. It implements
roughly the lexical conventions of Caml, but is parameterized by the
set of keywords of your language.
+
+ @author Jacques Garrigue
+ @author David Teller
*)
type token =
15 trunk/batteries/src/core/extlib/extHashtbl.mli
View
@@ -1,6 +1,7 @@
(*
* ExtHashtbl - extra functions over hashtables.
* Copyright (C) 2003 Nicolas Cannasse
+ * 2008 David Teller, LIFO, Universite d'Orleans
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,14 +21,20 @@
(** Extra functions over hashtables. *)
-(** Operations over hashtables.
- @documents Hashtbl
-*)
module Hashtbl :
- (** The wrapper module *)
sig
+ (** Operations over hashtables.
+
+ @author Xavier Leroy (base module)
+ @author Damien Doligez (base module)
+ @author Nicolas Cannasse
+ @author David Teller
+
+ @documents Hashtbl
+ *)
+
type ('a,'b) t = ('a,'b) Hashtbl.t
(** The type of a hashtable. *)
6 trunk/batteries/src/core/extlib/extInt.mli
View
@@ -1,7 +1,6 @@
(*
* ExtInt - Extended operations on integers
- * Copyright (C) 1996 Xavier Leroy
- * 2007 Bluestorm <bluestorm dot dylc on-the-server gmail dot com>
+ * Copyright (C) 2008 Gabriel Scherer
* 2008 David Teller
*
* This library is free software; you can redistribute it and/or
@@ -33,6 +32,9 @@ module Int :
This module implements {!Number.Numeric},
{!Number.Bounded}, {!Number.Discrete}.
+
+ @author Gabriel Scherer
+ @author David Teller
*)
type t = int
9 trunk/batteries/src/core/extlib/extInt32.mli
View
@@ -34,7 +34,14 @@ module Int32 :
Performance notice: values of type [int32] occupy more memory
space than values of type [int], and arithmetic operations on
[int32] are generally slower than those on [int]. Use [int32]
- only when the application requires exact 32-bit arithmetic. *)
+ only when the application requires exact 32-bit arithmetic.
+
+ @documents Int32
+
+ @author Xavier Leroy (base module)
+ @author Gabriel Scherer
+ @author David Teller
+*)
val zero : int32
(** The 32-bit integer 0. *)
23 trunk/batteries/src/core/extlib/extInt64.mli
View
@@ -23,6 +23,29 @@
module Int64 :
sig
+
+(** 64-bit integers.
+
+ This module provides operations on the type [int64]
+ of signed 64-bit integers. Unlike the built-in [int] type,
+ the type [int64] is guaranteed to be exactly 64-bit wide on all
+ platforms. All arithmetic operations over [int64] are taken
+ modulo 2{^64}.
+
+ Performance notice: values of type [int64] occupy more memory
+ space than values of type [int], and arithmetic operations on
+ [int64] are generally slower than those on [int]. Use [int64]
+ only when the application requires exact 64-bit arithmetic.
+
+ @documents Int64
+
+ @author Xavier Leroy (base module)
+ @author Gabriel Scherer
+ @author David Teller
+*)
+
+
+
val zero : int64
(** The 64-bit integer 0. *)
25 trunk/batteries/src/core/extlib/extList.mli
View
@@ -42,9 +42,16 @@
module List :
sig
- (** List operations.
+ (** List operations.
- @documents List *)
+ @documents List
+
+ @author Xavier Leroy (base module)
+ @author Brian Hurt
+ @author Nicolas Cannasse
+ @author Richard W.M. Jones
+ @author David Teller
+ *)
type 'a t = 'a list
(**The type of lists*)
@@ -402,6 +409,7 @@ module List :
have different lengths. Tail-recursive. *)
(** {6 Utilities}*)
+
val make_compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int
(** [make_compare c] generates the lexicographical order on lists
induced by [c]*)
@@ -446,6 +454,12 @@ module List :
(** [Different_list_size] is raised when applying functions such as
[iter2] on two lists having different size. *)
+ (** {6 Boilerplate code}*)
+ (** {7 S-Expressions}*)
+
+ val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a t
+ val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
+
(** {6 Obsolete functions} *)
val nth : 'a list -> int -> 'a
(** Obsolete. As [at]. *)
@@ -503,6 +517,7 @@ module ListLabels :
(**{6 Base operations}*)
+
val length : 'a list -> int
(** Return the length (number of elements) of the given list. *)
@@ -566,6 +581,7 @@ module ListLabels :
(**{6 Iterators}*)
+
val iter : f:('a -> unit) -> 'a list -> unit
(** [List.iter ~f:f [a1; ...; an]] applies function [f] in turn to
[a1; ...; an]. It is equivalent to
@@ -602,6 +618,7 @@ module ListLabels :
(** {6 Iterators on two lists} *)
+
val iter2 : f:('a -> 'b -> unit) -> 'a list -> 'b list -> unit
(** [List.iter2 ~f:f [a1; ...; an] [b1; ...; bn]] calls in turn
[f a1 b1; ...; f an bn].
@@ -632,6 +649,7 @@ module ListLabels :
different lengths. Tail-recursive. *)
(**{6 List scanning}*)
+
val for_all : f:('a -> bool) -> 'a list -> bool
(** [for_all ~f:p [a1; ...; an]] checks if all elements of the list
satisfy the predicate [p]. That is, it returns
@@ -723,6 +741,7 @@ module ListLabels :
Default comparator ( = ) is used if no comparison function specified. *)
(**{6 Association lists}*)
+
val assoc : 'a -> ('a * 'b) list -> 'b
(** [assoc a l] returns the value associated with key [a] in the list of
pairs [l]. That is,
@@ -760,6 +779,7 @@ module ListLabels :
(** {6 List transformations}*)
+
val split_at : int -> 'a list -> 'a list * 'a list
(** [split_at n l] returns two lists [l1] and [l2], [l1] containing the
first [n] elements of [l] and [l2] the others. Raise [Invalid_index] if
@@ -842,6 +862,7 @@ module ListLabels :
have different lengths. Tail-recursive. *)
(** {6 Utilities}*)
+
val make_compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int
(** [make_compare c] generates the lexicographical order on lists
induced by [c]*)
34 trunk/batteries/src/core/extlib/extNativeint.mli
View
@@ -1,6 +1,6 @@
(*
- * ExtInt - Extended native ints
- * Copyright (C) 2005 Damien Doligez
+ * ExtNativeint - Extended native ints
+ * Copyright (C) 2005 Xavier Leroy
* 2007 Bluestorm <bluestorm dot dylc on-the-server gmail dot com>
* 2008 David Teller
*
@@ -24,19 +24,23 @@ module Native_int :
sig
(** Processor-native integers.
- This module provides operations on the type [nativeint] of
- signed 32-bit integers (on 32-bit platforms) or
- signed 64-bit integers (on 64-bit platforms).
- This integer type has exactly the same width as that of a [long]
- integer type in the C compiler. All arithmetic operations over
- [nativeint] are taken modulo 2{^32} or 2{^64} depending
- on the word size of the architecture.
-
- Performance notice: values of type [nativeint] occupy more memory
- space than values of type [int], and arithmetic operations on
- [nativeint] are generally slower than those on [int]. Use [nativeint]
- only when the application requires the extra bit of precision
- over the [int] type.
+ This module provides operations on the type [nativeint] of
+ signed 32-bit integers (on 32-bit platforms) or
+ signed 64-bit integers (on 64-bit platforms).
+ This integer type has exactly the same width as that of a [long]
+ integer type in the C compiler. All arithmetic operations over
+ [nativeint] are taken modulo 2{^32} or 2{^64} depending
+ on the word size of the architecture.
+
+ Performance notice: values of type [nativeint] occupy more memory
+ space than values of type [int], and arithmetic operations on
+ [nativeint] are generally slower than those on [int]. Use [nativeint]
+ only when the application requires the extra bit of precision
+ over the [int] type.
+
+ @author Xavier Leroy (base module)
+ @author Gabriel Scherer
+ @author David Teller
*)
val zero : nativeint
13 trunk/batteries/src/core/extlib/extNum.mli
View
@@ -23,11 +23,16 @@
module Num :
sig
-(** Operation on arbitrary-precision numbers.
- Numbers (type [num]) are arbitrary-precision rational numbers,
- plus the special elements [1/0] (infinity) and [0/0] (undefined).
-*)
+ (** Operation on arbitrary-precision numbers.
+
+ Numbers (type {!num}) are arbitrary-precision rational numbers,
+ plus the special elements [1/0] (infinity) and [0/0] (undefined).
+
+ @author Valerie Menissier-Morain (base module)
+ @author Gabriel Scherer
+ @author David Teller
+ *)
open Nat
open Big_int
8 trunk/batteries/src/core/extlib/extRandom.mli
View
@@ -20,7 +20,13 @@
*)
module Random : sig
- (** Pseudo-random number generators (PRNG). *)
+ (** Pseudo-random number generators (PRNG).
+
+ @author Damien Doligez (base library)
+ @author David Teller
+
+ @documents Random
+*)
(** {6 Basic functions} *)
13 trunk/batteries/src/core/extlib/extStream.mli
View
@@ -31,8 +31,19 @@
This module is based on {{:http://www.pps.jussieu.fr/~li/software/sdflow/}Zheng Li's SDFlow}
*)
+
module Stream : sig
-(** Streams and parsers. *)
+(** Streams and parsers.
+
+ Streams are a read-and-forget data structure, comparable to enumerations.
+ In Batteries Included, streams are deprecated in favor of enumerations,
+ defined in module {!Enum}.
+
+ @author Zheng Li
+ @author David Teller
+
+ @documents Stream
+*)
type 'a t = 'a Stream.t
(** The type of streams holding values of type ['a]. *)
7 trunk/batteries/src/core/extlib/extString.mli
View
@@ -1,7 +1,7 @@
(*
* ExtString - Additional functions for string manipulations.
* Copyright (C) 2003 Nicolas Cannasse
- * Copyright (C) 1996,Xavier Leroy, INRIA Rocquencourt
+ * Copyright (C) 1996 Xavier Leroy, INRIA Rocquencourt
* Copyright (C) 2008 David Teller, LIFO, Universite d'Orleans
* Copyright (C) 2008 Edgar Friendly
*
@@ -30,6 +30,11 @@ sig
(** String operations.
+ @author Xavlier Leroy (base library)
+ @author Nicolas Cannasse
+ @author David Teller
+ @author Edgar Friendly
+
@documents String*)
exception Invalid_string
3  trunk/batteries/src/core/extlib/extUChar.mli
View
@@ -11,6 +11,9 @@ sig
This module implements Unicode (actually ISO-UCS) characters. All
31-bit code points are allowed.
+
+ @author Yamagata Yoriyuki (Camomile module)
+ @author Edgar Friendly
*)
(** Unicode characters. All 31bit code points are allowed.*)
8 trunk/batteries/src/core/extlib/extUTF8.mli
View
@@ -25,11 +25,11 @@ sig
(** UTF-8 encoded Unicode strings.
This module defines UTF-8 encoded Unicode strings, implemented in
- a manner comparable to native OCaml strings. This module is provided
- for compatibility but should be regarded as mostly obsoleted by
- {!Rope}.
+ a manner comparable to native OCaml strings. This module is
+ provided essentially for internal use and should be regarded as
+ mostly obsoleted by {!Rope}.
- @author Yamagata Yoriyuki
+ @author Yamagata Yoriyuki (Camomile)
@author Edgar Friendly
@author David Teller
*)
2  trunk/batteries/src/core/extlib/extUnit.mli
View
@@ -22,6 +22,8 @@ module Unit :
sig
(**
Operations on [unit].
+
+ @author David Teller
*)
type t = unit
6 trunk/batteries/src/core/extlib/file.mli
View
@@ -20,6 +20,12 @@
open IO
+(**
+ File manipulation
+
+ @author David Teller
+*)
+
(** {6 Utilities} *)
val lines_of : string -> string Enum.t
10 trunk/batteries/src/core/extlib/global.mli
View
@@ -1,6 +1,7 @@
(*
* Global - Mutable global variable
* Copyright (C) 2003 Nicolas Cannasse
+ * Copyright (C) 2008 David Teller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,10 +21,13 @@
(** Mutable global variable.
- Often in OCaml you want to have a global variable, which is mutable
+ Often in OCaml you want to have a global variable, which is mutable
and uninitialized when declared. You can use a ['a option ref] but
- this is not very convenient. The Global module provides functions
- to easily create and manipulate such variables.
+ this is not very convenient. The Global module provides functions
+ to easily create and manipulate such variables.
+
+ @author Nicolas Cannasse
+ @author David Teller (boilerplate code)
*)
type 'a t
2  trunk/batteries/src/core/extlib/labels.mli
View
@@ -43,6 +43,8 @@
None
)
]}
+
+ @author David Teller
*)
type 'a t
28 trunk/batteries/src/core/extlib/lazyList.mli
View
@@ -23,17 +23,23 @@
only computed whenever requested. This makes them particularly useful in
contexts where streams of data are to be handled.
- {b Note} For this documentation, we will assume the existence of a lazy list
- syntax extension such that [[^ ^]] is the empty lazy list and [[^ a;b;c ^]] is
- the lazy list containing elements [a], [b], [c].
-
- {b Note} Enumerations (as featured in module {!Enum}) and lazy lists (as featured
- in this module) are quite similar in purpose. Lazy lists are slightly higher level,
- insofar as no cloning is required to get them to work, which makes them slightly
- more useful in contexts where backtracking is common. Enumerations, on the other
- hand, are closer to traditional stream processing, require more low-level
- marking whenever backtracking is required, but may be faster and more memory-efficient
- when used properly. Either choice is recommended over OCaml's built-in {!Stream}.
+ {b Note} For this documentation, we will assume the existence of
+ a lazy list syntax extension such that [[^ ^]] is the empty lazy
+ list and [[^ a;b;c ^]] is the lazy list containing elements [a],
+ [b], [c].
+
+ {b Note} Enumerations (as featured in module {!Enum}) and lazy
+ lists (as featured in this module) are quite similar in
+ purpose. Lazy lists are slightly higher level, insofar as no
+ cloning is required to get them to work, which makes them
+ slightly more useful in contexts where backtracking is
+ common. Enumerations, on the other hand, are closer to
+ traditional stream processing, and require more low-level marking
+ whenever backtracking is required, but may be faster and more
+ memory-efficient when used properly. Either choice is recommended
+ over OCaml's built-in {!Stream}.
+
+ @author David Teller
*)
(** {6 Exceptions} *)
37 trunk/batteries/src/core/extlib/lazyListLabels.mli
View
@@ -19,21 +19,28 @@
*)
(** Lazy lists of elements.
- Lazy lists are similar to lists, with the exception that their contents are
- only computed whenever requested. This makes them particularly useful in
- contexts where streams of data are to be handled.
-
- {b Note} For this documentation, we will assume the existence of a lazy list
- syntax extension such that [[^ ^]] is the empty lazy list and [[^ a;b;c ^]] is
- the lazy list containing elements [a], [b], [c].
-
- {b Note} Enumerations (as featured in module {!Enum}) and lazy lists (as featured
- in this module) are quite similar in purpose. Lazy lists are slightly higher level,
- insofar as no cloning is required to get them to work, which makes them slightly
- more useful in contexts where backtracking is common. Enumerations, on the other
- hand, are closer to traditional stream processing, require more low-level
- marking whenever backtracking is required, but may be faster and more memory-efficient
- when used properly. Either choice is recommended over OCaml's [Stream].
+ Lazy lists are similar to lists, with the exception that their
+ contents are only computed whenever requested. This makes them
+ particularly useful in contexts where streams of data are to be
+ handled.
+
+ {b Note} For this documentation, we will assume the existence of
+ a lazy list syntax extension such that [[^ ^]] is the empty lazy
+ list and [[^ a;b;c ^]] is the lazy list containing elements [a],
+ [b], [c].
+
+ {b Note} Enumerations (as featured in module {!Enum}) and lazy
+ lists (as featured in this module) are quite similar in
+ purpose. Lazy lists are slightly higher level, insofar as no
+ cloning is required to get them to work, which makes them
+ slightly more useful in contexts where backtracking is
+ common. Enumerations, on the other hand, are closer to
+ traditional stream processing, require more low-level marking
+ whenever backtracking is required, but may be faster and more
+ memory-efficient when used properly. Either choice is recommended
+ over OCaml's [Stream].
+
+ @author David Teller
*)
(** {6 Exceptions} *)
2  trunk/batteries/src/core/extlib/monad.mli
View
@@ -34,6 +34,8 @@
This definition is compatible with the standard syntax extension for monads.
For more information, see {{:http://www.cas.mcmaster.ca/~carette/pa_monad/} the documentation of pa_monad}.
+
+ @author David Teller
*)
(** Signature for monads *)
3  trunk/batteries/src/core/extlib/number.mli
View
@@ -21,6 +21,9 @@
(**
A common interface for numbers.
+
+ @author Gabriel Scherer
+ @author David Teller
*)
5 trunk/batteries/src/core/extlib/optParse.mli
View
@@ -22,7 +22,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
-(** Modules for GNU [getopt(3)]-style command line parsing. *)
+(** Modules for GNU [getopt(3)]-style command line parsing.
+
+ @author Bardur Arantsson
+*)
(** This module contains the basic functions and types for defining
11 trunk/batteries/src/core/extlib/option.mli
View
@@ -22,10 +22,13 @@
(** Functions for the option type.
Options are an Ocaml standard type that can be either [None] (undefined)
- or [Some x] where x can be any value. Options are widely used in Ocaml
- to represent undefined values (a little like NULL in C, but in a type
- and memory safe way). This module adds some functions for working with
- options.
+ or [Some x] where x can be any value. Options are widely used in Ocaml
+ to represent undefined values (a little like NULL in C, but in a type
+ and memory safe way). This module adds some functions for working with
+ options.
+
+ @author Nicolas Cannasse
+ @author David Teller
*)
type 'a t = 'a option
2  trunk/batteries/src/core/toolchain/batlib_Findlib_Findlib.mli
View
@@ -13,6 +13,8 @@
[init] or [init_manually] for this.
@documents Findlib
+
+ @author Gerd Stolpmann
*)
exception No_such_package of string * string
3  trunk/batteries/src/core/toolchain/batlib_Sexp_Conv.mli
View
@@ -56,11 +56,14 @@
already aware of most types of Batteries-Included.
@documents Sexp
+ @author Markus Mottl (Sexplib)
+ @author David Teller (Batteries glue)
*)
open Bigarray
open Sexplib
+
(** The type of S-Expressions*)
type t = Sexp.t
31 trunk/batteries/src/syntax/pa_batteries/pa_batteries.ml
View
@@ -21,43 +21,36 @@
open Camlp4
open PreCast
-(*Gasp, this doesn't seem reliable.*)
-
-(*let at_start = ref true
-
-let _ =
-AstFilters.register_str_item_filter
- (Ast.map_str_item (function x ->
- if !at_start then
- let loc = Ast.loc_of_str_item x in
- at_start := false;
- <:str_item@loc<open Batteries;; $x$>>
- else x))#str_item*)
-
-open Camlp4
-
module Id = struct
let name = "pa_batteries"
let version = "0.1"
end
-let fresh () = Printf.sprintf "OPENIN_%i" (Oo.id (object end))
-
module Make (Syntax : Sig.Camlp4Syntax) = struct
include Syntax
open Sig
open Ast
+(* try
+ DELETE_RULE Gram implem: "#"; a_LIDENT; opt_expr; semi END
+ with Not_found -> Printf.eprintf "1\n"; assert false
+
+ try
+ DELETE_RULE Gram implem: str_item; semi; SELF END
+ with Not_found -> Printf.eprintf "2\n"; assert false
+ try
+ DELETE_RULE Gram implem: `EOI END
+ with Not_found -> Printf.eprintf "3\n"; assert false*)
+
DELETE_RULE Gram implem: "#"; a_LIDENT; opt_expr; semi END
DELETE_RULE Gram implem: str_item; semi; SELF END
DELETE_RULE Gram implem: `EOI END
+
let stopped_at _loc =
Some (Loc.move_line 1 _loc)
-(* let implem_next = Gram.Entry.mk "implem_next"*)
-
EXTEND Gram
GLOBAL:implem;
implem_next:
1  trunk/batteries/src/syntax/pa_mainfun/_tags
View
@@ -0,0 +1 @@
+<pa_mainfun.ml>:camlp4oof,use_camlp4
35 trunk/batteries/src/syntax/pa_batteries.ml → trunk/batteries/src/syntax/pa_mainfun/pa_mainfun.ml
View
@@ -1,9 +1,6 @@
(*
- * Pa_openin -- Syntax extension for local module opening
- * Copyright (C) 2006 Alain Frisch
- * 2007 Till Varoquaux
- * 2008 Gabriel Scherer
- * 2008 David Teller
+ * Pa_mainfun -- Remove need for "let _ = ..." to evaluate toplevel expressions
+ * Copyright (C) 2008 David Teller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,14 +17,10 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)
-
-
open Camlp4
-open PreCast
-AstFilters.register_str_item_filter (fun st -> <:str_item< open Foo; $st$ >>);;
-(*module Id = struct
- let name = "pa_batteries"
+module Id = struct
+ let name = "pa_mainfun"
let version = "0.1"
end
@@ -36,16 +29,10 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
open Sig
open Ast
-
-
- let f = object (self)
- inherit Ast.map as super
- method str_item = function
-
- | <:expr< $x$ + 0 >> |
- <:expr< 0 + $x$ >> -> self#expr x
- | e -> super#expr e
- end
-
-module M = Register.OCamlSyntaxExtension(Id)(Make)
-*)
+ EXTEND Gram
+ GLOBAL: str_item;
+ str_item: [[
+ e = expr -> <:str_item<let _ = $e$>>
+ ]];
+ END
+end
7 trunk/batteries/test/syntax/_tags
View
@@ -1,7 +0,0 @@
-# works
- <test_openin.ml>:syntax_camlp4o,pkg_batsyntax.openin.syntax
-
-# doesn't work
-# <test_openin.ml>:syntax_camlp4o,pkg_batsyntax.syntax
-
-# this must be related to the META, but I don't know how
1  trunk/batteries/test/syntax/test_openin.ml
View
@@ -1 +0,0 @@
-let test x = open List in map x
8 trunk/tests/myocamlbuild.ml
View
@@ -101,14 +101,16 @@ struct
(*The command-line for [use_batteries] and [use_batteries_r]*)
- let cl_use_boilerplate = [A"-package"; A"batteries,sexplib.syntax"]
- and cl_use_batteries = [A"-package"; A "batteries.pa_openin.syntax,batteries.pa_type_conv.syntax,batteries.pa_where.syntax,batteries.bin_prot.syntax,batteries.pa_batteries.syntax"; A "-package"; A "batteries"]
+ let cl_use_boilerplate = [A"-package"; A "batteries.pa_type_conv.syntax,batteries,sexplib.syntax"]
+ and cl_use_batteries = [A"-package"; A "batteries.pa_openin.syntax,batteries.pa_where.syntax,batteries.pa_batteries.syntax"; A "-package"; A "batteries"]
+ and cl_use_batteries_o = [A"-package"; A"batteries.pa_mainfun.syntax" ]
+ (*[cl_use_batteries_o]: extensions which only make sense in original syntax*)
and cl_camlp4o = [A"-syntax"; A "camlp4o"]
and cl_camlp4r = [A"-syntax"; A "camlp4r"] in
let cl_boilerplate_original = cl_use_boilerplate @ cl_camlp4o
and cl_boilerplate_revised = cl_use_boilerplate @ cl_camlp4r
- and cl_batteries_original = cl_use_batteries @ cl_camlp4o
+ and cl_batteries_original = cl_use_batteries @ cl_use_batteries_o @ cl_camlp4o
and cl_batteries_revised = cl_use_batteries @ cl_camlp4r in
(** Tag [use_boilerplate] provides boilerplate syntax extensions,
4 trunk/tests/test_random.ml
View
@@ -3,11 +3,13 @@
- Random.shuffle
- more [open...in...]
- <|
+ - simplified toplevel functions
*)
(*No need to [open Batteries], we're using syntax extensions*)
open Util.Random with self_init () (*Syntax extension*)
open Data.Mutable, Data.Persistent (*Syntax extension*)