1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 21:16:12 +03:00

Use the newtype deriving strategy to define the ToJSON instance for Metavar.

This commit is contained in:
Rob Rix 2017-09-10 19:15:55 +01:00
parent 8b6b4dcc00
commit 92e157cfb0

View File

@ -1,4 +1,4 @@
{-# LANGUAGE DataKinds, GeneralizedNewtypeDeriving, RankNTypes, TypeFamilies, TypeOperators #-}
{-# LANGUAGE DataKinds, DerivingStrategies, GeneralizedNewtypeDeriving, RankNTypes, TypeFamilies, TypeOperators #-}
module Diff where
import Data.Aeson
@ -43,6 +43,7 @@ diffFBindings _ = []
newtype Metavar = Metavar { unMetavar :: Int }
deriving (Eq, Ord, Show)
deriving newtype (ToJSON)
freeMetavariables :: (Foldable syntax, Functor syntax) => Diff syntax ann -> Set.Set Metavar
@ -232,7 +233,3 @@ instance (ToJSON b, ToJSONFields a, ToJSONFields1 f) => ToJSONFields (DiffF f a
toJSONFields (Copy vs a f) = [ "bindings" .= vs] <> toJSONFields a <> toJSONFields1 f
toJSONFields (Var (Metavar v)) = [ "metavar" .= v ]
toJSONFields (Patch a) = toJSONFields a
instance ToJSON Metavar where
toJSON (Metavar i) = toJSON i
toEncoding (Metavar i) = toEncoding i