While testing, I’d like to read and write a file from and to disk (JSON in, JSON out). How do I do this in PureScript? In Haskell I have something like
main :: IO ()
main = do
input <- readFile "input.json"
writeFile "output.json" $ process input
All my attempts so far have failed, including trying to use readFile
from import Node.FS.Sync
.
BTW, if there is any other (better) way of reading in my JSON file, let me know. (I am not a JavaScript expert but I would like to port some — strict — Haskell code to JS so that it can be used elsewhere.)
readFile
? – Phil Freemanrequire
. – Phil FreemanUnknown value bind
. Maybe I forgotimport Prelude
, hang on… – 0dBimport Prelude
is definitely the issue then. – Phil FreemanreadTextFile
andwriteTextFile
to get away from typeBuffer
so as to be able to process the file, and had to find out how to specify the encoding:Node.Encoding.UTF8
. – 0dB