3 ms·
Typeclasses to the rescue.. ls :: LsOptions -> IO Listing instance ToString Listing where ... instance Default LsOptions where def = LsOptions []
by joeyh 13y ago
Typeclasses 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.