1 line simple cat in Haskell

Hal Daume III hdaume@ISI.EDU
Wed, 13 Nov 2002 07:46:41 -0800 (PST)


I'm not sure why someone hasn't suggested

  main = interact id

which I think would accomplis everything you want, and probably be a heck
of a lot faster, as (apparently) putChar and getChar are quire
inefficient.

--
Hal Daume III

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Wed, 13 Nov 2002, William Lee Irwin III wrote:

> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>