Reading numbers from a file with lazy ByteString
Here are some notes.


bytestring's documentation clearly states that:



  This module is intended to be imported qualified, to avoid name clashes with Prelude functions. eg.
  
  import qualified Data.ByteString.Lazy.Char8 as C


This lets you unambiguously write map without Prelude qualifier.


There are some properties of map that allow you to write map f . map g as map (f.g).
tups can be rewritten as one-liner with maybe and fst

tups = maybe 0 fst


All of this leads to following code:

import qualified Data.ByteString.Lazy.Char8 as L
main = L.getContents &gt;&gt;= print . sum . map (maybe 0 fst . L.readInt) . L.words