Permalink
Browse files

* Tried to add a JS class that contains types that are JS values...

  Didn't work out though. Try again?
  • Loading branch information...
1 parent 6cdf015 commit bceb65f4adbd7326ab28b5c5d6bdb05488487df8 @spockz spockz committed Dec 20, 2011
@@ -9,6 +9,8 @@ import UHC.BoxArray
type JSArray x = BoxArray x
+instance JS (JSArray a)
+
foreign import jscript "%1.length"
lengthJSArray :: JSArray x -> Int
@@ -1,4 +1,4 @@
-module Language.UHC.JScript.JQuery.Ajax (AjaxOptions(..), JSAjaxOptions(..), AjaxCallback, Callback, AjaxRequestType(..), ajaxBackend, ajax, toJSOptions, mkJSAjaxCallback) where
+module Language.UHC.JScript.JQuery.Ajax (AjaxOptions(..), JSAjaxOptions(..), AjaxCallback, AjaxRequestType(..), ajaxBackend, ajax, toJSOptions, mkJSAjaxCallback) where
import Language.UHC.JScript.ECMA.String
import Language.UHC.JScript.Types
@@ -8,8 +8,7 @@ import Language.UHC.JScript.Primitives
import Data.List
-type Callback a b = JSPtr a -> String -> JSPtr b -> IO()
-type AjaxCallback a b = JSPtr a -> String -> JSPtr b -> IO()
+type AjaxCallback a b = JSPtr a -> String -> JSPtr b -> IO()
type JSAjaxCallback a b = JSFunPtr (AjaxCallback a b)
data AjaxRequestType = GET | POST
@@ -78,21 +78,26 @@ foreign import jscript "%1.html()"
setHTML :: JQuery -> String -> IO ()
setHTML j s = _setHTML j (toJS s)
+
foreign import jscript "%1.html(%2)"
_setHTML :: JQuery -> JSString -> IO ()
-
+
foreign import jscript "%1.hide()"
hide :: JQuery -> IO ()
addClass :: JQuery -> String -> IO ()
addClass j s = _addClass j (toJS s)
+wrapInner :: JQuery -> String -> IO ()
+wrapInner j = _wrapInner j . toJS
+
+foreign import jscript "%1.wrapInner(%2)"
+ _wrapInner :: JQuery -> JSString -> IO ()
+
-- Or return JQuery for chaining??? Does chaining even make sense?
foreign import jscript "%1.addClass(%2)"
_addClass :: JQuery -> JSString -> IO ()
-
-
-------------------------------------------------------------------------------
-- Effects
@@ -7,6 +7,9 @@ import UHC.Ptr
data JSPtr a
type JSFunPtr a = FunPtr a
+instance JS (JSPtr a)
+instance JS (JSString)
+
type JSString = PackedString
type AnonObj = JSPtr ()
@@ -4,6 +4,9 @@ module Language.UHC.JScript.Types where
import Control.Monad
+class JS a where
+
+
class ToJS a b where
toJS :: a -> b

0 comments on commit bceb65f

Please sign in to comment.