manual and tutorial online !

Date

After a bit of struggling I managed to convert the Cduce manual and tutorial in a drupal friendly format that I then imported for editing.

In the process I discovered that cduce does not handle cdata sections and is also not able to print xml that is not well-formed. Regarding the first problem, I plan to implement this feature shortly. Chatting with Alain, this can either be done by writing a printing function to flag to the xml printer that a string is actually a cdata section, or by adding a new type to type cdata section properly. I’m more inclined for he second solution and I’ll start working on it soon.

Regarding the second problem, this limitation make cduce less flexible than other solutions to handle xml, but at the same time is perfectly reasonable considering that cduce is a strongly typed language. However I think that adding a flag to the xml printer to output not well formed xml can be an handy feature to have.

At the end of the day I’ve resorted to write a simple xslt stylesheet to do the conversion (attached) and I’ll blog shortly about one small thing I didn’t know about xsl.

In the process I’ve also fixed a small bug in a drupal module.

The manual and tutorial are available here: http://web-cduce.pps.jussieu.fr/~abate/cduce-manual http://web-cduce.pps.jussieu.fr/~abate/cduce-tutorial

I’ll use these copies to update the documentation and eventually convert everything back to the original format.

This is the live tracker : http://web-cduce.pps.jussieu.fr/~abate/booktracker


Unit testing for Cduce

Date Tags cduce

I’ve written a small unit testing suite for cduce using the OUnit library (http://www.xs4all.nl/~mmzeeman/ocaml/ounit-doc/OUnit.html)

Everything is in my dacrs repo waiting for integration: http://web-cduce.pps.jussieu.fr/cgi-bin/darcsweb.cgi?r=cduce;a=summary

I wrote only a handful of tests. This is the main cduce program:

let t1 (s : Latin1) ( t : OUnit.test )    : OUnit.test = (`TestLabel, s, t)
let t2 (s : Latin1) ( f : `nil -> `nil )  : OUnit.test = (`TestLabel, s, (`TestCase, f))
let t3 (s : Latin1) ( l : [OUnit.test*] ) : OUnit.test = (`TestLabel, s, (`TestList, l))

let compare (a : Any) (b : Any) : Bool = a = b

type t = ( `A, Int )

let ae_t      = OUnit.assert_equal with { t } [compare] [] []

let ae_string = OUnit.assert_equal  with { Latin1   } [compare] [] []
let ae_int    = OUnit.assert_equal  with { Caml_int } [compare] [] []
let ae_bool   = OUnit.assert_equal  with { Bool }     [compare] [] []
let ae_Int    = OUnit.assert_equal  with { Int }      [compare] [] []
let ae_float  = OUnit.assert_equal  with { Float }    [compare] [] []
let ae_char   = OUnit.assert_equal  with { Char }     [compare] [] []

let test_funs     ( _ : `nil ) : `nil = ae_Int 45 funs.a

let test_scalar : OUnit.test =
    let factres =
        93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
    in
    let test1 ( _ : `nil ) : `nil = ae_Int factres (scalars.facto 100)
    in
    let test2 ( _ : `nil ) : `nil = ae_Int 10 (scalars.abs -10) in
    let test3 ( _ : `nil ) : `nil = ae_Int 10 (scalars.wrap 100) in
    let test4 ( _ : `nil ) : `nil = ae_Int 10 (scalars.exp_wrap 100) in
    let test5 ( _ : `nil ) : `nil =
        try let _ = (scalars.exp_wrap 101) in raise "Failure"
        with _ -> `nil
    in
    let test6 ( _ : `nil ) : `nil = ae_Int 35 (scalars.eval (`add, 10,
    (`add, 20, 5))) in
    let test7 ( _ : `nil ) : `nil = ae_bool `true (scalars.interval_unicode 'a')
    in
    let test8 ( _ : `nil ) : `nil = ae_bool `false (scalars.interval_unicode 'z')
    in
    let test9 ( _ : `nil ) : `nil = ae_Int 97 (scalars.ic 'a') in
    let test10 ( _ : `nil ) : `nil = ae_char 'a' (scalars.ci 97) in
    let test11 ( _ : `nil ) : `nil =
        namespace ns1 = "A" in
        ae_bool `true (compare `ns1:B scalars.atom) in
    let test12 ( _ : `nil ) : `nil = ae_bool `true (compare [ "A" 'B' ]
    scalars.split) in
    t3 "Test Scalars" [
        (t2 "facto"  test1)
        (t2 "abs"  test2)
        (t2 "wrap"  test3)
        (t2 "exception wrap positive"  test4)
        (t2 "exception wrap negative"  test5)
        (t2 "expr eval negative"  test6)
        (t2 "interval unicode positive"  test7)
        (t2 "interval unicode negative"  test8)
        (t2 "int of char"  test9)
        (t2 "char of int"  test10)
        (t2 "atom"  test11)
        (t2 "split"  test12)
]

let test_operators : OUnit.test =
    let test1 ( _ : `nil ) : `nil =
        ae_bool `true (compare [ 1 2 3 4 ] (operators.seq [1 2] [3 4]))
    in
    let test2 ( _ : `nil ) : `nil = ae_bool `true (operators.neq 1 2) in
    let test3 ( _ : `nil ) : `nil = ae_bool `true notes.load_notes in

    t3 "Test Built-in Operators" [
        (t2 "Sequence"  test1)
        (t2 "neq"  test2)
        (t2 "load_xml"  test3)
    ]


let suite : OUnit.test = t3 "Cduce test suite" [
    test_scalar
    test_operators
]

let _ = OUnit.run_test_tt_main suite

Automatic Ocaml Types for Cduce

Date Tags cduce

A minor limitation of cduce is that all ocaml types must be declared in cduce. This is cumbersome when trying to use an ocaml library from cduce.

I’ve created a small patch to cduce to allow to use ocaml types directly in a cduce program.

The patch is available in my personal darcs repository and pending to be integrated in the main tree.

The repository is here: http://web-cduce.pps.jussieu.fr/cgi-bin/darcsweb.cgi

and the patch http://web-cduce.pps.jussieu.fr/cgi-bin/darcsweb.cgi?r=cduce;a=commit;h=20070621141511-6a509-90fe027988c1d5f12efe21e9cfd7a826aa5a5527.gz

and the tree can be retrived via darcs with

darcs get http://web-cduce.pps.jussieu.fr/darcs/cduce

New server for cduce.org

Date

I’ve migrated the cduce website to a new server located at paris 7 / chevaleret. Everything should work as before. I’ve also migrated the cduce code from cvs to svn.

The online repository is at

http://web-cduce.pps.jussieu.fr/cgi-bin/viewcvs.cgi/?root=svn

Since we’re still in a transition phase, at the moment access to the snv repository is restricted to developers only.


Patch to mod-caml

I’ve done a bit of work to use http://merjis.com/developers/mod_caml|mod-caml with apache 2.2 . I’ve uploaded everything on the debian gforge website http://alioth.debian.org/projects/pkg-ocaml-maint/|alioth.

to recompile the package you can get it via svn

 svn co svn://svn.debian.org/svn/pkg-ocaml-maint/trunk/packages/mod-caml

Then you can compile the package with svn-buildpackage.

I’ve also wrote a small patch to recursively load dependent modules. I attached a simple loader module that is partially a rip-off of some GPL code I found on the net.