Difference between revisions of "Yhc/Javascript"

From HaskellWiki
< Yhc
Jump to navigation Jump to search
(Added Echo/Unicode and Echo/DOM/CPS demos)
Line 23: Line 23:
 
* Third party code of some "general" purpose works in web browser
 
* Third party code of some "general" purpose works in web browser
 
|- valign="top"
 
|- valign="top"
|'''Tested with:'''||Netscape 7/Linux, MSIE 6.0/Windows 2000, Konqueror 3.5.5/Linux, Opera/Windows<br>
+
|'''Tested with:'''||Netscape 7/Linux, MSIE 6.0/Windows 2000, Konqueror 3.5.5/Linux, Opera/Windows, Firefox/ Mac OS X<br>
 
<small><sup>feel free to add your own combination of browser/os where you got this demo working</sup></small>
 
<small><sup>feel free to add your own combination of browser/os where you got this demo working</sup></small>
 
|- valign="top"
 
|- valign="top"

Revision as of 12:54, 12 April 2007

YCR2JS, a Converter of Yhc Core to Javascript

Table of Contents

  1. Brief Overview
  2. Users Guide
  3. Programmers Guide
  4. Inner Workings
  5. Examples and Demos
Echo
Description: Type any text in the input field provided, and see it echoed right above after Enter is pressed. Just for fun, type any decimal number and see it converted to a Roman number, and vice versa. For more fun, a timer is provided: measure how fast your browser runs Haskell ;)
Features: Lowest possible level of interaction with web browser:
  • Simple monadic framework
  • Wrapping Javascript functions to become Haskell functions
  • Calling Haskell functions from Javascript
  • Access to Javascript (including DOM) objects and properties
  • Handling of Javascript exceptions in Haskell
  • Events handling
  • Third party code of some "general" purpose works in web browser
Tested with: Netscape 7/Linux, MSIE 6.0/Windows 2000, Konqueror 3.5.5/Linux, Opera/Windows, Firefox/ Mac OS X

feel free to add your own combination of browser/os where you got this demo working

Demo URL: http://darcs.haskell.org/yhc/web/jsdemos/Echo.html
Haskell Source: http://darcs.haskell.org/yhc/web/jsdemos/Echo.hs
http://darcs.haskell.org/yhc/web/jsdemos/Roman.hs (C) Malcolm Wallace
Echo/Unicode
Description: Around March 20, 2007, handling of Unicode character properties was added to the Yhc/Javascript runtime. This implementation is based on the Unicode Character Database available from the Unicode Consortium. The database was compiled in Javascript and included in the output web page. This demo program is just recompilation of the same Echo source, but with the new runtime that supports Unicode. The Javascript Unicode Characters Database adds about 70k to the web page size.
Features: Same as in the above demo program. Replacement of functions like toUpper, toLower, isAlpha etc. to direct Javascript implementations affects the timing shown by the program: in some browsers there may be some speedup, in other browsers there may be a slowdown.
Demo URL: http://darcs.haskell.org/yhc/web/jsdemos/EchoUnicode.html
Echo/DOM/CPS
Description: Finally, the DOM framework has been implemented. IDL files provided by the Web Consortium were converted into set of Haskell modules using modified sources of H/Direct, mainly the OMG IDL parser. The DOM framework uses Continuation passing style (CPS) rather than monadic style: this is believed to make adoption of Fudgets easier as they use mainly CPS style in their internals. This demo web page looks similar to the previous Echo demo, and provides the same "functionality". This demo web page also uses unicode-enabled versions of character functions.
Features: Utilization of the type-safe DOM Level1 interface:
  • Demonstration of the CPS style
  • No unsafe direct access to Javascript objects needed: a library is now available
Demo URL: http://darcs.haskell.org/yhc/web/jsdemos/EchoCPS.html
Haskell Source: http://darcs.haskell.org/yhc/web/jsdemos/EchoCPS.hs
http://darcs.haskell.org/yhc/web/jsdemos/Roman.hs (C) Malcolm Wallace


--DimitryGolubovsky 20 March 2007