Whoa, I haven’t expected so many answers, and such discussion.
I think I have to clarify the problem I’m trying to solve. (Right now I’m heading towards some simple FFI solution, but I think the problem is more general.)
#1 The actual problem is that I want to let people, who doesn’t know PureScript, but know JavaScript, to provide complex data structures to be used with the functions written in PureScript, provided by my application.
In other words: I have written some application, that consumes quite complex data. I’d like users to be able to provide data using JS only. (So far, my app requires those data in more sophisticated PureScript format, so PS compiler is needed.)
I decided to use only types with simple JS runtime representations: all the primitive types, plus records.
No ADTs, not even Maybe (it requires type constructors in JS).
ADTs can be used in my FFI functions, since they are not supposed to be exposed in my application’s API. It’s ok to use type constructors internally - it’s not ok to tell my users to use them (since they have no idea, that PureScript exists).
As for JSON… Well, it could be used. I’m not a big fan of this format, I prefer to use more native ones (like POJO). In the end, I think, I’ll use whatever is leaner.
#2 By the FFI solution, I mean to actually solve the problem in JavaScript, and call the function(s) from PureScript. As simple as that.
JavaScript has no problems with heterogenous collections (arrays), so it is quite easy to process. The more difficult part is data validation: it’s not difficult per se, but I chose PureScript since I strongly prefer strong and sound type system over this thing that is available is JS.
Yet, I also try to be reasonable. My goal is to solve my problem, and not to solve it all in PureScript.
My rule of thumb is: whenever I can solve problem in JavaScript with just a couple of lines, within minutes, while trying to solve the same problem in PureScript leads to hours of work, and the results are not so great, I simply use FFI.
Following this rule, my codebase is 99% PureScript, and 1% of really simple JavaScript.
BTW, I’m going to show you the application, and share my development experience, as soon as I’ll find some spare time to do it.