caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] dynamic HTML pages
@ 2003-04-08  7:27 David Monniaux
  2003-04-08  9:19 ` Maxence Guesdon
  2003-04-08 11:59 ` Mattias Waldau
  0 siblings, 2 replies; 11+ messages in thread
From: David Monniaux @ 2003-04-08  7:27 UTC (permalink / raw)
  To: Liste CAML

Hello,

I'm investigating solutions for generating dynamic HTML pages using OCaml
programs. So far, I've looked at the following systems:

* OCamlNet/NetString can transform between a SGML/HTML parse tree and a
  SGML/HTML file.

  This may be a solution; perhaps it would be better if there were some
  camlp4 syntactic sugar for creating the parse tree nodes.

  Slight concern: the entire page must be fully generated between being
  transmitted.

* Bedouin: interesting attempt at enforcing well-formedness through type
  safety, but the project seems dead in the water.

* WDialog: isn't it a bit of overkill?

* Antoine Miné's OCamlHTML: a bit rudimentary.

Are there projects that I missed? Any experience?


David Monniaux            http://www.di.ens.fr/~monniaux
Laboratoire d'informatique de l'École Normale Supérieure,
Paris, France

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] dynamic HTML pages
  2003-04-08  7:27 [Caml-list] dynamic HTML pages David Monniaux
@ 2003-04-08  9:19 ` Maxence Guesdon
  2003-04-08 11:59 ` Mattias Waldau
  1 sibling, 0 replies; 11+ messages in thread
From: Maxence Guesdon @ 2003-04-08  9:19 UTC (permalink / raw)
  Cc: Liste CAML


> Hello,
> 
> I'm investigating solutions for generating dynamic HTML pages using OCaml
> programs. So far, I've looked at the following systems:
> 
> * OCamlNet/NetString can transform between a SGML/HTML parse tree and a
>   SGML/HTML file.
> 
>   This may be a solution; perhaps it would be better if there were some
>   camlp4 syntactic sugar for creating the parse tree nodes.
> 
>   Slight concern: the entire page must be fully generated between being
>   transmitted.
> 
> * Bedouin: interesting attempt at enforcing well-formedness through type
>   safety, but the project seems dead in the water.
> 
> * WDialog: isn't it a bit of overkill?
> 
> * Antoine Miné's OCamlHTML: a bit rudimentary.
> 
> Are there projects that I missed? Any experience?

Have a look at the toolhtml library, included in Cameleon:
http://pauillac.inria.fr/~guesdon/Tools/cameleon/cameleon.html

