Skip to content

Instantly share code, notes, and snippets.

@ujihisa
Forked from ujihisa/split implementations in Haskell.hs
Created October 10, 2011 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ujihisa/1274512 to your computer and use it in GitHub Desktop.
Save ujihisa/1274512 to your computer and use it in GitHub Desktop.
import qualified Text.Parsec as P
main = do
print $ ", hello, world,!" `split` ", "
t `split` b = case P.parse (split' (P.string b)) "split" t of Right x -> x
split' b = P.anyChar `P.manyTill` (P.eof P.<|> (P.try b >> return ())) `P.manyTill` P.eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment