4 ms·
I think most Unix commands have a function type which is not representable in haskell, if you don't want to fall back to strings everywhere. So you end up with
by peq 13y ago
I think most Unix commands have a function type which is not representable in haskell, if you don't want to fall back to strings everywhere. So you end up with many functions like ls and ls'. For a shell I prefer a dynamically typed language.
- joeyh 13y agoTypeclasses to the rescue.. ls :: LsOptions -> IO Listing instance ToString Listing where ... instance Default LsOptions where def = LsOptions [] Now a single `ls` function can yield regular textual output, or the more specific Listing type can be used if you want to say, map over the files listed. toString <$> ls def map toUpper . filesListed <$> ls def The repl can automate the application of toString of course, so the user can just enter `ls def`. Someone better at this than I could probably find a way to make the def parameter be optional, too.