Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eatonphil/mod_ocaml
Apache module to allow embedded OCAML.
https://github.com/eatonphil/mod_ocaml
Last synced: 3 days ago
JSON representation
Apache module to allow embedded OCAML.
- Host: GitHub
- URL: https://github.com/eatonphil/mod_ocaml
- Owner: eatonphil
- License: gpl-2.0
- Created: 2015-01-08T17:27:54.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-08T17:29:53.000Z (almost 10 years ago)
- Last Synced: 2024-10-13T04:13:05.670Z (about 1 month ago)
- Language: C
- Size: 113 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
WHAT IS OCAML?
==============OCAML [1] is derived from the CAML language. We include the description
from its home at INRIA here:Caml is a programming language, easy to learn, easy to use, and yet
amazingly powerful.It is developed and distributed by INRIA (the main French research institute
for computer science), since 1984. It is freely available for Unix, PC or
Macintosh.Objective Caml (OCAML) is a general purpose programming language that combines
functional, imperative, and object-oriented programming. The language is
statically typed; its type system ensures the correct evaluation of
programs. Types are automatically inferred. The language offers powerful
constructions such as user-definable data-types, the ability to define
functions by pattern-matching, and an exception mechanism. Programming in
the large is facilitated by a full-fledge class-based object-oriented layer
and an expressive module system.NOW, WHAT IS MOD_OCAML?
=======================Generally, mod_ocaml is a flexible module for use with the famous Apache
Web Server[2]. Probably you know how to benefit of other modules with
unbelievable capabilities, like PHP (mod_php4) or Perl (mod_perl).One of the advantages of the Apache Server is the possibility to extend its
features by adding modules to your configuration. At this point, mod_ocaml
comes up.mod_ocaml is designed to work with the 1.3 family of Apache's all over the
world.HOW DOES IT WORK?
=================Thanks to a appropriate "AddHandler" directive in your httpd.conf, all
OCAML-Pages (usually with the file extension .ocml) will be handed to mod_ocaml
for further processing.mod_ocaml requires the OCAML interpreter to be installed on your system. You
get it on OCAML's virtual home[1].
Every time a page is rendered by the mod_ocaml parser, the interpreter is
called to evaluate the OCAML commands generated by mod_ocaml.Much like PHP, mod_ocaml gives you the facility to mix up HTML and OCAML
code on your pages. mod_ocaml features a sort of preprocessor (parser) which
extracts the parts of your page and converts them into OCAML commands. For
example, the HTML parts of your page are built into printf()-commands that
are understandable for the OCAML interpreter.Oh, and we wondered how to make code defined in a fictive OCAML statement #1
available in the OCAML statements #2 ... #n, too: More than one call to the
interpreter would destroy this, because the single OCAML parts of the page
would not know about each other. Then we had the idea to just convert the
separating HTML blocks into OCAML and calling the interpreter only once. In
consequence, you can define some functions, variables, etc. on top of your
page and use them on bottom without further work."Problematic" characters like " are escaped automatically, and the OCAML
interpreter doesn't complain about them. Don't worry about this, mod_ocaml
will do it for you.PRACTICAL USE
=============You simply write poor old HTML code and save it under your webserver root.
Choose the extension you entered at the "AddHandler" directive in
httpd.conf (per default, this is .ocml). So you save a file named, e. g.
test.ocml.Until now, you didn't use any of the mod_ocaml benefits. Try to include OCAML
code, and it will be displayed "as is". Since you want your OCAML code to be
interpreted and evaluated, you have to inform mod_ocaml of this:As you can see, the init tag for your OCAML parts is "". As said before: It is much like PHP, but it's OCAML with all
its advantages and possibilities of functional and imperative programming.
Everything that is located on the outside of these OCAML blocks will be
displayed "as is".This solution makes it also possible to include HTML code within a loop
statement like "while" or "for", e. g. when outputting big HTML tables with
many cells and columns. But don't forget about the functional focus of OCAML
when using things like that ;-)INTEROPERABILITY
================Sure. You want to process GET requests within your mod_ocaml pages. You call
your pages like http://www.some.where/mypage.ocml?a=foo&b=bar. After that,
you have two variables a and b which are fully available to your OCAML code.
Just include them with $a and $b, like this:Printf.printf ("$n");;
Please note: YOU (as web developer, programmer, ...) are responsible for
proper implementing these external vars, e. g. including in quotation for
strings, etc. Also take care of input checking if you're expecting lists
and other cool data types from the "outside" ;-)We didn't want to check this external input. Not because we were too lazy,
but you shall have all the possibilities to do with mod_ocaml what YOU want.
Additionally, OCAML is a typed language and you just have to pay attention
to what you are doing. When we set up the concept of mod_ocaml, we didn't
want to destroy this intention.JUST MORE
=========You are currently reading the README file of mod_ocaml. But mod_ocaml is
more than a website-scripting-wrapper to the OCAML interpreter: You can use
almost every interpreter with it.AUTHORS
=======We both are students of computer science at the Technical University of Munich,
Germany[3]. In October 2002, we heard of OCAML for the first time. Our
prof, Prof. Dr. Alois Knoll[4] tries quite hard to make us familiar with
functional programming, and he really loves OCAML and its powerful features.You can reach us best via e-mail:
Andreas Brandmaier
orLeonhard Fellermayr
orBUGS
====... are always and everywhere. So please provide us with your bug reports.
We tried hard to avoid bugs and we will try even harder to remove what is
left of them.LICENSE
=======mod_ocaml is released under the terms of the GNU Public License, which is
included with this package. We hope mod_ocaml is useful for you. Enjoy!REFERENCES
==========
[1] http://caml.inria.fr/
[2] http://httpd.apache.org/
[3] http://www.in.tum.de/
[4] http://wwwknoll.informatik.tu-muenchen.de/~knoll/