haste-compiler- Haskell To ECMAScript compiler

Safe HaskellNone



Haste-specific JSON library. JSON is common enough that it's a good idea to create as fast and small an implementation as possible. To that end, the parser is implemented entirely in Javascript, and works with any browser that supports JSON.parse; IE does this from version 8 and up, and everyone else has done it since just about forever.



data JSON Source


Num !Double 
Str !JSString 
Bool !Bool 
Arr ![JSON] 
Dict ![(JSString, JSON)] 


Num JSON Source

This instance may be a bad idea, but it's nice to be able to create JSON objects using plain numeric literals.

Show JSON Source 
IsString JSON Source 
JSType JSON Source 
Serialize JSON Source 

toObject :: JSON -> JSAny Source

Create a JavaScript object from a JSON object. Only makes sense in a browser context, obviously.

(!) :: JSON -> JSString -> JSON infixl 5 Source

Look up a JSON object from a JSON dictionary. Panics if the dictionary isn't a dictionary, or if it doesn't contain the given key.

(~>) :: JSONLookup a => a -> JSString -> Maybe JSON infixl 5 Source

Look up a key in a JSON dictionary. Return Nothing if the key can't be found for some reason.