Skip to content

sshine/hs-jq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hs-jq

jq is a command-line JSON processor. It is also a domain-specific combinator language, which makes it easy to analyse and optimize. This project aims to reimplement jq in Haskell, mostly because it's fun.

Check it out

There is currently no executable. To see the tests that pass you can:

$ git clone https://github.com/sshine/hs-jq.git
$ cd hs-jq
$ stack test

You can also experiment with the parser manually using GHCi:

$ stack ghci
> parseExpr "def map(f): [ .[] | f ]; map(.foo)"
Right (FuncDef "map" [FilterParam "f"]
        (List [Pipe (ValueIterator Identity) (FilterCall "f" Nothing)])
        (FilterCall "map" (Just [DotField "foo"])))

Why?

  • I think jq is a really cool domain-specific language, but I'm really bad at it.

    Maybe if I write an interpreter for it, I will become better at it.

  • This implementation will

    • confirm that the original jq implementation works as intended.
    • document the original jq syntax as documented in JBOL.
    • prototype improvements to jq, such as syntax-preserving arithmetic, arbitrary-size numbers, fusion of combinators, and linting.
  • Writing property-based tests in Haskell is a lot more convenient than doing so in C. This will give me an opportunity to experiment with Hedgehog.

  • It would be really cool if you could transform Aeson Values using a quasi-quoter. This would give me a chance to explore how quasi-quoters work in Haskell.

    slugs :: Value -> Either JqError Value
    slugs = [jq| .exercises | map(.slug) |]

Comparable projects

Status

Parser: 72 out of 653 tests failed.

Contributing

If you like this project, or if you're looking for an opportunity to practice writing open source Haskell, feel free to open an issue or a PR, or send me an email. A good starting point could be to look through issues labelled "help wanted".

In connection to Hacktoberfest 2019 I received 9 PRs. Thanks a bunch, guys!

About

🪲 Implementing jq in Haskell

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published