I am fairly new to Haskell and I'm just starting to learn how to work with attoparsec for parsing huge chunks of english text from a .txt file. I know how to get the number of words in a .txt file without using attoparsec, but I'm kinda stuck with attoparsec. When I run my code below, on let's say

"Hello World, I am Elliot Anderson.

And I'm Mr.Robot.

"

I only get back:

World, I am Elliot Anderson.

And I'm Mr.Robot.

" (Prose {word = "Hello"})

This is my current code:

{-# LANGUAGE OverloadedStrings #-} import Control.Exception (catch, SomeException) import System.Environment (getArgs) import Data.Attoparsec.Text import qualified Data.Text.IO as Txt import Data.Char import Control.Applicative ((<*>), (*>), (<$>), (<|>), pure) {- This is how I would usually get the length of the list of words in a .txt file normally. countWords :: String -> Int countWords input = sum $ map (length.words) (lines input) -} data Prose = Prose { word :: String } deriving Show prose :: Parser Prose prose = do word <- many' $ letter return $ Prose word main :: IO() main = do input <- Txt.readFile "small.txt" print $ parse prose input

Also how can I get the integer count of words, later on? Furthermore any suggestions on how to get started with attoparsec?