Latest package versions on Hackage as JSONP
Haskell JavaScript
Latest commit a63d5f9 Sep 15, 2012 @sol Remove unnecessary GHC option
Failed to load latest commit information.
example Update documentation Mar 26, 2012
src Use hspec-1.3 Aug 6, 2012
test Remove unnecessary GHC option Sep 15, 2012
.ghci Use standard layout, rename to hackage-jsonp Mar 26, 2012
.gitignore Cabalize Mar 24, 2012
.travis.yml Use hspec-1.3 Aug 6, 2012
LICENSE Cabalize Mar 24, 2012
README.markdown Minor README fix Mar 26, 2012
Setup.lhs Cabalize Mar 24, 2012
hackage-jsonp.cabal Use hspec-1.3 Aug 6, 2012



Parse the Hackage upload log and write the latest version of each package into a JSON/JSONP file.

Up-to-date versions of both JSON and JSONP are repeatedly generated at The JSONP callback is hard-coded to hackagePackageVersionsCallback.


Haskell (aeson/syb)

import           Data.Maybe
import qualified Data.Map as Map
import           Network.URI
import           Network.HTTP
import           Data.Aeson.Generic

url :: String
url = ""

-- | Return latest version of a package.
-- >>> getVersion "hspec"
-- Just "0.9.2"
getVersion :: String -> IO (Maybe String)
getVersion name = do
  r <- simpleHTTP request >>= getResponseBody
  return (decode r >>= Map.lookup name)
    request = (mkRequest GET . fromJust . parseURI) url


JSONP allows a javascript client to relax the same origin policy and retrieve the above JSON by providing the callback function hackagePackageVersionsCallback.


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
      The latest version of hspec is <span id="result">???</span>.
    <script src=""></script>
    <script src="custom.js"></script>


$(document).ready(function() {

  /* fetch latest packages versions, the result will be passed to
   * hackagePackageVersionsCallback(..) */

function hackagePackageVersionsCallback(response) {

  /* output latest version of hspec */
  var version = $(response).attr("hspec");