-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Protocol buffer compiler for the proto-lens library.
--   
--   Turn protocol buffer files (.proto) into Haskell files (.hs) which can
--   be used with the proto-lens package. The library component of this
--   package contains compiler code (namely Data.ProtoLens.Compiler.*) is
--   not guaranteed to have stable APIs.'
@package proto-lens-protoc
@version 0.3.1.0


-- | Some utility functions, classes and instances for nicer code
--   generation.
--   
--   Re-exports simpler versions of the types and constructors from
--   <tt>haskell-src-exts</tt>.
--   
--   We define orphan instances of IsString for various syntax datatypes,
--   with some intelligence about Haskell names. For example, <tt>"foo" ::
--   Exp</tt> is treated as a variable and <tt><a>Foo</a> :: Exp</tt> is
--   treated as a constructor.
module Data.ProtoLens.Compiler.Combinators

-- | Application of a Haskell type or expression to an argument. For
--   example, to represent <tt>f x y</tt>, you can write
--   
--   <pre>
--   "f" @@ "x" @@ "y"
--   </pre>
class App a
(@@) :: App a => a -> a -> a
type Promoted = Promoted ()
type Type = Type ()
type TyVarBind = TyVarBind ()
type QName = QName ()
type Pat = Pat ()
type Name = Name ()
type ModulePragma = ModulePragma ()
type ModuleName = ModuleName ()
type ExportSpec = ExportSpec ()

-- | A declaration, along with an optional comment.
data CommentedDecl
CommentedDecl :: (Maybe String) -> Decl -> CommentedDecl

-- | A hand-rolled type for modules, which allows comments on top-level
--   declarations.
data Module
Module :: ModuleName -> (Maybe [ExportSpec]) -> [ModulePragma] -> [ImportDecl ()] -> [CommentedDecl] -> Module
type Match = Match ()
type InstHead = InstHead ()
type FieldUpdate = FieldUpdate ()
type Alt = Alt ()
type Exp = Exp ()
type Deriving = Deriving ()
type Decl = Decl ()
type ConDecl = ConDecl ()
type Asst = Asst ()
prettyPrint :: Pretty a => a -> String
prettyPrim :: Pretty a => a -> Doc
classA :: QName -> [Type] -> Asst
equalP :: Type -> Type -> Asst
conDecl :: Name -> [Type] -> ConDecl
recDecl :: Name -> [(Name, Type)] -> ConDecl
patSynSig :: Name -> Type -> Decl
patSyn :: Pat -> Pat -> Decl
dataDecl :: Name -> [ConDecl] -> Deriving -> Decl
newtypeDecl :: Name -> Type -> Deriving -> Decl
dataDeclHelper :: DataOrNew () -> Name -> [ConDecl] -> Deriving -> Decl
deriving' :: [QName] -> Deriving
funBind :: [Match] -> Decl
instType :: Type -> Type -> InstDecl ()
instMatch :: [Match] -> InstDecl ()
instDeclWithTypes :: [Asst] -> InstHead -> [InstDecl ()] -> Decl
instDecl :: [Asst] -> InstHead -> [[Match]] -> Decl
typeSig :: [Name] -> Type -> Decl
let' :: [Decl] -> Exp -> Exp
case' :: Exp -> [Alt] -> Exp
alt :: Pat -> Exp -> Alt
stringExp :: String -> Exp
tuple :: [Exp] -> Exp
lambda :: [Pat] -> Exp -> Exp
(@::@) :: Exp -> Type -> Exp
infixl 2 @::@
recConstr :: QName -> [FieldUpdate] -> Exp
recUpdate :: Exp -> [FieldUpdate] -> Exp
var :: QName -> Exp
con :: QName -> Exp
list :: [Exp] -> Exp
fieldUpdate :: QName -> Exp -> FieldUpdate
ihApp :: InstHead -> [Type] -> InstHead
tyParen :: Type -> Type

