Skip to content

Add a bind record codgen #6

Open
@paluh

Description

@paluh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions