We can imagine an extension to the current mkFFI which actually produces an record of bound methods / properties as follows like:
_Person ::
{ firstName :: Person -> Effect String
, lastName :: Person -> Effect String
, setFirstName :: Person -> String -> Effect Unit
, setLastName :: Person -> String -> Effect Unit
}
_Person = mkNewtypedFFI (Proxy :: Proxy Person)
bindPerson p =
{ firstName: _Person.firstName p
, lastName: _Person.lastName p
, setFirstName: _Person.setFirstName p
, setLastName: _Person.setLastName p
}
So finally users could just do:
do
let
p' = bindPerson p
p'.setFirstName "John"
n <- p'.firstName
We should just generate this bindPerson function using heterogenous and warn that there is an extra allocation behind the scene.
We can imagine an extension to the current
mkFFIwhich actually produces an record of bound methods / properties as follows like:So finally users could just do:
We should just generate this
bindPersonfunction usingheterogenousand warn that there is an extra allocation behind the scene.