Open bergmark opened 11 years ago
And fayToJs
and jsToFay
looks like this:
if (_obj instanceof $_Main$R) {
var obj_ = {"instance": "R"};
var obj_slot1 = Fay$$fayToJs(["user","S",[]],_(_obj.slot1));
if (undefined !== obj_slot1) {
obj_['slot1'] = obj_slot1;
}
return obj_;
}
if (obj["instance"] === "Q") {
return new $_Main$Q(Fay$$jsToFay(["string"],obj["slot1"]));
}
if (obj["instance"] === "R") {
return new $_Main$R(Fay$$jsToFay(["user","S",[]],obj["slot1"]));
}
Can we fix this with a Map Name Name
for type aliases?
Yeah, I guess we can do that. There'll need to be a little bit of Type -> Type
resolving, too (e.g. type Foo a = String
and then Foo Int
→ String
). I mentioned this on IRC months ago but forgot to make a ticket.
Does Automatic
solve this (temporarily)? It might be a good idea to give a warning until this is implemented properly.
I just hit this; I don't think Automatic
does solve it, if I'm using it correctly:
module Aliases where
import Prelude
import FFI
type Name = String
alert :: Automatic Name -> Fay ()
alert = ffi "window['alert'](%1)"
main :: Fay ()
main = alert "James"
alerts "[Object object]". Same for without Automatic
.
:+1: encountered this issue.. also tried using Automatic without success. Stripping type aliases out of my code has solved this temporarily, but it's not a nice solution.
Reported by cmccann and lucca on irc, I reproduced it like this:
=>
So if the ffi signature is concrete as in
putStrLn
the encoding works, but not for the genericprint
.