diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-10-05 17:40:58 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-10-05 17:40:58 -0600 |
commit | 7646708d8968579186bf914da74291a10457afeb (patch) | |
tree | e188dc19c1affa5c9e79d085bc42248952073e34 /src/Main.hs | |
parent | 3ceedaf5f5193fadadcb011c40df1688cfed279d (diff) | |
download | fiddle-7646708d8968579186bf914da74291a10457afeb.tar.gz fiddle-7646708d8968579186bf914da74291a10457afeb.tar.bz2 fiddle-7646708d8968579186bf914da74291a10457afeb.zip |
Much better handling for the generic syntax tree.
It now converts normal data into JSON rather than using "show".
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Main.hs b/src/Main.hs index 4da2295..2e4ee7a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,7 +2,7 @@ module Main where import Control.Monad (forM_) import Control.Monad.Identity (Identity) -import Data.Aeson (Value (..), encode) +import Data.Aeson (ToJSON (..), Value (..), encode) import qualified Data.ByteString.Lazy.Char8 as BL import qualified Data.Text as Text import qualified Data.Text.IO as TextIO @@ -138,7 +138,7 @@ processCompilationResult ma = encode $ alterGenericSyntaxTree cleanupIdentifiers $ toGenericSyntaxTree $ - fmap (Just . String . Text.pack . show) ast + fmap (Just . toJSON) ast return ExitSuccess Nothing -> do putStrLn "\x1b[1;31mCompilation Failed\x1b[0m" @@ -155,7 +155,7 @@ handleParsingFailure diags = do cleanupIdentifiers :: GenericSyntaxTree Identity a -> Maybe (GenericSyntaxTree Identity a) cleanupIdentifiers (SyntaxTreeObject _ _ _ tr) | Just (Identifier n _) <- castT tr = - Just $ SyntaxTreeValue (Text.unpack n) + Just $ SyntaxTreeValue (String n) where castT :: (Typeable t, Typeable f, Typeable a, Typeable t') => t f a -> Maybe (t' f a) castT = cast |