I wrote a ffi code such as:
class SubRow (r :: # Type) (s :: # Type)
instance subrow :: Union r t s => SubRow r s
foreign import _table_to_sheet
:: forall opts eff
. SubRow opts (dateNF :: String, cellDates :: Boolean, raw :: Boolean)
=> EffFn2 eff HTMLTableElement { | opts } Sheet
tableToSheet table opts =
runEffFn2 _table_to_sheet table opts
exports._table_to_sheet = function(table,opts) {
console.log(table);
console.log(opts);
return XLSX.utils.table_to_sheet(table,opts);
};
When I called tableToSheet with table DOM and {raw: true} as arguments, an empty Object and undefined was passed to javascript _table_to_sheet function.
If I remove the SubRow constraint such as follows, it works corretly.
foreign import _table_to_sheet
:: forall opts eff
. EffFn2 eff HTMLTableElement { | opts } Sheet
Purescript compiler version 0.11.6.
Constraints always manifest as a real argument which the compiler implicitly fills in (even if the argument is empty). I'd recommend not typing FFI functions with constraints (passing everything you need in explicitly), and leave that for PureScript code.
Ah, so this was not a bug :)
Thank you. As your advice, I'll move the SubRow constraint to tableToSheet function.
Closing as this was not a bug.
Most helpful comment
Constraints always manifest as a real argument which the compiler implicitly fills in (even if the argument is empty). I'd recommend not typing FFI functions with constraints (passing everything you need in explicitly), and leave that for PureScript code.