This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreign import js "saveObject(%1, %2)" | |
jsSaveObject :: JSString -> a -> IO () | |
saveObject :: String -> a -> IO () | |
saveObject s a = jsSaveObject (toJS s) a | |
foreign import js "loadObject(%1)" | |
jsLoadObject :: JSString -> IO a | |
loadObject = jsLoadObject . toJS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jsSaveGlobalObject(name, obj) { | |
allObjects[name] = obj; | |
return [1,0]; | |
} | |
function jsLoadGlobalObject(name) { | |
return [1,0,allObjects[name]]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreign import ccall jsSaveGlobalObject :: JSString -> Ptr a -> IO () | |
foreign import ccall jsLoadGlobalObject :: JSString -> IO (Ptr a) | |
saveGlobalObject :: String -> a -> IO () | |
saveGlobalObject name obj = jsSaveGlobalObject (toJSStr name) (toPtr obj) | |
loadGlobalObject :: String -> IO a | |
loadGlobalObject name = do | |
ptr <- jsLoadGlobalObject (toJSStr name) | |
return $ fromPtr ptr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Document | |
data Context2D | |
data Canvas | |
foreign import js "document" | |
document :: IO Document | |
foreign import js "%1.getElementById(%2)" | |
jsGetElementById :: Document -> JSString -> IO Canvas | |
getElementById doc = jsGetElementById doc . toJS | |
foreign import js "%1.getContext('2d')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreign import js "%1.fillRect(%*)" | |
fillRect :: Context2D -> Double -> Double -> Double -> Double -> IO () | |
foreign import js "%1.setFillColor(%*)" | |
setFillColor :: Context2D -> Double -> Double -> Double -> Double -> IO () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jsGetContext2d(canvas, _) { | |
return [1,0,canvas.getContext("2d")]; | |
} | |
function jsFillRect(context, x, y, width, height, _) { | |
context.fillRect(x,y,width,height); | |
return [1,0]; | |
} | |
function jsSetFillColor(context, color, _) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Haste.Prim | |
import Haste.DOM | |
newtype Context2D = Context2D JSAny | |
foreign import ccall "jsGetContext2D" | |
jsGetContext2d :: Elem -> IO Context2D | |
getContext2d name = withElem name getContext2D | |
foreign import ccall "jsFillRect" | |
fillRect :: Context2D -> Double -> Double -> Double -> Double -> IO () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<command-line>:0: warning: "__STDC__" redefined [enabled by default] | |
<built-in>:0: note: this is the location of the previous definition | |
<command-line>:0: warning: "__STDC__" redefined [enabled by default] | |
<built-in>:0: note: this is the location of the previous definition | |
containers-0.4.1.0/Data/Set.hs:22: warning: missing terminating " character [enabled by default] | |
containers-0.4.1.0/Data/Set.hs:27: warning: missing terminating " character [enabled by default] | |
containers-0.4.1.0/Data/Set.hs:496: warning: missing terminating ' character [enabled by default] | |
containers-0.4.1.0/Data/Set.hs:515: warning: missing terminating ' character [enabled by default] | |
containers-0.4.1.0/Data/Set.hs:606: warning: missing terminating ' character [enabled by default] | |
containers-0.4.1.0/Data/Set.hs:607: warning: missing terminating ' character [enabled by default] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EH analyses: Type checking | |
containers-0.4.1.0/Data/Set.hs-cpp:521-536: | |
Occur cycle: | |
type var: 4_13881_2 | |
to type : {! i_4_13881_1[] !} -> v_4_13881_2 | |
containers-0.4.1.0/Data/Set.hs-cpp:521-536: | |
Occur cycle: | |
type var: 4_14227_2 | |
to type : {! i_4_13881_1[] !} -> v_4_14227_2 | |
containers-0.4.1.0/Data/Set.hs-cpp:521-536: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html><head><title>Example</title> | |
<script type="text/javascript" src="example.js"></script> | |
</head> | |
<body> | |
Input 1: <input type="text" id="form1"> | |
Input 2: <input type="text" id="form2"> | |
</body> | |
</html> |