@@ -401,21 +401,9 @@ foreign import javascript unsafe "console.log($1); $r = JSON['parse']($1);"
401401
402402rawDecode :: (FromJSON a) => T.Text -> Maybe a
403403rawDecode bs = do
404− -- Below copied from Reflex.Dom.WebSocket.Foreign
405− -- tmp <- Just $ unsafePerformIO $ putStrLn ("bs: " ++ BS.unpack bs)
406− -- error ("bs: " ++ BS.unpack bs)
407− -- let (b, off, len) = fromByteString bs
408− -- x = return $ js_dataView off len $ jsval $ getArrayBuffer b :: _
409− -- tmp <- error (BS.unpack bs)
410−
411− -- let jsv = if BS.length bs == 0
412− -- then unsafePerformIO $ jsval . getArrayBuffer <$> create 0
413− -- else js_dataView off len $ jsval $ getArrayBuffer b
414404
415405 let jsv = T.textToJSString bs
416406
417− -- let jsv = _ bs
418− -- TODO pFromJSVal to avoid unsafePerformIO
419407 let res = unsafePerformIO $ try $ aesonFromJSVal $ js_jsonParse $ jsval jsv
420408 case res of
421409 Left (_e :: SomeException) -> Nothing
@@ -429,8 +417,6 @@ rawDecode bs = do
429417-- copied from http://lpaste.net/raw/353535 Thanks ncl28!
430418aesonFromJSVal :: JSVal -> IO (Maybe A.Value)
431419aesonFromJSVal r = do
432− putStrLn "Hello"
433− print $ jsonTypeOf r
434420 case jsonTypeOf r of
435421 JSONNull -> return (Just A.Null)
436422 JSONInteger -> liftM (A.Number . flip scientific 0 . (toInteger :: Int -> Integer))