morpheus-graphql-code-gen-utils 0.28.4 → 0.28.5
raw patch · 4 files changed
+40/−35 lines, 4 filesdep ~prettyprinterdep ~reludesetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: prettyprinter, relude
API changes (from Hackage documentation)
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.AssociatedType
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.CodeGenConstructor
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.CodeGenField
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.CodeGenType
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.CodeGenTypeName
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.DerivingClass
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.FIELD_TYPE_WRAPPER
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.MethodArgument
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.PrintableValue
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq Data.Morpheus.CodeGen.Internal.AST.TypeValue
+ Data.Morpheus.CodeGen.Internal.AST: instance GHC.Classes.Eq body => GHC.Classes.Eq (Data.Morpheus.CodeGen.Internal.AST.TypeClassInstance body)
Files
- Setup.hs +2/−0
- morpheus-graphql-code-gen-utils.cabal +4/−4
- src/Data/Morpheus/CodeGen/Internal/AST.hs +28/−25
- src/Data/Morpheus/CodeGen/Internal/Name.hs +6/−6
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
morpheus-graphql-code-gen-utils.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.38.1.+-- This file has been generated from package.yaml by hpack version 0.36.1. -- -- see: https://github.com/sol/hpack name: morpheus-graphql-code-gen-utils-version: 0.28.4+version: 0.28.5 synopsis: Morpheus GraphQL CLI description: code generator for Morpheus GraphQL category: web, graphql, cli@@ -44,8 +44,8 @@ , containers >=0.4.2.1 && <1.0.0 , morpheus-graphql-core >=0.28.0 && <0.29.0 , mtl >=2.0.0 && <3.0.0- , prettyprinter >=1.7.0 && <2.0.0- , relude >=0.3.0 && <2.0.0+ , prettyprinter >=1.2.1 && <2.0.0+ , relude >=0.1.1 && <2.0.0 , template-haskell >=2.0.0 && <3.0.0 , text >=1.2.3 && <3.0.0 , unordered-containers >=0.2.8 && <1.0.0
src/Data/Morpheus/CodeGen/Internal/AST.hs view
@@ -62,7 +62,7 @@ = SHOW | GENERIC | CLASS_EQ- deriving (Show)+ deriving (Eq, Show) instance Pretty DerivingClass where pretty SHOW = "Show"@@ -77,7 +77,7 @@ | TypeValueList [TypeValue] | TypedValueMaybe (Maybe TypeValue) | PrintableTypeValue PrintableValue- deriving (Show)+ deriving (Eq, Show) renderField :: (FieldName, TypeValue) -> Doc n renderField (fName, fValue) = pretty (unpackName fName :: Text) <+> "=" <+> pretty fValue@@ -86,8 +86,8 @@ pretty (TypeValueObject name xs) = pretty (unpackName name :: Text) <+> "{"- <> vsep (punctuate "," (map renderField xs))- <> "}"+ <> vsep (punctuate "," (map renderField xs))+ <> "}" pretty (TypeValueNumber x) = pretty x pretty (TypeValueString x) = pretty (show x :: String) pretty (TypeValueBool x) = pretty x@@ -101,7 +101,7 @@ cgConstructors :: [CodeGenConstructor], cgDerivations :: [DerivingClass] }- deriving (Show)+ deriving (Eq, Show) isNewType :: CodeGenType -> Bool isNewType CodeGenType {cgConstructors = [CodeGenConstructor {constructorFields = [_]}]} = True@@ -111,10 +111,10 @@ pretty t@CodeGenType {..} = (if isNewType t then "newtype" else "data") <+> ignore (print cgTypeName)- <> renderConstructors cgConstructors- <> line- <> indent 2 (renderDeriving cgDerivations)- <> line+ <> renderConstructors cgConstructors+ <> line+ <> indent 2 (renderDeriving cgDerivations)+ <> line where renderConstructors [cons] = (" =" <+>) $ print' cons renderConstructors conses = nest 2 . (line <>) . vsep . prefixVariants $ map print' conses@@ -128,7 +128,7 @@ { constructorName :: CodeGenTypeName, constructorFields :: [CodeGenField] }- deriving (Show)+ deriving (Eq, Show) instance Printer CodeGenConstructor where print CodeGenConstructor {constructorFields = [CodeGenField {fieldName = "_", ..}], ..} =@@ -147,7 +147,7 @@ wrappers :: [FIELD_TYPE_WRAPPER], fieldIsNullable :: Bool }- deriving (Show)+ deriving (Eq, Show) instance Printer CodeGenField where print CodeGenField {..} = infix' (print fieldName) "::" (foldr renderWrapper (print fieldType) wrappers)@@ -159,7 +159,7 @@ | ARG TypeName | TAGGED_ARG TH.Name FieldName TypeRef | GQL_WRAPPER TypeWrapper- deriving (Show)+ deriving (Eq, Show) renderWrapper :: FIELD_TYPE_WRAPPER -> HSDoc n -> HSDoc n renderWrapper PARAMETRIZED = (.<> "m")@@ -174,7 +174,7 @@ typeParameters :: [Text], typename :: TypeName }- deriving (Show)+ deriving (Eq, Show) getFullName :: CodeGenTypeName -> TypeName getFullName CodeGenTypeName {..} = camelCaseTypeName namespace typename@@ -208,12 +208,12 @@ <> "module" <+> pretty moduleName <+> "where"- <> line- <> line- <> vsep (map renderImport $ organizeImports imports)- <> line- <> line- <> vsep (filter notEmpty $ map pretty types)+ <> line+ <> line+ <> vsep (map renderImport $ organizeImports imports)+ <> line+ <> line+ <> vsep (filter notEmpty $ map pretty types) notEmpty :: Doc a -> Bool notEmpty x = not $ null (show x :: String)@@ -248,7 +248,7 @@ assoc :: [(TH.Name, AssociatedType)], typeClassMethods :: [(TH.Name, MethodArgument, body)] }- deriving (Show)+ deriving (Eq, Show) instance (Pretty a) => Pretty (TypeClassInstance a) where pretty TypeClassInstance {..} =@@ -257,9 +257,9 @@ <+> printTHName typeClassName <+> typeHead <+> "where"- <> line- <> indent 2 (vsep (map renderAssoc assoc <> map renderMethodD typeClassMethods))- <> line+ <> line+ <> indent 2 (vsep (map renderAssoc assoc <> map renderMethodD typeClassMethods))+ <> line where typeHead = unpack (print typeClassTarget) renderAssoc (name, a) = "type" <+> printTHName name <+> typeHead <+> "=" <+> pretty a@@ -271,7 +271,7 @@ data AssociatedType = AssociatedTypeName TH.Name | AssociatedLocations [DirectiveLocation]- deriving (Show)+ deriving (Eq, Show) printTHName :: TH.Name -> Doc ann printTHName = ignore . print@@ -287,7 +287,7 @@ = NoArgument | ProxyArgument | DestructArgument TH.Name [TH.Name]- deriving (Show)+ deriving (Eq, Show) instance Pretty MethodArgument where pretty NoArgument = ""@@ -296,6 +296,9 @@ data PrintableValue where PrintableValue :: forall a. (Show a, Lift a) => a -> PrintableValue++instance Eq PrintableValue where+ a == b = show a == show b instance Show PrintableValue where show (PrintableValue a) = show a
src/Data/Morpheus/CodeGen/Internal/Name.hs view
@@ -35,9 +35,9 @@ camelCaseTypeName :: [N.Name t] -> TypeName -> TypeName camelCaseTypeName list name =- packName- $ T.concat- $ map (capitalize . unpackName) (list <> [coerce name])+ packName $+ T.concat $+ map (capitalize . unpackName) (list <> [coerce name]) toHaskellTypeName :: TypeName -> Text toHaskellTypeName "String" = "Text"@@ -53,9 +53,9 @@ camelCaseFieldName :: TypeName -> FieldName -> FieldName camelCaseFieldName nSpace name =- packName- $ uncapitalize (unpackName nSpace)- <> capitalize (unpackName name)+ packName $+ uncapitalize (unpackName nSpace)+ <> capitalize (unpackName name) toHaskellName :: FieldName -> String toHaskellName name