Haskell for reformed perlmongers

Aug 15, 2006 14:09

Do you miss being able to type while (<>) { ... } ? If so, just slap the following in your local handyfunctions library:

import System
import IO
import Monad

perlGetContents :: IO String
perlGetContents = do
args <- getArgs
if (args == []) then getContents
else foldr (liftM2 (++)) (return "") $
map ((hGetContents =<<) . flip openFile ReadMode) args

Now you can do things like:

cat "main = putStr =<< perlGetContents" > cat.hs

:)

UPDATE: Added a linebreak for all those narrow people out there ;)

haskell, hack, code

Previous post Next post
Up