-- 
Maxence Guesdon

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [Caml-list] dynamic HTML pages
  2003-04-08  7:27 [Caml-list] dynamic HTML pages David Monniaux
  2003-04-08  9:19 ` Maxence Guesdon
@ 2003-04-08 11:59 ` Mattias Waldau
  2003-04-08 12:28   ` mixing different languages (was: RE: [Caml-list] dynamic HTML pages) David Monniaux
  1 sibling, 1 reply; 11+ messages in thread
From: Mattias Waldau @ 2003-04-08 11:59 UTC (permalink / raw)
  To: 'David Monniaux', 'Liste CAML'

I use HereDoc by Alain Frisch. I think I use an old version. 

It works like JSP. Very simple to use. Based on camlp4.

(I use FragmentO1, since FragmentO1_fast is unstable)

/Mattias

> -----Original Message-----
> From: owner-caml-list@pauillac.inria.fr 
> [mailto:owner-caml-list@pauillac.inria.fr] On Behalf Of David Monniaux
> Sent: den 8 april 2003 09:27
> To: Liste CAML
> Subject: [Caml-list] dynamic HTML pages
> 
> 
> Hello,
> 
> I'm investigating solutions for generating dynamic HTML pages 
> using OCaml programs. So far, I've looked at the following systems:
> 
> * OCamlNet/NetString can transform between a SGML/HTML parse 
> tree and a
>   SGML/HTML file.
> 
>   This may be a solution; perhaps it would be better if there 
> were some
>   camlp4 syntactic sugar for creating the parse tree nodes.
> 
>   Slight concern: the entire page must be fully generated 
> between being
>   transmitted.
> 
> * Bedouin: interesting attempt at enforcing well-formedness 
> through type
>   safety, but the project seems dead in the water.
> 
> * WDialog: isn't it a bit of overkill?
> 
> * Antoine Miné's OCamlHTML: a bit rudimentary.
> 
> Are there projects that I missed? Any experience?
> 
> 
> David Monniaux            http://www.di.ens.fr/~monniaux
> Laboratoire d'informatique de l'École Normale Supérieure, 
> Paris, France
> 
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: 
http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs
FAQ: http://caml.inria.fr/FAQ/ Beginner's list:
http://groups.yahoo.com/group/ocaml_beginners

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-08 11:59 ` Mattias Waldau
@ 2003-04-08 12:28   ` David Monniaux
  2003-04-09 17:03     ` Fred Yankowski
  2003-04-09 18:12     ` Miles Egan
  0 siblings, 2 replies; 11+ messages in thread
From: David Monniaux @ 2003-04-08 12:28 UTC (permalink / raw)
  To: 'Liste CAML'

On Tue, 8 Apr 2003, Mattias Waldau wrote:

> I use HereDoc by Alain Frisch. I think I use an old version. 
> It works like JSP. Very simple to use. Based on camlp4.

This is slightly off-topic, but:

In the case of dynamic WWW pages, it is often the case that the same
script or program actually contains code written in several languages:
HTML, SQL, OCaml/PHP/Perl, XML...

For integration, a mechanism of quotation/antiquotations (à la Camlp4) is
nice.

Are there any text editors that are aware of such mixed programs?

Another alternative for HTML would be to have a regular HTML page, perhaps
edited with HTML generation tools (FrontPage, Quanta+...), with special
tags indicating special actions.

For instance: a table output from a bibliographic database would look like
<table><tbody>
<foreach item=entry><td><param name=author></td>
<td><param name=title></td></foreach>
</tbody></table>

It would only be a matter of parsing this regular HTML page with a SGML
parser such as OCamlNet, replacing <foreach>...</foreach> by iteration and
<param> tags by iteration variables.

Has there been something done around that kind of things?


David Monniaux            http://www.di.ens.fr/~monniaux
Laboratoire d'informatique de l'École Normale Supérieure,
Paris, France

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-08 12:28   ` mixing different languages (was: RE: [Caml-list] dynamic HTML pages) David Monniaux
@ 2003-04-09 17:03     ` Fred Yankowski
  2003-04-09 17:24       ` Brian Skahan
  2003-04-13 14:01       ` Pierre Weis
  2003-04-09 18:12     ` Miles Egan
  1 sibling, 2 replies; 11+ messages in thread
From: Fred Yankowski @ 2003-04-09 17:03 UTC (permalink / raw)
  Cc: 'Liste CAML'

On Tue, Apr 08, 2003 at 02:28:50PM +0200, David Monniaux wrote:
> Are there any text editors that are aware of such mixed programs?

Emacs has an available MMM package -- Multiple Major Modes -- that
applies different modes to different sections of any given file based
on patterns that define the different language regions.  It works
fairly well with, for example, PHP code embedded in HTML, presenting
the PHP code with php-mode and the HTML code with an html mode, using
the font-coloring and other mode-specific view and behavior specific
to each mode in the particular regions.

That said, I now try for a strict separation of imperative code and
HTML code, so that my HTML template files have no language specific
code and contain only formal parameters and markings of optional and
repeated blocks of HTML content.  I haven't used OCaml to generate
HTML pages, but that's the approach I would want there too.

The "Zope Page Templates" used in the Zope/python webserver framework
are particularly elegant implementation of this approach, doing all
templating in a slightly enhanced version of XHTML.  But they are slow
(absent caching) because of the XML parsing required.

