Skip to content

Incorrect output for FFI definitions with additional haskell arguments #253

@davidsd

Description

@davidsd

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]];
  });
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions