Created
January 24, 2011 16:46
-
-
Save blt/793501 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
import Prelude hiding (words) | |
import Control.Applicative hiding (many) | |
import Data.Attoparsec as P | |
import Data.Attoparsec.Char8 as P8 | |
import Data.ByteString as B | |
import Data.Word | |
civil :: B.ByteString | |
civil = "That government is best which governs least" | |
space_w8 :: Parser Word8 | |
space_w8 = P.satisfy P8.isSpace_w8 <?> "space" | |
skipSpaces :: Parser () | |
skipSpaces = P.satisfy P8.isHorizontalSpace *> | |
P.skipWhile P8.isHorizontalSpace | |
words :: Parser [B.ByteString] | |
words = many $ skipSpaces *> P.takeTill P8.isSpace_w8 <* P8.char8 ' ' | |
main :: IO () | |
main = do | |
parseTest words civil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to parse
civil
into a list of words; instead I getEh?