-- 
Fred Yankowski      fred@ontosys.com           tel: +1.630.879.1312
OntoSys, Inc	    PGP keyID: 7B449345        fax: +1.630.879.1370
www.ontosys.com     38W242 Deerpath Rd, Batavia, IL 60510-9461, USA

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-09 17:03     ` Fred Yankowski
@ 2003-04-09 17:24       ` Brian Skahan
  2003-04-10  7:20         ` Christian Lindig
  2003-04-13 14:01       ` Pierre Weis
  1 sibling, 1 reply; 11+ messages in thread
From: Brian Skahan @ 2003-04-09 17:24 UTC (permalink / raw)
  To: 'Liste CAML'

[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

* Fred Yankowski <fred@ontosys.com> [030409 13:05]:
> On Tue, Apr 08, 2003 at 02:28:50PM +0200, David Monniaux wrote:
> > Are there any text editors that are aware of such mixed programs?
> 
> Emacs has an available MMM package -- Multiple Major Modes -- that
> applies different modes to different sections of any given file based
> on patterns that define the different language regions.  It works
> fairly well with, for example, PHP code embedded in HTML, presenting
> the PHP code with php-mode and the HTML code with an html mode, using
> the font-coloring and other mode-specific view and behavior specific
> to each mode in the particular regions.

Vim has a similar feature, though I don't think its implemented for ocaml at
the moment.  It works for mixed php/html, python(psp)/html, and jsp/html.
Porting the jsp syntax file to psp was trivial, so I expect getting ocaml to
work would not be difficult.

Regards,
Brian

-- 
  _/_/_/_/_/   Brian Skahan _/ bskahan@etria.com    _/_/_/_/_/
 _/_/  Towson University   _/    Baltimore, MD U.S.      _/_/
_/_/_/_/_/        http://www.etria.com            _/_/_/_/_/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-08 12:28   ` mixing different languages (was: RE: [Caml-list] dynamic HTML pages) David Monniaux
  2003-04-09 17:03     ` Fred Yankowski
@ 2003-04-09 18:12     ` Miles Egan
  2003-04-09 23:00       ` Jeff Henrikson
  1 sibling, 1 reply; 11+ messages in thread
From: Miles Egan @ 2003-04-09 18:12 UTC (permalink / raw)
  To: David Monniaux; +Cc: 'Liste CAML'

[-- Attachment #1: Type: text/plain, Size: 2011 bytes --]

On Tue, 2003-04-08 at 05:28, David Monniaux wrote:
> On Tue, 8 Apr 2003, Mattias Waldau wrote:
> 
> > I use HereDoc by Alain Frisch. I think I use an old version. 
> > It works like JSP. Very simple to use. Based on camlp4.
> 
> This is slightly off-topic, but:
> 
> In the case of dynamic WWW pages, it is often the case that the same
> script or program actually contains code written in several languages:
> HTML, SQL, OCaml/PHP/Perl, XML...

I've used half a dozen different web frameworks in the last several
years and the one thing they all seem to have in common is some kind of
highly dynamic template/expression language.

Most recently I've been using Jakarta Tapestry, which uses ognl
(http://www.ognl.org), a library that evaluates dynamic expressions on
java objects and relies heavily on reflection.  In fact, many of the
more interesting Java projects I've seen recently make heavy use of
reflection or even direct bytecode manipulation to free themselves of
the strictures of the type system and achieve various kinds of
metaprogramming.

It's hard to imagine doing some of the same things in a language like
OCaml, where runtime metaprogramming is difficult if not impossible. 
How would one implement something like a general-purpose
object-relational mapper, for instance, in OCaml.  Is this just a
fundmental engineering tradeoff of highly typed languages?  Do you have
to sacrifice metaprogramming and runtime introspection for type
inference and type safety?

It seems somewhat ironic to me that large projects in strictly typed
languages often end up building in some kind of meta-object layer and
that all the highly dynamic languages (lisp, python, etc) work hard to
do fancy type inference under the hood?  Perhaps it's just a fact of
life that many complex software systems need to find some common middle
ground with a combination strict type checking and powerful
metaprogramming / introspection features?

-- 
Miles Egan <miles@caddr.com>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-09 18:12     ` Miles Egan
@ 2003-04-09 23:00       ` Jeff Henrikson
  2003-04-10  0:19         ` Miles Egan
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff Henrikson @ 2003-04-09 23:00 UTC (permalink / raw)
  To: Miles Egan; +Cc: caml-list

I'm not sure I understand what you want, but wouldn't just having a 
program spew stuff back into its own toplevel be a sledgehammer for 
dynamic metaprogramming?  I'm surprised I haven't seen more code that 
does this.  That combined with being able to do things like recurse 
over your own source code (esp. data types) with camlp4 seems way 
better than could be done by hand mucking java byte codes.  But again, 
I'm not sure what you want.


Jeff Henrikson


. . .
> It's hard to imagine doing some of the same things in a language like
> OCaml, where runtime metaprogramming is difficult if not impossible.
> How would one implement something like a general-purpose
> object-relational mapper, for instance, in OCaml.  Is this just a
> fundmental engineering tradeoff of highly typed languages?  Do you have
> to sacrifice metaprogramming and runtime introspection for type
> inference and type safety?
>
> It seems somewhat ironic to me that large projects in strictly typed
> languages often end up building in some kind of meta-object layer and
> that all the highly dynamic languages (lisp, python, etc) work hard to
> do fancy type inference under the hood?  Perhaps it's just a fact of
> life that many complex software systems need to find some common middle
> ground with a combination strict type checking and powerful
> metaprogramming / introspection features?
>
> -- 
> Miles Egan <miles@caddr.com>
> <signature.asc>

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-09 23:00       ` Jeff Henrikson
@ 2003-04-10  0:19         ` Miles Egan
  0 siblings, 0 replies; 11+ messages in thread
From: Miles Egan @ 2003-04-10  0:19 UTC (permalink / raw)
  To: Jeff Henrikson; +Cc: caml list

[-- Attachment #1: Type: text/plain, Size: 1796 bytes --]

Take object-relational mapping as an example.  Let's say I want to write
an o-r mapping layer that can persist arbitrary classes without having
access to their source code.

On Wed, 2003-04-09 at 16:00, Jeff Henrikson wrote:
> I'm not sure I understand what you want, but wouldn't just having a 
> program spew stuff back into its own toplevel be a sledgehammer for 
> dynamic metaprogramming?  I'm surprised I haven't seen more code that 
> does this.  That combined with being able to do things like recurse 
> over your own source code (esp. data types) with camlp4 seems way 
> better than could be done by hand mucking java byte codes.  But again, 
> I'm not sure what you want.
> 
> 
> Jeff Henrikson
> 
> 
> . . .
> > It's hard to imagine doing some of the same things in a language like
> > OCaml, where runtime metaprogramming is difficult if not impossible.
> > How would one implement something like a general-purpose
> > object-relational mapper, for instance, in OCaml.  Is this just a
> > fundmental engineering tradeoff of highly typed languages?  Do you have
> > to sacrifice metaprogramming and runtime introspection for type
> > inference and type safety?
> >
> > It seems somewhat ironic to me that large projects in strictly typed
> > languages often end up building in some kind of meta-object layer and
> > that all the highly dynamic languages (lisp, python, etc) work hard to
> > do fancy type inference under the hood?  Perhaps it's just a fact of
> > life that many complex software systems need to find some common middle
> > ground with a combination strict type checking and powerful
> > metaprogramming / introspection features?
> >
> > -- 
> > Miles Egan <miles@caddr.com>
> > <signature.asc>
-- 
Miles Egan <miles@caddr.com>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-09 17:24       ` Brian Skahan
@ 2003-04-10  7:20         ` Christian Lindig
  0 siblings, 0 replies; 11+ messages in thread
From: Christian Lindig @ 2003-04-10  7:20 UTC (permalink / raw)
  To: Caml Mailing List

On Wed, Apr 09, 2003 at 01:24:38PM -0400, Brian Skahan wrote:
> Vim has a similar feature, though I don't think its implemented for
> ocaml at the moment.  It works for mixed php/html, python(psp)/html,
> and jsp/html.

As an example, find below a Vim syntax file for mixing LaTeX and OCaml
in NoWEB documents.  The OCaml code shows up inline like in
[[List.length]] and in named chunks:

<<foo.ml>>=
let f x = x
@

Here, LaTeX is on the outer level, and OCaml code is mixed in. I the
context discussed, OCaml probably would be on the outer level.

It is easy to exchange either LaTeX or OCaml for a different language or
define new delimiters.  However, I found that using Perl instead of
OCaml did not work for some reason. I am not aware of a general
framework for mixing languages in Vim.

" syntax file for vim: ts=8 sw=4 et:
" 
" Language:	NoWEB
" Maintainer:	Christian Lindig <lindig@eecs.harvard.edu>
" Last Change:	Mon Feb  3 21:42:55 CET 2003
" Remark:	Includes tex, ocaml 
"
" A NoWEB file typically uses LaTeX for markup plus a programming
" language. 
" 

runtime! syntax/tex.vim
unlet b:current_syntax

syn include @Noweb     syntax/ocaml.vim     " or any other language
syn region  nowebTT    start="\[\["hs=s+2 end="\]\]"he=e-2 
syn region  nowebName  start="<<" end=">>" oneline contains=nowebTT
syn region  nowebCode  start="^<<.*>>=" end="^@ *$" contains=nowebName, @Noweb

hi def link nowebName String
hi def link nowebTT   Constant
" hi def link nowebCode Special " use, if @Noweb undefined

let b:current_syntax="noweb"

-- Christian

-- 
Christian Lindig         http://www.eecs.harvard.edu/~lindig/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
  2003-04-09 17:03     ` Fred Yankowski
  2003-04-09 17:24       ` Brian Skahan
@ 2003-04-13 14:01       ` Pierre Weis
  1 sibling, 0 replies; 11+ messages in thread
From: Pierre Weis @ 2003-04-13 14:01 UTC (permalink / raw)
  To: Fred Yankowski; +Cc: caml-list

Hi Fred,

[...]
> That said, I now try for a strict separation of imperative code and
> HTML code, so that my HTML template files have no language specific
> code and contain only formal parameters and markings of optional and
> repeated blocks of HTML content.  I haven't used OCaml to generate
> HTML pages, but that's the approach I would want there too.
[...]
> Fred Yankowski      fred@ontosys.com           tel: +1.630.879.1312

That's precisely the simple idea used in htmlc (see
http://pauillac.inria.fr/htmlc/eng.htm): the HTML templates are HTML
files with SSI directives and occurrences of variables to be replaced
by their values. Variable values are defined separately in simple
configuration files; environment specific variables can also occur:
their value is then picked up from the environment.

Normally, those HTML templates are statically compiled while updating
the Web site (thus checking for errors in advance, before serving the
pages). However, htmlc can be called dynamically to produce the answer
to a query.

Htmlc is written in Objective Caml and you're welcome to join the
development team or send enhancement patches; any suggestion is also
warmly welcome.

All the best,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-04-13 14:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-08  7:27 [Caml-list] dynamic HTML pages David Monniaux
2003-04-08  9:19 ` Maxence Guesdon
2003-04-08 11:59 ` Mattias Waldau
2003-04-08 12:28   ` mixing different languages (was: RE: [Caml-list] dynamic HTML pages) David Monniaux
2003-04-09 17:03     ` Fred Yankowski
2003-04-09 17:24       ` Brian Skahan
2003-04-10  7:20         ` Christian Lindig
2003-04-13 14:01       ` Pierre Weis
2003-04-09 18:12     ` Miles Egan
2003-04-09 23:00       ` Jeff Henrikson
2003-04-10  0:19         ` Miles Egan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).