solvuu / phat

Strongly typed file path and file system operations.
ISC License
27 stars 4 forks source link

Filesys.exists: improve return type #7

Closed agarwal closed 8 years ago

agarwal commented 8 years ago

Filesys.exists currently returns `No if the path exists but as a different type of object, e.g:

utop # Path.dir_path "/usr" |> ok_exn |> Filesys.exists;;
- : [ `No | `Unknown | `Yes ] = `Yes

utop # Path.file_path "/usr" |> ok_exn |> Filesys.exists;;
- : [ `No | `Unknown | `Yes ] = `No

The latter is misleading. One is likely to think the path doesn't exist at all. We should probably include an additional return type: `Yes_as_other_object to mean the path does exist but not as the type of object you were checking for.

agarwal commented 8 years ago

Or perhaps we should define exists and exists_any. The first one cares about the object type, and the second doesn't.

agarwal commented 8 years ago

The function now definitely requires documentation. Once added, I can close this issue.

pveber commented 8 years ago

Done!