Skip to content

Commit 9939221

Browse files
committed
2 parents 21f3beb + cc77bbe commit 9939221

File tree

5 files changed

+248
-54
lines changed

5 files changed

+248
-54
lines changed

script/rss2html.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ let get_opml () =
188188
"OCaml Planet" in
189189
(* Broken feeds will be marked with [is_comment = true]. *)
190190
let opml = Opml1.of_atom ~head feeds in
191-
(* Sort by name. (FIXME: one may want to ignore spaces.) *)
192-
let by_name o1 o2 = String.compare o1.Opml1.text o2.Opml1.text in
191+
(* Sort by name. *)
192+
let by_name o1 o2 = String.compare (String.trim o1.Opml1.text) (String.trim o2.Opml1.text) in
193193
{ opml with Opml1.body = List.sort by_name opml.Opml1.body }
194194

195195
let opml fname =

site/404.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- ((! set title Docs !)) ((! set documentation !)) ((! set nobreadcrumb !)) -->
2+
3+
<div class="center">
4+
<div class="head">
5+
<h1><b>404</b></h1>
6+
<h5><b>Oops, page not found!</b> <br>The page doesn't exist or some other error occurred.</h5>
7+
<a href="https://ocaml.org/" class="btn">Home</a>
8+
</div>
9+
</div>

site/css/ocamlorg.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,16 @@ ul.translations:after { content: "]"; }
549549
height: 0px;
550550
}
551551
}
552+
.center{
553+
display: table;
554+
text-align: center;
555+
width: 100%;
556+
height:53vh;
557+
}
558+
.head{
559+
display: table-cell;
560+
vertical-align:middle;
561+
}
552562

553563
/* Footer
554564
***********************************************************************/

site/learn/success.fr.md

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
<!-- ((! set title Quelques succès !)) ((! set learn !)) -->
22

