
tutufan:
Thanks for your replies. Hoogle is pretty cool--I didn't know about that.
I ended up with this, which is pretty close to the original (it will also bomb if given non-integer input):
import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.Maybe as M
main = do contents <- L.getContents print (sumFile contents) where sumFile = sum . map (fst . M.fromJust . L.readInt) . L.words
One further problem I've encountered: My Haskell program runs under 'runghc', but I get a link error when compiling it (GHC 6.8.2, latest Ubuntu). Any suggestions?
Oh wow, runghc is an interpreter. It is on average about 30x slower than compiled code. To compile, try something like: ghc -O2 --make A.hs And enjoy the native codes. :) -- Don