Re: [Caml-list] New Ocaml Plug-in for NetBeans

2008-09-02 Thread Maxence Guesdon
On Wed, 27 Aug 2008 23:24:38 +0300
kirillkh [EMAIL PROTECTED] wrote:

 Hi,
 
 Sorry for a late reply. This line caught my attention:
 
 - Chamo uses .annot files to display type information (Alt-t),
 
 
 - Can Chamo infer and display type of an arbitrary expression in the source
 code?
 - Does it work for user-created types (which, supposedly, don't have .annot
 files)?
 - Is it tolerant to erroneous/incomplete code?

Chamo uses .annot files produced by the compiler when the -dtypes is
specified. If the expression has a type indicated in the .annot file, than
it is displayed, else no indication is displayed. If the source file has
been modified after the .annot file was created, then a message indicate
that the current .annot file is obsolete and must be updated by compiling
again. This is the same behaviour as under emacs.

Regards,

-- 
Maxence Guesdon   http://yquem.inria.fr/~guesdon/
Service Expérimentation et Développements https://devel.inria.fr/rocq/
INRIA Paris-Rocquencourt  http://www.inria.fr/rocquencourt/



___
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] `This expression is not a function it cannot be applied'

2008-09-02 Thread Christian Sternagel
Is there a way to be able to apply something of an abstract data type 
without knowing the internal representation?


E.g., when having the module
module Parser : sig
 type ('a,'tok) t
 val token : ('tok - 'a option) - ('a,'tok) t
end = struct
 type ('a,'tok) t = 'tok list - ('a * 'tok list)
 let token ... = ...
end

I want to be able to apply the result of (token (function Ident s - 
Some s | None)) to some further input (since it is a parser), however, 
this is not possible since the result type is not functional.


The only way out I see is to `unabstract' the type and give its internal 
representation. Or is there another possibility?


cheers

christian


___
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] `This expression is not a function it cannot be applied'

2008-09-02 Thread David Baelde
You can provide your own application function, as follows.

On Tue, Sep 2, 2008 at 10:00 AM, Christian Sternagel
[EMAIL PROTECTED] wrote:
 E.g., when having the module
 module Parser : sig
  type ('a,'tok) t
  val token : ('tok - 'a option) - ('a,'tok) t
  val apply : ('a,'tok) t - 'tok list - ('a * 'tok list)
 end = [...]

This amouns to provide a cast from the abstract type to the function
type, while keeping the liberty on how it's implemented.

Cheers,
--
David

___
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] `This expression is not a function it cannot be applied'

2008-09-02 Thread David Teller
Or you can use ExtLib's enumerations for the purpose of abstraction.
That's what I'm doing in my parser combinator library.

Cheers,
 David


On Tue, 2008-09-02 at 10:34 +0200, blue storm wrote:
 On Tue, Sep 2, 2008 at 10:26 AM, David Baelde [EMAIL PROTECTED] wrote:
  This amouns to provide a cast from the abstract type to the function
  type, while keeping the liberty on how it's implemented.
 
 If you want even more implementation liberty, you should consider
 making the internal token collection type abstract : you use a list
 for now, but might want to use Streams or lazy lists or what not
 someday.
 
 That would give something like that :
 module Parser : sig
   type ('a,'tok) t
   type 'tok input
   val token : ('tok - 'a option) - ('a,'tok) t
   val apply : ('a,'tok) t - 'tok input - ('a * 'tok input)
   val input_of_list : 'tok list - 'tok input
 end = [...]
 
 ___
 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
 
-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings 
liquidations. 

___
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] Two questions on OCamlDoc

2008-09-02 Thread David Teller
And while I'm asking complex questions, can anyone think of a way of
asking OCamlDoc to resolve [string] to [String.t], ['a list] to ['a
List.t], ['a array] to ['a Array.t], etc?

Thanks,
 David

