Personal tools

Yhc/Javascript

From HaskellWiki

< Yhc(Difference between revisions)
Jump to: navigation, search
(Added Echo/Unicode and Echo/DOM/CPS demos)
Line 32: Line 32:
 
|'''Echo/Unicode'''
 
|'''Echo/Unicode'''
 
|- valign="top"
 
|- valign="top"
|'''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 [http://www.unicode.org Unicode Consortium]. The database was compiled in Javascript and included in the output web page. This demo program is just recompilation of the same source, but with the new runtime that supports 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 [http://www.unicode.org 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.
 
|- valign="top"
 
|- valign="top"
 
|'''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.
 
|'''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.
 
|- valign="top"
 
|- valign="top"
 
|'''Demo URL:'''||http://darcs.haskell.org/yhc/web/jsdemos/EchoUnicode.html
 
|'''Demo URL:'''||http://darcs.haskell.org/yhc/web/jsdemos/EchoUnicode.html
  +
|-
  +
|'''Echo/DOM/CPS'''
  +
|- valign="top"
  +
|'''Description:'''||Finally, the DOM framework has been implemented. IDL files provided by the [http://www.w3.org Web Consortium] were converted into set of Haskell modules using modified sources of [http://haskell.org/hdirect 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 [http://www.md.chalmers.se/Cs/Research/Functional/Fudgets 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.
  +
|- valign="top"
  +
|'''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
  +
|- valign="top"
  +
|'''Demo URL:'''||http://darcs.haskell.org/yhc/web/jsdemos/EchoCPS.html
  +
|- valign="top"
  +
|'''Haskell Source:'''||http://darcs.haskell.org/yhc/web/jsdemos/EchoCPS.hs<br> http://darcs.haskell.org/yhc/web/jsdemos/Roman.hs (C) Malcolm Wallace
 
|}
 
|}
   
   
--[[User:DimitryGolubovsky|DimitryGolubovsky]] 19:02, 6 November 2006 (UTC)
+
--[[User:DimitryGolubovsky|DimitryGolubovsky]] 20 March 2007

Revision as of 03:12, 20 March 2007

1 YCR2JS, a Converter of Yhc Core to Javascript

1.1 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

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