From 26707bab6926d1ab0b6d215a0daef8f1e7b73698 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Fri, 1 Jun 2018 15:41:21 -0700 Subject: [PATCH] Update Declaration.Datatype to hold deriving clause --- src/Data/Syntax/Declaration.hs | 2 +- src/Language/Haskell/Syntax.hs | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index 2fc337360..a23b59e80 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -182,7 +182,7 @@ instance Evaluatable Decorator -- | An ADT, i.e. a disjoint sum of products, like 'data' in Haskell, or 'enum' in Rust or Swift. -data Datatype a = Datatype { datatypeName :: !a, datatypeConstructors :: ![a] } +data Datatype a = Datatype { datatypeName :: a, datatypeConstructors :: [a], datatypeDeriving :: a } deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 Data.Syntax.Declaration.Datatype where liftEq = genericLiftEq diff --git a/src/Language/Haskell/Syntax.hs b/src/Language/Haskell/Syntax.hs index 86d6defa9..ab5d8f35c 100644 --- a/src/Language/Haskell/Syntax.hs +++ b/src/Language/Haskell/Syntax.hs @@ -20,7 +20,7 @@ instance Show1 Module where liftShowsPrec = genericLiftShowsPrec instance Evaluatable Module data StrictType a = StrictType { strictTypeIdentifier :: !a, strictTypeParameters :: !a } - deriving (Diffable, Eq, Foldable, Functor, Generic1, Hashable1, Mergeable, Ord, Show, Traversable, FreeVariables1, Declarations1) + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 StrictType where liftEq = genericLiftEq instance Ord1 StrictType where liftCompare = genericLiftCompare @@ -31,7 +31,7 @@ instance ToJSONFields1 StrictType instance Evaluatable StrictType newtype StrictTypeVariable a = StrictTypeVariable { strictTypeVariableIdentifier :: a } - deriving (Diffable, Eq, Foldable, Functor, Generic1, Hashable1, Mergeable, Ord, Show, Traversable, FreeVariables1, Declarations1) + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 StrictTypeVariable where liftEq = genericLiftEq instance Ord1 StrictTypeVariable where liftCompare = genericLiftCompare @@ -59,7 +59,8 @@ instance Show1 TypeSynonym where liftShowsPrec = genericLiftShowsPrec instance Evaluatable TypeSynonym -data UnitConstructor a = UnitConstructor deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) +data UnitConstructor a = UnitConstructor + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 UnitConstructor where liftEq = genericLiftEq instance Ord1 UnitConstructor where liftCompare = genericLiftCompare @@ -67,7 +68,8 @@ instance Show1 UnitConstructor where liftShowsPrec = genericLiftShowsPrec instance Evaluatable UnitConstructor -newtype TupleConstructor a = TupleConstructor { tupleConstructorArity :: Int } deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) +newtype TupleConstructor a = TupleConstructor { tupleConstructorArity :: Int } + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 TupleConstructor where liftEq = genericLiftEq instance Ord1 TupleConstructor where liftCompare = genericLiftCompare @@ -75,7 +77,8 @@ instance Show1 TupleConstructor where liftShowsPrec = genericLiftShowsPrec instance Evaluatable TupleConstructor -data ListConstructor a = ListConstructor deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) +data ListConstructor a = ListConstructor + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 ListConstructor where liftEq = genericLiftEq instance Ord1 ListConstructor where liftCompare = genericLiftCompare @@ -83,7 +86,8 @@ instance Show1 ListConstructor where liftShowsPrec = genericLiftShowsPrec instance Evaluatable ListConstructor -data FunctionConstructor a = FunctionConstructor deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) +data FunctionConstructor a = FunctionConstructor + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 FunctionConstructor where liftEq = genericLiftEq instance Ord1 FunctionConstructor where liftCompare = genericLiftCompare @@ -91,7 +95,8 @@ instance Show1 FunctionConstructor where liftShowsPrec = genericLiftShowsPrec instance Evaluatable FunctionConstructor -data RecordDataConstructor a = RecordDataConstructor { recordDataConstructorName :: !a, recordDataConstructorFields :: !a } deriving (Diffable, Eq, Foldable, Functor, Generic1, Hashable1, Mergeable, Ord, Show, Traversable, FreeVariables1, Declarations1) +data RecordDataConstructor a = RecordDataConstructor { recordDataConstructorName :: !a, recordDataConstructorFields :: !a } + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 RecordDataConstructor where liftEq = genericLiftEq instance Ord1 RecordDataConstructor where liftCompare = genericLiftCompare @@ -101,7 +106,8 @@ instance ToJSONFields1 RecordDataConstructor instance Evaluatable RecordDataConstructor -data Field a = Field { fieldName :: !a, fieldBody :: !a } deriving (Diffable, Eq, Foldable, Functor, Generic1, Hashable1, Mergeable, Ord, Show, Traversable, FreeVariables1, Declarations1) +data Field a = Field { fieldName :: !a, fieldBody :: !a } + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 Field where liftEq = genericLiftEq instance Ord1 Field where liftCompare = genericLiftCompare @@ -111,7 +117,8 @@ instance ToJSONFields1 Field instance Evaluatable Field -newtype Pragma a = Pragma ByteString deriving (Diffable, Eq, Foldable, Functor, Generic1, Hashable1, Mergeable, Ord, Show, Traversable, FreeVariables1, Declarations1) +newtype Pragma a = Pragma ByteString + deriving (Eq, Ord, Show, Foldable, Traversable, Functor, Generic1, Hashable1, Diffable, Mergeable, FreeVariables1, Declarations1, ToJSONFields1) instance Eq1 Pragma where liftEq = genericLiftEq instance Ord1 Pragma where liftCompare = genericLiftCompare