| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.DocL.Javascript
Rationale
This is basically a JSON encoding library, however it goes beyond JSON by allowing raw javascript to be used as a value. This allows, for instance, function calls and anonymous functions to be placed in the data when used in a javascript context. This is needed to expose some options in C3.js, e.g. customizing tick formatting.
The Obj type
Represents a javascript object or scalar value.
Class of types that can be converted to an Obj.
Minimal complete definition
Methods
Converts to an Obj.
toObjList :: [a] -> Obj Source
Only for writing instances. This function serves the same role as
showList
Instances
Constructing javascript types
(/:) :: ToObj a => String -> a -> Prop Source
Constructs a Prop.
>>>toObj ["tail" /: True, "nose" /: "wet"]{"nose":"wet","tail":true}
javascript :: String -> Obj Source
Raw unescaped javascript.
>>>toObj ["speak" /: javascript "function(){alert('Woof!');}"]{"speak":function(){alert('Woof!');}}