News for hackers. Stuff that matters.
Re:Hell: A Haskell Shell by peq on Friday November 22, 2013 @01:25PM (#6782654)
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.
Re:Hell: A Haskell Shell by joeyh on Friday November 22, 2013 @02:38PM (#6783214)
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.