Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] recursive modules redux, & interface files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dave Berry <Dave@k...>
Subject: RE: [Caml-list] recursive modules redux, & interface files
To be more general, perhaps specifications could be interleaved with
declarations in modules.  In addition to including entire structures,
this would let you specify the type of a function separately from it's
implementation:

val map: ('a -> 'b) -> 'a list -> 'b list
let rec map f l = 
  match ...

This is one aspect I like about Haskell's syntax.  I find it clearer
than the current:

let rec map (f: 'a -> 'b) (l: 'a list) =
  match ...

I prefer Hendrik's suggestion of explicitly including a signature to the
earlier suggestion of automatically including types from a signature
constraint.  If you automatically include types from a signature
constraint, the signature stops being a constraint, and you might match
signatures that you never intended to.

I assume Hendrik is considering the case where an interface already
exists, and you're writing the implementation.  Another case is where
you're writing a module without an explicit interface, but you want to
constrain just some of the external view.  Using specifications in the
module itself might help here too:

type coleur = Rouge | Vert | Bleu
(both type and implementation exported)

type animal
type animal = Chien | Chat | Oiseau
(only the type is visible outside the module)

I've no idea how easy or hard it would be to incorporate this into
either the semantics or the implementation of the language.  But from a
pragmatic point of view, it seems a relatively clean change.

Dave.


-----Original Message-----
From: Hendrik Tews [mailto:tews@tcs.inf.tu-dresden.de]
Sent: Thursday, March 22, 2001 12:03
To: caml-list@inria.fr
Subject: Re: [Caml-list] recursive modules redux, & interface files

What about changing
include, such that including a signature into a structure
includes all types and all exceptions?

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr