Fast combinator parsing for bytestrings and text

Version on this page:
LTS Haskell 9.13:
Stackage Nightly 2017-11-18:
Latest on Hackage:
BSD3 licensed and maintained by Bryan O'Sullivan

Module documentation for

There are no documented modules for this package.

Welcome to attoparsec

attoparsec is a fast Haskell parser combinator library, aimed particularly at dealing efficiently with network protocols and complicated text/binary file formats.

Join in!

I'm happy to receive bug reports, fixes, documentation enhancements, and other improvements.

Please report bugs via the github issue tracker.

Master git repository:

  • git clone git://


This library is written and maintained by Bryan O'Sullivan, .


  • runScanner now correctly returns the final state (
  • Parser, ZeptoT, Buffer, and More now expose Semigroup instances.
  • Parser, and ZeptoT now expose MonadFail instances.

  • Restore the fast specialised character set implementation for Text
  • Move testsuite from test-framework to tasty
  • Performance optimization of takeWhile and takeWhile1

  • Fixed a bug in the implementations of inClass and notInClass for Text (

  • Made the parser type in the Zepto module a monad transformer (needed by aeson's string unescaping parser).

  • Fixed a case folding bug in the ByteString version of stringCI.

  • Fixed an indexing bug in the new Text implementation of string, reported by Michel Boucey.

  • Fixed a case where the string parser would consume an unnecessary amount of input before failing a match, when it could bail much earlier (

  • Added more context to error messages (

  • Fixed incorrect tracking of Text lengths (

  • Fixed the incorrect tracking of capacity if the initial buffer was empty (

  • Fixed a data corruption bug that occurred under some circumstances if a buffer grew after prompting for more input (

  • Now compatible with GHC 7.9

  • Reintroduced the Chunk class, used by the parsers package

  • A new internal representation makes almost all real-world parsers faster, sometimes by big margins. For example, parsing JSON data with aeson is now up to 70% faster. These performance improvements also come with reduced memory consumption and some new capabilities.

  • The new match combinator gives both the result of a parse and the input that it matched.

  • The test suite has doubled in size. This made it possible to switch to the new internal representation with a decent degree of confidence that everything was more or less working.

  • The benchmark suite now contains a small family of benchmarks taken from real-world uses of attoparsec.

  • A few types that ought to have been private now are.

  • A few obsolete modules and functions have been marked as deprecated. They will be removed from the next major release.

  • New function scientific is compatible with rational, but parses integers more efficiently (

  • The new Chunk typeclass allows for some code sharing with Ed Kmett's parsers package:

  • New function runScanner generalises scan to return the final state of the scanner as well as the input consumed.

  • New dependency: the scientific package. This allows us to parse numbers much more efficiently.

  • peekWord8', peekChar': new primitive parsers that allow single-character lookahead.

Used by 646 packages:
3dmodels, abnf, ace, aeson, aeson-attoparsec, aeson-bson, AesonBson, aeson-compat, aeson-extra, aeson-native, aeson-pretty, aeson-qq, aeson-quick, aeson-schema, aeson-streams, aeson-utils, airship, amazonka-core, api-tools, apotiki, arx, ascii-vector-avc, attic-schedule, AttoBencode, AttoJson, atto-lisp, attoparsec-arff, attoparsec-binary, attoparsec-csv, attoparsec-data, attoparsec-enumerator, attoparsec-expr, attoparsec-ip, attoparsec-iso8601, attoparsec-iteratee, attoparsec-parsec, attoparsec-path, attoparsec-text, attoparsec-time, attoparsec-trans, attoparsec-uri, attosplit, authenticate, authinfo-hs, avers, avwx, awesomium, aws, aws-dynamodb-streams, aws-general, azure-acs, azure-servicebus, banwords, battleships, beeminder-api, bencoding, betacode, bgmax, BiobaseBlast, BiobaseInfernal, BiobaseNewick, biohazard, biostockholm, bitcoin-rpc, boolean-like, borel, buildwrapper, bytestring-conversion, bytestring-from, bytestring-time, cab, cake3, campfire, cases, cassava, Cassava, cassy, cayley-client, chesshs, chronos, cisco-spark-api, cjk, clash-lib, clckwrks, clckwrks-plugin-bugs, clckwrks-plugin-ircbot, clckwrks-plugin-mailinglist, clckwrks-plugin-media, clckwrks-plugin-page, clogparse, codec-rpm, Combinatorrent, comma, conduit-extra, conduit-find, conduit-tokenize-attoparsec, configuration-tools, configurator, configurator-ng, confsolve, couchdb-conduit, couchdb-enumerator, couch-hs, couch-simple, country, cpuinfo, credentials-cli, cron, cron-compat, crypto-pubkey-openssh, crypt-sha512, css-syntax, css-text, csv-conduit, csv-enumerator, CurryDB, cypher, damnpacket, danibot, darcs, darcs-fastconvert, data-named, datasets, dataurl, d-bus, delimited-text, dhcp-lease-parser, dictionaries, diff-parse, dingo-core, dns, doccheck, dockercook, domain-auth, dot-linker, dsmc, dtd, dtd-text, duckling, dustme, email-header, emailparse, email-postmark, email-validate, engine-io, engine-io-wai, env-parser, ersatz, ert, esotericbot, expressions, ez-couch, factual-api, fasta, fastirc, FastxPipe, fb, fibon, file-templates, find-conduit, fit, fixedwidth-hs, fixhs, float-binstring, foldl-transduce-attoparsec, follow-file, fpco-api, frontmatter, ftp-client, gcodehs, gender, generic-aeson, ghcjs-base-stub, ghc-prof, ghc-time-alloc-prof, git-object, glabrous, gli, glirc, gogol-core, googleplus, gopher-proxy, gpx-conduit, graphql, graphql-api, groundhog, groundhog-postgresql, hack2-handler-mongrel2-http, hackage-diff, hackage-server, hadoop-formats, hadoop-rpc, hadoop-tools, haiji, hamtsolo, haskdeep, haskell-gi, haskell-tor, hasmin, hasql, hasql-postgres, hats, hbeanstalk, hchesslib, hdbc-postgresql-hstore, HDBC-postgresql-hstore, hdbi, hdbi-postgresql, heavy-logger, hedn, heist, hgithub, himpy, hirt, hit, hMollom, hnormalise, HongoDB, hoodle-core, hoodle-extra, hoodle-parser, hoodle-publish, hOpenPGP, hopenpgp-tools, hops, hosc-json, hostname-validate, hosts-server, hp2any-core, hp2pretty, hpdft, hRESP, hruby, hsbc, hsdev, hsimport, hslogger-reader, hslogstash, HSmarty, hsnsq, hsoz, hspec-attoparsec, hs-pkpass, hsrelp, hstorchat, hstradeking, html-email-validate, html-entities, html-parse, html-tokenizer, http-api-data, http-attoparsec, http-date, http-enumerator, http-grammar, http-link-header, http-pony-serve-wai, http-pony-transformer-http, http-pony-transformer-startline, https-everywhere-rules, http-streams, HulkImport, hweblib, hw-json, hw-json-lens, hworker, hw-parser, hw-succinct, hw-xml, hyperpublic, ib-api, ical, ide-backend, ide-backend-common, ihttp, imap, influxdb, ini, inject, inserts, io-streams, io-streams-haproxy, ip, IPv6Addr, IPv6DB, irc, irc-bytestring, irc-core, irc-dcc, iterIO, jenkinsPlugins2nix, jmacro-rpc, jobqueue, jose, jose-jwt, jsaddle, JSONb, JSON-Combinator, jsonextfilter, json-fu, JsonGrammar, json-incremental-decoder, json-pointer, json-rpc, jsonrpc-conduit, jsonsql, json-togo, json-tools, jsontsv, jsonxlsx, karver, keenser, keter, kevin, kit, laika, lambdiff, language-openscad, language-puppet, legion-discovery, legion-extra, leksah-server, lens-aeson, libjenkins, libmpd, librato, libstackexchange, lio-simple, liquid, liquid-fixpoint, list-t-attoparsec, llvm-hs, llvm-hs-pure, llvm-tools, lmonad-yesod, lss, ltext, luachunk, macbeth-lib, magicbane, mailchimp, makefile, mangopay, markdown, markdown-kate, marquise, matrix-market-attoparsec, memcache-conduit, memcache-haskell, meminfo, merge-bash-history, microformats2-parser, microlens-aeson, midi-simple, moesocks, mole, mongrel2-handler, mqtt, mqtt-hs, mtgoxapi, multiaddr, multihash, MutationOrder, mysql-simple, mystem, nagios-perfdata, namecoin-update, NaturalLanguageAlphabets, nc-indicators, ndjson-conduit, neko-obfs, nested-routes, netpbm, network-anonymous-i2p, network-anonymous-tor, network-api-support, network-attoparsec, network-bitcoin, network-pgi, neural, ngrams-loader, nix-derivation, notmuch-web, ntrip-client, NXTDSL, oidc-client, openpgp-asciiarmor, open-symbology, optparse-applicative-simple, organize-imports, orgmode-parse, orgstat, osc, ot, PageIO, pandoc-citeproc, parco-attoparsec, parse-help, parsers, pcd-loader, pcre-utils, pdf-toolbox-content, pdf-toolbox-core, persistent, persistent-audit, persistent-mongoDB, persistent-parser, persistent-redis, persistent-zookeeper, pg, pgsql-simple, pg-store, pgstream, pianola, ping-parser-attoparsec, ping-wrapper, pipes-aeson, pipes-attoparsec, pipes-attoparsec-streaming, pipes-fastx, pipes-files, planar-graph, playlists, playlists-http, plot-light, ply-loader, pontarius-xmpp, positron, postgresql-query, postgresql-simple, postgresql-simple-bind, postgresql-typed, postie, postmark, postmark-streams, processor-creative-kit, proc-net, procstat, project-m36, proto-lens, pseudo-boolean, push-notify-ccs, python-pickle, qif, quack, QuasiText, QuickPlot, quickson, Quickson, raft, rakhana, rdf, readme-lhs, redis-io, redis-resp, rei, relapse, replicant, resolve, rethinkdb, rethinkdb-wereHamster, riak, ripple, ripple-federation, rison, robots-txt, romkan, roshask, rosmsg, route-generator, rtorrent-rpc, sarsi, scalable-server, scanner-attoparsec, scholdoc-citeproc, scion-browser, scp-streams, scrape-changes, second-transfer, semver, seqloc, seqloc-datafiles, serf, servant, servant-auth-hmac, servant-client, servant-haxl-client, servant-server, servant-snap, servant-subscriber, sexp, shopify, simple, SimpleLog, simple-templates, simple-text-format, sindre, siphon, skeleton, skylighting, skype4hs, skypelogexport, sloane, smallcaps, smtlib2-pipe, smtp-mail-ng, smtps-gmail, snap, snap-core, snap-cors, snap-language, snaplet-auth-acid, snaplet-sqlite-simple-jwt-auth, snaplet-wordpress, snap-predicates, snap-server, socketio, socket-io, sourcemap, space, Spintax, sproxy, sqlite-simple, sscgi, sssp, stack, stackage-sandbox, stash, STL, stompl, stomp-queue, streaming-osm, streaming-utils, strelka, string-random, stutter, substring-parser, subtitleParser, SVGFonts, svg-tree, svm-light-utils, svndump, swagger-test, swearjure, syntax-attoparsec, syntax-example, syntax-example-json, system-info, system-linux-proc, system-locale, tablize, taggy, tag-stream, tagstream-conduit, tai64, tamarin-prover-term, task, teleshell, templater, tensorflow, terminfo-hs, texrunner, text-ldap, text-regex-replace, text-time, th-printf, thrift, thyme, time-exts, time-http, timeparsers, timerep, time-warp, tinyMesh, tiphys, tkyprof, tnet, toml, toysolver, trajectory, tremulous-query, tsvsql, twentefp-websockets, twill, twitter-conduit, twitter-enumerator, unicoder, uniform-io, units-attoparsec, unjson, uploadcare, uri-bytestring, uri-parse, URLb, usb-hid, utc, vado, vaultaire-common, vcf, vgrep, vigilance, wai-app-file-cgi, wai-cors, wai-handler-devel, wai-predicates, wai-routing, waldo, warc, wavefront, WaveFront, wavefront-obj, wcwidth, weather-api, web3, webcrank, webdriver, webdriver-snoy, websockets, wikicfp-scraper, wobsurv, WordAlignment, wreq, wreq-sb, xcffib, xlsior, xml2json, xml-conduit, xml-enumerator, xournal-parser, xsd, xss-sanitize, yahoo-finance-conduit, yaml, yate, yesod-bin, yesod-csp, yesod-datatables, yesod-form, yesod-routes-flow, yesod-routes-typescript, yesod-static, yesod-test, yi-core, yi-keymap-vim, yxdb-utils, zre
comments powered byDisqus