1
1
mirror of https://github.com/github/semantic.git synced 2025-01-08 16:39:47 +03:00

Fix semantic-parse build.

Needed a JSON-marshalling instance for Parse.Err-wrapped values.

Fixes #575.
This commit is contained in:
Patrick Thomson 2020-06-29 15:16:54 -04:00
parent 956338eb2f
commit 336a74c2e6

View File

@ -15,7 +15,8 @@ module AST.Marshal.JSON
( MarshalJSON(..) ( MarshalJSON(..)
) where ) where
import Data.Aeson as Aeson import AST.Parse
import Data.Aeson as Aeson hiding (Success)
import Data.List.NonEmpty (NonEmpty) import Data.List.NonEmpty (NonEmpty)
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text import qualified Data.Text as Text
@ -78,6 +79,10 @@ instance (GValue t) => GValue ([] :.: t) where
instance (GValue t) => GValue (NonEmpty :.: t) where instance (GValue t) => GValue (NonEmpty :.: t) where
gvalue (Comp1 ts) = toJSON $ fmap gvalue ts gvalue (Comp1 ts) = toJSON $ fmap gvalue ts
instance (GValue t) => GValue (Err :.: t) where
gvalue (Comp1 (Success t)) = gvalue t
gvalue (Comp1 (Fail _)) = Null
-- GFields operates on product field types: it takes an accumulator, a datatype, and returns a new accumulator value. -- GFields operates on product field types: it takes an accumulator, a datatype, and returns a new accumulator value.
class GFields f where class GFields f where
gfields :: ToJSON a => [(Text, Value)] -> f a -> [(Text, Value)] gfields :: ToJSON a => [(Text, Value)] -> f a -> [(Text, Value)]