Hi.
I've managed to make a *very* simple wrapper around the xts library for
R into OCaml. (Need to be downloaded from CRAN for OCaml users, but I
expect other wrapping to be fairly similar...). The good, good, good
thing (from my humble point of view) is that all loading is done
statically: Loading the R interpreter is done statically. Loading the
xts library is done statically... etc...
See below.
Hopefully, one may one day consider R to be a statically-typed,
type-inferred, compiled, statistical language, with Lwt-style
multithreading.
:)
yziq...@seldon:~/git/ocamlr-xts$ ocamlbuild xts.cmo
Finished, 1 target (0 cached) in 00:00:00.
+ ocamlfind ocamlc -c -package R.interpreter -o xts.cmo xts.ml
File "xts.ml", line 37, characters 4-9:
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
Finished, 2 targets (0 cached) in 00:00:00.
yziq...@seldon:~/git/ocamlr-xts$ cd _build/; ocaml-batteries
Objective Caml version 3.11.1
_________________________________
| | | |
[| + | | Batteries Included - |
|_______|_|_______________________|
_________________________________
| | | |
| - Type '#help;;' | | + |]
|_______________________|_|_______|
# #require "R.interpreter";;
R interpreter statically loaded.
# #load "xts.cmo";;
xts library statically loaded.
Le chargement a nécessité le package : xts
Le chargement a nécessité le package : zoo
Attachement du package : 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
xts now requires a valid TZ variable to be set
no TZ var is set, setting to TZ=GMT
Printing stuff at "compile-time"... That's ugly, I know...
# R.sexptype Xts.xts;;
- : R.sexptype = R.PromSxp
So we indeed have a function.
# let x = R.eval [Xts.xts];;
val x : R.sexp = <abstr>
We construct a dummy time series...
# R.sexptype x;;
- : R.sexptype = R.RealSxp
#
Cool...
The xts.ml code is essentially:
(* You describe the library, its name and symbols. *)
module Description : R.LibraryDescription = struct
let name = "xts"
let symbols = ["xts"]
end
(* You instatiate the library per se. *)
module Library : R.Library = OCamlR.Require (Description)
(* Then you name the sexps in the same order as the symbols above. *)
let [xts] = Library.root
The OCamlR wrapper and the xts binding are not finished at all, but an
OCaml-R Debian package for 64 bits is available at
http://yziquel.homelinux.org/topos/debian-ocamlr.html
http://yziquel.homelinux.org/topos/debian-repository.html
http://yziquel.homelinux.org/debian/pool/main/o/ocaml-r/
when my laptop's up, wifi working, et ceterae. All in french for now,
and documentation is not up to date... That will come.
OCaml-R itself is hosted here:
https://gna.org/projects/ocaml-r/
--
Guillaume Yziquel
http://yziquel.homelinux.org/
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel