-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Scrap your qualified import clutter -- -- See https://theam.github.io/require @package require @version 0.4.9 -- | This module contains functions for file handling. The names of the -- functions and data types are chosen in a way to suggest a qualified -- import. -- --
-- import qualified Require.File as File --module Require.File -- | Wraps the name of a file as given by the user. Usually this -- corresponds to the file's path. newtype Name Name :: Text -> Name -- | Associates a file's contents with the path from which it was read. data Input Input :: Name -> Text -> Input [inputName] :: Input -> Name [inputContent] :: Input -> Text -- | A type-safe wrapper for line numbers. newtype LineNumber LineNumber :: Int -> LineNumber -- | Identifies a specific line in a file. data LineTag LineTag :: !Name -> !LineNumber -> LineTag -- | Returns the LineTag referencing the first line in a given -- FileInput. -- -- Note that the tag's line number is 1-based, which fits well with how -- GHC understands {-# LINE ... #-} pragmas. initialLineTag :: Input -> LineTag -- | Returns a line tag from the same file but referencing the next line. advanceLineTag :: LineTag -> LineTag -- | read name reads the contents of the file identified by -- name. read :: Name -> IO Input -- | write name lines writes all every line in lines to -- the file identified by name and appends a newline. writeLines :: Name -> [Text] -> IO () -- | Splits the input into lines and annotates each with a LineTag. inputLines :: Input -> [(LineTag, Text)] -- | Returns the FilePath corresponding a given Name. nameToPath :: Name -> FilePath instance GHC.Enum.Enum Require.File.LineNumber module Require.Error data Error MissingRequiresFile :: Error MissingOptionalRequiresFile :: Error AutorequireImpossible :: Error describe :: Error -> [String] die :: Name -> Error -> IO a instance GHC.Show.Show Require.Error.Error instance GHC.Classes.Eq Require.Error.Error module Require.Types -- | A type-safe wrapper around a fully qualified module name. newtype ModuleName ModuleName :: Text -> ModuleName [unModuleName] :: ModuleName -> Text -- | Describes the different directives which require special processing -- during the transformation step. data RequireDirective ModuleDirective :: ModuleName -> RequireDirective RequireDirective :: RequireInfo -> RequireDirective AutorequireDirective :: RequireDirective -- | Describes the contents of a parsed require directive. -- --
-- require riFullModuleName as riModuleAlias (riImportedTypes) --data RequireInfo RequireInfo :: !ModuleName -> !Text -> !Text -> RequireInfo [riFullModuleName] :: RequireInfo -> !ModuleName [riModuleAlias] :: RequireInfo -> !Text [riImportedTypes] :: RequireInfo -> !Text data AutorequireMode a -- | Include the contents of the Requires file directly after the -- module … where directive. AutorequireEnabled :: a -> AutorequireMode a -- | Include the contents of the Requires file when the user specifies the -- autorequire directive. AutorequireOnDirective :: Maybe a -> AutorequireMode a -- | Don't do any auto-requiring. AutorequireDisabled :: AutorequireMode a instance Data.Traversable.Traversable Require.Types.AutorequireMode instance Data.Foldable.Foldable Require.Types.AutorequireMode instance GHC.Base.Functor Require.Types.AutorequireMode instance GHC.Show.Show Require.Types.RequireInfo instance GHC.Show.Show Require.Types.ModuleName instance GHC.Classes.Eq Require.Types.ModuleName module Require.Parser type Parser = Parsec Void Text requireDirective :: Parser RequireDirective -- | parseMaybe p input runs the parser p on -- input and returns the result inside Just on success -- and Nothing on failure. This function also parses eof, -- so if the parser doesn't consume all of its input, it will fail. -- -- The function is supposed to be useful for lightweight parsing, where -- error messages (and thus file names) are not important and entire -- input should be parsed. For example, it can be used when parsing of a -- single number according to a specification of its format is desired. parseMaybe :: (Ord e, Stream s) => Parsec e s a -> s -> Maybe a module Require.Transform -- | The monad stack used during transformation: -- -- type TransformM = StateT TransformState (WriterT (DList Text) (Either Error)) data TransformState TransformState :: (LineTag -> TransformM ()) -> !Maybe ModuleName -> !AutorequireMode Input -> TransformState [tstLineTagOutput] :: TransformState -> LineTag -> TransformM () [tstHostModule] :: TransformState -> !Maybe ModuleName [tstAutorequire] :: TransformState -> !AutorequireMode Input -- | Outputs a single line. output :: Text -> TransformM () -- | Outputs the pragma representation of the given line tag. renderLineTag :: LineTag -> TransformM () -- | Ignore the given line tag, specifically don't render it. ignoreLineTag :: LineTag -> TransformM () transform :: AutorequireMode Input -> Input -> Either Error [Text] process :: Bool -> (LineTag, Text) -> TransformM () processAutorequireContent :: Input -> TransformM () renderImport :: Bool -> LineTag -> RequireInfo -> TransformM () module Require data CommandArguments CommandArguments :: Text -> Text -> Text -> CommandArguments findRequires :: IO (Maybe Name) requireMain :: IO () autorequireMain :: IO () run :: AutorequireMode Name -> Name -> Name -> IO () instance GHC.Generics.Generic Require.CommandArguments instance Options.Generic.ParseRecord Require.CommandArguments