2

I'm trying to wrap parts of the titanium api with PureScripts foreign function interface but I'm having trouble working out what the type definitions of the functions should be.

module Ti where

  foreign import data Window :: *

  foreign import window
    """ function (config) {
      return function () {
        return Ti.UI.createWindow(config);
      }
    } """ :: ??? -> Window

    foreign import open
    """ function (window) {
      return function () {
        window.open();
        return window;
      }
    } """ :: Window -> Window

    main = do
      w <- window ???
      open w
2
  • Not sure why you return a function of no arguments unless you expect to call import with config to create a function. Or is this supposed to be side-effecting? Commented Dec 27, 2014 at 22:23
  • @elclanrs I wanted to return a function with a single argument, I just wasn't sure what the type of that argument should be. I will be experimenting with Phil Freemans' answer using pursescript-options. Commented Dec 31, 2014 at 19:32

1 Answer 1

2

You might consider using the Foreign type from the purescript-foreign library as the argument type, together with the purescript-options library to construct the appropriate options object.

I've written a short guide to the purescript-options library here, and there is another example in the project repository.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.