On Sat, Sep 18, 2010 at 11:47 PM, Jeremy Shaw <[email protected]> wrote: > A RESTful API with JSON results sounds perfect. I will be surprised if the > API useful for 3rd party sites happens to map on to the URL structure used > by the main site. But if that works, all the better :) > > Of course, if your site which is creating the JSON is written in Haskell, > and my site which is using it is written in Haskell, then it would be nice > if I could somehow benefit from the haskell type checker telling me that you > have changed your JSON a bit. > > In some small experimental RESTful-ish sites a I have made I tend to make > the return values of the API be an algrebraic data type that all the API > functions return. Then I have functions like SiteRetVal -> JSON, SiteRetVal > -> XML, etc, which makes it easy to convert the output to whatever format > the client wants. With a system like that, it is possible to have the > SiteRetVal be in it's own hackage library. Your site and my site would both > depend on that package. Then when you change the API return values, I get a > new version of that library to type-check against... Not sure how > valuable/feasible it is in practice though. I have only developed a > prototype far enough to determine that it *can* be done. Whether it *should* > be done remains to be seen.
There's one better: in addition to providing JSON output, I could provide the output of the default Show typeclass (call the mimetype x-text/haskell-show?), and then you can just use a readMay on your end. Still using the intermediate package idea. > Also, there maybe be some issues with using the accept header. In theory, > you may someday provide XML (in addition to JSON). But I think that some > browsers list xml has a higher preference than html. So then normal browser > users will start getting xml instead of html? I don't think any browsers list text/xml by default, rather application/xhtml+xml, though I could be wrong. > Anyway, the basic idea of a simple RESTful API with JSON is exactly what I > was hoping for. The rest is implementation details, which I don't care much > about as long as it works. I definitely do not want to turn this into a > design by committee project. > > Also, once the site is 'done', it would be nice to hirer a graphic designer > to give it a nice, clean, professional look. Of course, if we want to make this an enterprise project, we would do the graphic design by committee. "I think blue is a nice color" "Yes, but isn't that excluding the 50.23% of our target audience that's female?" "Do women not like blue?" "Let's take a vote, all in favor of women not liking blue?" ... "OK, so as not be gender specific, we'll use a black background with mauve text." Sounds like a good idea to me. Michael _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
