Version française
Home     About     Download     Resources     Contact us    
Browse thread
Functional unparsing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hezekiah M. Carty <hcarty@a...>
Subject: Re: [Caml-list] Functional unparsing
On Wed, Apr 15, 2009 at 4:41 PM, Andrey Riabushenko <cdome@bk.ru> wrote:
> Something like that:
>
> Stats.linear_regression "y ~ x1 exp(x2) log(x3) x3^2"
> Returns float -> float -> float -> float -> regression_result = <fun>
...
> 2. The second question regarding function unparsing. I haven't used this
> technique before. Are there some docs, blog articles, descriptions and etc?
> The only relevant documentation I have found is printf.ml :). Might someone
> have a minimal working example to demonstrate?

The Batteries Print module and associated syntax extension may be a
useful base for implementing something similar to what you are
proposing:

http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=batteries/batteries.git;a=blob_plain;f=src/core/extlib/print.ml;hb=HEAD
and
http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=batteries/batteries.git;a=tree;f=src/syntax/pa_strings;hb=HEAD

This allows for syntax like:
Print.printf p"This is a list of integers: %{int list}"
to return:
int list -> unit = <fun>

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science