mirror of
https://github.com/github/semantic.git
synced 2025-01-05 14:11:33 +03:00
Use the newtype deriving strategy to define the ToJSON instance for Metavar.
This commit is contained in:
parent
8b6b4dcc00
commit
92e157cfb0
@ -1,4 +1,4 @@
|
|||||||
{-# LANGUAGE DataKinds, GeneralizedNewtypeDeriving, RankNTypes, TypeFamilies, TypeOperators #-}
|
{-# LANGUAGE DataKinds, DerivingStrategies, GeneralizedNewtypeDeriving, RankNTypes, TypeFamilies, TypeOperators #-}
|
||||||
module Diff where
|
module Diff where
|
||||||
|
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
@ -43,6 +43,7 @@ diffFBindings _ = []
|
|||||||
|
|
||||||
newtype Metavar = Metavar { unMetavar :: Int }
|
newtype Metavar = Metavar { unMetavar :: Int }
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
deriving newtype (ToJSON)
|
||||||
|
|
||||||
|
|
||||||
freeMetavariables :: (Foldable syntax, Functor syntax) => Diff syntax ann -> Set.Set Metavar
|
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 (Copy vs a f) = [ "bindings" .= vs] <> toJSONFields a <> toJSONFields1 f
|
||||||
toJSONFields (Var (Metavar v)) = [ "metavar" .= v ]
|
toJSONFields (Var (Metavar v)) = [ "metavar" .= v ]
|
||||||
toJSONFields (Patch a) = toJSONFields a
|
toJSONFields (Patch a) = toJSONFields a
|
||||||
|
|
||||||
instance ToJSON Metavar where
|
|
||||||
toJSON (Metavar i) = toJSON i
|
|
||||||
toEncoding (Metavar i) = toEncoding i
|
|
||||||
|
Loading…
Reference in New Issue
Block a user