paulyoung / purescript-corefn

A library for working with the PureScript functional core.
Apache License 2.0
23 stars 7 forks source link

Support new JSON format #42

Closed paulyoung closed 6 years ago

paulyoung commented 6 years ago

Should close #41.

This is a port of FromJSON.hs. ~I still need to port TestCoreFn.hs.~

paulyoung commented 6 years ago

The tests include the JSON output from running stack test --test-arguments="-p corefn" on a modified TestCoreFn.hs, with the following diff applied:

diff --git a/tests/TestCoreFn.hs b/tests/TestCoreFn.hs
index 3f6972b1..5b0f0a79 100644
--- a/tests/TestCoreFn.hs
+++ b/tests/TestCoreFn.hs
@@ -12,6 +12,9 @@ import Data.Aeson
 import Data.Aeson.Types
 import Data.Version

+import Data.ByteString.Lazy.Char8
+import Debug.Trace
+
 import Language.PureScript.AST.Literals
 import Language.PureScript.AST.SourcePos
 import Language.PureScript.Comments
@@ -34,7 +37,8 @@ parseModule = parse moduleFromJSON
 parseMod :: Module Ann -> Result (Module Ann)
 parseMod m =
   let v = Version [0] []
-  in snd <$> parseModule (moduleToJSON v m)
+      j = moduleToJSON v m
+  in snd <$> parseModule (trace (unpack (encode j)) j)

 isSuccess :: Result a -> Bool
 isSuccess (Success _) = True
paulyoung commented 6 years ago

I'm seeing 2 issues with converting corefn.json files that are produced with pulp init.

I'm looking into whether this is an issue with my conversion or the original Haskell version.

paulyoung commented 6 years ago

Actually, everything is fine. Some modules in the output directory were old and using the old format.