User: Password:
|
|
Subscribe / Log in / New account

Attn: Development Editor, Latest Caml Weekly News

From:  "Alan Schmitt" <alan.schmitt-AT-polytechnique.org>
To:  lwn <lwn-AT-lwn.net>, cwn <cwn-AT-lists.idyll.org>
Subject:  Attn: Development Editor, Latest Caml Weekly News
Date:  Tue, 24 Jan 2012 17:26:31 +0100
Message-ID:  <F2B5AD88-E7C0-43E4-946B-B886232EDF64@polytechnique.org>
Archive-link:  Article

Hello,

Here is the latest Caml Weekly News, for the week of January 17 to 24, 
2012.

1) otags reloaded 3.12.1 for OCaml 3.12.1
2) ounit v1.1.1: Unit testing framework
3) polymorphic variants in match statements
4) Other Caml News

========================================================================
1) otags reloaded 3.12.1 for OCaml 3.12.1
Archive: 
<https://sympa-roc.inria.fr/wws/arc/caml-list/2012-01/msg0...>
------------------------------------------------------------------------
** Hendrik Tews announced:

better late than never: I would like to announce the first
release of otags reloaded for OCaml 3.12. It is available at

     <http://askra.de/software/otags/>

Otags reloaded generates tags tables for emacs and vi/vim.

Note that otags (by default) refuses to compile with OCaml
3.12.0, because that version contains a bug that makes otags
quite unusable.

Otags reloaded is distributed under GPL v3.

========================================================================
2) ounit v1.1.1: Unit testing framework
Archive: 
<https://sympa-roc.inria.fr/wws/arc/caml-list/2012-01/msg0...>
------------------------------------------------------------------------
** Sylvain Le Gall announced:

OUnit is a unit testing framework for OCaml, inspired by the JUnit tool 
for
Java, and the HUnit tool for Haskell.

More information on [HUnit](<http://hunit.sourceforge.net>)

In version 1.1.1:

- bracket now enforce returning unit
- update examples
- ListSimpleMake now use the provided comparator for all elements

This version is already available on oasis-db (and can be installed 
through
odb):
<http://oasis.ocamlcore.org/dev/view/ounit/1.1.1>

Homepage:
<http://ounit.forge.ocamlcore.org>

Get source code:
$ darcs get <http://darcs.ocamlcore.org/repos/ounit>

Browse source code:
<http://darcs.ocamlcore.org/cgi-bin/darcsweb.cgi?r=ounit;a...>

========================================================================
3) polymorphic variants in match statements
Archive: 
<https://sympa-roc.inria.fr/wws/arc/caml-list/2012-01/msg0...>
------------------------------------------------------------------------
** Milan Stanojevi? asked and Jacques Garrigue replied:

> Hi, we're trying to understand the type inference with polymorphic
> variants in match statements. This is a simplification of an actual
> case that happened in practice.
>
> 1)
> let f i a =
> match i, a with
> | true, `A -> `B
> | false, x -> x
>
> fails with
> File "foo.ml", line 4, characters 16-17:
> Error: This expression has type [< `A ]
>     but an expression was expected of type [> `B ]
>     The first variant type does not allow tag(s) `B
>
> 2) changing false to _
> let f i a =
> match i, a with
> | true, `A -> `B
> | _, x -> x
>
> this succeeds with
> val f : bool -> ([> `A | `B ] as 'a) -> 'a
>
> 3) changing x in (1) to _ , and using a on the right side
> let f i a =
> match i, a with
> | true, `A -> `B
> | false, _ -> a
>
> this fails in the same way as (1)
>
> 4) finally adding another case to match statement
> let f i a =
> match i, a with
> | true, `A -> `B
> | false, x -> x
> | true, x -> x
>
> this succeeds with the same type as (2)
>
>
> So it seems there is some interaction between type inference and
> exhaustivnest of the match statements.
>
> Can someone shed some light on what is going on here?

Indeed. The basic idea is to close variant types when leaving them
open would make the pattern matching non-exhaustive.
Here, if we assume that a has type [`A | `B], then the pattern-matching
becomes non-exhaustive, so the type inferred is just [`A]
(i.e. the list of all constructors appearing inside the patterns at this
position).

Actually, the theory is a bit more complicated, and the full details are
in the following paper, but you should just expect the above behavior
in practice.

         Typing deep pattern-matching in presence of polymorphic 
variants.
         <http://www.math.nagoya-u.ac.jp/~garrigue/papers/index.html>

Note that there is also another way to make (1) type, without adding
new cases

   let f i a =
     match i, a with
     | true, `A -> `B
     | false, (`A as x) -> x;;
   val f : bool -> [< `A ] -> [> `A | `B ] = <fun>

Here we have removed the connection between a and the output,
allowing `A to be combine with `B without changing the type of a.

========================================================================
4) Other Caml News
------------------------------------------------------------------------
** From the ocamlcore planet blog:

Thanks to Alp Mestan, we now include in the Caml Weekly News the links 
to the
recent posts from the ocamlcore planet blog at 
<http://planet.ocamlcore.org/>.

libsndfile:
   <https://forge.ocamlcore.org/projects/libsndfile/>

OCaml Submodule Pattern:
   <http://www.nicollet.net/2012/01/ocaml-submodule-pattern/>

OUnit 1.1.1:
   <http://caml.inria.fr/cgi-bin/hump.cgi?contrib=293>

Otags 3.12.1:
   <http://caml.inria.fr/cgi-bin/hump.cgi?contrib=294>

A puzzle about typing:
   <http://math.andrej.com/2012/01/20/a-puzzle-about-typing/>

Happy new year from the Ocsigen team:
   <http://ocsigen.org/>

1D integration:
   <https://forge.ocamlcore.org/projects/integration1d/>

Share your mistakes: adventures in optimization:
   
<http://blog.incubaid.com/2012/01/17/share-your-mistakes-a...>

========================================================================
Old cwn
------------------------------------------------------------------------

If you happen to miss a CWN, you can send me a message
(alan.schmitt@polytechnique.org) and I'll mail it to you, or go take a 
look at
the archive (<http://alan.petitepomme.net/cwn/>) or the RSS feed of the
archives (<http://alan.petitepomme.net/cwn/cwn.rss>). If you also wish
to receive it every week by mail, you may subscribe online at
<http://lists.idyll.org/listinfo/caml-news-weekly/> .

========================================================================


(Log in to post comments)


Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds