Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

Browse thread
Is this interface a good idea?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-20 (06:53)
From: Alain Frisch <frisch@c...>
Subject: Re: "ocaml_beginners"::[] Is this interface a good idea?
On Mon, 20 May 2002, Matt Armstrong wrote:

> As my first "real" OCaml module, I want to produce a filename module
> that will type the different kinds of filename components and only
> allow me to combine them in the correct way. E.g.

You can try with an interface like:

type directory
type file
type absolute
type relative
type ('a,'b) path

val concat: ('a, directory) path -> (relative, 'b) path -> ('a,'b) path
val parse_relative_dir : string -> (relative,directory) path
...

and the implementation:

type directory
type file
type absolute
type relative
type ('a,'b) path = string

let concat = (^)
...


The interface should make it possible to build only values of type
('a,'b) path when 'a = relative or absolute and 'b = directory or file.


-- Alain