1 line simple cat in Haskell

William Lee Irwin III wli@holomorphy.com
Wed, 13 Nov 2002 03:41:48 -0800


On Wed, Nov 13, 2002 at 03:29:53PM +0900, Ahn Ki-yung wrote:
> If you are steaming with compicated codes, then how about taking a break.
> Let's play with a simple cat.
> \begin{code}
> main = mapM (>>=putChar) getCharS where getCharS = getChar:getCharS
> \end{code}

Why not this?

main = mapM_ (\h -> mapM_ putChar =<< hGetContents h) =<< mapM (flip openFile $ ReadMode) =<< getArgs


Bill