Optimize EmptyDataDecls to Ptr in the FFI
bergmark opened this issue · 1 comments
bergmark commented
data Text
data JQuery
select :: Text -> Fay JQuery
select = ffi "$(%1)"
currently produces:
Test.select = function($p1){
return new Fay$$$(function(){
return new Fay$$Monad(Fay$$jsToFay(["user","JQuery",[]],$(Fay$$fayToJs(["user","Text",[]],$p1))));
});
};
This is unnecessary, we know that an EmptyDataDecl won't produce any transcoding. This can be fixed manually by:
select :: Ptr Text -> Fay (Ptr JQuery)
select = ffi "$(%1)"
Test.select = function($p1){
return new Fay$$$(function(){
return new Fay$$Monad($($p1));
});
};
The compiler can easily do this instead of the user, just keep track of all types that are EmptyDataDecls and turn the type into x
or Ptr Foo
either in desugaring, or in the FFI module.
bergmark commented
Man, wrong repository... :(