Until recently, it wasn’t clear to me the “right way” to bring foreign data into PureScript.
For a while I was using purescript-foreign. I would get data from outside PureScript, and then use
readArray, etc. to gradually build larger parsers to get an ADT (abstract data type). The paradigm seemed like
read[type] functions were being used as building blocks to larger data types.
That paradigm works to a certain extend, but the problem is
Array, and native DOM elements. There’s some discussion of this in a few purescript-foreign issues: #49, #30
Ultimately the big questions is, how do you get data outside PureScript into PureScript? This is my current understanding:
Are the types more complicated and are they from an API? Then use purescript-argonaut or generics-rep. Use argonaut to
manually encode/decode, and generic-rep to automatically do so.
- Converting Data To and From Json in PureScript
- Automatically de/encoding JSON in Purescript using Generics-Rep