Git Product home page Git Product logo

haskell-soda's Introduction

haskell-soda

This library provides Haskell bindings for the Socrata Open Data API (SODA).

Introduction

Disclaimer: This is not an official library from Socrata. There currently aren't any official Haskell bindings for SODA (or any other unofficial ones that I'm aware of), but if you want to use the official bindings for another programming language, you can find a list of them at the SODA documentation page for Libraries & SDKs.

The main benefit to using this library, besides being able to make calls to SODA natively in Haskell, is that it gives strong compile-time guarantees that your query is both syntactically and semantically correct, which makes this library unique among the other language bindings for SODA. The structure of the functions assures that syntactic rules, like balanced parenthesis and SODA functions having the right amount of input parameters, are never violated. It also gives semantic guarantees because all of the SoQL query datatypes have been encoded into the types that this library uses, and are used with all values, columns, and SODA functions. This will prevent things like $where=location = 3 + 'Foo' from ever being constructed without even having to deal with runtime exception handling.

The library currently requires more boilerplate than I would have liked, but you at least get the benefits mentioned above in exchange. If you're making queries as part of a hobby project, then this might not be the library you want to use, and you could probably get away with just simply constructing URL strings. However, if you need a higher degree of confidence that your query will be correctly constructed, then this library might be helpful. It might also be helpful if you are writing a lot of code that creates SODA queries from combinations of smaller parts, rather than using long, static/hardcoded queries. I'm also looking for ways to reduce the boilerplate, but there isn't a specific plan of how to do that yet. You can currently reduce some of the boilerplate with utility functions such as those I describe in the tips section of the documentation.

These bindings are currently designed for version 2.1 of SODA. The library also currently only contains functionality for consumer/query related API calls; It doesn't have any functionality for the publishing side of the API. However, if there's demand for it, then that could be in the plans for the future.

This library is still very new, so the design might fluctuate a bit initially and it will probably be a while until it is ready for use in any sort of production environment. Getting to production quality could be sped up with some help, though! I'm still pretty new to creating larger projects with Haskell, so any suggestions, submitted issues, or pull requests are more than welcome.

The following is a short example of a SODA call for the URL https://data.ct.gov/resource/y6p2-px98.json?category=Fruit&item=Peaches

category = Column "category" :: Column SodaText
item     = Column "item"     :: Column SodaText

response = getSodaResponse Nothing "data.ct.gov" "y6p2-px98" $
    emptyQuery { filters = Just [ category $= SodaVal "Fruit", item $= SodaVal "Peaches"] }

Documentation

The documentation for the library is located in the docs directory. You can also view the Haddock documentation for more info. The official documentation for the API itself is located at the Socrata website.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.