[Caml-list] ANN: pa_polyrec: syntax for polymorphic recursion

2009-09-28 Thread Jeremy Yallop
I'm pleased to announce the initial release of pa_polyrec, a syntax extension 
for polymorphic recursion in OCaml.


   https://forge.ocamlcore.org/projects/pa-polyrec/

There are several methods for encoding polymorphic-recursive functions in OCaml; 
this extension allows them to be written directly, using a natural syntax.  For 
example, given the following type of perfectly-balanced trees we might wish to 
write a function for summing the leaves.


  type 'a perfect = Zero of 'a | Succ of ('a * 'a) perfect

In standard OCaml such a function can be written as follows:

  let sump f =
(object (o)
method sump : 'a. ('a -> int) -> 'a perfect -> int =
  fun f -> function
   | Zero x -> f x
   | Succ x -> o#sump (fun (a, b) -> f a + f b) x
 end)#sump f

  let sum_perfect = sump id

Using pa_polyrec one can write the function in the following less obfuscated 
style:

  let rec sump : 'a. ('a -> int) -> 'a perfect -> int =
fun f -> function
 | Zero x -> f x
 | Succ x -> sump (fun (a, b) -> f a + f b) x

  let sum_perfect = sump id

Note that the type variable 'a in the type of the function is quantified: this 
is what differentiates polymorphic-recursive functions from standard OCaml 
recursive function definitions.


More complex usage is supported, including mutual recursion.  A number of 
examples are included in the distribution, including several modules from Chris 
Okasaki's thesis "Purely Functional Data Structures" and code from Richard Bird 
and Ross Paterson's paper "de Bruijn notation as a nested datatype".


___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] WGT 2010 Call for Papers

2009-09-28 Thread Workshop on Generative Technologies


[ Apologies for multiple copies of this announcement ]



 FIRST CALL FOR PAPERS

   Second Workshop on Generative Technologies
   WGT 2010

http://wgt2010.elte.hu/

   a satellite event of the
  13th European Joint Conferences on
Theory and Practice of Software
 (ETAPS 2010)
Paphos - Cyprus
March 27, 2010




IMPORTANT DATES

- Submission of full paper: November 23, 2009
- Submission of tool demo paper: November 23, 2009
- Author notification: January 4, 2010
- Final version due: January 18, 2010



SCOPE

Generative programming is an emerging paradigm aimed
at automating important tasks in software development,
compile-time and run-time code transformation, and the creation of
domain-specific languages and flexible libraries. The purpose of the
workshop is to provide a forum for researchers and practitioners working in
this area to discuss
state-of-the-art generative technologies and tools, and
exchange ideas about the future of generative programming.
Papers describing practical applications of generative styles,
and new research directions are expected. Suggested areas of
interest in the workshop include, but are not limited to:

- Generative programming, metaprogramming
- Separation of concerns
- Intentional programming
- Domain engineering and domain analysis
- Product-line architectures
- Feature-based techniques
- Compile-time and run-time code transformation
- Multi-stage languages
- Generic and Active library-development
- Analysis of language support for generative programming
- Semantics, type-systems of generative programs
- Case Studies and Demonstration Cases



PAPER SUBMISSION

