1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Merge pull request #302 from github/json-and-core-are-breaking-up

Remove FileCheck conversion of Core to JSON.
This commit is contained in:
Patrick Thomson 2019-10-02 18:42:50 -04:00 committed by GitHub
commit cf78f20470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 63 deletions

View File

@ -21,68 +21,6 @@ import Data.Scope (Scope, Incr)
import qualified Data.Scope as Scope
import Data.Name
instance ToJSON a => ToJSON (Named a) where
toJSON _ = object []
instance ToJSON1 Named where
liftToJSON f _ (Named i a) = object
[ "name" .= i
, "value" .= f a
]
-- Loses information compared to the toJSON instance
-- due to an infelicity in how Aeson's toJSON1 is implemented.
-- The correct thing to do here is to manually munge the bytestring
-- together as a builder, but we don't even hit this code path,
-- so it will do for now.
liftToEncoding f _ (Named _ a) = f a
instance ToJSON2 Incr where
liftToJSON2 f _ g _ = \case
Scope.Z a -> f a
Scope.S b -> g b
liftToEncoding2 f _ g _ = \case
Scope.Z a -> f a
Scope.S b -> g b
deriving newtype instance (ToJSON a) => ToJSON (Ignored a)
instance (Functor f, ToJSON1 f, ToJSON a) => ToJSON1 (Scope a f) where
liftToJSON f g (Scope.Scope a) = toJSON1 (fmap (toJSON2 . fmap (liftToJSON f g)) a)
liftToEncoding f g (Scope.Scope a) = liftToEncoding inner outer a where
inner = liftToEncoding2 toEncoding toEncodingList hoist loist
outer = liftToEncodingList2 toEncoding toEncodingList hoist loist
hoist = liftToEncoding f g
loist = liftToEncodingList f g
deriving anyclass instance (Functor f, ToJSON1 f) => ToJSON1 (Core f)
instance (ToJSON1 (sig (Term sig))) => ToJSON1 (Term sig) where
liftToJSON f _ (Var a) = f a
liftToJSON f g (Term s) = liftToJSON f g s
liftToEncoding f _ (Var a) = f a
liftToEncoding f g (Term s) = liftToEncoding f g s
instance (ToJSON1 (f k), ToJSON1 (g k)) => ToJSON1 ((:+:) f g k) where
liftToJSON f g (L h) = liftToJSON f g h
liftToJSON f g (R h) = liftToJSON f g h
liftToEncoding f g (L h) = liftToEncoding f g h
liftToEncoding f g (R h) = liftToEncoding f g h
instance (ToJSON1 f) => ToJSON1 (Ann f) where
liftToJSON f g (Ann loc term) =
let
rest = case liftToJSON f g term of
Object os -> HashMap.toList os
other -> ["value" .= other]
in object (["location" .= loc] <> rest)
-- We default to deriving the default toEncoding definition (that piggybacks
-- off of toJSON) so that we never hit the problematic code paths associated
-- with toEncoding above.
instance ToJSON a => ToJSON (File a) where
toJSON File{fileLoc, fileBody} = object
[ "location" .= fileLoc

View File

@ -56,7 +56,6 @@ assertJQExpressionSucceeds directive tree core = do
(heap, [File _ (Right result)]) -> pure $ Aeson.object
[ "scope" Aeson..= heap
, "heap" Aeson..= result
, "tree" Aeson..= Aeson.toJSON1 core
]
_other -> HUnit.assertFailure "Couldn't run scope dumping mechanism; this shouldn't happen"