Skip to content
Browse files

New AjaxCallback type works.

Now trying the different one with the contstraint on the ajax and ajaxQ calls
itself.
  • Loading branch information...
1 parent bceb65f commit 0a1e7600e1c09f9e3124a18eac2703417ce0d725 @spockz committed Dec 21, 2011
View
10 uhc-jscript/src/Language/UHC/JScript/JQuery/Ajax.hs
@@ -8,8 +8,8 @@ import Language.UHC.JScript.Primitives
import Data.List
-type AjaxCallback a b = JSPtr a -> String -> JSPtr b -> IO()
-type JSAjaxCallback a b = JSFunPtr (AjaxCallback a b)
+type AjaxCallback = forall a b. JS a => a -> String -> JSPtr b -> IO()
+type JSAjaxCallback = JSFunPtr (AjaxCallback)
data AjaxRequestType = GET | POST
deriving Show
@@ -48,7 +48,7 @@ toJSOptions options = let url' = toJS (ao_url options)
}
-ajaxBackend :: (JSPtr a -> IO ()) -> AjaxOptions a -> AjaxCallback a b -> AjaxCallback a b -> IO ()
+ajaxBackend :: (JSPtr a -> IO ()) -> AjaxOptions a -> AjaxCallback -> AjaxCallback -> IO ()
ajaxBackend cont options onSuccess onFailure =
do let jsOptions = toJSOptions options
onSuccess' <- mkJSAjaxCallback onSuccess
@@ -59,13 +59,13 @@ ajaxBackend cont options onSuccess onFailure =
_ <- setAttr "error" onFailure' o
_ajaxQ (toJS "jcu_app") o
-ajax :: AjaxOptions a -> AjaxCallback a b -> AjaxCallback a b -> IO ()
+ajax :: AjaxOptions a -> AjaxCallback -> AjaxCallback -> IO ()
ajax = ajaxBackend _ajax
foreign import jscript "wrapper"
- mkJSAjaxCallback :: AjaxCallback a b -> IO (JSAjaxCallback a b)
+ mkJSAjaxCallback :: AjaxCallback -> IO (JSAjaxCallback)
foreign import jscript "$.ajax(%1)"
View
2 uhc-jscript/src/Language/UHC/JScript/JQuery/AjaxQueue.hs
@@ -8,7 +8,7 @@ import Language.UHC.JScript.JQuery.Ajax
import Language.UHC.JScript.Assorted (alert, _alert)
-ajaxQ :: String -> AjaxOptions a -> AjaxCallback a b -> AjaxCallback a b -> IO ()
+ajaxQ :: String -> AjaxOptions a -> AjaxCallback -> AjaxCallback -> IO ()
ajaxQ queuename = ajaxBackend (_ajaxQ $ toJS queuename)
foreign import jscript "$.ajaxq(%*)"

0 comments on commit 0a1e760

Please sign in to comment.
Something went wrong with that request. Please try again.