I am trying to import the following JavaScript function into PureScript using the FFI:
function getGreeting() {
return "Hi, welcome to the show."
}
but I am not sure what the type should be. The closest I get to is something like:
foreign import getGreeting :: Unit -> String
I do want getGreeting
to stay a function, and not convert it to a constant.
Is there a better way to write the type? I tried to see what PureScript does if I define a dummy function in PureScript itself with that type of signature:
var getGreeting = function (v) {
return "Hi, welcome to the show.";
};
Is there a way to get rid of that v
parameter that is not being used?
TIA
Unit -> String
is a perfectly good type for that, or perhaps forall a. a -> String
. The latter type may seem too permissive, but we know for sure that the a
is unused thanks to parametricity, so that the function still must be constant.