Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a thought experiment, Get-ChildItem is a poor choice of API. Instead, it should really just be Get<T> <args>

Get<Folder> -path "C:\Users\Me\My Documents"

Would return a match of type <Folder|nil>

similarly

Find<Folder> -path "C:\Users" -match "Me"

Would return a match of type <Folder[]|nil>

or

Find<Any> -path "C:\Users" -match "Me"

Would return a match of type <Any[]|nil> where Any is

File|Folder|DotFile|Symlink

In as few lines I provided a clean API which unfortunately doesn't exist in any one language but rather borrows from multiple languages, <T> representing C# generic types, File|Folder representing an F# union sum type, Any type a la Rust.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: