[Haskell-beginners] "downcasting"

Daniel Trstenjak daniel.trstenjak at gmail.com
Wed Mar 27 09:22:27 CET 2013


Hi Jamie,

> I'm sorry, but I copied exact code and I'm still getting an error:
> 
> $:l tst.hs 
> [1 of 1] Compiling Main             ( tst.hs, interpreted )
> Ok, modules loaded: Main.
> $let a = toJSObject [("A","a")]
> $a
> JSONObject {fromJSObject = [("A","a")]}
> $encode a
> "{\"A\":\"a\"}"
> $getJSObj a
> 
> <interactive>:428:10:
>     Couldn't match expected type `JSValue'
>                 with actual type `JSObject [Char]'
>     In the first argument of `getJSObj', namely `a'
>     In the expression: getJSObj a
>     In an equation for `it': it = getJSObj a
> $

'getJSObj' seems to extract a JSObject from a JSValue, but
you are giving a JSObject to 'getJSObj'.

Try this:

getJSObj $ JSValue a


Greetings,
Daniel



More information about the Beginners mailing list