morpheus-graphql-code-gen-utils 0.28.1 → 0.28.2
raw patch · 6 files changed
+44/−44 lines, 6 filesdep ~bytestringdep ~containersdep ~unordered-containers
Dependency ranges changed: bytestring, containers, unordered-containers
Files
- morpheus-graphql-code-gen-utils.cabal +5/−5
- src/Data/Morpheus/CodeGen/Internal/AST.hs +19/−19
- src/Data/Morpheus/CodeGen/Internal/Flags.hs +4/−4
- src/Data/Morpheus/CodeGen/Internal/Name.hs +6/−6
- src/Data/Morpheus/CodeGen/Printer.hs +1/−1
- src/Data/Morpheus/CodeGen/TH.hs +9/−9
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.36.0.+-- This file has been generated from package.yaml by hpack version 0.38.1. -- -- see: https://github.com/sol/hpack name: morpheus-graphql-code-gen-utils-version: 0.28.1+version: 0.28.2 synopsis: Morpheus GraphQL CLI description: code generator for Morpheus GraphQL category: web, graphql, cli@@ -40,13 +40,13 @@ ghc-options: -Wall build-depends: base >=4.7.0 && <5.0.0- , bytestring >=0.10.4 && <0.15.0- , containers >=0.4.2.1 && <=0.7+ , bytestring >=0.10.4 && <1.0.0+ , 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 , template-haskell >=2.0.0 && <3.0.0 , text >=1.2.3 && <3.0.0- , unordered-containers >=0.2.8 && <0.3.0+ , unordered-containers >=0.2.8 && <1.0.0 default-language: Haskell2010
src/Data/Morpheus/CodeGen/Internal/AST.hs view
@@ -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@@ -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@@ -184,8 +184,8 @@ instance Printer CodeGenTypeName where print cgName =- HSDoc (not $ null (typeParameters cgName)) $- parametrizedType+ HSDoc (not $ null (typeParameters cgName))+ $ parametrizedType (unpackName (getFullName cgName)) (typeParameters cgName) @@ -199,7 +199,7 @@ types :: [dec] } -instance Pretty dec => Pretty (ModuleDefinition dec) where+instance (Pretty dec) => Pretty (ModuleDefinition dec) where pretty ModuleDefinition {..} = vsep (map renderExtension (sort extensions))@@ -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)@@ -250,16 +250,16 @@ } deriving (Show) -instance Pretty a => Pretty (TypeClassInstance a) where+instance (Pretty a) => Pretty (TypeClassInstance a) where pretty TypeClassInstance {..} = "instance" <> optional renderTypeableConstraints (typeParameters typeClassTarget) <+> 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
src/Data/Morpheus/CodeGen/Internal/Flags.hs view
@@ -40,16 +40,16 @@ Flags ) -deriving instance MonadError GQLError m => MonadError GQLError (CodeGenT ctx m)+deriving instance (MonadError GQLError m) => MonadError GQLError (CodeGenT ctx m) instance MonadTrans (CodeGenT ctx) where lift = CodeGenT . lift . lift -runCodeGenT :: Monad m => CodeGenT ctx m a -> ctx -> m (a, Flags)+runCodeGenT :: (Monad m) => CodeGenT ctx m a -> ctx -> m (a, Flags) runCodeGenT (CodeGenT m) ctx = runStateT (runReaderT m ctx) mempty -langExtension :: MonadState Flags m => Text -> m ()+langExtension :: (MonadState Flags m) => Text -> m () langExtension ext = modify (FlagLanguageExtension ext :) -requireExternal :: MonadState Flags m => Text -> m ()+requireExternal :: (MonadState Flags m) => Text -> m () requireExternal ext = modify (FlagExternal ext :)
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
src/Data/Morpheus/CodeGen/Printer.hs view
@@ -48,7 +48,7 @@ renderList :: HSDoc n -> HSDoc n renderList = pack . list . pure . rawDocument -print' :: Printer a => a -> Doc n+print' :: (Printer a) => a -> Doc n print' = unpack . print pack :: Doc n -> HSDoc n
src/Data/Morpheus/CodeGen/TH.hs view
@@ -66,7 +66,7 @@ _' :: PatQ _' = toVar (mkName "_") -v' :: ToVar Name a => a+v' :: (ToVar Name a) => a v' = toVar (mkName "v") wrappedType :: TypeWrapper -> Type -> Type@@ -108,7 +108,7 @@ class ToString a b where toString :: a -> b -instance ToString a b => ToString a (Q b) where+instance (ToString a b) => ToString a (Q b) where toString = pure . toString instance ToString TypeName Lit where@@ -129,7 +129,7 @@ class ToCon a b where toCon :: a -> b -instance ToCon a b => ToCon a (Q b) where+instance (ToCon a b) => ToCon a (Q b) where toCon = pure . toCon instance (ToName a) => ToCon a Type where@@ -150,7 +150,7 @@ class ToVar a b where toVar :: a -> b -instance ToVar a b => ToVar a (Q b) where+instance (ToVar a b) => ToVar a (Q b) where toVar = pure . toVar instance (ToName a) => ToVar a Type where@@ -163,7 +163,7 @@ toVar = VarP . toName class Apply a where- apply :: ToCon i a => i -> [a] -> a+ apply :: (ToCon i a) => i -> [a] -> a instance Apply TypeQ where apply = foldl' appT . toCon@@ -289,7 +289,7 @@ foldr applyWrapper (toCon fieldType) wrappers ) -printTypeSynonym :: ToName a => a -> [Name] -> Type -> Dec+printTypeSynonym :: (ToName a) => a -> [Name] -> Type -> Dec printTypeSynonym name params = TySynD (toName name) (toTypeVars params) instance ToName CodeGenTypeName where@@ -322,7 +322,7 @@ printType (AssociatedLocations xs) = pure $ foldr (AppT . AppT PromotedConsT . PromotedT . toName) PromotedNilT xs printType (AssociatedTypeName name) = toCon name -instance PrintExp body => PrintDec (TypeClassInstance body) where+instance (PrintExp body) => PrintDec (TypeClassInstance body) where printDec TypeClassInstance {..} = instanceD (printConstraints typeClassContext)@@ -345,8 +345,8 @@ instance PrintDec CodeGenType where printDec CodeGenType {..} =- pure $- DataD+ pure+ $ DataD [] (toName cgTypeName) (toTypeVars $ map toName $ typeParameters cgTypeName)