packages feed

morpheus-graphql-code-gen-utils 0.23.0 → 0.24.0

raw patch · 3 files changed

+29/−22 lines, 3 filesdep ~morpheus-graphql-corePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: morpheus-graphql-core

API changes (from Hackage documentation)

Files

morpheus-graphql-code-gen-utils.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           morpheus-graphql-code-gen-utils-version:        0.23.0+version:        0.24.0 synopsis:       Morpheus GraphQL CLI description:    code generator for Morpheus GraphQL category:       web, graphql, cli@@ -41,7 +41,7 @@       base >=4.7.0 && <5.0.0     , bytestring >=0.10.4 && <0.12.0     , containers >=0.4.2.1 && <0.7.0-    , morpheus-graphql-core >=0.23.0 && <0.24.0+    , morpheus-graphql-core >=0.24.0 && <0.25.0     , prettyprinter >=1.7.0 && <2.0.0     , relude >=0.3.0 && <2.0.0     , template-haskell >=2.0.0 && <3.0.0
src/Data/Morpheus/CodeGen/Internal/AST.hs view
@@ -30,6 +30,7 @@     TypeWrapper,     unpackName,   )+import qualified Data.Text as T import qualified Language.Haskell.TH.Syntax as TH import Prettyprinter   ( Doc,@@ -43,6 +44,7 @@     nest,     pretty,     punctuate,+    space,     tupled,     vsep,     (<+>),@@ -70,14 +72,14 @@   deriving (Show)  renderField :: (FieldName, TypeValue) -> Doc n-renderField (fName, fValue) = pretty (unpackName fName :: Text) <> "=" <+> pretty fValue+renderField (fName, fValue) = pretty (unpackName fName :: Text) <+> "=" <+> pretty fValue  instance Pretty TypeValue where   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@@ -120,6 +122,8 @@   deriving (Show)  instance Printer CodeGenConstructor where+  print CodeGenConstructor {constructorFields = [CodeGenField {fieldName = "_", ..}], ..} =+    pack (print' constructorName <+> unpack (foldr renderWrapper (print fieldType) wrappers))   print CodeGenConstructor {constructorFields = [], ..} =     print constructorName   print CodeGenConstructor {..} = do@@ -190,31 +194,29 @@   pretty ModuleDefinition {..} =     vsep       (map renderExtension extensions)-      <> "{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}"       <> line       <> line-      <> "{-# HLINT ignore \"Use camelCase\" #-}"-      <> line-      <> line       <> "module"       <+> pretty moduleName       <+> "where"         <> line         <> line-        <> vsep (map renderImport imports)+        <> vsep (map renderImport $ sortWith fst imports)         <> line         <> line         <> vsep (map pretty types)  renderExtension :: Text -> Doc ann-renderExtension name = "{-#" <+> "LANGUAGE" <+> pretty name <+> "#-}"+renderExtension txt+  | T.isPrefixOf "{-#" txt = pretty txt+  | otherwise = "{-#" <+> "LANGUAGE" <+> pretty txt <+> "#-}"  renderImport :: (Text, [Text]) -> Doc ann renderImport (src, ls) = "import" <+> pretty src <> renderImportList ls  renderImportList :: [Text] -> Doc ann renderImportList ["*"] = ""-renderImportList xs = tupled (map pretty xs)+renderImportList xs = space <> tupled (map pretty xs)  data TypeClassInstance body = TypeClassInstance   { typeClassName :: TH.Name,@@ -234,10 +236,11 @@       <+> "where"         <> 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-      renderMethodD (name, args, method) = printTHName name <+> pretty args <+> "=" <+> pretty method+      renderMethodD (name, args, method) = printTHName name <+> pretty args <> "=" <> pretty method  renderTypeableConstraints :: [Text] -> Doc n renderTypeableConstraints xs = tupled (map (("Typeable" <+>) . pretty) xs) <+> "=>"@@ -265,5 +268,5 @@  instance Pretty MethodArgument where   pretty NoArgument = ""-  pretty ProxyArgument = "_"-  pretty (DestructArgument x xs) = unpack (print x .<> pack (hsep $ map printTHName xs))+  pretty ProxyArgument = "_ "+  pretty (DestructArgument x xs) = unpack (print x .<> pack (hsep $ map printTHName xs)) <> " "
src/Data/Morpheus/CodeGen/TH.hs view
@@ -238,13 +238,6 @@ printDerivClause :: [DerivingClass] -> DerivClause printDerivClause derives = DerivClause Nothing (map (ConT . genName) derives) -printField :: CodeGenField -> (Name, Bang, Type)-printField CodeGenField {..} =-  ( toName fieldName,-    Bang NoSourceUnpackedness NoSourceStrictness,-    foldr applyWrapper (toCon fieldType) wrappers-  )- applyWrapper :: FIELD_TYPE_WRAPPER -> Type -> Type applyWrapper PARAMETRIZED = (`AppT` m') applyWrapper MONAD = AppT m'@@ -276,9 +269,20 @@ printConstraints = cxt . map constraint  printConstructor :: CodeGenConstructor -> Con+printConstructor CodeGenConstructor {constructorFields = [field], ..}+  | fieldName field == "_" = NormalC (toName constructorName) [ignoreName $ printField field]+  where+    ignoreName (_, b, t) = (b, t) printConstructor CodeGenConstructor {..}   | null constructorFields = NormalC (toName constructorName) []   | otherwise = RecC (toName constructorName) (map printField constructorFields)++printField :: CodeGenField -> (Name, Bang, Type)+printField CodeGenField {..} =+  ( toName fieldName,+    Bang NoSourceUnpackedness NoSourceStrictness,+    foldr applyWrapper (toCon fieldType) wrappers+  )  printTypeSynonym :: ToName a => a -> [Name] -> Type -> Dec printTypeSynonym name params = TySynD (toName name) (toTypeVars params)