Download CDuce Programming Language User`s manual
Transcript
are included in the produced toplevel. The -l options give the OCaml units to be linked in (e.g. x.cmx or x.cmxa)(the -p option automatically include the units). In a custom toplevel, the directive #builtins prints the name of embedded OCaml values. 7.7 Examples Getting the value of an environment variable let home = Sys.getenv "home";; Ejecting your CD with CDuce This example demonstrates how to use OCamlSDL library. Sdl.init `None [ `EVERYTHING ];; let cd = Sdlcdrom.cd_open 0;; Sdlcdrom.cd_eject cd;; If you put these lines in a file cdsdl.cd, you can compile and link it with: cduce --compile cdsdl.cd -I `ocamlfind query ocamlsdl` ocamlfind ocamlc -o cdsdl -pp "cdo2ml -static" -impl cdsdl.cdo -package cduce,ocamlsdl -linkpkg \ Accessing MySQL This example demonstrates how to use ocaml-mysql library. let db = Mysql.connect Mysql.defaults;; match Mysql.list_dbs db `None [] with | (`Some,l) -> print [ 'Databases: ' !(string_of l) '\n' ] | `None -> [];; print [ 'Client info: ' !(Mysql.client_info []) '\n' 'Host info: ' !(Mysql.host_info db) '\n' 'Server info: ' !(Mysql.server_info db) '\n' 'Proto info: ' !(string_of (Mysql.proto_info db)) '\n' ];; If you put these lines in a file cdmysql.cd, you can compile and link it with: cduce --compile cdmysql.cd -I `ocamlfind query mysql` ocamlfind ocamlc -o cdmysql -pp "cdo2ml -static" -impl cdmysql.cdo -package cduce,mysql -linkpkg 53 \