[Haskell-cafe] develop new Haskell shell?

Donn Cave donn at drizzle.com
Thu May 11 20:48:54 EDT 2006

On Thu, 11 May 2006, Brian Hulley wrote:
> -- catenate all files in a specified directory
> catenate outputFile dir = withDir dir $
>                                             ls >>= cat outputFile

So, you would apply this like
     catenate "result" "/etc/stuff"  ?  String literals need quotes?

> Of course the above could no doubt be improved but surely it is already far 
> easier to understand and much more powerful than the idiosyncratic text 
> based approach used in UNIX shells (including rc).

(cd /etc/stuff; cat * > result)


> renif extFrom extTo fileName =
>         case split fileName of
>              (n, ext) | ext == extFrom -> rename fileName (unsplit (n, extTo))
>              _ -> return ()
> %    ls >>= mapM_ (renif "txt" "hs")

$  for a in *.txt; do mv $a $(basename $a .txt); done

?  Not saying the UNIX shell is a rich and well structured programming
environment, and maybe FP is a good direction for that problem.  But
don't underestimate it, the principles behind it are sharp, and while
I think you could expect to win on complex data structures, you can't
afford to lose on simple commands, because that's where most of the
action is.

Hm.  Not to pick at the details too much, but you know "cat" is
actually a standard UNIX command, that writes to standard output
and has no output file parameter?  What's up with the new parameter
in your version - was it not going to be workable the way it was?

	Donn Cave, donn at drizzle.com

More information about the Haskell-Cafe mailing list