Skip to content

Instantly share code, notes, and snippets.

@igrep
Created October 20, 2012 11:36
Show Gist options
  • Select an option

  • Save igrep/3923075 to your computer and use it in GitHub Desktop.

Select an option

Save igrep/3923075 to your computer and use it in GitHub Desktop.
import qualified Data.Text.IO as TIO (hGetLine)
import Data.Text (Text)
import qualified Data.Text as T
import System.IO
import Control.Applicative ((<$>), (<*>), pure)
hGetLines :: Handle -> IO [Text]
hGetLines h = do
eof <- hIsEOF h
if eof
then pure []
else (:) <$> TIO.hGetLine h <*> hGetLines h
main :: IO ()
main =
hGetLines stdin >>= mapM_ (putStrLn . show . T.length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment