1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Move Composite constructor to Go.Syntax

This commit is contained in:
Rick Winfrey 2017-11-21 12:43:56 -08:00
parent 2927f38bf9
commit 769548b4b3
3 changed files with 11 additions and 21 deletions

View File

@ -178,24 +178,5 @@ instance Eq1 Reference where liftEq = genericLiftEq
instance Ord1 Reference where liftCompare = genericLiftCompare
instance Show1 Reference where liftShowsPrec = genericLiftShowsPrec
-- Misc
-- A channel literal in Go
newtype Channel a = Channel { channelContent :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Channel where liftEq = genericLiftEq
instance Ord1 Channel where liftCompare = genericLiftCompare
instance Show1 Channel where liftShowsPrec = genericLiftShowsPrec
-- A composite literal in Go
data Composite a = Composite { compositeType :: !a, compositeElement :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Composite where liftEq = genericLiftEq
instance Ord1 Composite where liftCompare = genericLiftCompare
instance Show1 Composite where liftShowsPrec = genericLiftShowsPrec
-- TODO: Object literals as distinct from hash literals? Or coalesce object/hash literals into “key-value literals”?
-- TODO: Function literals (lambdas, procs, anonymous functions, what have you).

View File

@ -41,6 +41,7 @@ type Syntax =
, Statement.PostDecrement
, Statement.PostIncrement
, Expression.MemberAccess
, Go.Syntax.Composite
, Go.Syntax.DefaultPattern
, Go.Syntax.Defer
, Go.Syntax.Field
@ -59,7 +60,6 @@ type Syntax =
, Literal.Array
, Literal.Channel
, Literal.Complex
, Literal.Composite
, Literal.Float
, Literal.Hash
, Literal.Integer
@ -217,7 +217,7 @@ comment :: Assignment
comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
compositeLiteral :: Assignment
compositeLiteral = makeTerm <$> symbol CompositeLiteral <*> children (Literal.Composite <$> expression <*> expression)
compositeLiteral = makeTerm <$> symbol CompositeLiteral <*> children (Go.Syntax.Composite <$> expression <*> expression)
element :: Assignment
element = symbol Element *> children expression

View File

@ -10,6 +10,15 @@ import Data.Functor.Classes.Show.Generic
import Data.Mergeable
import GHC.Generics
-- A composite literal in Go
data Composite a = Composite { compositeType :: !a, compositeElement :: !a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 Composite where liftEq = genericLiftEq
instance Ord1 Composite where liftCompare = genericLiftCompare
instance Show1 Composite where liftShowsPrec = genericLiftShowsPrec
-- | A default pattern in a Go select or switch statement (e.g. `switch { default: s() }`).
newtype DefaultPattern a = DefaultPattern { defaultPatternBody :: a }
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)