On Tue, 2008-09-02 at 13:47 +0200, David Teller wrote:
 Hi everyone,
 
  I'm currently toying with OCamlDoc, with very little success. I'm
 attempting to do two things:
 * getting OCamlDoc to understand that some modules (which I can modify)
 contain the documentation for some other modules (which I can't) replace
 some modules with others
 * inlining the documentation for modules in modules which import those.
 
 I need a little help.
 
 Let me detail this.
 
 *** Documentation replacement ***
 My project uses modules M_lib1, M_lib2... which come from a variety of
 libraries. For each of these modules, I have created  a module
 M_lib1_with_doc, M_lib2_with_doc, which imports the corresponding
 library module but tailors the documentation to my project. However, for
 technical reasons of mechanical generation, assuming that M_lib1 refers
 to M_lib2, M_lib1_with_doc still refers to M_lib2 instead of referring
 to M_lib2_with_doc. Consequently, when generating the documentation of
 M_lib1_with_doc, ocamldoc doesn't link the generated pages to the
 documentation of M_lib2_with_doc but rather attempts to link it to
 M_lib2 (and fails, as expected).
 
 Now, I could rework the mechanical generation of my modules and in time,
 I will. However, for the moment, I'm looking for a purely OCamlDoc-based
 solution. I'd like to be able to ask OCamlDoc to please consider every
 reference to M_lib2 as actually meaning a reference to M_lib2_with_doc.
 
 I have tried to override method [text#html_of_Ref], without much
 success. Is there a simple solution for this?
 
 *** Inlining modules ***
 I have a few modules whose sole role is to include one or two existing
 modules. By default, when meeting [include], OCamlDoc, ocamldoc only
 generates a link from the container module to the inlined module. In
 this case, I'd rather want the whole documentation of each of these
 modules to be inlined.
 
 Is that possible?
 
 Thanks in advance,
  David
 
-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings 
liquidations. 

___
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] Two questions on OCamlDoc

2008-09-02 Thread Maxence Guesdon
On Tue, 02 Sep 2008 13:47:08 +0200
David Teller [EMAIL PROTECTED] wrote:

  Hi everyone,

Hello,

  I'm currently toying with OCamlDoc, with very little success. I'm
 attempting to do two things:
 * getting OCamlDoc to understand that some modules (which I can modify)
 contain the documentation for some other modules (which I can't) replace
 some modules with others
 * inlining the documentation for modules in modules which import those.
 
 I need a little help.
 
 Let me detail this.
 
 *** Documentation replacement ***
 My project uses modules M_lib1, M_lib2... which come from a variety of
 libraries. For each of these modules, I have created  a module
 M_lib1_with_doc, M_lib2_with_doc, which imports the corresponding
 library module but tailors the documentation to my project. However, for
 technical reasons of mechanical generation, assuming that M_lib1 refers
 to M_lib2, M_lib1_with_doc still refers to M_lib2 instead of referring
 to M_lib2_with_doc. Consequently, when generating the documentation of
 M_lib1_with_doc, ocamldoc doesn't link the generated pages to the
 documentation of M_lib2_with_doc but rather attempts to link it to
 M_lib2 (and fails, as expected).
 
 Now, I could rework the mechanical generation of my modules and in time,
 I will. However, for the moment, I'm looking for a purely OCamlDoc-based
 solution. I'd like to be able to ask OCamlDoc to please consider every
 reference to M_lib2 as actually meaning a reference to M_lib2_with_doc.
 
 I have tried to override method [text#html_of_Ref], without much
 success. Is there a simple solution for this?

A simple way (but not always possible, due to name clashes) would be to
use some script to perform string substitution in generated html files; in
your example, replacing all M_lib2 by M_lib2_with_doc. you could indeed
try to do this by overriding the method html_of_Ref. What problem do you
encounter ?

Another way would be to use some cat commands to create new
..._with_doc.ml files, compile them and use your ..._with_doc.mli as
documented interface.

 *** Inlining modules ***
 I have a few modules whose sole role is to include one or two existing
 modules. By default, when meeting [include], OCamlDoc, ocamldoc only
 generates a link from the container module to the inlined module. In
 this case, I'd rather want the whole documentation of each of these
 modules to be inlined. 

 Is that possible?

May be. You could try to override the method html_of_module_element so that,
when you encounter a Element_included_module, you search the real module by
its name and print its elements instead of just include 

Does this help ?

Regards,

Maxence


-- 
Maxence Guesdon   http://yquem.inria.fr/~guesdon/
Service Expérimentation et Développements https://devel.inria.fr/rocq/
INRIA Paris-Rocquencourt  http://www.inria.fr/rocquencourt/



___
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] Two questions on OCamlDoc

2008-09-02 Thread Maxence Guesdon
On Tue, 02 Sep 2008 14:05:31 +0200
David Teller [EMAIL PROTECTED] wrote:

 And while I'm asking complex questions, can anyone think of a way of
 asking OCamlDoc to resolve [string] to [String.t], ['a list] to ['a
 List.t], ['a array] to ['a Array.t], etc?

Maybe raw string substitution ?

Hacking in the internal representation of types to change their names way
work but it's currently out of my abilities.

Regards,

Maxence

-- 
Maxence Guesdon   http://yquem.inria.fr/~guesdon/
Service Expérimentation et Développements https://devel.inria.fr/rocq/
INRIA Paris-Rocquencourt  http://www.inria.fr/rocquencourt/



___
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] Another question on OcamlDoc

2008-09-02 Thread David Teller
According to the documentation, ocamlfind can manage that.

Cheers,
 David

On Tue, 2008-09-02 at 14:48 +0200, Jan Kybic wrote:
- how can I tell OcamlDoc to run a preprocessor on the file first?
  (I am using ocaml+twt)

-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings 
liquidations. 

___
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] 'open' on objects?

2008-09-02 Thread Peng Zang
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tuesday 02 September 2008 03:03:28 pm Chris Clearwater wrote:
 Is it possible to create an object by extending another object?

 I'd like to do something like this:

 ...
 object
   open (an_object:class_type)
   ...
 end
 ...

The short answer is I think you can only extend classes (through inheritance).  
I don't think you can extend an object (eg. add methods to an object).

Peng
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFIvaFZfIRcEFL/JewRAvcSAKDOTE2+niYho6tTHbhI4h7h3L5K0wCfdXti
LM7dnZLJTrGnCcQoh5M6tCU=
=KBtf
-END PGP SIGNATURE-