RESEARCH PAPERS  (full papers, 8-10 pages) as well as TOOL DEMO PAPERS (up
to 2 pages) should be submitted to
the WGT 2010 organizers in ENTCS format (http://www.entcs.org). Submissions
should be sent by e-mail to w...@aszt.inf.elte.hu.


Further information will be available at the WGT 2010 home page.
At least one author of each accepted submission must register
and present the paper at the workshop.



PROCEEDINGS

After revision, final copies of the accepted papers will be
published in Electronic Notes in Theoretical Computer Science
(ENTCS), Elsevier Science (http://www.entcs.org).



PROGRAM COMMITTEE

- Don Batory University of Texas at Austin (USA)
- Jaakko Järvi   Texas A&M University (USA)
- Julia Lawall   University of Copenhagen (DK)
- Hanspeter Mössenböck   Johannes Kepler University Linz (AT)
- Zoltán PorkolábEotvos Lorand University (HUN)
- Awais Rashid   Lancaster University (UK)
- Joao Saraiva   University of Minho (POR)
- Bran Selic Malina Software Corp (CAN)
- Yannis Smaragdakis University of Massachusetts, Amherst (USA)



ORGANIZING COMMITTEE

- Zoltan Porkolab   Eotvos Lorand University (HUN)
- Norbert PatakiEotvos Lorand University (HUN)
- Zalan Szugyi  Eotvos Lorand University (HUN)

  e-mail: w...@aszt.inf.elte.hu

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] xpath or alternatives

2009-09-28 Thread Till Varoquaux
There are a few projects out here:

xtisp
http://www.xtisp.org

xstream
http://yquem.inria.fr/~frisch/xstream/

and of course the good old cduce/xduce/ocamlduce. All in all naive
querying is not hard and tree automata:

(e.g.) http://www.grappa.univ-lille3.fr/~filiot/tata/

can provide a good middle ground between efficiency and simplicity.
The problem you might run into is that XML is a tricky format to deal
with and some of these tools will choke up on complex files
(namespaces,switching character encoding, weird entities in the DTD
etc..).

Till

P.S.: Alain has a good paper on how to compile queries (as done in
cduce). I am just too lazy to look for it.


On Mon, Sep 28, 2009 at 8:48 AM, Yaron Minsky  wrote:
> I don't have the code in front of me, but I've done something like this
> using the list monad. i.e., using bind (= concat-map) and map chained
> together, along with a couple operators I wrote for lifting bits of XML
> documents into lists, by say returning the subnodes of the present node as a
> list.
>
> It was quite effective.  I got the inspiration from a similar tool we have
> for navigating s-expressions, which we should release at some point...
>
> Yaron Minsky
>
> On Sep 28, 2009, at 8:17 AM, Richard Jones  wrote:
>
>>
>> I need to do some relatively simple extraction of fields from an XML
>> document.  In Perl I would use xpath, very specifically if $xml was an
>> XML document[1] stored as a string, then:
>>
>>   my $p = XML::XPath->new (xml => $xml);
>>   my @disks = $p->findnodes ('//devices/disk/source/@dev');
>>   push (@disks, $p->findnodes ('//devices/disk/source/@file'));
>>
>> This isn't type safe or pretty, but it is very easy to use for quick
>> and dirty extraction.
>>
>> What is the OCaml equivalent for this sort of code?
>>
>> Alain Frisch has a library called Xpath
>> (http://alain.frisch.fr/soft.html#xpath), but unfortunately this
>> relies on the now obsolete wlex program.
>>
>> Is there a completely alternative way to do this?  Better still, in 3
>> lines of code??
>>
>> Rich.
>>
>> [1] for XML doc, see: http://libvirt.org/formatdomain.html
>>
>> --
>> Richard Jones
>> Red Hat
>>
>> ___
>> Caml-list mailing list. Subscription management:
>> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
>> Archives: http://caml.inria.fr
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
> ___
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] xpath or alternatives

2009-09-28 Thread Yaron Minsky
I don't have the code in front of me, but I've done something like  
this using the list monad. i.e., using bind (= concat-map) and map  
chained together, along with a couple operators I wrote for lifting  
bits of XML documents into lists, by say returning the subnodes of the  
present node as a list.


It was quite effective.  I got the inspiration from a similar tool we  
have for navigating s-expressions, which we should release at some  
point...


Yaron Minsky

On Sep 28, 2009, at 8:17 AM, Richard Jones  wrote:



I need to do some relatively simple extraction of fields from an XML
document.  In Perl I would use xpath, very specifically if $xml was an
XML document[1] stored as a string, then:

   my $p = XML::XPath->new (xml => $xml);
   my @disks = $p->findnodes ('//devices/disk/source/@dev');
   push (@disks, $p->findnodes ('//devices/disk/source/@file'));

This isn't type safe or pretty, but it is very easy to use for quick
and dirty extraction.

What is the OCaml equivalent for this sort of code?

Alain Frisch has a library called Xpath
(http://alain.frisch.fr/soft.html#xpath), but unfortunately this
relies on the now obsolete wlex program.

Is there a completely alternative way to do this?  Better still, in 3
lines of code??

Rich.

[1] for XML doc, see: http://libvirt.org/formatdomain.html

--
Richard Jones
Red Hat

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] JIT & HLVM, LLVM

2009-09-28 Thread Gerd Stolpmann

Am Sonntag, den 27.09.2009, 13:35 -0400 schrieb Edgar Friendly:
> Vincent Aravantinos wrote:
> > Hi,
> > 
> > I think what Jon means is that, with JIT, polymorphic functions can be
> > specialized at run-time
> > and allow optimizations that are not currently achieved by the Ocaml
> > native code compiler.
> > 
> > V.
> 
> The alternative to specializing at runtime using JIT is to do it at
> compile time (/ link time) using a form of whole-program analysis.  How
> expensive would this be, and how hard would it be to still support
> separate compilation?
> 
> And how much would the OCaml world cry if we didn't have fully-separate
> compilation? 

We don't have fully separate compilation anyway (in native mode). The
compiler can already dump an intermediate representation of functions
into .cmx files, and can use that for cross-module inlining. This
feature is optional for the user. Of course, it increases the number of
modules that need to be recompiled when something is changed.

If we keep that spirit of giving the user a choice: Of course the "Ocaml
world" would appreciate when the actual code generation can be delayed
in order to gain performance improvements by whole-program analysis.
However, for projects with several 100KLOC the compile time could be
drastically increased, and I don't think users with such large programs
would actually use that feature.

Gerd

>  At the moment, and for the foreseeable future, anything
> binary is bound tightly to the compiler version, and binary distribution
> of modules seems pretty much impossible due to this and unknown other
> factors.  How much easier would the above be given the source code /
> some intermediate representation to generate specialized code with?
> 
> E
> 
> ___
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
-- 

Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany 
g...@gerd-stolpmann.de  http://www.gerd-stolpmann.de
Phone: +49-6151-153855  Fax: +49-6151-997714


___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] xpath or alternatives

