Permalink
Browse files

Added reader requirements + fixed a code alignment

  • Loading branch information...
1 parent 8bee0aa commit cf823cb0c9a6536ebe5968d87ef10ae86fbd3b07 @spockz spockz committed Aug 28, 2012
Showing with 26 additions and 24 deletions.
  1. +26 −24 EHC/text/TopicJavaScriptIFL.cltex
@@ -46,18 +46,19 @@ Utrecht Haskell Compiler (UHC) \cite{dijkstra09uhc-arch,www09uhc} to compile
Haskell code to JavaScript, effectively turning JavaScript into a high-level
byte-code of some sorts.
-In this paper, we introduce the UHC JavaScript backend, a compiler backend that
-allows one to compile Haskell to JavaScript, while keeping Haskell's lazy
-semantics. To overcome the impedance-mismatch between Haskell and JavaScript,
-we have extended UHC's Foreign Function Interface (FFI) with a small
-JavaScript-like expression language we call the Foreign Expression Language
-(FEL). With these enhancements to the FFI, we claim that it is now possible to
-write complete JavaScript applications using only Haskell. We back this claim
-up by porting a web-based Prolog proof assistant from JavaScript to Haskell.
-While this paper focusses on Haskell, the ideas should be relatively easy to
-implement in similar languages. Additionally we provide a library containing
-bindings to the JavaScript standard functionality and bindings to several other
-commonly used JavaScript libraries.
+In this paper, we introduce the UHC JavaScript backend, a compiler backend that
+allows one to compile Haskell to JavaScript, while keeping Haskell's lazy
+semantics. We assume at least some familiarity with the Haskell Foreign
+Function Interface (FFI) and with JavaScript. To overcome the
+impedance-mismatch between Haskell and JavaScript, we have extended UHC's FFI
+with a small JavaScript-like expression language we call the Foreign Expression
+Language (FEL). With these enhancements to the FFI, we claim that it is now
+possible to write complete JavaScript applications using only Haskell. We back
+this claim up by porting a web-based Prolog proof assistant from JavaScript to
+Haskell. While this paper focusses on Haskell, the ideas should be relatively
+easy to implement in similar languages. Additionally we provide a library
+containing bindings to the JavaScript standard functionality and bindings to
+several other commonly used JavaScript libraries.
With this paper, we make the following contributions:
@@ -545,16 +546,17 @@ which is part of our RTS.
% and hiding the scope that one would expect to get when we would be using plain
%\js. One way to deal with this problem is by creating a wrapper function that
-Figure \ref{code:this} shows how the |wrappedThis| function can be used to
-obtain the value of an HTML input field. |valString| is a function that gets
-the value of a \jq object as a |String|, while |alert| shows an alert box
-containing the provided message. We query the DOM using jQuery, retrieving all
-\texttt{input} elements, such as text fields, in the DOM. We define a function
-|alertHndlr| that takes the string value of a jQuery object and then shows it
-in an alert box. Note the explicit |this| parameter. We then wrap it so it
-becomes a \js function, after which we partially apply it to an explicit |this|
-parameter using |wrappedThis|. Finally, we bind the event handler to all input
-fields retrieved by our jQuery selector.
+Figure \ref{code:this} shows how the |wrappedThis| function can be used to
+obtain the value of an HTML input field. The code above the definition of
+|bindInput| is copied from the \js library. |valString| is a function that gets
+the value of a \jq object as a |String|. We query the DOM using jQuery,
+retrieving all \texttt{input} elements, such as text fields, in the DOM. We
+define a function |alertHndlr| that takes the string value of a jQuery object
+and then shows it in an alert box. Note the explicit |this| parameter. We then
+wrap it so it becomes a \js function, after which we partially apply it to an
+explicit |this| parameter using |wrappedThis|. Finally, we bind the event
+handler to all input fields retrieved by our jQuery selector.
+
%TODO: Rewrite the bit above?
@@ -578,8 +580,8 @@ foreign import js "wrappedThis(%1)"
wrappedThis :: JThisEventHandler -> IO JEventHandler
bindInput = do
- let alertHndlr :: ThisEventHandler
- alertHndlr this _ = valString this >>= alert
+ let alertHndlr :: ThisEventHandler
+ alertHndlr this _ = valString this >>= alert
inputField <- jQuery "input"
eh <- mkJThisEventHandler alertHndlr >>= wrappedThis
bind inputField (toJS "blur") eh

0 comments on commit cf823cb

Please sign in to comment.