Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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.

Dawid