Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Added basic instances for the JS class

* Added the safe fromJS. (Although it is not *completely* safe.)
  • Loading branch information...
commit 25c2d138f71a13cfd0f06870536d2016c2ad1e95 1 parent 006edbc
@spockz spockz authored
View
3  uhc-jscript/src/Language/UHC/JScript/JQuery/JQuery.hs
@@ -113,6 +113,9 @@ foreign import jscript "%1.wrapInner(%2)"
-- Or return JQuery for chaining??? Does chaining even make sense?
foreign import jscript "%1.addClass(%2)"
_addClass :: JQuery -> JSString -> IO ()
+
+foreign import jscript "%1.remove()"
+ remove :: JQuery -> IO ()
-------------------------------------------------------------------------------
-- Effects
View
18 uhc-jscript/src/Language/UHC/JScript/SafeTypes.hs
@@ -0,0 +1,18 @@
+module Language.UHC.JScript.SafeTypes where
+
+import Language.UHC.JScript.ECMA.String (JSString)
+
+foreign import jscript "typeof(%1)"
+ typeof :: a -> JSString
+
+-- | Would like fun dep here
+class FromJS a b => FromJSPlus a b where
+ jsType :: a -> b -> String
+ check :: a -> b -> Bool
+ check a b = jsType a b == fromJS (typeof a)
+ fromJSP :: a -> Maybe b
+ fromJSP a = let (v::b) = fromJS a
+ in if check a v then
+ Just v
+ else
+ Nothing
View
5 uhc-jscript/src/Language/UHC/JScript/Types.hs
@@ -4,7 +4,12 @@ module Language.UHC.JScript.Types where
import Control.Monad
+
+
class JS a where
+
+instance JS ()
+instance JS Int
class ToJS a b where
Please sign in to comment.
Something went wrong with that request. Please try again.