Skip to content

Instantly share code, notes, and snippets.

@eric-corumdigital
Created March 8, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric-corumdigital/945cb1a53f1c863b6c7e8f54c4daf348 to your computer and use it in GitHub Desktop.
Save eric-corumdigital/945cb1a53f1c863b6c7e8f54c4daf348 to your computer and use it in GitHub Desktop.
PureScript Foreign Non-Plain Object Import
import foreign data XImpl :: Type
type X = { a :: Number, b :: Number, impl :: XImpl }
foreign import foo :: forall eff. Eff eff X
---
exports.foo = function() {
var x = doFoo();
return { a: x.a, b: x.b, impl: x };
};
@eric-corumdigital
Copy link
Author

foreign import bar :: forall eff. X -> Eff eff Unit

---

exports.bar = function(wrappedX) {
  return function () {
    var x = wrappedX.impl;
    doBar(x);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment