I'm experimenting with parsing AWS JSON with purescript.
Given the Data.JSON.S3 module provided, here's what I see in the console:
$> eitherDecode "{ \"Records\": [{ \"s3\": { \"bucket\": { \"name\": \"foo\"}, \"object\": { \"key\": \"bar.png\" } } } ] }" :: Either String Records
Left ("fromList Cons (Tuple (\"s3\") (JObject fromList Cons (Tuple (\"bucket\") (JObject fromList Cons (Tuple (\"name\") (JString \"foo\")) (Nil))) (Cons (Tuple (\"object\") (JObject fromList Cons (Tuple (\"key\") (JString \"bar.png\")) (Nil))) (Nil)))) (Nil) is not (Either a b).")
Parsing the individual S3 objects works as expected. Why doesn't this work?
IRC sorted me out. Instead of
data Records = Records (Array (Either String S3))
I just neededdata Records = Records (Array S3)
I feel like I'm still working too hard though... so I'll probably come back to this...