-- | A simple clause of a function binding.
match :: Name -> [Pat] -> Exp -> Match ()
uncommented :: Decl -> CommentedDecl
commented :: String -> Decl -> CommentedDecl
prettyPrintModule :: Module -> String
getModuleName :: Module -> ModuleName
languagePragma :: [Name] -> ModulePragma
optionsGhcPragma :: String -> ModulePragma
exportVar :: QName -> ExportSpec
exportAll :: QName -> ExportSpec
exportWith :: QName -> [Name] -> ExportSpec
pApp :: QName -> [Pat] -> Pat
pVar :: Name -> Pat
pWildCard :: Pat
stringPat :: String -> Pat
qual :: ModuleName -> Name -> QName
unQual :: Name -> QName
tyCon :: QName -> Type
tyList :: Type -> Type
tyPromotedList :: [Type] -> Type
tyPromotedString :: String -> Type
tyPromotedCon :: Promoted -> Type
tyForAll :: [TyVarBind] -> [Asst] -> Type -> Type
tyBang :: Type -> Type

-- | Whether this character belongs to an Ident (e.g., "foo") or a symbol
--   (e.g., "<a>$</a>").
isIdentChar :: Char -> Bool
litInt :: Integer -> Exp
litFrac :: Rational -> Exp
pLitInt :: Integer -> Pat
string :: String -> Literal ()
modifyModuleName :: (String -> String) -> ModuleName -> ModuleName

-- | An import declaration.
data ImportDecl l
ImportDecl :: l -> ModuleName l -> Bool -> Bool -> Bool -> Maybe String -> Maybe ModuleName l -> Maybe ImportSpecList l -> ImportDecl l

-- | annotation, used by parser for position of the <tt>import</tt>
--   keyword.
[importAnn] :: ImportDecl l -> l

-- | name of the module imported.
[importModule] :: ImportDecl l -> ModuleName l

-- | imported <tt>qualified</tt>?
[importQualified] :: ImportDecl l -> Bool