3+
*Table of contents*
34
# Quelques succès
4-
*Contenu*
5+
6+
## Jane Street
7+
[<img src='/img/users/jane-street.jpg' alt='Jane Street'
8+
style='clear: left; margin-right: 10px' />](http://janestreet.com/technology/)
9+
10+
Jane Street est une société de négoce propriétaire qui utilise OCaml comme sa
11+
plate-forme de développement primaire.Notre exploitation fonctionne à grande
12+
échelle, générant des milliards de dollars de transactions chaque jour à partir
13+
de nos bureaux de Hong Kong,Londres et New York, avec des stratégies qui couvrent
14+
de nombreuses classes d’actifs, fuseaux horaires et régimes réglementaires.
15+
16+
Presque tous nos logiciels sont écrits dans OCaml, du code de recherche statistique
17+
aux outils d’administration des systèmes en retour de notre infrastructure de trading
18+
en temps réel.Le système de type d’OCaml agit comme un ensemble riche et bien intégré
19+
d’outils d’analyse statique qui aident à améliorer la qualité de notre code, en
20+
attrapant les bogues le plus tôt possible.Chaque jour, des milliards de dollars de
21+
transactions passent par nos systèmes, ce qui fait en sorte que les choses se passent
22+
bien.Dans le même temps, OCaml est très productif, nous aidant à nous adapter rapidement
23+
à l’évolution des conditions du marché.
24+
25+
Jane Street contribue aux bibliothèques open-source à l’ensemble de la communauté depuis
26+
de nombreuses années, y compris Core, notre bibliothèque standard alternative, Async, une
27+
bibliothèque coopérative de concurrence, et plusieurs extensions syntaxiques comme binprot
28+
et sexplib.Tous ces éléments peuvent être trouvés à <http://janestreet.github.io>.Au total,
29+
nous avons ouvert plus de 200k lignes de code.
530

631
## Le synchroniseur de fichiers Unison
7-
[<img src='/img/unison-thumb.jpg' alt='Screenshot' title='Screenshot of Unison&#39;s main window' />](/img/unison.png)
32+
[<img src='/img/unison-thumb.jpg' style='clear: left; margin-right: 10px'
33+
alt='Screenshot' title='Screenshot of Unison&#39;s main window' />](/img/unison.png)
834

935
[Unison](http://www.cis.upenn.edu/%7Ebcpierce/unison/) est un outil de
1036
synchronisation de fichiers populaire, qui fonctionne sous Windows et
@@ -37,7 +63,9 @@ unique parmi les projets de grande taille écrits en OCaml, d'avoir été
3763
L'adoption d'OCaml a été comme une bouffée d'air pur. »
3864

3965
## Le client pair-à-pair MLdonkey
40-
[<img src='/img/mldonkey-thumb.jpg' alt='Screenshot' title='Screenshot of one of MLdonkey&#39;s windows' />](/img/mldonkey.jpg)
66+
[<img src='/img/mldonkey-thumb.jpg'
67+
style='clear: left; margin-right: 10px'
68+
alt='Screenshot' title='Screenshot of one of MLdonkey&#39;s windows' />](/img/mldonkey.jpg)
4169

4270
[MLdonkey](http://mldonkey.sourceforge.net/Main_Page) est un client
4371
pair-à-pair multi-plateformes et multi-réseaux. Il a été le premier
@@ -61,8 +89,10 @@ tâche de fond et sans surveillance humaine, et peut être contrôlé à
6189
l'aide d'une interface au choix parmi trois : GTK, web et telnet. »
6290

6391
## Le Langage de Modélisation Financière de LexiFi
64-
[<img src='/img/lexifi-thumb.jpg alt='Screenshot'
65-
title='A report produced by LexiFi software' />](/img/lexifi.jpg)
92+
[<img src='/img/lexifi-thumb.jpg'
93+
style='clear: left; margin-right: 10px'
94+
alt='Screenshot' title='A report produced by LexiFi software'
95+
/>](/img/lexifi.jpg)
6696

6797
Développé par la société [LexiFi](http://www.lexifi.com/), le Langage de
6898
Modélisation Financière (MLFi) est le premier langage formel capable de
@@ -118,7 +148,8 @@ l'environnement d'exécution sont les principales raisons de notre
118148
intérêt pour OCaml. »
119149

120150
## L'assistant de preuve Coq
121-
[<img src='/img/coq-thumb.jpg' alt='Screenshot' title='Screenshot of Coq&#39;s integrated development environment' />](/img/coq.jpg)
151+
[<img src='/img/coq-thumb.jpg' alt='Screenshot' style='clear: left; margin-right: 10px'
152+
title='Screenshot of Coq&#39;s integrated development environment' />](/img/coq.jpg)
122153

123154
*[Jean-Christophe Filliâtre](http://www.lri.fr/%7Efilliatr/) (CNRS), un
124155
des développeurs de Coq :* « L'outil [Coq](http://coq.inria.fr/) est un
@@ -139,7 +170,8 @@ fault »), ce qui est indispensable à un outil dont le but premier est
139170
justement la rigueur. »
140171

141172
## L'analyseur statique ASTRÉE
142-
[<img src='/img/astree.gif' alt='A340' title='ASTRÉE has been used to certify the Airbus A340 flight control software' />](https://www.airbus.com/aircraft/previous-generation-aircraft/a340-family.html)
173+
[<img src='/img/astree.gif' alt='A340' style='clear: left; margin-right: 10px'
174+
title='ASTRÉE has been used to certify the Airbus A340 flight control software' />](https://www.airbus.com/aircraft/previous-generation-aircraft/a340-family.html)
143175

144176
*[David Monniaux](http://www-verimag.imag.fr/~monniaux/) (CNRS), membre
145177
du projet ASTRÉE :* « [ASTRÉE](http://www.astree.ens.fr/) est un
@@ -197,6 +229,9 @@ language and robustness of its implementation provided a great
197229
productivity boost.”
198230

199231
## FFTW
232+
<img src='/img/fftw-thumb.png' alt='FFTW'
233+
style='clear: left; margin-right: 10px' />
234+
200235
[FFTW](http://www.fftw.org/) est une librairie C [très
201236
rapide](http://www.fftw.org/benchfft/) permettant d'effectuer des
202237
Transformées de Fourier Discrètes (DFT). Elle emploie un puissant
@@ -215,4 +250,17 @@ sont portables : un même programme donnera de bons résultats sur la
215250
plupart des architectures sans modification. D'où le nom « FFTW, » qui
216251
signifie « Fastest Fourier Transform in the West. »
217252

253+
## Liquidsoap
254+
[Liquidsoap](http://liquidsoap.fm/) est clairement bien établie dans
255+
l’industrie de la radio (internet).Liquidsoap est bien connu comme un
256+
outil avec des capacités uniques, et a beaucoup d’utilisateurs, y compris
257+
les grands commerciaux.Il n’est pas développé comme une entreprise, mais les
258+
entreprises développent des services ou des logiciels sur le dessus de celui-ci.
259+
Par exemple, Sourcefabric développe et vend du temps d’antenne au-dessus de Liquidsoap.
218260

261+
## Haxe
262+
[Haxe](http://haxe.org/) est une boîte à outils open source basée sur un
263+
langage de programmation moderne, de haut niveau, strictement typé, un
264+
compilateur croisé, une bibliothèque standard multiplateforme complète et
265+
des moyens d’accéder aux capacités natives de chaque plate-forme.Le compilateur
266+
Haxe a été entièrement écrit dans OCaml.

site/learn/tutorials/command-line_arguments.md

Lines changed: 172 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,178 @@
22
<!-- ((! set center !)) -->
33

44
# Command-line arguments
5-
This is a short tutorial for those who are writing their first OCaml
6-
program and are wondering how to read arguments that are passed on the
7-
command line.
8-
9-
## argv
10-
Like in the C programming language, the arguments that are passed to a
11-
given program are stored in an array. Following the tradition, this
12-
array is named `argv`. It is found in the `Sys` module of the standard
13-
library, therefore its full name is `Sys.argv`. The number of arguments
14-
including the name of the program itself is simply the length of the
15-
array. It is obtained using the `Array.length` function.
16-
17-
## Simple example
18-
The following program displays the arguments with their position in
19-
`Sys.argv`:
5+
6+
In this tutorial we learn how to read command line arguments directly, using
7+
OCaml's `Sys.argv` array, and then how to do so more easily using the standard
8+
library's `Arg` module.
9+
10+
## Sys.argv
11+
12+
Like in C and many other languages, the arguments that are passed to a given
13+
program on the command line are stored in an array. Following tradition, this
14+
array is named `argv`. It is found in the `Sys` module of the standard library,
15+
therefore its full name is `Sys.argv`. The number of arguments including the
16+
name of the program itself is simply the length of the array. It is obtained
17+
using the `Array.length` function.
18+
19+
The following program displays the arguments with their position in `Sys.argv`:
20+
21+
```ocaml
22+
for i = 0 to Array.length Sys.argv - 1 do
23+
Printf.printf "[%i] %s\n" i Sys.argv.(i)
24+
done
25+
```
26+
27+
If you save the program above as `args.ml`, and run `ocaml args.ml arg1 arg2
28+
arg3`, here is what you get:
29+
30+
```
31+
[0] args.ml
32+
[1] arg1
33+
[2] arg2
34+
[3] arg3
35+
```
36+
37+
Note that `ocaml` launched a subprocess that actually runs the program where
38+
argv is `args.ml arg1 arg2 arg3`. You can also compile your program using
39+
`ocamlopt -o args args.ml`, and then running `./args arg1 arg2 arg3` and you
40+
will get:
41+
42+
```
43+
[0] ./args
44+
[1] arg1
45+
[2] arg2
46+
[3] arg3
47+
```
48+
49+
## Using the Arg module
50+
51+
The OCaml standard library has a module for writing command line interfaces, so
52+
we do not have to use `Sys.argv` directly. We shall consider the example from
53+
the OCaml documentation, a program for appending files.
54+
55+
First, we set up the usage message to be printed in the case of a malformed
56+
command line, or when help is requested:
57+
58+
```ocaml
59+
let usage_msg = "append [-verbose] <file1> [<file2>] ... -o <output>"
60+
```
61+
62+
Now, we create some references to hold the information gathered from the
63+
command line. The `Arg` module will fill these in for us as the command line is
64+
read.
65+
66+
```ocaml
67+
let verbose = ref false
68+
69+
let input_files = ref []
70+
71+
let output_file = ref ""
72+
```
73+
74+
We have a boolean reference for the `-verbose` flag with a default value of
75+
`false`. Then we have a reference to a list which will hold the names of all
76+
the input files. Finally, we have a string reference into which the single
77+
output file name specified by `-o` will be placed.
78+
79+
We will need a function to handle the anonymous inputs, that is to say the ones
80+
with no flag before them. In this case these are our input file names. Our
81+
function simply adds the file name to the reference defined earlier.
82+
83+
```ocaml
84+
let anon_fun filename =
85+
input_files := filename :: !input_files
86+
```
87+
88+
Finally we build the list of command line flag specifcations. Each is a tuple
89+
of the flag name, the action to be taken when it is encountered, and the help
90+
string.
91+
92+
```ocaml
93+
let speclist =
94+
[("-verbose", Arg.Set verbose, "Output debug information");
95+
("-o", Arg.Set_string output_file, "Set output file name")]
96+
```
97+
98+
We have two kinds of action here: the `Arg.Set` action which sets a boolean
99+
reference, and the `Arg.Set_string` action which sets a string reference. Our
100+
`input_files` reference will of course be updated by the `anon_fun` function
101+
already defined.
102+
103+
We can now call `Arg.parse`, giving it our specification list, anonymous
104+
function, and usage message. Once it returns, the references will be filled
105+
with all the information required to append our files.
20106

21107
```ocaml
22108
let () =
23-
for i = 0 to Array.length Sys.argv - 1 do
24-
Printf.printf "[%i] %s\n" i Sys.argv.(i)
25-
done
26-
```
27-
If you save the program above as `args.ml`, and run
28-
`ocaml args.ml arg1 arg2 arg3`, here is what you get:
29-
30-
[0] args.ml
31-
[1] arg1
32-
[2] arg2
33-
[3] arg3
34-
35-
Note that `ocaml` launched a subprocess that actually runs the program
36-
where argv is `args.ml arg1 arg2 arg3`. You can also compile your
37-
program using `ocamlopt -o args args.ml`, and then run
38-
`./args arg1 arg2 arg3` and you will get:
39-
40-
[0] ./args
41-
[1] arg1
42-
[2] arg2
43-
[3] arg3
44-
45-
## Tools for parsing command-line options
46-
There are libraries that let you process command-line arguments
47-
without having to scan the `Sys.argv` array yourself:
48-
49-
* `Arg` is a module of the standard library.
50-
* [Getopt](https://opam.ocaml.org/packages/getopt/)
51-
for OCaml is similar to [GNU
52-
getopt](http://www.gnu.org/software/libc/manual/html_node/Getopt.html).
109+
Arg.parse speclist anon_fun usage_msg;
110+
(* Main functionality here *)
111+
```
112+
113+
Let's save our program as `append.ml` and compile it with `ocamlopt -o append
114+
append.ml` and try it out:
115+
116+
```shell
117+
$./append -verbose one.txt two.txt -o three.txt
118+
119+
$./append one.txt two.txt
120+
121+
$./append -quiet
122+
./append: unknown option '-quiet'.
123+
append [-verbose] <file1> [<file2>] ... -o <output>
124+
-verbose Output debug information
125+
-o Set output file name
126+
-help Display this list of options
127+
--help Display this list of options
128+
129+
$./append -help
130+
append [-verbose] <file1> [<file2>] ... -o <output>
131+
-verbose Output debug information
132+
-o Set output file name
133+
-help Display this list of options
134+
--help Display this list of options
135+
```
136+
137+
Here is the whole program:
138+
139+
```ocaml
140+
let usage_msg = "append [-verbose] <file1> [<file2>] ... -o <output>"
141+
142+
let verbose = ref false
143+
144+
let input_files = ref []
145+
146+
let output_file = ref ""
147+
148+
let anon_fun filename =
149+
input_files := filename :: !input_files
150+
151+
let speclist =
152+
[("-verbose", Arg.Set verbose, "Output debug information");
153+
("-o", Arg.Set_string output_file, "Set output file name")]
154+
155+
let () =
156+
Arg.parse speclist anon_fun usage_msg;
157+
(* Main functionality here *)
158+
```
159+
160+
The `Arg` module has many more actions than just `Set` and `Set_string`, and
161+
some lower-level function for parsing more complicated command lines.
162+
163+
## Other tools for parsing command-line options
164+
165+
There are libraries with facilities different from or more extensive than the
166+
built-in `Arg` module:
167+
168+
* [Cmdliner](https://erratique.ch/software/cmdliner/doc/Cmdliner) is a modern
169+
interface for command line processing, which also generates UNIX man pages
170+
automatically.
171+
172+
* [Clap](https://opam.ocaml.org/packages/clap/) is an imperative command line
173+
parser.
174+
175+
* [Minicli](https://opam.ocaml.org/packages/minicli/) has good support for
176+
rejecting malformed command lines which others might sliently accept.
177+
178+
* [Getopt](https://opam.ocaml.org/packages/getopt/) for OCaml is similar to
179+
[GNU getopt](http://www.gnu.org/software/libc/manual/html_node/Getopt.html).

0 commit comments

Comments
 (0)