@@ -1,17 +1,31 @@
1−## Foreign Function Interface
1+Foreign Function Interface
2+==========================
23
3−The `foreign import` keyword declares a value which is defined in Javascript, and its type:
4+Importing Values
5+----------------
46
5−```haskell
6−foreign import pow :: (Number, Number) -> Number
7−```
7+The `foreign import` keyword declares a value which is defined in Javascript, and its type::
88
9−To declare a new type with no constructors, use `foreign import data` and provide the kind:
9+ foreign import pow :: Number -> Number -> Number
1010
11−```haskell
12−foreign import data IO :: * -> *
13−
14−foreign import console :: {
15− log :: String -> IO {}
16−}
17−```
11+Inline Javascript
12+-----------------
13+
14+A foreign import declaration may optionally contain its definition in Javascript as a string literal. If this is provided, the string will be inserted directly into the generated Javascript before the current module definition::
15+
16+ foreign import pow "function pow(n) {\
17+ \ return function(p) {\
18+ \ return Math.pow(n, p);\
19+ \ };\
20+ \}" :: Number -> Number -> Number
21+
22+Importing Types
23+---------------
24+
25+To declare a new type with no constructors, use `foreign import data` and provide the kind::
26+
27+ foreign import data DOM :: *
28+
29+ foreign import document :: {
30+ createElement :: String -> DOM
31+ }