-- | imported with <tt>{-# SOURCE #-}</tt>?
[importSrc] :: ImportDecl l -> Bool

-- | Import <tt>safe</tt>?
[importSafe] :: ImportDecl l -> Bool

-- | imported with explicit package name
[importPkg] :: ImportDecl l -> Maybe String

-- | optional alias name in an <tt>as</tt> clause.
[importAs] :: ImportDecl l -> Maybe ModuleName l

-- | optional list of import specifications.
[importSpecs] :: ImportDecl l -> Maybe ImportSpecList l
instance Data.ProtoLens.Compiler.Combinators.App Data.ProtoLens.Compiler.Combinators.Type
instance Data.ProtoLens.Compiler.Combinators.App Data.ProtoLens.Compiler.Combinators.Exp
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.Promoted
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.Type
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.TyVarBind
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.QName
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.Pat
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.Name
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.ModuleName
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.InstHead
instance Data.String.IsString Data.ProtoLens.Compiler.Combinators.Exp


-- | This module takes care of collecting all the definitions in a .proto
--   file and assigning Haskell names to all of the defined things
--   (messages, enums and field names).
module Data.ProtoLens.Compiler.Definitions

-- | <a>Env</a> contains a mapping of proto names (as specified in the
--   .proto file) to Haskell names. The keys are fully-qualified names, for
--   example, ".package.Message.Submessage". (The protocol_compiler tool
--   emits all message field types in this form, even if they refer to
--   local definitions.)
--   
--   The type <tt>n</tt> can be either a <a>Name</a> (when talking about
--   definitions within the current file) or a (qualified) <a>QName</a>
--   (when talking about definitions either from this or another file).
type Env n = Map Text (Definition n)
data Definition n
Message :: (MessageInfo n) -> Definition n
Enum :: (EnumInfo n) -> Definition n

-- | All the information needed to define or use a proto message type.
data MessageInfo n
MessageInfo :: n -> DescriptorProto -> [FieldInfo] -> [OneofInfo] -> Name -> MessageInfo n

-- | Haskell type name
[messageName] :: MessageInfo n -> n
[messageDescriptor] :: MessageInfo n -> DescriptorProto

-- | Fields not belonging to a oneof.
[messageFields] :: MessageInfo n -> [FieldInfo]

-- | The oneofs in this message, associated with the fields that belong to
--   them.
[messageOneofFields] :: MessageInfo n -> [OneofInfo]

-- | The name of the Haskell field in this message that holds the unknown
--   fields.
[messageUnknownFields] :: MessageInfo n -> Name
data ServiceInfo
ServiceInfo :: Text -> Text -> [MethodInfo] -> ServiceInfo
[serviceName] :: ServiceInfo -> Text
[servicePackage] :: ServiceInfo -> Text
[serviceMethods] :: ServiceInfo -> [MethodInfo]
data MethodInfo
MethodInfo :: Text -> Text -> Text -> Text -> Bool -> Bool -> MethodInfo
[methodName] :: MethodInfo -> Text
[methodIdent] :: MethodInfo -> Text
[methodInput] :: MethodInfo -> Text
[methodOutput] :: MethodInfo -> Text
[methodClientStreaming] :: MethodInfo -> Bool
[methodServerStreaming] :: MethodInfo -> Bool

-- | Information about a single field of a proto message.
data FieldInfo
FieldInfo :: FieldDescriptorProto -> FieldName -> FieldInfo
[fieldDescriptor] :: FieldInfo -> FieldDescriptorProto
[plainFieldName] :: FieldInfo -> FieldName
data OneofInfo
OneofInfo :: FieldName -> Name -> [OneofCase] -> OneofInfo
[oneofFieldName] :: OneofInfo -> FieldName

-- | The name of the sum type corresponding to this oneof.
[oneofTypeName] :: OneofInfo -> Name

-- | The individual fields that make up this oneof.
[oneofCases] :: OneofInfo -> [OneofCase]
data OneofCase
OneofCase :: FieldInfo -> Name -> Name -> OneofCase
[caseField] :: OneofCase -> FieldInfo

-- | The constructor for building a <a>oneofTypeName</a> from the value in
--   this field.
[caseConstructorName] :: OneofCase -> Name

-- | The name for building <tt>Prism</tt> definition.
[casePrismName] :: OneofCase -> Name
data FieldName
FieldName :: Symbol -> Name -> FieldName

-- | The overloaded name of lenses that access this field. For example, if
--   the field is called "foo_bar" in the .proto then <tt>overloadedName ==
--   "fooBar"</tt> and we might generate <tt>fooBar</tt> and/or
--   <tt>maybe'fooBar</tt> lenses to access the data.
--   
--   May be shared between two different message data types in the same
--   module.
[overloadedName] :: FieldName -> Symbol

-- | The Haskell name of this internal record field; for example,
--   "_Foo<tt>Bar</tt>baz. Unique within each module.
[haskellRecordFieldName] :: FieldName -> Name

-- | A string that refers to the name (in Haskell) of a lens that accesses
--   a field.
--   
--   For example, in the signature of the overloaded lens
--   
--   <pre>
--   foo :: HasLens "foo" ... =&gt; Lens ...
--   </pre>
--   
--   a <a>Symbol</a> is used to construct both the type-level argument to
--   <tt>HasLens</tt> and the name of the function <tt>foo</tt>.
data Symbol
nameFromSymbol :: Symbol -> Name

-- | Construct a promoted, type-level string.
promoteSymbol :: Symbol -> Type

-- | All the information needed to define or use a proto enum type.
data EnumInfo n
EnumInfo :: n -> n -> n -> EnumDescriptorProto -> [EnumValueInfo n] -> EnumInfo n
[enumName] :: EnumInfo n -> n
[enumUnrecognizedName] :: EnumInfo n -> n
[enumUnrecognizedValueName] :: EnumInfo n -> n
[enumDescriptor] :: EnumInfo n -> EnumDescriptorProto
[enumValues] :: EnumInfo n -> [EnumValueInfo n]

-- | Information about a single value case of a proto enum.
data EnumValueInfo n
EnumValueInfo :: n -> EnumValueDescriptorProto -> Maybe Name -> EnumValueInfo n
[enumValueName] :: EnumValueInfo n -> n
[enumValueDescriptor] :: EnumValueInfo n -> EnumValueDescriptorProto

-- | If <a>Nothing</a>, we turn value into a normal constructor of the
--   enum. If <tt><a>Just</a> n</tt>, we're treating it as an alias of the
--   constructor <tt>n</tt> (a PatternSynonym in Haskell). This mirrors the
--   behavior of the Java API.
[enumAliasOf] :: EnumValueInfo n -> Maybe Name
qualifyEnv :: ModuleName -> Env Name -> Env QName
unqualifyEnv :: Env Name -> Env QName

-- | Collect all the definitions in the given file (including definitions
--   nested in other messages), and assign Haskell names to them.
collectDefinitions :: FileDescriptorProto -> Env Name
collectServices :: FileDescriptorProto -> [ServiceInfo]

-- | Look up the Haskell name for the type of a given field (message or
--   enum).
definedFieldType :: FieldDescriptorProto -> Env QName -> Definition QName

-- | Look up the Haskell name for the type of a given type.
definedType :: Text -> Env QName -> Definition QName
camelCase :: Text -> Text
instance GHC.Base.Functor Data.ProtoLens.Compiler.Definitions.Definition
instance GHC.Base.Functor Data.ProtoLens.Compiler.Definitions.EnumInfo
instance GHC.Base.Functor Data.ProtoLens.Compiler.Definitions.EnumValueInfo
instance GHC.Base.Functor Data.ProtoLens.Compiler.Definitions.MessageInfo
instance GHC.Base.Monoid Data.ProtoLens.Compiler.Definitions.Symbol
instance GHC.Base.Semigroup Data.ProtoLens.Compiler.Definitions.Symbol
instance Data.String.IsString Data.ProtoLens.Compiler.Definitions.Symbol
instance GHC.Classes.Ord Data.ProtoLens.Compiler.Definitions.Symbol
instance GHC.Classes.Eq Data.ProtoLens.Compiler.Definitions.Symbol


-- | This module builds the actual, generated Haskell file for a given
--   input .proto file.
module Data.ProtoLens.Compiler.Generate

-- | Generate a Haskell module for the given input file(s). input contains
--   all defined names, incl. those in this module
generateModule :: ModuleName -> [ModuleName] -> SyntaxType -> ModifyImports -> Env Name -> Env QName -> [ServiceInfo] -> [Module]
fileSyntaxType :: FileDescriptorProto -> SyntaxType
type ModifyImports = ImportDecl () -> ImportDecl ()
reexported :: ModifyImports
instance GHC.Read.Read Data.ProtoLens.Compiler.Generate.UseReexport
instance GHC.Classes.Eq Data.ProtoLens.Compiler.Generate.UseReexport
instance GHC.Classes.Eq Data.ProtoLens.Compiler.Generate.SyntaxType
instance GHC.Show.Show Data.ProtoLens.Compiler.Generate.SyntaxType

module Data.ProtoLens.Compiler.Plugin

-- | The filename of an input .proto file.
type ProtoFileName = Text
data ProtoFile
ProtoFile :: FileDescriptorProto -> ModuleName -> Env Name -> [ServiceInfo] -> [ProtoFileName] -> Env QName -> ProtoFile
[descriptor] :: ProtoFile -> FileDescriptorProto
[haskellModule] :: ProtoFile -> ModuleName
[definitions] :: ProtoFile -> Env Name
[services] :: ProtoFile -> [ServiceInfo]

-- | The names of proto files exported (transitively, via "import public"
--   decl) by this file.
[exports] :: ProtoFile -> [ProtoFileName]
[exportedEnv] :: ProtoFile -> Env QName
analyzeProtoFiles :: Text -> [FileDescriptorProto] -> Map ProtoFileName ProtoFile
collectEnvFromDeps :: [ProtoFileName] -> Map ProtoFileName ProtoFile -> Env QName

-- | Get the output file path (for CodeGeneratorResponse.File) for a
--   Haskell ModuleName.
outputFilePath :: String -> Text

-- | Get the Haskell <a>ModuleName</a> corresponding to a given .proto
--   file.
moduleName :: Text -> FileDescriptorProto -> ModuleName

-- | Get the Haskell module name corresponding to a given .proto file.
moduleNameStr :: String -> FilePath -> String


-- | Helper functions to generate proto files as part of a
--   <tt>Setup.hs</tt> script.
--   
--   These functions assume that the <tt>proto-lens-protoc</tt> executable
--   is on the PATH, and throw an exception otherwise. That executable will
--   be installed automatically as part of installing this package; in
--   particular, it should be enough to just list `proto-lens-protoc` in a
--   user package's `build-dependencies`.
--   
--   See <tt>README.md</tt> for instructions on how to use proto-lens with
--   Cabal.
module Data.ProtoLens.Setup

-- | This behaves the same as <a>defaultMain</a>, but auto-generates
--   Haskell files from .proto files which are:
--   
--   <ul>
--   <li>Listed in the <tt>.cabal</tt> file under
--   <tt>extra-source-files</tt>,</li>
--   <li>Located under the given root directory, and</li>
--   <li>Correspond to a module (<tt>"Proto.*"</tt>) in `exposed-modules`
--   or `other-modules` of some component in the <tt>.cabal</tt> file.</li>
--   </ul>
--   
--   Writes the generated files to the autogen directory
--   (<tt>dist/build/autogen</tt> for Cabal, and
--   <tt>.stack-work/dist/.../build/autogen</tt> for stack).
--   
--   Throws an exception if the <tt>proto-lens-protoc</tt> executable is
--   not on the PATH.
defaultMainGeneratingProtos :: FilePath -> IO ()

-- | This behaves the same as <a>defaultMain</a>, but auto-generates
--   Haskell files from the .proto files listed. The given .proto files
--   should be under the given root directory.
--   
--   Writes the generated files to the autogen directory
--   (<tt>dist/build/autogen</tt> for Cabal, and
--   <tt>.stack-work/dist/.../build/autogen</tt> for stack).
--   
--   Throws an exception if the <tt>proto-lens-protoc</tt> executable is
--   not on the PATH.
defaultMainGeneratingSpecificProtos :: FilePath -> (LocalBuildInfo -> IO [FilePath]) -> IO ()

-- | Augment the given <a>UserHooks</a> to auto-generate Haskell files from
--   the .proto files which are:
--   
--   <ul>
--   <li>Listed in the <tt>.cabal</tt> file under
--   <tt>extra-source-files</tt>,</li>
--   <li>Located under the given root directory, and</li>
--   <li>Correspond to a module (<tt>"Proto.*"</tt>) in `exposed-modules`
--   or `other-modules` of some component in the <tt>.cabal</tt> file.</li>
--   </ul>
--   
--   Writes the generated files to the autogen directory
--   (<tt>dist/build/autogen</tt> for Cabal, and
--   <tt>.stack-work/dist/.../build/autogen</tt> for stack).
--   
--   Throws an exception if the <tt>proto-lens-protoc</tt> executable is
--   not on the PATH.
generatingProtos :: FilePath -> UserHooks -> UserHooks

-- | Augment the given <a>UserHooks</a> to auto-generate Haskell files from
--   the .proto files returned by a function <tt>getProtos</tt>.
--   
--   Writes the generated files to the autogen directory
--   (<tt>dist/build/autogen</tt> for Cabal, and
--   <tt>.stack-work/dist/.../build/autogen</tt> for stack).
--   
--   Throws an exception if the <tt>proto-lens-protoc</tt> executable is
--   not on the PATH.
generatingSpecificProtos :: FilePath -> (LocalBuildInfo -> IO [FilePath]) -> UserHooks -> UserHooks

-- | Run the proto compiler to generate Haskell files from the given .proto
--   files.
--   
--   Writes the generated files to the autogen directory
--   (<tt>dist/build/autogen</tt> for Cabal, and
--   <tt>.stack-work/dist/.../build/autogen</tt> for stack).
--   
--   Throws an exception if the <tt>proto-lens-protoc</tt> executable is
--   not on the PATH.
generateProtosWithImports :: [FilePath] -> FilePath -> [FilePath] -> IO ()

-- | Run the proto compiler to generate Haskell files from the given .proto
--   files.
--   
--   Writes the generated files to the autogen directory
--   (<tt>dist/build/autogen</tt> for Cabal, and
--   <tt>.stack-work/dist/.../build/autogen</tt> for stack).
--   
--   Throws an exception if the <tt>proto-lens-protoc</tt> executable is
--   not on the PATH.
generateProtos :: FilePath -> FilePath -> [FilePath] -> IO ()
