Haskell Hacking: a journal of Haskell programming

Haskell Hacking has moved => Go here.
2006-12-20

Programming Haskell: argument handling and a complete cat annotations

Just some tidy ups of the previous article, on implementing unix 'cat' in Haskell.

Firstly, several people wrote in to point out the bug in the -b option. Rather than squeezing only blank lines, it would do more of a 'uniq' kind of thing, squeezing all duplicates:

    render Squeeze   = map head. group

Rather than:

    render Squeeze   = map head. groupBy (\x y -> all (all isSpace) [x,y])

Secondly, the complete source is now available via darcs, with a cabal build system.

    $ darcs get http://www.cse.unsw.edu.au/~dons/code/caths
    Copying patch 2 of 2... done!
    Applying patch 2 of 2... done.
    Finished getting.

    $ cd caths
    $ runhaskell Setup.lhs configure --prefix=/home/dons
    $ runhaskell Setup.lhs build
    $ runhaskell Setup.lhs install

And you're done.

Next week

We'll look at writing an SMP-parallel, bytestring-based url checker in Haskell:

    $ urlcheck ph-3-redux.txt                                 
    Found 0 broken links. Checked 4 links (4 unique) in 1 file.
    Search time 0 secs

/home :: /haskell :: permalink :: rss

About

Real World Haskell

RWH Book Cover

Archives

Recommended

Blog Roll

Syndicate