
26 Jan
2005
26 Jan
'05
10:50 a.m.
Malcolm Wallace wrote:
Good point. Ideally, you want to be able to write all FilePath code
polymorphically at type (Path p => p), and have a decent defaulting mechanism available to choose a particular instance at compile time (perhaps conditionally, based on OS platform).
Sadly, in the absence of a better 'default' declaration semantics, we are left having to resolve the ambiguity ourselves, or resort to some other type-system extension, like as you say existentials.
You could define a type in the library using conditional compilation: #ifdef Unix type SystemPath = UnixPath #endif #ifdef Windows type SystemPath = WindowsPath #endif Then you do: let myPath = (emptyPath :: SystemPath) in ... Keean.