___
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] on polymorphic compare and objects

2008-09-02 Thread Peng Zang
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I recently came across a post on Janest lamenting the perils of polymorphic 
compare.

  http://ocaml.janestcapital.com/?q=comment/reply/33

They make a great point, and I thought of a solution that has worked well for 
me in the past few months that I would like to share, in part, to solicit 
feedback from the community.

Here is my approach.  It is, in part, excerpted from a conversation with Brain 
Hurt and also posted on the Janest blog.  As warning, my approach does use 
some magic and OCaml guts but no more than what is made available for OCaml/C 
interface.  It is also mostly hidden once done.

- 

The (compare) function has the signature ('a - 'a - bool).  That means it is 
a function that imposes a total ordering for *all* types -- even those that 
have not yet been defined. Clearly, it cannot be the desired ordering for all 
(and future) types.  If OCaml had a content equality function (ie. two 
things are equal if they can be used
interchangably in pure functions) it would have a similar problem.

It is my opinion that this approach is really just for convenience and
performance reasons.  The right solution would use something like
type classes or go with Java's object based solution (eg. Comparable
interface).

Here's my solution to this.  I modify the (compare) and other similar 
functions to check for objects and use its appropriate method if available.  
In otherwords, if you call compare on a (int,int) tuple, it has OCaml's 
standard behavior.  But if you call compare on a [int,int] tuple class, it 
will use the class' compare method.  This hybrids
between OCaml's polymorphic solution and the Java, method-dispatch solution.

One might also think of it as a hook.  If the user defines some type that has
unique comparison behavior he/she can do so by wrapping the type in a class
and specifying the unique behavior via the compare method.  This means the
rest of the code never needs to know and use special compare functions.  It
can always use compare, knowing that it will automatically do the right
thing.

In this way (compare) and (content-equals) can actually be well defined for
all (including future) types.  Let's take as an example, the content-equals
function which I'll just call equal for now.  (equal) has a very specific
semantic meaning: it returns true if its two arguments are exchangable in a
pure context (ie. no side-effects).  (equal) is well defined for all simple
types: int, float, string, etc..  For objects, we require that all objects
implement an equal method that satisfies the semantic contract.  Thus (equal)
the function is also well defined on objects.  For all other types, whatever
they may be, either the default structural comparison behavior of (equal)
satisfies the semantic contract or it does not.  If it does, then (equal) is
well defined.  If it does not, we require it to be wrapped in an object so
that an appropriate behavior can be specified.

As a concrete example consider:

  type xycoord = (int, int)

As it happens, structural equality is what we want.  Since (equal) already
does this we are done.

Now consider:

  type rational_number = (int, int)

Here, structural equality is not what we want.  (1/2) is the same rational
number as (2/4) but they are not structurally equal.  Thus in order to satisfy
the semantic contract of (equal) we must instead do:

  class type rational_number = object
method equal : rational_number - bool
...
  end


Meanwhile, a function like List.assoc, but defined using (equal), works
equally well on both types.

This approach lets you keep the OCaml approach of a polymorphic compare/equal
function, but does not limit you to a single algorithm for performing the 
comparison.  It buys you the power of objects (much like that of type 
classes) but without the requirement that everything be an object.  I have 
found it to be a sweet spot and use it in my code regularly.

- 


As always, I welcome any comments, suggestions, questions or flames =]


Peng
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFIvcevfIRcEFL/JewRAqQaAJ485qiwtMKy5W9dJbIvNzklH/DZ3wCfQlR6
UrtMhcho4xm4mII2Depv+vs=
=HZ9F
-END PGP SIGNATURE-

___
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] Mailing list archive for August

2008-09-02 Thread Erik de Castro Lopo
Maxence Guesdon wrote:

 Erik de Castro Lopo wrote:

  I was browsing the Ocaml mailing list archive when I noticed that
  the archive for August was missing:
  
  http://caml.inria.fr/pub/ml-archives/caml-list/
  
  Is that intentional or is something messed up?
 
 Sorry for the late answer. This should be fixed now.

It is. Thanks.

The other issue with the archives is that the dates seem really messed
up. For instance, in the page:

   http://caml.inria.fr/pub/ml-archives/caml-list/

It says:

39801 messages archived
from NaN-NaN-NaN (NaN:NaN) to NaN-NaN-NaN (NaN:NaN)
archive updated NaN-NaN-NaN (NaN:NaN) 

And on individual messages like this one:


http://caml.inria.fr/pub/ml-archives/caml-list/2008/09/f2734d8ac036565f65c7c15f27a7cc70.en.html

it has:

Date:   NaN-NaN-NaN (NaN:NaN) 

Obviously, something is way wrong with date calculations.

Erik
-- 
-
Erik de Castro Lopo
-
An older MS internal whitepaper from August 2000 on switching
Hotmail, which MS acquired in 1997, from front-end servers
running FreeBSD and back-end database servers running Solaris
to a whole farm running Win2K, reads like a veritable sales
brochure for UNIX
-- http://www.theregister.co.uk/content/4/28226.html

___
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