<commit_before><commit_msg>Update from Hackage at 2021-12-11T23:50:49Z<commit_after>homepage: https://github.com/jlagarespo/parse#readme
changelog-type: markdown
hash: 70c79d151d9b41ab808b2650d29c455e5c272591de2fc08bf060e1cd18405ecd
test-bench-deps:
  base: '>=4.7 && <5'
  parse: -any
  tasty-hunit: ==0.10.0.3
  tasty: ==1.4.2
maintainer: <EMAIL>
synopsis: Simple way to parse strings with Python-like format strings.
changelog: |
  # Changelog for parse

  ## 0.1.0.0 - First version
  That's it, enjoy.
basic-deps:
  split: ==0.2.3.4
  base: '>=4.7 && <5'
  template-haskell: ==2.16.0.0
all-versions:
- 0.1.0.0
author: <NAME>
latest: 0.1.0.0
description-type: markdown
description: |
  # parse
  Haskell, while notorious for its extremely powerful [parser combinators
  library](https://hackage.haskell.org/package/parsec), lacks a quick-and-dirty way to parse
  simple-formatted strings in a one-liner. This is especially frustrating for [Advent of
  Code](https://adventofcode.com/), where the input to [some
  puzzles](https://adventofcode.com/2021/day/5), which is in other languages fairly painless to parse,
  requires some overly convoluted, hacky and noncompact solution.

  Envious of Python's [parse](https://pypi.org/project/parse/) package, I decided to write my own,
  very stripped down version, in Haskell. This package provides a way to create a sort of template for
  how strings should look, and then parse them accodringly. While inspired by Python format strings,
  the type of each field is not specified in the string itself, and as a matter of fact, if the
  compiler can't guess them by their use, they must be specified explicitly (like in the example.)

  Examples:
  ```hs
  parse "It's {}, I love it!" "It's spam, I love it!" :: String
   == "spam"

  parse "{} + {} = {}" "2.1568743 + 7.196057 = 9.3529313" :: (String, String, String)
   == ("2.1568743","7.196057","9.3529313")
  ```

  A safe variant of `parse` is also provided, that returns `Maybe` instead of throwing an error:
  ```hs
  parse "{} * {} = {}" "2 + 3 = 5" :: (String, String, String)
  *** Exception: No candidates for "" in "2 + 3 = 5".

  -- Whereas:
  parseMaybe "{} * {} = {}" "2 + 3 = 5" :: Maybe (String, String, String)
   == Nothing
  ```

  You can also parse lists quite easily:
  ```hs
  map read $ parseList "{}, {}, {}, {}, {}, {}, {}, {}, {}, {}" "1, 2, 3, 5, 7, 11, 13, 17, 19, 23" :: [Int]
   == [1,2,3,5,7,11,13,17,19,23]
  ```
  (Note: You're still parsing a fixed amount of values, but now you can, as shown in the example, map
  stuff to it.)

  It should be noted that this package lacks most of the features supplied by
  [parse](https://pypi.org/project/parse/), instead providing only basic parsing functionality. This
  may or may not change in the future.
license-name: BSD-3-Clause
{'fraction_non_alphanumeric': 0.1423487544483986, 'fraction_numerical': 0.06441281138790035, 'mean_word_length': 3.740303541315346, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1321151', 'n_tokens_mistral': 1069, 'n_tokens_neox': 945, 'n_words': 333}