JSAny / Generics and enumerated data types

18 views
Skip to first unread message

Maarten Dungen

unread,
Apr 10, 2017, 11:37:08 AM4/10/17
to haste-compiler
Hi all,

I have the following problem, when trying to run the following code:

import GHC.Generics
import Haste
import Haste.Foreign

data Message = Skip | Tick { tick::Int }
  deriving (Show, Generic,ToAny, FromAny)

main = fr (to 5) >>= writeLog . show
  where
    to n = toAny (Tick n)
    fr :: JSAny -> IO Message
    fr = fromAny

results in this error:
Uncaught TypeError: Cannot read property 'tick' of undefined

Seems like something goes wrong in the encoding. Any pointers or work arounds appreciated. 

kind regards,

Maarten

Reply all
Reply to author
Forward
0 new messages