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

Browse thread
Fine-grained types with more general library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-10 (19:07)
From: Dawid Toton <dawid.toton@u...>
Subject: Fine-grained types with more general library
I have a type (e.g. of path to file)

type path = string list

 and many operations (e.g. path manipulation). Then I need to have two 
kinds of paths (e.g. local and remote) and want type system to enforce 
proper usage (some functions act on remote paths only etc.). So I create 
new two types:

type remote_t = Remote path
type local_t = Local path

Then I avoid using type path for greater safety. But I have a problem: 
can't use path manipulation library on these new types. I have created 
"mirror" versions of the library for each new type, but this made my 
source code unmaintainable. What is the right solution?

I'd prefer not to contaminate the path library with things specific to 
this particular problem, since it's reused.