Entries
1 Oct 2007
Updated Nice titles
Back in 2003, Stuart Langridge popularized what became known as “Nice Titles”. In essence they consist in a bit of javascript code that displays fancy hovering boxes on top of links, as can be seen here.
Nice titles have became hugely popular, and many people proposed variants. I will mention those of Dunstan Orchard and Mark Wubben. This entry presents yet another implementation, with some features found only in some of the above versions, and some entirely new. I've also corrected what I believed to be bugs.
What's in this version?
- The nicetitles follow the mouse.
- The size of the nicetitles is not fixed. This avoids some overflow problems when their content is too big.
- The nicetitles do not go outside of the window, and they try moderately hard not to appear on top of the mouse cursor.
- The nicetitles appear after a little delay (and e.g.
‘sup’
tags inside the text of the anchors do not cause delays). - Nicetitles can be used to display image thumbnails. Currently,
‘img’
tags with the‘thumb’
class automatically receive thumbnails; see the photographs on the right. - The code is modular and hides the functions that should not be redefined by other javascript modules.
- The code is thoroughly tested under various versions of Gecko, Internet Explorer (versions 6 and 7), Opera (versions 8 and 9), Konqueror and Safari 3 (for Windows).
The source code is available, as a
plain
.js
file or
pretty-printed.
You also need to add inside the file an implementation of
the addEvent
function that correctly handles the scopes
for the ‘this’
keyword. I currently use
Justin Diaz's
version.
Finally, the
css
stylesheet I use on this site can be used as an example to format
the nicetitles boxes.
I am interested to hear about any problem encountered while using this code. My mail can be found on this page, should you wish to contact me.
Updates:
- 2007-10: fixed a bug in Safari
10 Sep 2006
ICFP Programming Contest 2006 - Untyped raytracers and polymorphic variants
Alain Frisch has created a webpage about our participation to the 2006 ICFP programming contest. This year's problems were quite varied, and my main contribution was to solve the raytracer subproblem.
The raytracer had to be written in a langage where functions are 2D boxes composed of wires. Those wires link atomic boxes that themselves perform operations of construction and deconstruction on completely untyped objects. I wrote an ML solution to the problem (this was in itself non-trivial), and we compiled it into a 2D function using code written by Alain and Nicolas.
The main peculiarity of my solution is that it is typed, even though it dutifully follows the untyped representation of the specification. I used polymorphic variants, which enabled me to define the type (for example) of ray-tracing values or of lists as subtypes of the generic value type.
type value = [ | `Unit | `Pair of value * value | `Inl of value | `Inr of value ] type valrt = [ `Inl of u | `Inr of [ `Inl of u | `Inr of [`Inl of u]]] type 'a vlist = [ `Inl of [`Pair of 'a * 'b] | `Inr of [`Unit] ] as 'b
The full solution is available, as
a ml
file or as
a pretty-printed html
page.
More details on the rest of our submission can be found on
our team's page.
28 Oct 2005
Replacing applications by let constructs in OCaml
In ML-based languages, the construction let x = e in e'
is equivalent, at execution-time, to (fun x -> e') e
.
However this property does not hold during type-checking: the
let
construct permits to generalize the type variables
which are free in the environment; this way, more polymorphism can be
introduced.
Consequently, it is potentially helpful to replace all applications by
let
bindings. In OCaml, this can be done automatically by Camlp4 (this
patch is intended for OCaml 3.09; otherwise, change _loc
to
loc
).
To compile a cmo
usable as a parser by Camlp4, use
ocamlc -I +camlp4 -pp "camlp4r pa_extend.cmo q_MLast.cmo" -c pa_o_let_extend.ml
.
You can create an extended Camlp4 executable by using
mkcamlp4 -o $(CAMLP4LET) pa_o.cmo pa_o_let_extend.cmo pr_o.cmo
(for a Camlp4 accepting the original syntax as input).
Thanks to Daniel de Rauglaudre and Michel Mauny, who have been instrumental in helping me write this extension.
25 Sep 2004
ICFP Programming Contest 2004
As we guessed (we were warned in advance that we had won a prize, and the performances of our ants seemed too low to win one of the first two prizes), we have won the Judge's Prize of the ICFP Programming Contest 2004. As expected, we received the prize thanks to the design of our intermediate language (the ultimate goal was to compile ant brains) ; the compiler was mainly due to Xavier Leroy, with additions from Damien Doligez and myself.
A full webpage for our submission is now available, thanks to Yann.