1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Upate Go related constructors to have Ord and Ord1 instances

This commit is contained in:
Rick Winfrey 2017-10-10 13:37:47 -07:00
parent 7dd673ada9
commit beebeb9991
3 changed files with 28 additions and 14 deletions

View File

@ -163,16 +163,18 @@ instance Show1 Set where liftShowsPrec = genericLiftShowsPrec
-- A channel literal in Go -- A channel literal in Go
newtype Channel a = Channel { channelContent :: a } newtype Channel a = Channel { channelContent :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Channel where liftEq = genericLiftEq instance Eq1 Channel where liftEq = genericLiftEq
instance Ord1 Channel where liftCompare = genericLiftCompare
instance Show1 Channel where liftShowsPrec = genericLiftShowsPrec instance Show1 Channel where liftShowsPrec = genericLiftShowsPrec
-- A composite literal in Go -- A composite literal in Go
data Composite a = Composite { compositeType :: !a, compositeElement :: !a } data Composite a = Composite { compositeType :: !a, compositeElement :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Composite where liftEq = genericLiftEq instance Eq1 Composite where liftEq = genericLiftEq
instance Ord1 Composite where liftCompare = genericLiftCompare
instance Show1 Composite where liftShowsPrec = genericLiftShowsPrec instance Show1 Composite where liftShowsPrec = genericLiftShowsPrec
-- TODO: Object literals as distinct from hash literals? Or coalesce object/hash literals into “key-value literals”? -- TODO: Object literals as distinct from hash literals? Or coalesce object/hash literals into “key-value literals”?

View File

@ -26,9 +26,10 @@ instance Ord1 Else where liftCompare = genericLiftCompare
instance Show1 Else where liftShowsPrec = genericLiftShowsPrec instance Show1 Else where liftShowsPrec = genericLiftShowsPrec
newtype Goto a = Goto { gotoLocation :: a } newtype Goto a = Goto { gotoLocation :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Goto where liftEq = genericLiftEq instance Eq1 Goto where liftEq = genericLiftEq
instance Ord1 Goto where liftCompare = genericLiftCompare
instance Show1 Goto where liftShowsPrec = genericLiftShowsPrec instance Show1 Goto where liftShowsPrec = genericLiftShowsPrec
-- TODO: Alternative definition would flatten if/else if/else chains: data If a = If ![(a, a)] !(Maybe a) -- TODO: Alternative definition would flatten if/else if/else chains: data If a = If ![(a, a)] !(Maybe a)
@ -197,14 +198,16 @@ instance Show1 ScopeExit where liftShowsPrec = genericLiftShowsPrec
-- | Post increment operator (e.g. 1++ in Go, or i++ in C). -- | Post increment operator (e.g. 1++ in Go, or i++ in C).
newtype PostIncrement a = PostIncrement a newtype PostIncrement a = PostIncrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 PostIncrement where liftEq = genericLiftEq instance Eq1 PostIncrement where liftEq = genericLiftEq
instance Ord1 PostIncrement where liftCompare = genericLiftCompare
instance Show1 PostIncrement where liftShowsPrec = genericLiftShowsPrec instance Show1 PostIncrement where liftShowsPrec = genericLiftShowsPrec
-- | Post decrement operator (e.g. 1-- in Go, or i-- in C). -- | Post decrement operator (e.g. 1-- in Go, or i-- in C).
newtype PostDecrement a = PostDecrement a newtype PostDecrement a = PostDecrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 PostDecrement where liftEq = genericLiftEq instance Eq1 PostDecrement where liftEq = genericLiftEq
instance Ord1 PostDecrement where liftCompare = genericLiftCompare
instance Show1 PostDecrement where liftShowsPrec = genericLiftShowsPrec instance Show1 PostDecrement where liftShowsPrec = genericLiftShowsPrec

View File

@ -17,9 +17,10 @@ instance Ord1 Annotation where liftCompare = genericLiftCompare
instance Show1 Annotation where liftShowsPrec = genericLiftShowsPrec instance Show1 Annotation where liftShowsPrec = genericLiftShowsPrec
data Function a = Function { functionParameters :: [a], functionReturn :: a } data Function a = Function { functionParameters :: [a], functionReturn :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Function where liftEq = genericLiftEq instance Eq1 Function where liftEq = genericLiftEq
instance Ord1 Function where liftCompare = genericLiftCompare
instance Show1 Function where liftShowsPrec = genericLiftShowsPrec instance Show1 Function where liftShowsPrec = genericLiftShowsPrec
newtype Product a = Product { productElements :: [a] } newtype Product a = Product { productElements :: [a] }
@ -30,51 +31,59 @@ instance Ord1 Product where liftCompare = genericLiftCompare
instance Show1 Product where liftShowsPrec = genericLiftShowsPrec instance Show1 Product where liftShowsPrec = genericLiftShowsPrec
data Array a = Array { arraySize :: Maybe a, arrayElementType :: a } data Array a = Array { arraySize :: Maybe a, arrayElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Array where liftEq = genericLiftEq instance Eq1 Array where liftEq = genericLiftEq
instance Ord1 Array where liftCompare = genericLiftCompare
instance Show1 Array where liftShowsPrec = genericLiftShowsPrec instance Show1 Array where liftShowsPrec = genericLiftShowsPrec
newtype BiDirectionalChannel a = BiDirectionalChannel { biDirectionalChannelElementType :: a } newtype BiDirectionalChannel a = BiDirectionalChannel { biDirectionalChannelElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 BiDirectionalChannel where liftEq = genericLiftEq instance Eq1 BiDirectionalChannel where liftEq = genericLiftEq
instance Ord1 BiDirectionalChannel where liftCompare = genericLiftCompare
instance Show1 BiDirectionalChannel where liftShowsPrec = genericLiftShowsPrec instance Show1 BiDirectionalChannel where liftShowsPrec = genericLiftShowsPrec
newtype Interface a = Interface { interfaceElements :: [a] } newtype Interface a = Interface { interfaceElements :: [a] }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Interface where liftEq = genericLiftEq instance Eq1 Interface where liftEq = genericLiftEq
instance Ord1 Interface where liftCompare = genericLiftCompare
instance Show1 Interface where liftShowsPrec = genericLiftShowsPrec instance Show1 Interface where liftShowsPrec = genericLiftShowsPrec
data Map a = Map { mapKeyType :: a, mapElementType :: a } data Map a = Map { mapKeyType :: a, mapElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Map where liftEq = genericLiftEq instance Eq1 Map where liftEq = genericLiftEq
instance Ord1 Map where liftCompare = genericLiftCompare
instance Show1 Map where liftShowsPrec = genericLiftShowsPrec instance Show1 Map where liftShowsPrec = genericLiftShowsPrec
newtype Pointer a = Pointer { pointerType :: a } newtype Pointer a = Pointer { pointerType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Pointer where liftEq = genericLiftEq instance Eq1 Pointer where liftEq = genericLiftEq
instance Ord1 Pointer where liftCompare = genericLiftCompare
instance Show1 Pointer where liftShowsPrec = genericLiftShowsPrec instance Show1 Pointer where liftShowsPrec = genericLiftShowsPrec
newtype ReceiveChannel a = ReceiveChannel { receiveChannelElementType :: a } newtype ReceiveChannel a = ReceiveChannel { receiveChannelElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 ReceiveChannel where liftEq = genericLiftEq instance Eq1 ReceiveChannel where liftEq = genericLiftEq
instance Ord1 ReceiveChannel where liftCompare = genericLiftCompare
instance Show1 ReceiveChannel where liftShowsPrec = genericLiftShowsPrec instance Show1 ReceiveChannel where liftShowsPrec = genericLiftShowsPrec
newtype SendChannel a = SendChannel { sendChannelElementType :: a } newtype SendChannel a = SendChannel { sendChannelElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 SendChannel where liftEq = genericLiftEq instance Eq1 SendChannel where liftEq = genericLiftEq
instance Ord1 SendChannel where liftCompare = genericLiftCompare
instance Show1 SendChannel where liftShowsPrec = genericLiftShowsPrec instance Show1 SendChannel where liftShowsPrec = genericLiftShowsPrec
newtype Slice a = Slice { sliceElementType :: a } newtype Slice a = Slice { sliceElementType :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Slice where liftEq = genericLiftEq instance Eq1 Slice where liftEq = genericLiftEq
instance Ord1 Slice where liftCompare = genericLiftCompare
instance Show1 Slice where liftShowsPrec = genericLiftShowsPrec instance Show1 Slice where liftShowsPrec = genericLiftShowsPrec
data TypeParameters a = TypeParameters { typeParameters :: ![a] } data TypeParameters a = TypeParameters { typeParameters :: ![a] }