2009-09-28 Thread Richard Jones

I need to do some relatively simple extraction of fields from an XML
document.  In Perl I would use xpath, very specifically if $xml was an
XML document[1] stored as a string, then:

my $p = XML::XPath->new (xml => $xml);
my @disks = $p->findnodes ('//devices/disk/source/@dev');
push (@disks, $p->findnodes ('//devices/disk/source/@file'));

This isn't type safe or pretty, but it is very easy to use for quick
and dirty extraction.

What is the OCaml equivalent for this sort of code?

Alain Frisch has a library called Xpath
(http://alain.frisch.fr/soft.html#xpath), but unfortunately this
relies on the now obsolete wlex program.

Is there a completely alternative way to do this?  Better still, in 3
lines of code??

Rich.

[1] for XML doc, see: http://libvirt.org/formatdomain.html

-- 
Richard Jones
Red Hat

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] Re: React.E.switch issue.

2009-09-28 Thread Daniel Bünzli
Sorry I'm travelling in a sparsely connected area. Besides I'm heading
to a region where it seems the internet was closed down by the local
government. If that is still the case I won't be able to respond for
some weeks.

Now quickly two things.

1) It seems to me that you are using events where signals should be
used. Signals should be used to represent "state". Your "accumulating
event" sounds like state to me, use a signal for that.

2) If you really want a primitive event (or signal) to generate new
_primitive_ event occurences (or signal updates), just wrap the call
to the event sending (or signal update) function in a thunk and store
it in a queue, once the update cycle is over dequeue the next thunk
and invoke it. Fixed point operators will in effect perform something
similar but preserve the applicative nature of your program -- however
I think that you are right in your case they won't help.

Now I really suggest you to think hard about 1). I'm sure you can get
a clean solution, something like use S.fold with the (primitive) event
of the server to accumulate the unparsed input and remember the last
parsed message.

Best,

Daniel

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] HLVM...

2009-09-28 Thread Richard Jones
On Sun, Sep 27, 2009 at 03:09:02PM -0700, David McClain wrote:
> ... remember too, in signal and image processing applications,  
> converting to raw machine integers and plowing ahead is often  
> counterproductive.
> 
> Rather we need saturating arithmetic to avoid abrupt transitions on  
> overflow conditions, or modulo addressing. Neither of these is native  
> to SSM, and have to be synthesized. DSP chips on the other hand almost  
> always offer these variations implicitly or explicitly.

Please confine messages about HLVM to one thread, and don't
start a new thread for every message you post.

Rich.

-- 
Richard Jones
Red Hat

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] Pre-processor sub-process

2009-09-28 Thread Olivier Andrieu
Hi,

On Sun, Sep 27, 2009 at 22:58, Matthieu Dubuget
 wrote:
> Hello,
>
> I'm trying to have bin-prot compiled with mingw version of OCaml with
> the original OCamlMakefile.
>
> This fails on my computer.
>
> I reproduced the problem here:
>
> On linux, there is no problem:
>
> On cygwin:
> $ uname
> CYGWIN_NT-5.1
> $ echo $BIN_PROT_CPP
> cpp
> $ echo $pp
> $BIN_PROT_CPP $ARCH_FLAGS
> $ ocamlc -c -verbose -pp "echo $pp && $pp" write_ml.ml
> + echo $BIN_PROT_CPP $ARCH_FLAGS && $BIN_PROT_CPP $ARCH_FLAGS
> "write_ml.ml" > c:\DOCUME~1\matt\LOCALS~1\Temp\camlpp8a6978
> $BIN_PROT_CPP $ARCH_FLAGS
> '$BIN_PROT_CPP' n'est pas reconnu en tant que commande interne
> ou externe, un programme excutable ou un fichier de commandes.
> File "write_ml.ml", line 1, characters 0-1:
> Error: Preprocessor error
>
> It seems that when the pre-processor is called, the environment is not
> given to the sub-process?
>
> Can anybody reproduce this problem (or better: provide a solution), or
> did I something bad?

what ocaml-win32 port are you using exactly ? This looks like the
mingw (or MSVC) port because the error message you get looks like one
from CMD.EXE, the Windows shell. The cygwin port uses cygwin's sh
whereas the mingw/msvc port use cmd.exe.

You'll have to use cmd.exe's syntax for environment variable
expansion: %BIN_PROT_CPP% I believe.

HTH,
-- 
  Olivier

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs