HJavaScript has an Array type , but I donβt see a way to build a literal that would translate, for example, JS as [1,2,3] . I do not want to create new Array() and then insert elements into it if I do not need it.
Ideally, I execute a function like array :: [t] -> Array t .
I could use JConst to implement Array , but it seems to hack something that should be straight forward. I could also make the create-and-push method higher to implement Array , but that is also not very convenient.
Here is the Array by clicking; not so good.
array :: [Exp a] -> JS (JArray a) array xs = do arr <- new Array () mapM_ (`push` arr) xs return arr
source share