The following code in JQuery.hs:
data CloneType = WithoutDataAndEvents | WithDataAndEvents | DeepWithDataAndEvents
clone :: CloneType -> JQuery -> Fay JQuery
clone WithoutDataAndEvents = ffi "%2['clone'](false)"
clone WithDataAndEvents = ffi "%2['clone'](true, false)"
clone DeepWithDataAndEvents = ffi "%2['clone'](true, true)"
leads to the following JS output:
var JQuery$clone = function($p1){
return new Fay$$$(function(){
if (Fay$$_($p1) instanceof $_JQuery$WithoutDataAndEvents) {
return Fay$$_(JQuery$ffi)(Fay$$list("%2['clone'](false)"));
}
if (Fay$$_($p1) instanceof $_JQuery$WithDataAndEvents) {
return Fay$$_(JQuery$ffi)(Fay$$list("%2['clone'](true, false)"));
}
if (Fay$$_($p1) instanceof $_JQuery$DeepWithDataAndEvents) {
return Fay$$_(JQuery$ffi)(Fay$$list("%2['clone'](true, true)"));
}
throw ["unhandled case in clone",[$p1]];
});
};
The following code in JQuery.hs:
leads to the following JS output: