adius [6:27 AM]
How can I implement such a function: foreign import doSomething :: String -> Maybe Number ?
justinw [6:28 AM]
you have to give the constructors to the JS also
(a -> Maybe a) and (Maybe a), Just and Nothing
otherwise you can choose to return foreign and just return either the read result or Nothing on both Nothing and a parse failure
bklaric [6:42 AM]
FWIW what I do is write:
foreign import doSomethingImpl :: String -> Nullable Number
doSomething = doSomethingImpl >>> toMaybe
because dealing with PureScript values like Maybe in JavaScript is not nice.
adius [7:03 AM]
dealing with PureScript type constructors like Maybe in JavaScript is not nice
That’s what I thought 
Cool, exactly what I was looking for! Thanks @bklaric
bklaric [7:05 AM]
You’re welcome.
gabejohnson [8:55 AM]
@adius, @justinw was saying
foreign import doSomethingImp :: forall a. (a -> Maybe a) -> Maybe a -> String -> Maybe Number
doSomething :: String -> Maybe Number
doSomething = doSomethingImpl Just Nothing
You could also replace a with Number if you wanted.
But toMaybe essentially does ^