-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell Tool Stack -- -- Please see the documentation at https://docs.haskellstack.org -- for usage information. -- -- If building a stack executable for distribution, please -- download the source code from -- https://github.com/commercialhaskell/stack/releases and build -- it using Stack itself in order to ensure identical behaviour to -- official binaries. This package on Hackage is provided for convenience -- and bootstrapping purposes. -- -- Note that the API for the library is not currently stable, and may -- change significantly, even between minor releases. It is currently -- only intended for use by the executable. @package stack @version 2.9.3 -- | Wrapper functions of Simple and Client to add the -- 'User-Agent' HTTP request header to each request. module Network.HTTP.StackClient httpJSON :: (MonadIO m, FromJSON a) => Request -> m (Response a) httpLbs :: MonadIO m => Request -> m (Response LByteString) httpNoBody :: MonadIO m => Request -> m (Response ()) httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a -- | Modify the request so that non-2XX status codes generate a runtime -- StatusCodeException, by using throwErrorStatusCodes setRequestCheckStatus :: Request -> Request -- | Set the request method setRequestMethod :: ByteString -> Request -> Request -- | Set the given request header to the given list of values. Removes any -- previously set header values with the same name. setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request -- | Add a request header name/value combination addRequestHeader :: HeaderName -> ByteString -> Request -> Request -- | Set the request body to the given RequestBody. You may want to -- consider using one of the convenience functions in the modules, e.g. -- requestBodyJSON. -- -- Note: This will not modify the request method. For that, please -- use requestMethod. You likely don't want the default of -- GET. setRequestBody :: RequestBody -> Request -> Request -- | Get all response headers getResponseHeaders :: Response a -> [(HeaderName, ByteString)] -- | Get the response body getResponseBody :: Response a -> a -- | Get the integral status code of the response getResponseStatusCode :: Response a -> Int -- | Convert a URL into a Request. -- -- This function defaults some of the values in Request, such as -- setting method to GET and requestHeaders -- to []. -- -- Since this function uses MonadThrow, the return monad can be -- anything that is an instance of MonadThrow, such as IO -- or Maybe. -- -- You can place the request method at the beginning of the URL separated -- by a space, e.g.: -- -- @@ parseRequest "POST http://httpbin.org/post" @@ -- -- Note that the request method must be provided as all capital letters. -- -- A Request created by this function won't cause exceptions on -- non-2XX response status codes. -- -- To create a request which throws on non-2XX status codes, see -- parseUrlThrow parseRequest :: MonadThrow m => String -> m Request -- | Extract a URI from the request. -- -- Since 0.1.0 getUri :: Request -> URI -- | Everything from the host to the query string. -- -- Since 0.1.0 path :: Request -> ByteString -- | Check the response immediately after receiving the status and headers. -- This can be useful for throwing exceptions on non-success status -- codes. -- -- In previous versions of http-client, this went under the name -- checkStatus, but was renamed to avoid confusion about the new -- default behavior (doing nothing). checkResponse :: Request -> Request -> Response BodyReader -> IO () -- | Same as parseRequest, except will throw an HttpException -- in the event of a non-2XX response. This uses -- throwErrorStatusCodes to implement checkResponse. parseUrlThrow :: MonadThrow m => String -> m Request -- | Custom HTTP request headers -- -- The Content-Length and Transfer-Encoding headers are set automatically -- by this module, and shall not be added to requestHeaders. -- -- If not provided by the user, Host will automatically be set -- based on the host and port fields. -- -- Moreover, the Accept-Encoding header is set implicitly to gzip for -- convenience by default. This behaviour can be overridden if needed, by -- setting the header explicitly to a different value. In order to omit -- the Accept-Header altogether, set it to the empty string "". If you -- need an empty Accept-Header (i.e. requesting the identity encoding), -- set it to a non-empty white-space string, e.g. " ". See RFC 2616 -- section 14.3 for details about the semantics of the Accept-Header -- field. If you request a content-encoding not supported by this module, -- you will have to decode it yourself (see also the decompress -- field). -- -- Note: Multiple header fields with the same field-name will result in -- multiple header fields being sent and therefore it's the -- responsibility of the client code to ensure that the rules from RFC -- 2616 section 4.2 are honoured. -- -- Since 0.1.0 requestHeaders :: Request -> RequestHeaders -- | Get the current global Manager getGlobalManager :: IO Manager -- | Apply digest authentication to this request. -- -- Note that this function will need to make an HTTP request to the -- server in order to get the nonce, thus the need for a Manager -- and to live in IO. This also means that the request body will -- be sent to the server. If the request body in the supplied -- Request can only be read once, you should replace it with a -- dummy value. -- -- In the event of successfully generating a digest, this will return a -- Just value. If there is any problem with generating the -- digest, it will return Nothing. applyDigestAuth :: (MonadIO m, MonadThrow n) => ByteString -> ByteString -> Request -> Manager -> m (n Request) -- | User friendly display of a DigestAuthException displayDigestAuthException :: DigestAuthException -> String -- | All information on how to connect to a host and what should be sent in -- the HTTP request. -- -- If you simply wish to download from a URL, see parseRequest. -- -- The constructor for this data type is not exposed. Instead, you should -- use either the defaultRequest value, or parseRequest -- to construct from a URL, and then use the records below to make -- modifications. This approach allows http-client to add configuration -- options without breaking backwards compatibility. -- -- For example, to construct a POST request, you could do something like: -- --
-- initReq <- parseRequest "http://www.example.com/path"
-- let req = initReq
-- { method = "POST"
-- }
--
--
-- For more information, please see
-- http://www.yesodweb.com/book/settings-types.
--
-- Since 0.1.0
data Request
-- | When using one of the RequestBodyStream /
-- RequestBodyStreamChunked constructors, you must ensure that the
-- GivesPopper can be called multiple times. Usually this is not a
-- problem.
--
-- The RequestBodyStreamChunked will send a chunked request body.
-- Note that not all servers support this. Only use
-- RequestBodyStreamChunked if you know the server you're sending
-- to supports chunked request bodies.
--
-- Since 0.1.0
data RequestBody
RequestBodyLBS :: ByteString -> RequestBody
RequestBodyBS :: ByteString -> RequestBody
-- | A simple representation of the HTTP response.
--
-- Since 0.1.0
data Response body
-- | An exception which may be generated by this library
data HttpException
-- | Most exceptions are specific to a Request. Inspect the
-- HttpExceptionContent value for details on what occurred.
HttpExceptionRequest :: Request -> HttpExceptionContent -> HttpException
-- | A URL (first field) is invalid for a given reason (second argument).
InvalidUrlException :: String -> String -> HttpException
data HttpExceptionContent
-- | Generated by the parseUrlThrow function when the server
-- returns a non-2XX response status code.
--
-- May include the beginning of the response body.
StatusCodeException :: Response () -> ByteString -> HttpExceptionContent
-- | The server responded with too many redirects for a request.
--
-- Contains the list of encountered responses containing redirects in
-- reverse chronological order; including last redirect, which triggered
-- the exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpExceptionContent
-- | Either too many headers, or too many total bytes in a single header,
-- were returned by the server, and the memory exhaustion protection in
-- this library has kicked in.
OverlongHeaders :: HttpExceptionContent
-- | The server took too long to return a response. This can be altered via
-- responseTimeout or managerResponseTimeout.
ResponseTimeout :: HttpExceptionContent
-- | Attempting to connect to the server timed out.
ConnectionTimeout :: HttpExceptionContent
-- | An exception occurred when trying to connect to the server.
ConnectionFailure :: SomeException -> HttpExceptionContent
-- | The status line returned by the server could not be parsed.
InvalidStatusLine :: ByteString -> HttpExceptionContent
-- | The given response header line could not be parsed
InvalidHeader :: ByteString -> HttpExceptionContent
-- | The given request header is not compliant (e.g. has newlines)
InvalidRequestHeader :: ByteString -> HttpExceptionContent
-- | An exception was raised by an underlying library when performing the
-- request. Most often, this is caused by a failing socket action or a
-- TLS exception.
InternalException :: SomeException -> HttpExceptionContent
-- | A non-200 status code was returned when trying to connect to the proxy
-- server on the given host and port.
ProxyConnectException :: ByteString -> Int -> Status -> HttpExceptionContent
-- | No response data was received from the server at all. This exception
-- may deserve special handling within the library, since it may indicate
-- that a pipelining has been used, and a connection thought to be open
-- was in fact closed.
NoResponseDataReceived :: HttpExceptionContent
-- | Exception thrown when using a Manager which does not have
-- support for secure connections. Typically, you will want to use
-- tlsManagerSettings from http-client-tls to overcome
-- this.
TlsNotSupported :: HttpExceptionContent
-- | The request body provided did not match the expected size.
--
-- Provides the expected and actual size.
WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpExceptionContent
-- | The returned response body is too short. Provides the expected size
-- and actual size.
ResponseBodyTooShort :: Word64 -> Word64 -> HttpExceptionContent
-- | A chunked response body had invalid headers.
InvalidChunkHeaders :: HttpExceptionContent
-- | An incomplete set of response headers were returned.
IncompleteHeaders :: HttpExceptionContent
-- | The host we tried to connect to is invalid (e.g., an empty string).
InvalidDestinationHost :: ByteString -> HttpExceptionContent
-- | An exception was thrown when inflating a response body.
HttpZlibException :: ZlibException -> HttpExceptionContent
-- | Values in the proxy environment variable were invalid. Provides the
-- environment variable name and its value.
InvalidProxyEnvironmentVariable :: Text -> Text -> HttpExceptionContent
-- | Attempted to use a Connection which was already closed
ConnectionClosed :: HttpExceptionContent
-- | Proxy settings are not valid (Windows specific currently) @since 0.5.7
InvalidProxySettings :: Text -> HttpExceptionContent
-- | Not Found 404
notFound404 :: Status
-- | HTTP Header names according to
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
hAccept :: HeaderName
-- | HTTP Header names according to
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
hContentLength :: HeaderName
-- | HTTP Header names according to
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
hContentMD5 :: HeaderName
-- | HTTP Method constants.
methodPut :: Method
-- | Add form data to the Request.
--
-- This sets a new requestBody, adds a content-type request header
-- and changes the method to POST.
formDataBody :: MonadIO m => [Part] -> Request -> m Request
-- | Construct a Part from form name, filepath and a
-- RequestBody
--
--
-- partFileRequestBody "who_calls" "caller.json" $ RequestBodyBS "{\"caller\":\"Jason J Jason\"}"
--
--
-- -- -- empty upload form -- partFileRequestBody "file" mempty mempty ---- -- The Part does not have a content type associated with it. partFileRequestBody :: forall (m :: Type -> Type). Applicative m => Text -> FilePath -> RequestBody -> PartM m -- | Make a Part whose content is a strict ByteString. -- -- The Part does not have a file name or content type associated -- with it. partBS :: forall (m :: Type -> Type). Applicative m => Text -> ByteString -> PartM m -- | Make a Part whose content is a lazy ByteString. -- -- The Part does not have a file name or content type associated -- with it. partLBS :: forall (m :: Type -> Type). Applicative m => Text -> ByteString -> PartM m -- | Set the user-agent request header setGitHubHeaders :: Request -> Request -- | Download the given URL to the given location. If the file already -- exists, no download is performed. Otherwise, creates the parent -- directory, downloads to a temporary file, and on file download -- completion moves to the appropriate destination. -- -- Throws an exception if things go wrong download :: HasTerm env => Request -> Path Abs File -> RIO env Bool -- | Same as download, but will download a file a second time if it -- is already present. -- -- Returns True if the file was downloaded, False otherwise redownload :: HasTerm env => Request -> Path Abs File -> RIO env Bool -- | Copied and extended version of Network.HTTP.Download.download. -- -- Has the following additional features: * Verifies that response -- content-length header (if present) matches expected length * Limits -- the download to (close to) the expected # of bytes * Verifies that the -- expected # bytes were downloaded (not too few) * Verifies md5 if -- response includes content-md5 header * Verifies the expected hashes -- -- Throws VerifiedDownloadException. Throws IOExceptions related to file -- system operations. Throws HttpException. verifiedDownload :: HasTerm env => DownloadRequest -> Path Abs File -> (Maybe Integer -> ConduitM ByteString Void (RIO env) ()) -> RIO env Bool verifiedDownloadWithProgress :: HasTerm env => DownloadRequest -> Path Abs File -> Text -> Maybe Int -> RIO env Bool data CheckHexDigest CheckHexDigestString :: String -> CheckHexDigest CheckHexDigestByteString :: ByteString -> CheckHexDigest CheckHexDigestHeader :: ByteString -> CheckHexDigest -- | A request together with some checks to perform. -- -- Construct using the downloadRequest smart constructor and -- associated setters. The constructor itself is not exposed to avoid -- breaking changes with additional fields. data DownloadRequest -- | Default to retrying seven times with exponential backoff starting from -- one hundred milliseconds. -- -- This means the tries will occur after these delays if necessary: -- --
-- forgivingAbsence (resolveFile …) >>= rejectMissingFile --rejectMissingFile :: MonadIO m => Maybe (Path Abs File) -> m (Maybe (Path Abs File)) -- | See rejectMissingFile. rejectMissingDir :: MonadIO m => Maybe (Path Abs Dir) -> m (Maybe (Path Abs Dir)) -- | Convert to a ByteString using toFilePath and UTF8. pathToByteString :: Path b t -> ByteString -- | Convert to a lazy ByteString using toFilePath and UTF8. pathToLazyByteString :: Path b t -> ByteString pathToText :: Path b t -> Text tryGetModificationTime :: MonadIO m => Path Abs File -> m (Either () UTCTime) -- | Finding files. module Path.Find -- | Find the location of a file matching the given predicate. findFileUp :: (MonadIO m, MonadThrow m) => Path Abs Dir -> (Path Abs File -> Bool) -> Maybe (Path Abs Dir) -> m (Maybe (Path Abs File)) -- | Find the location of a directory matching the given predicate. findDirUp :: (MonadIO m, MonadThrow m) => Path Abs Dir -> (Path Abs Dir -> Bool) -> Maybe (Path Abs Dir) -> m (Maybe (Path Abs Dir)) -- | Find files matching predicate below a root directory. -- -- NOTE: this skips symbolic directory links, to avoid loops. This may -- not make sense for all uses of file finding. -- -- TODO: write one of these that traverses symbolic links but efficiently -- ignores loops. findFiles :: Path Abs Dir -> (Path Abs File -> Bool) -> (Path Abs Dir -> Bool) -> IO [Path Abs File] -- | findInParents f path applies f to path and -- its parents until it finds a Just or reaches the root -- directory. findInParents :: MonadIO m => (Path Abs Dir -> m (Maybe a)) -> Path Abs Dir -> m (Maybe a) module Paths_stack version :: Version getBinDir :: IO FilePath getLibDir :: IO FilePath getDynLibDir :: IO FilePath getDataDir :: IO FilePath getLibexecDir :: IO FilePath getDataFileName :: FilePath -> IO FilePath getSysconfDir :: IO FilePath module Stack.Prelude -- | Path version withSystemTempDir :: MonadUnliftIO m => String -> (Path Abs Dir -> m a) -> m a -- | Like withSystemTempDir, but the temporary directory is not -- deleted. withKeepSystemTempDir :: MonadUnliftIO m => String -> (Path Abs Dir -> m a) -> m a -- | Consume the stdout and stderr of a process feeding strict -- ByteStrings to the consumers. -- -- Throws a ReadProcessException if unsuccessful in launching, -- or ExitCodeException if the process itself fails. sinkProcessStderrStdout :: forall e o env. (HasProcessContext env, HasLogFunc env, HasCallStack) => String -> [String] -> ConduitM ByteString Void (RIO env) e -> ConduitM ByteString Void (RIO env) o -> RIO env (e, o) -- | Consume the stdout of a process feeding strict ByteStrings to a -- consumer. If the process fails, spits out stdout and stderr as error -- log level. Should not be used for long-running processes or ones with -- lots of output; for that use sinkProcessStderrStdout. -- -- Throws a ReadProcessException if unsuccessful. sinkProcessStdout :: (HasProcessContext env, HasLogFunc env, HasCallStack) => String -> [String] -> ConduitM ByteString Void (RIO env) a -> RIO env a logProcessStderrStdout :: (HasCallStack, HasProcessContext env, HasLogFunc env) => ProcessConfig stdin stdoutIgnored stderrIgnored -> RIO env () -- | Read from the process, ignoring any output. -- -- Throws a ReadProcessException exception if the process fails. readProcessNull :: (HasProcessContext env, HasLogFunc env, HasCallStack) => String -> [String] -> RIO env () -- | Use the new ProcessContext, but retain the working directory -- from the parent environment. withProcessContext :: HasProcessContext env => ProcessContext -> RIO env a -> RIO env a -- | Remove a trailing carriage pure if present stripCR :: Text -> Text -- | Prompt the user by sending text to stdout, and taking a line of input -- from stdin. prompt :: MonadIO m => Text -> m Text -- | Prompt the user by sending text to stdout, and collecting a line of -- input from stdin. While taking input from stdin, input echoing is -- disabled, to hide passwords. -- -- Based on code from cabal-install, Distribution.Client.Upload promptPassword :: MonadIO m => Text -> m Text -- | Prompt the user by sending text to stdout, and collecting a line of -- input from stdin. If something other than "y" or "n" is entered, then -- print a message indicating that "y" or "n" is expected, and ask again. promptBool :: MonadIO m => Text -> m Bool -- | Name of the stack program. -- -- NOTE: Should be defined in Stack.Constants, but not doing so -- due to the GHC stage restrictions. stackProgName :: String stackProgName' :: Text -- | Like First Bool, but the default is True. newtype FirstTrue FirstTrue :: Maybe Bool -> FirstTrue [getFirstTrue] :: FirstTrue -> Maybe Bool -- | Get the Bool, defaulting to True fromFirstTrue :: FirstTrue -> Bool -- | Helper for filling in default values defaultFirstTrue :: (a -> FirstTrue) -> Bool -- | Like First Bool, but the default is False. newtype FirstFalse FirstFalse :: Maybe Bool -> FirstFalse [getFirstFalse] :: FirstFalse -> Maybe Bool -- | Get the Bool, defaulting to False fromFirstFalse :: FirstFalse -> Bool -- | Helper for filling in default values defaultFirstFalse :: (a -> FirstFalse) -> Bool -- | Write a Builder to a file and atomically rename. writeBinaryFileAtomic :: MonadIO m => Path absrel File -> Builder -> m () -- | Report a bug in Stack. bugReport :: String -> String -> String -- | Report a pretty bug in Stack. bugPrettyReport :: String -> StyleDoc -> StyleDoc -- | A 'pretty' blank line. blankLine :: StyleDoc -- | Append two lists, i.e., -- --
-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] -- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...] ---- -- If the first list is not finite, the result is the first list. (++) :: [a] -> [a] -> [a] infixr 5 ++ -- | The value of seq a b is bottom if a is bottom, and -- otherwise equal to b. In other words, it evaluates the first -- argument a to weak head normal form (WHNF). seq is -- usually introduced to improve performance by avoiding unneeded -- laziness. -- -- A note on evaluation order: the expression seq a b does -- not guarantee that a will be evaluated before -- b. The only guarantee given by seq is that the both -- a and b will be evaluated before seq -- returns a value. In particular, this means that b may be -- evaluated before a. If you need to guarantee a specific order -- of evaluation, you must use the function pseq from the -- "parallel" package. seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b infixr 0 `seq` -- | <math>. filter, applied to a predicate and a list, -- returns the list of those elements that satisfy the predicate; i.e., -- --
-- filter p xs = [ x | x <- xs, p x] ---- --
-- >>> filter odd [1, 2, 3] -- [1,3] --filter :: (a -> Bool) -> [a] -> [a] -- | <math>. zip takes two lists and returns a list of -- corresponding pairs. -- --
-- >>> zip [1, 2] ['a', 'b'] -- [(1,'a'),(2,'b')] ---- -- If one input list is shorter than the other, excess elements of the -- longer list are discarded, even if one of the lists is infinite: -- --
-- >>> zip [1] ['a', 'b'] -- [(1,'a')] -- -- >>> zip [1, 2] ['a'] -- [(1,'a')] -- -- >>> zip [] [1..] -- [] -- -- >>> zip [1..] [] -- [] ---- -- zip is right-lazy: -- --
-- >>> zip [] undefined -- [] -- -- >>> zip undefined [] -- *** Exception: Prelude.undefined -- ... ---- -- zip is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zip :: [a] -> [b] -> [(a, b)] -- | Extract the first component of a pair. fst :: (a, b) -> a -- | Extract the second component of a pair. snd :: (a, b) -> b -- | otherwise is defined as the value True. It helps to make -- guards more readable. eg. -- --
-- f x | x < 0 = ... -- | otherwise = ... --otherwise :: Bool -- | If the first argument evaluates to True, then the result is the -- second argument. Otherwise an AssertionFailed exception is -- raised, containing a String with the source file and line -- number of the call to assert. -- -- Assertions can normally be turned on or off with a compiler flag (for -- GHC, assertions are normally on unless optimisation is turned on with -- -O or the -fignore-asserts option is given). When -- assertions are turned off, the first argument to assert is -- ignored, and the second argument is returned as the result. assert :: Bool -> a -> a -- | <math>. map f xs is the list obtained by -- applying f to each element of xs, i.e., -- --
-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] -- map f [x1, x2, ...] == [f x1, f x2, ...] ---- --
-- >>> map (+1) [1, 2, 3] -- [2,3,4] --map :: (a -> b) -> [a] -> [b] -- | Application operator. This operator is redundant, since ordinary -- application (f x) means the same as (f $ x). -- However, $ has low, right-associative binding precedence, so it -- sometimes allows parentheses to be omitted; for example: -- --
-- f $ g $ h x = f (g (h x)) ---- -- It is also useful in higher-order situations, such as map -- ($ 0) xs, or zipWith ($) fs xs. -- -- Note that ($) is levity-polymorphic in its result -- type, so that foo $ True where foo :: Bool -> -- Int# is well-typed. ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 $ -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | general coercion to fractional types realToFrac :: (Real a, Fractional b) => a -> b -- | Conditional failure of Alternative computations. Defined by -- --
-- guard True = pure () -- guard False = empty ---- --
-- >>> safeDiv 4 0 -- Nothing ---- --
-- >>> safeDiv 4 2 -- Just 2 ---- -- A definition of safeDiv using guards, but not guard: -- --
-- safeDiv :: Int -> Int -> Maybe Int -- safeDiv x y | y /= 0 = Just (x `div` y) -- | otherwise = Nothing ---- -- A definition of safeDiv using guard and Monad -- do-notation: -- --
-- safeDiv :: Int -> Int -> Maybe Int -- safeDiv x y = do -- guard (y /= 0) -- return (x `div` y) --guard :: Alternative f => Bool -> f () -- | The join function is the conventional monad join operator. It -- is used to remove one level of monadic structure, projecting its bound -- argument into the outer level. -- -- 'join bss' can be understood as the do -- expression -- --
-- do bs <- bss -- bs ---- --
-- atomically :: STM a -> IO a ---- -- is used to run STM transactions atomically. So, by specializing -- the types of atomically and join to -- --
-- atomically :: STM (IO b) -> IO (IO b) -- join :: IO (IO b) -> IO b ---- -- we can compose them as -- --
-- join . atomically :: STM (IO b) -> IO b ---- -- to run an STM transaction and the IO action it returns. join :: Monad m => m (m a) -> m a -- | The Bounded class is used to name the upper and lower limits of -- a type. Ord is not a superclass of Bounded since types -- that are not totally ordered may also have upper and lower bounds. -- -- The Bounded class may be derived for any enumeration type; -- minBound is the first constructor listed in the data -- declaration and maxBound is the last. Bounded may also -- be derived for single-constructor datatypes whose constituent types -- are in Bounded. class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a -- | Class Enum defines operations on sequentially ordered types. -- -- The enumFrom... methods are used in Haskell's translation of -- arithmetic sequences. -- -- Instances of Enum may be derived for any enumeration type -- (types whose constructors have no fields). The nullary constructors -- are assumed to be numbered left-to-right by fromEnum from -- 0 through n-1. See Chapter 10 of the Haskell -- Report for more details. -- -- For any type that is an instance of class Bounded as well as -- Enum, the following should hold: -- --
-- enumFrom x = enumFromTo x maxBound -- enumFromThen x y = enumFromThenTo x y bound -- where -- bound | fromEnum y >= fromEnum x = maxBound -- | otherwise = minBound --class Enum a -- | Convert to an Int. It is implementation-dependent what -- fromEnum returns when applied to a value that is too large to -- fit in an Int. fromEnum :: Enum a => a -> Int -- | The Eq class defines equality (==) and inequality -- (/=). All the basic datatypes exported by the Prelude -- are instances of Eq, and Eq may be derived for any -- datatype whose constituents are also instances of Eq. -- -- The Haskell Report defines no laws for Eq. However, instances -- are encouraged to follow these properties: -- --
-- (x `quot` y)*y + (x `rem` y) == x --rem :: Integral a => a -> a -> a -- | integer division truncated toward negative infinity div :: Integral a => a -> a -> a -- | integer modulus, satisfying -- --
-- (x `div` y)*y + (x `mod` y) == x --mod :: Integral a => a -> a -> a -- | simultaneous quot and rem quotRem :: Integral a => a -> a -> (a, a) -- | simultaneous div and mod divMod :: Integral a => a -> a -> (a, a) -- | conversion to Integer toInteger :: Integral a => a -> Integer infixl 7 `div` infixl 7 `mod` infixl 7 `quot` infixl 7 `rem` -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Instances of Monad should satisfy the following: -- --
-- do a <- as -- bs a --(>>=) :: Monad m => m a -> (a -> m b) -> m b -- | Sequentially compose two actions, discarding any value produced by the -- first, like sequencing operators (such as the semicolon) in imperative -- languages. -- -- 'as >> bs' can be understood as the do -- expression -- --
-- do as -- bs --(>>) :: Monad m => m a -> m b -> m b -- | Inject a value into the monadic type. return :: Monad m => a -> m a infixl 1 >>= infixl 1 >> -- | The Data class comprehends a fundamental primitive -- gfoldl for folding over constructor applications, say terms. -- This primitive can be instantiated in several ways to map over the -- immediate subterms of a term; see the gmap combinators later -- in this class. Indeed, a generic programmer does not necessarily need -- to use the ingenious gfoldl primitive but rather the intuitive -- gmap combinators. The gfoldl primitive is completed by -- means to query top-level constructors, to turn constructor -- representations into proper terms, and to list all possible datatype -- constructors. This completion allows us to serve generic programming -- scenarios like read, show, equality, term generation. -- -- The combinators gmapT, gmapQ, gmapM, etc are all -- provided with default definitions in terms of gfoldl, leaving -- open the opportunity to provide datatype-specific definitions. (The -- inclusion of the gmap combinators as members of class -- Data allows the programmer or the compiler to derive -- specialised, and maybe more efficient code per datatype. Note: -- gfoldl is more higher-order than the gmap combinators. -- This is subject to ongoing benchmarking experiments. It might turn out -- that the gmap combinators will be moved out of the class -- Data.) -- -- Conceptually, the definition of the gmap combinators in terms -- of the primitive gfoldl requires the identification of the -- gfoldl function arguments. Technically, we also need to -- identify the type constructor c for the construction of the -- result type from the folded term type. -- -- In the definition of gmapQx combinators, we use -- phantom type constructors for the c in the type of -- gfoldl because the result type of a query does not involve the -- (polymorphic) type of the term argument. In the definition of -- gmapQl we simply use the plain constant type constructor -- because gfoldl is left-associative anyway and so it is readily -- suited to fold a left-associative binary operation over the immediate -- subterms. In the definition of gmapQr, extra effort is needed. We use -- a higher-order accumulation trick to mediate between left-associative -- constructor application vs. right-associative binary operation (e.g., -- (:)). When the query is meant to compute a value of type -- r, then the result type within generic folding is r -> -- r. So the result of folding is a function to which we finally -- pass the right unit. -- -- With the -XDeriveDataTypeable option, GHC can generate -- instances of the Data class automatically. For example, given -- the declaration -- --
-- data T a b = C1 a b | C2 deriving (Typeable, Data) ---- -- GHC will generate an instance that is equivalent to -- --
-- instance (Data a, Data b) => Data (T a b) where -- gfoldl k z (C1 a b) = z C1 `k` a `k` b -- gfoldl k z C2 = z C2 -- -- gunfold k z c = case constrIndex c of -- 1 -> k (k (z C1)) -- 2 -> z C2 -- -- toConstr (C1 _ _) = con_C1 -- toConstr C2 = con_C2 -- -- dataTypeOf _ = ty_T -- -- con_C1 = mkConstr ty_T "C1" [] Prefix -- con_C2 = mkConstr ty_T "C2" [] Prefix -- ty_T = mkDataType "Module.T" [con_C1, con_C2] ---- -- This is suitable for datatypes that are exported transparently. class Typeable a => Data a -- | Left-associative fold operation for constructor applications. -- -- The type of gfoldl is a headache, but operationally it is a -- simple generalisation of a list fold. -- -- The default definition for gfoldl is const -- id, which is suitable for abstract datatypes with no -- substructures. gfoldl :: Data a => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. () => g -> c g) -> a -> c a -- | Unfolding constructor applications gunfold :: Data a => (forall b r. Data b => c (b -> r) -> c r) -> (forall r. () => r -> c r) -> Constr -> c a -- | Obtaining the constructor from a given datum. For proper terms, this -- is meant to be the top-level constructor. Primitive datatypes are here -- viewed as potentially infinite sets of values (i.e., constructors). toConstr :: Data a => a -> Constr -- | The outer type constructor of the type dataTypeOf :: Data a => a -> DataType -- | Mediate types and unary type constructors. -- -- In Data instances of the form -- --
-- instance (Data a, ...) => Data (T a) ---- -- dataCast1 should be defined as gcast1. -- -- The default definition is const Nothing, which -- is appropriate for instances of other forms. dataCast1 :: (Data a, Typeable t) => (forall d. Data d => c (t d)) -> Maybe (c a) -- | Mediate types and binary type constructors. -- -- In Data instances of the form -- --
-- instance (Data a, Data b, ...) => Data (T a b) ---- -- dataCast2 should be defined as gcast2. -- -- The default definition is const Nothing, which -- is appropriate for instances of other forms. dataCast2 :: (Data a, Typeable t) => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a) -- | A generic transformation that maps over the immediate subterms -- -- The default definition instantiates the type constructor c in -- the type of gfoldl to an identity datatype constructor, using -- the isomorphism pair as injection and projection. gmapT :: Data a => (forall b. Data b => b -> b) -> a -> a -- | A generic query with a left-associative binary operator gmapQl :: Data a => (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r -- | A generic query with a right-associative binary operator gmapQr :: forall r r'. Data a => (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r -- | A generic query that processes the immediate subterms and returns a -- list of results. The list is given in the same order as originally -- specified in the declaration of the data constructors. gmapQ :: Data a => (forall d. Data d => d -> u) -> a -> [u] -- | A generic query that processes one child by index (zero-based) gmapQi :: Data a => Int -> (forall d. Data d => d -> u) -> a -> u -- | A generic monadic transformation that maps over the immediate subterms -- -- The default definition instantiates the type constructor c in -- the type of gfoldl to the monad datatype constructor, defining -- injection and projection using return and >>=. gmapM :: (Data a, Monad m) => (forall d. Data d => d -> m d) -> a -> m a -- | Transformation of at least one immediate subterm does not fail gmapMp :: (Data a, MonadPlus m) => (forall d. Data d => d -> m d) -> a -> m a -- | Transformation of one immediate subterm with success gmapMo :: (Data a, MonadPlus m) => (forall d. Data d => d -> m d) -> a -> m a -- | A type f is a Functor if it provides a function fmap -- which, given any types a and b lets you apply any -- function from (a -> b) to turn an f a into an -- f b, preserving the structure of f. Furthermore -- f needs to adhere to the following: -- -- -- -- Note, that the second law follows from the free theorem of the type -- fmap and the first law, so you need only check that the former -- condition holds. class Functor (f :: Type -> Type) -- | fmap is used to apply a function of type (a -> b) -- to a value of type f a, where f is a functor, to produce a -- value of type f b. Note that for any type constructor with -- more than one parameter (e.g., Either), only the last type -- parameter can be modified with fmap (e.g., b in -- `Either a b`). -- -- Some type constructors with two parameters or more have a -- Bifunctor instance that allows both the last and the -- penultimate parameters to be mapped over. -- --
-- >>> fmap show Nothing -- Nothing -- -- >>> fmap show (Just 3) -- Just "3" ---- -- Convert from an Either Int Int to an Either Int -- String using show: -- --
-- >>> fmap show (Left 17) -- Left 17 -- -- >>> fmap show (Right 17) -- Right "17" ---- -- Double each element of a list: -- --
-- >>> fmap (*2) [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> fmap even (2,2) -- (2,True) ---- -- It may seem surprising that the function is only applied to the last -- element of the tuple compared to the list example above which applies -- it to every element in the list. To understand, remember that tuples -- are type constructors with multiple type parameters: a tuple of 3 -- elements (a,b,c) can also be written (,,) a b c and -- its Functor instance is defined for Functor ((,,) a -- b) (i.e., only the third parameter is free to be mapped over with -- fmap). -- -- It explains why fmap can be used with tuples containing -- values of different types as in the following example: -- --
-- >>> fmap even ("hello", 1.0, 4)
-- ("hello",1.0,True)
--
fmap :: Functor f => (a -> b) -> f a -> f b
-- | Replace all locations in the input with the same value. The default
-- definition is fmap . const, but this may be
-- overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$
-- | Basic numeric class.
--
-- The Haskell Report defines no laws for Num. However,
-- (+) and (*) are customarily expected
-- to define a ring and have the following properties:
--
-- -- abs x * signum x == x ---- -- For real numbers, the signum is either -1 (negative), -- 0 (zero) or 1 (positive). signum :: Num a => a -> a -- | Conversion from an Integer. An integer literal represents the -- application of the function fromInteger to the appropriate -- value of type Integer, so such literals have type -- (Num a) => a. fromInteger :: Num a => Integer -> a infixl 7 * infixl 6 + infixl 6 - -- | The Ord class is used for totally ordered datatypes. -- -- Instances of Ord can be derived for any user-defined datatype -- whose constituent types are in Ord. The declared order of the -- constructors in the data declaration determines the ordering in -- derived Ord instances. The Ordering datatype allows a -- single comparison to determine the precise ordering of two objects. -- -- Ord, as defined by the Haskell report, implements a total order -- and has the following properties: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Read in Haskell 2010 is equivalent to -- --
-- instance (Read a) => Read (Tree a) where
--
-- readsPrec d r = readParen (d > app_prec)
-- (\r -> [(Leaf m,t) |
-- ("Leaf",s) <- lex r,
-- (m,t) <- readsPrec (app_prec+1) s]) r
--
-- ++ readParen (d > up_prec)
-- (\r -> [(u:^:v,w) |
-- (u,s) <- readsPrec (up_prec+1) r,
-- (":^:",t) <- lex s,
-- (v,w) <- readsPrec (up_prec+1) t]) r
--
-- where app_prec = 10
-- up_prec = 5
--
--
-- Note that right-associativity of :^: is unused.
--
-- The derived instance in GHC is equivalent to
--
-- -- instance (Read a) => Read (Tree a) where -- -- readPrec = parens $ (prec app_prec $ do -- Ident "Leaf" <- lexP -- m <- step readPrec -- return (Leaf m)) -- -- +++ (prec up_prec $ do -- u <- step readPrec -- Symbol ":^:" <- lexP -- v <- step readPrec -- return (u :^: v)) -- -- where app_prec = 10 -- up_prec = 5 -- -- readListPrec = readListPrecDefault ---- -- Why do both readsPrec and readPrec exist, and why does -- GHC opt to implement readPrec in derived Read instances -- instead of readsPrec? The reason is that readsPrec is -- based on the ReadS type, and although ReadS is mentioned -- in the Haskell 2010 Report, it is not a very efficient parser data -- structure. -- -- readPrec, on the other hand, is based on a much more efficient -- ReadPrec datatype (a.k.a "new-style parsers"), but its -- definition relies on the use of the RankNTypes language -- extension. Therefore, readPrec (and its cousin, -- readListPrec) are marked as GHC-only. Nevertheless, it is -- recommended to use readPrec instead of readsPrec -- whenever possible for the efficiency improvements it brings. -- -- As mentioned above, derived Read instances in GHC will -- implement readPrec instead of readsPrec. The default -- implementations of readsPrec (and its cousin, readList) -- will simply use readPrec under the hood. If you are writing a -- Read instance by hand, it is recommended to write it like so: -- --
-- instance Read T where -- readPrec = ... -- readListPrec = readListPrecDefault --class Read a class (Num a, Ord a) => Real a -- | the rational equivalent of its real argument with full precision toRational :: Real a => a -> Rational -- | Efficient, machine-independent access to the components of a -- floating-point number. class (RealFrac a, Floating a) => RealFloat a -- | a constant function, returning the radix of the representation (often -- 2) floatRadix :: RealFloat a => a -> Integer -- | a constant function, returning the number of digits of -- floatRadix in the significand floatDigits :: RealFloat a => a -> Int -- | a constant function, returning the lowest and highest values the -- exponent may assume floatRange :: RealFloat a => a -> (Int, Int) -- | The function decodeFloat applied to a real floating-point -- number returns the significand expressed as an Integer and an -- appropriately scaled exponent (an Int). If -- decodeFloat x yields (m,n), then x -- is equal in value to m*b^^n, where b is the -- floating-point radix, and furthermore, either m and -- n are both zero or else b^(d-1) <= abs m < -- b^d, where d is the value of floatDigits -- x. In particular, decodeFloat 0 = (0,0). If the -- type contains a negative zero, also decodeFloat (-0.0) = -- (0,0). The result of decodeFloat x is -- unspecified if either of isNaN x or -- isInfinite x is True. decodeFloat :: RealFloat a => a -> (Integer, Int) -- | encodeFloat performs the inverse of decodeFloat in the -- sense that for finite x with the exception of -0.0, -- uncurry encodeFloat (decodeFloat x) = x. -- encodeFloat m n is one of the two closest -- representable floating-point numbers to m*b^^n (or -- ±Infinity if overflow occurs); usually the closer, but if -- m contains too many bits, the result may be rounded in the -- wrong direction. encodeFloat :: RealFloat a => Integer -> Int -> a -- | exponent corresponds to the second component of -- decodeFloat. exponent 0 = 0 and for finite -- nonzero x, exponent x = snd (decodeFloat x) -- + floatDigits x. If x is a finite floating-point -- number, it is equal in value to significand x * b ^^ -- exponent x, where b is the floating-point radix. -- The behaviour is unspecified on infinite or NaN values. exponent :: RealFloat a => a -> Int -- | The first component of decodeFloat, scaled to lie in the open -- interval (-1,1), either 0.0 or of absolute -- value >= 1/b, where b is the floating-point -- radix. The behaviour is unspecified on infinite or NaN -- values. significand :: RealFloat a => a -> a -- | multiplies a floating-point number by an integer power of the radix scaleFloat :: RealFloat a => Int -> a -> a -- | True if the argument is an IEEE "not-a-number" (NaN) value isNaN :: RealFloat a => a -> Bool -- | True if the argument is an IEEE infinity or negative infinity isInfinite :: RealFloat a => a -> Bool -- | True if the argument is too small to be represented in -- normalized format isDenormalized :: RealFloat a => a -> Bool -- | True if the argument is an IEEE negative zero isNegativeZero :: RealFloat a => a -> Bool -- | True if the argument is an IEEE floating point number isIEEE :: RealFloat a => a -> Bool -- | a version of arctangent taking two real floating-point arguments. For -- real floating x and y, atan2 y x -- computes the angle (from the positive x-axis) of the vector from the -- origin to the point (x,y). atan2 y x returns -- a value in the range [-pi, pi]. It follows the -- Common Lisp semantics for the origin when signed zeroes are supported. -- atan2 y 1, with y in a type that is -- RealFloat, should return the same value as atan -- y. A default definition of atan2 is provided, but -- implementors can provide a more accurate implementation. atan2 :: RealFloat a => a -> a -> a -- | Extracting components of fractions. class (Real a, Fractional a) => RealFrac a -- | The function properFraction takes a real fractional number -- x and returns a pair (n,f) such that x = -- n+f, and: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Show is equivalent to -- --
-- instance (Show a) => Show (Tree a) where -- -- showsPrec d (Leaf m) = showParen (d > app_prec) $ -- showString "Leaf " . showsPrec (app_prec+1) m -- where app_prec = 10 -- -- showsPrec d (u :^: v) = showParen (d > up_prec) $ -- showsPrec (up_prec+1) u . -- showString " :^: " . -- showsPrec (up_prec+1) v -- where up_prec = 5 ---- -- Note that right-associativity of :^: is ignored. For example, -- --
-- fail s >>= f = fail s ---- -- If your Monad is also MonadPlus, a popular definition is -- --
-- fail _ = mzero --class Monad m => MonadFail (m :: Type -> Type) fail :: MonadFail m => String -> m a -- | Class for string-like datastructures; used by the overloaded string -- extension (-XOverloadedStrings in GHC). class IsString a fromString :: IsString a => String -> a -- | A functor with application, providing operations to -- --
-- (<*>) = liftA2 id ---- --
-- liftA2 f x y = f <$> x <*> y ---- -- Further, any definition must satisfy the following: -- --
pure id <*> v = -- v
pure (.) <*> u -- <*> v <*> w = u <*> (v -- <*> w)
pure f <*> -- pure x = pure (f x)
u <*> pure y = -- pure ($ y) <*> u
-- forall x y. p (q x y) = f x . g y ---- -- it follows from the above that -- --
-- liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v ---- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- --
-- >>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
--
--
-- -- >>> produceFoo :: Applicative f => f Foo ---- --
-- >>> produceBar :: Applicative f => f Bar -- -- >>> produceBaz :: Applicative f => f Baz ---- --
-- >>> mkState :: Applicative f => f MyState -- -- >>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz --(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. -- -- This became a typeclass method in 4.10.0.0. Prior to that, it was a -- function defined in terms of <*> and fmap. -- --
-- >>> liftA2 (,) (Just 3) (Just 5) -- Just (3,5) --liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. -- --
-- >>> Just 2 *> Just 3 -- Just 3 ---- --
-- >>> Nothing *> Just 3 -- Nothing ---- -- Of course a more interesting use case would be to have effectful -- computations instead of just returning pure values. -- --
-- >>> import Data.Char
--
-- >>> import Text.ParserCombinators.ReadP
--
-- >>> let p = string "my name is " *> munch1 isAlpha <* eof
--
-- >>> readP_to_S p "my name is Simon"
-- [("Simon","")]
--
(*>) :: Applicative f => f a -> f b -> f b
-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*
infixl 4 *>
infixl 4 <*>
-- | The Foldable class represents data structures that can be reduced to a
-- summary value one element at a time. Strict left-associative folds are
-- a good fit for space-efficient reduction, while lazy right-associative
-- folds are a good fit for corecursive iteration, or for folds that
-- short-circuit after processing an initial subsequence of the
-- structure's elements.
--
-- Instances can be derived automatically by enabling the
-- DeriveFoldable extension. For example, a derived instance for
-- a binary tree might be:
--
--
-- {-# LANGUAGE DeriveFoldable #-}
-- data Tree a = Empty
-- | Leaf a
-- | Node (Tree a) a (Tree a)
-- deriving Foldable
--
--
-- A more detailed description can be found in the Overview
-- section of Data.Foldable#overview.
--
-- For the class laws see the Laws section of
-- Data.Foldable#laws.
class Foldable (t :: TYPE LiftedRep -> Type)
-- | Given a structure with elements whose type is a Monoid, combine
-- them via the monoid's (<>) operator. This fold
-- is right-associative and lazy in the accumulator. When you need a
-- strict left-associative fold, use foldMap' instead, with
-- id as the map.
--
-- -- >>> fold [[1, 2, 3], [4, 5], [6], []] -- [1,2,3,4,5,6] ---- --
-- >>> fold $ Node (Leaf (Sum 1)) (Sum 3) (Leaf (Sum 5))
-- Sum {getSum = 9}
--
--
-- Folds of unbounded structures do not terminate when the monoid's
-- (<>) operator is strict:
--
-- -- >>> fold (repeat Nothing) -- * Hangs forever * ---- -- Lazy corecursive folds of unbounded structures are fine: -- --
-- >>> take 12 $ fold $ map (\i -> [i..i+2]) [0..] -- [0,1,2,1,2,3,2,3,4,3,4,5] -- -- >>> sum $ take 4000000 $ fold $ map (\i -> [i..i+2]) [0..] -- 2666668666666 --fold :: (Foldable t, Monoid m) => t m -> m -- | Map each element of the structure into a monoid, and combine the -- results with (<>). This fold is -- right-associative and lazy in the accumulator. For strict -- left-associative folds consider foldMap' instead. -- --
-- >>> foldMap Sum [1, 3, 5]
-- Sum {getSum = 9}
--
--
--
-- >>> foldMap Product [1, 3, 5]
-- Product {getProduct = 15}
--
--
-- -- >>> foldMap (replicate 3) [1, 2, 3] -- [1,1,1,2,2,2,3,3,3] ---- -- When a Monoid's (<>) is lazy in its second -- argument, foldMap can return a result even from an unbounded -- structure. For example, lazy accumulation enables -- Data.ByteString.Builder to efficiently serialise large data -- structures and produce the output incrementally: -- --
-- >>> import qualified Data.ByteString.Lazy as L -- -- >>> import qualified Data.ByteString.Builder as B -- -- >>> let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20 -- -- >>> let lbs = B.toLazyByteString $ foldMap bld [0..] -- -- >>> L.take 64 lbs -- "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" --foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m -- | Right-associative fold of a structure, lazy in the accumulator. -- -- In the case of lists, foldr, when applied to a binary operator, -- a starting value (typically the right-identity of the operator), and a -- list, reduces the list using the binary operator, from right to left: -- --
-- foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...) ---- -- Note that since the head of the resulting expression is produced by an -- application of the operator to the first element of the list, given an -- operator lazy in its right argument, foldr can produce a -- terminating expression from an unbounded list. -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldr f z = foldr f z . toList ---- --
-- >>> foldr (||) False [False, True, False] -- True ---- --
-- >>> foldr (||) False [] -- False ---- --
-- >>> foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd'] -- "foodcba" ---- --
-- >>> foldr (||) False (True : repeat False) -- True ---- -- But the following doesn't terminate: -- --
-- >>> foldr (||) False (repeat False ++ [True]) -- * Hangs forever * ---- --
-- >>> take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1) -- [1,4,7,10,13] --foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b -- | Left-associative fold of a structure but with strict application of -- the operator. -- -- This ensures that each step of the fold is forced to Weak Head Normal -- Form before being applied, avoiding the collection of thunks that -- would otherwise occur. This is often what you want to strictly reduce -- a finite structure to a single strict result (e.g. sum). -- -- For a general Foldable structure this should be semantically -- identical to, -- --
-- foldl' f z = foldl' f z . toList --foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b -- | List of elements of a structure, from left to right. If the entire -- list is intended to be reduced via a fold, just fold the structure -- directly bypassing the list. -- --
-- >>> toList Nothing -- [] ---- --
-- >>> toList (Just 42) -- [42] ---- --
-- >>> toList (Left "foo") -- [] ---- --
-- >>> toList (Node (Leaf 5) 17 (Node Empty 12 (Leaf 8))) -- [5,17,12,8] ---- -- For lists, toList is the identity: -- --
-- >>> toList [1, 2, 3] -- [1,2,3] --toList :: Foldable t => t a -> [a] -- | Test whether the structure is empty. The default implementation is -- Left-associative and lazy in both the initial element and the -- accumulator. Thus optimised for structures where the first element can -- be accessed in constant time. Structures where this is not the case -- should have a non-default implementation. -- --
-- >>> null [] -- True ---- --
-- >>> null [1] -- False ---- -- null is expected to terminate even for infinite structures. The -- default implementation terminates provided the structure is bounded on -- the left (there is a leftmost element). -- --
-- >>> null [1..] -- False --null :: Foldable t => t a -> Bool -- | Returns the size/length of a finite structure as an Int. The -- default implementation just counts elements starting with the -- leftmost. Instances for structures that can compute the element count -- faster than via element-by-element counting, should provide a -- specialised implementation. -- --
-- >>> length [] -- 0 ---- --
-- >>> length ['a', 'b', 'c'] -- 3 -- -- >>> length [1..] -- * Hangs forever * --length :: Foldable t => t a -> Int -- | Does the element occur in the structure? -- -- Note: elem is often used in infix form. -- --
-- >>> 3 `elem` [] -- False ---- --
-- >>> 3 `elem` [1,2] -- False ---- --
-- >>> 3 `elem` [1,2,3,4,5] -- True ---- -- For infinite structures, the default implementation of elem -- terminates if the sought-after value exists at a finite distance from -- the left side of the structure: -- --
-- >>> 3 `elem` [1..] -- True ---- --
-- >>> 3 `elem` ([4..] ++ [3]) -- * Hangs forever * --elem :: (Foldable t, Eq a) => a -> t a -> Bool -- | The sum function computes the sum of the numbers of a -- structure. -- --
-- >>> sum [] -- 0 ---- --
-- >>> sum [42] -- 42 ---- --
-- >>> sum [1..10] -- 55 ---- --
-- >>> sum [4.1, 2.0, 1.7] -- 7.8 ---- --
-- >>> sum [1..] -- * Hangs forever * --sum :: (Foldable t, Num a) => t a -> a -- | The product function computes the product of the numbers of a -- structure. -- --
-- >>> product [] -- 1 ---- --
-- >>> product [42] -- 42 ---- --
-- >>> product [1..10] -- 3628800 ---- --
-- >>> product [4.1, 2.0, 1.7] -- 13.939999999999998 ---- --
-- >>> product [1..] -- * Hangs forever * --product :: (Foldable t, Num a) => t a -> a infix 4 `elem` -- | Functors representing data structures that can be transformed to -- structures of the same shape by performing an -- Applicative (or, therefore, Monad) action on each -- element from left to right. -- -- A more detailed description of what same shape means, the -- various methods, how traversals are constructed, and example advanced -- use-cases can be found in the Overview section of -- Data.Traversable#overview. -- -- For the class laws see the Laws section of -- Data.Traversable#laws. class (Functor t, Foldable t) => Traversable (t :: Type -> Type) -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results see traverse_. -- --
-- >>> traverse Just [1,2,3,4] -- Just [1,2,3,4] ---- --
-- >>> traverse id [Right 1, Right 2, Right 3, Right 4] -- Right [1,2,3,4] ---- -- In the next examples, we show that Nothing and Left -- values short circuit the created structure. -- --
-- >>> traverse (const Nothing) [1,2,3,4] -- Nothing ---- --
-- >>> traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4] -- Nothing ---- --
-- >>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0] -- Left 0 --traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) -- | Evaluate each action in the structure from left to right, and collect -- the results. For a version that ignores the results see -- sequenceA_. -- --
-- >>> sequenceA [Just 1, Just 2, Just 3] -- Just [1,2,3] ---- --
-- >>> sequenceA [Right 1, Right 2, Right 3] -- Right [1,2,3] ---- -- The next two example show Nothing and Just will short -- circuit the resulting structure if present in the input. For more -- context, check the Traversable instances for Either and -- Maybe. -- --
-- >>> sequenceA [Just 1, Just 2, Just 3, Nothing] -- Nothing ---- --
-- >>> sequenceA [Right 1, Right 2, Right 3, Left 4] -- Left 4 --sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. For a version -- that ignores the results see mapM_. -- --
-- >>> sequence $ Right [1,2,3,4] -- [Right 1,Right 2,Right 3,Right 4] ---- --
-- >>> sequence $ [Right 1,Right 2,Right 3,Right 4] -- Right [1,2,3,4] ---- -- The following examples demonstrate short circuit behavior for -- sequence. -- --
-- >>> sequence $ Left [1,2,3,4] -- Left [1,2,3,4] ---- --
-- >>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4] -- Left 0 --sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) -- | Representable types of kind *. This class is derivable in GHC -- with the DeriveGeneric flag on. -- -- A Generic instance must satisfy the following laws: -- --
-- from . to ≡ id -- to . from ≡ id --class Generic a -- | The class of semigroups (types with an associative binary operation). -- -- Instances should satisfy the following: -- -- class Semigroup a -- | An associative operation. -- --
-- >>> [1,2,3] <> [4,5,6] -- [1,2,3,4,5,6] --(<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | The class of monoids (types with an associative binary operation that -- has an identity). Instances should satisfy the following: -- --
-- >>> "Hello world" <> mempty -- "Hello world" --mempty :: Monoid a => a -- | An associative operation -- -- NOTE: This method is redundant and has the default -- implementation mappend = (<>) since -- base-4.11.0.0. Should it be implemented manually, since -- mappend is a synonym for (<>), it is expected that -- the two functions are defined the same way. In a future GHC release -- mappend will be removed from Monoid. mappend :: Monoid a => a -> a -> a -- | Fold a list using the monoid. -- -- For most types, the default definition for mconcat will be -- used, but the function is included in the class definition so that an -- optimized version can be provided for specific types. -- --
-- >>> mconcat ["Hello", " ", "Haskell", "!"] -- "Hello Haskell!" --mconcat :: Monoid a => [a] -> a data Bool False :: Bool True :: Bool -- | A String is a list of characters. String constants in Haskell -- are values of type String. -- -- See Data.List for operations on lists. type String = [Char] -- | The character type Char is an enumeration whose values -- represent Unicode (or equivalently ISO/IEC 10646) code points (i.e. -- characters, see http://www.unicode.org/ for details). This set -- extends the ISO 8859-1 (Latin-1) character set (the first 256 -- characters), which is itself an extension of the ASCII character set -- (the first 128 characters). A character literal in Haskell has type -- Char. -- -- To convert a Char to or from the corresponding Int value -- defined by Unicode, use toEnum and fromEnum from the -- Enum class respectively (or equivalently ord and -- chr). data Char -- | Double-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- double-precision type. data Double -- | Single-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- single-precision type. data Float -- | A fixed-precision integer type with at least the range [-2^29 .. -- 2^29-1]. The exact range for a given implementation can be -- determined by using minBound and maxBound from the -- Bounded class. data Int -- | 8-bit signed integer type data Int8 -- | 16-bit signed integer type data Int16 -- | 32-bit signed integer type data Int32 -- | 64-bit signed integer type data Int64 -- | Arbitrary precision integers. In contrast with fixed-size integral -- types such as Int, the Integer type represents the -- entire infinite range of integers. -- -- Integers are stored in a kind of sign-magnitude form, hence do not -- expect two's complement form when using bit operations. -- -- If the value is small (fit into an Int), IS constructor -- is used. Otherwise Integer and IN constructors are used -- to store a BigNat representing respectively the positive or the -- negative value magnitude. -- -- Invariant: Integer and IN are used iff value doesn't fit -- in IS data Integer -- | Natural number -- -- Invariant: numbers <= 0xffffffffffffffff use the NS -- constructor data Natural -- | The Maybe type encapsulates an optional value. A value of type -- Maybe a either contains a value of type a -- (represented as Just a), or it is empty (represented -- as Nothing). Using Maybe is a good way to deal with -- errors or exceptional cases without resorting to drastic measures such -- as error. -- -- The Maybe type is also a monad. It is a simple kind of error -- monad, where all errors are represented by Nothing. A richer -- error monad can be built using the Either type. data Maybe a Nothing :: Maybe a Just :: a -> Maybe a data Ordering LT :: Ordering EQ :: Ordering GT :: Ordering -- | Arbitrary-precision rational numbers, represented as a ratio of two -- Integer values. A rational number may be constructed using the -- % operator. type Rational = Ratio Integer -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= -- operations from the Monad class. data IO a -- | A Word is an unsigned integral type, with the same size as -- Int. data Word -- | 8-bit unsigned integer type data Word8 -- | 16-bit unsigned integer type data Word16 -- | 32-bit unsigned integer type data Word32 -- | 64-bit unsigned integer type data Word64 -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> s -- Left "foo" -- -- >>> let n = Right 3 :: Either String Int -- -- >>> n -- Right 3 -- -- >>> :type s -- s :: Either String Int -- -- >>> :type n -- n :: Either String Int ---- -- The fmap from our Functor instance will ignore -- Left values, but will apply the supplied function to values -- contained in a Right: -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> fmap (*2) s -- Left "foo" -- -- >>> fmap (*2) n -- Right 6 ---- -- The Monad instance for Either allows us to chain -- together multiple actions which may fail, and fail overall if any of -- the individual steps failed. First we'll write a function that can -- either parse an Int from a Char, or fail. -- --
-- >>> import Data.Char ( digitToInt, isDigit )
--
-- >>> :{
-- let parseEither :: Char -> Either String Int
-- parseEither c
-- | isDigit c = Right (digitToInt c)
-- | otherwise = Left "parse error"
--
-- >>> :}
--
--
-- The following should work, since both '1' and '2'
-- can be parsed as Ints.
--
--
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither '1'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Right 3 ---- -- But the following should fail overall, since the first operation where -- we attempt to parse 'm' as an Int will fail: -- --
-- >>> :{
-- let parseMultiple :: Either String Int
-- parseMultiple = do
-- x <- parseEither 'm'
-- y <- parseEither '2'
-- return (x + y)
--
-- >>> :}
--
--
-- -- >>> parseMultiple -- Left "parse error" --data Either a b Left :: a -> Either a b Right :: b -> Either a b -- | Non-empty (and non-strict) list type. data NonEmpty a (:|) :: a -> [a] -> NonEmpty a infixr 5 :| -- | CallStacks are a lightweight method of obtaining a partial -- call-stack at any point in the program. -- -- A function can request its call-site with the HasCallStack -- constraint. For example, we can define -- --
-- putStrLnWithCallStack :: HasCallStack => String -> IO () ---- -- as a variant of putStrLn that will get its call-site and -- print it, along with the string given as argument. We can access the -- call-stack inside putStrLnWithCallStack with -- callStack. -- --
-- >>> :{
-- putStrLnWithCallStack :: HasCallStack => String -> IO ()
-- putStrLnWithCallStack msg = do
-- putStrLn msg
-- putStrLn (prettyCallStack callStack)
-- :}
--
--
-- Thus, if we call putStrLnWithCallStack we will get a
-- formatted call-stack alongside our string.
--
-- -- >>> putStrLnWithCallStack "hello" -- hello -- CallStack (from HasCallStack): -- putStrLnWithCallStack, called at <interactive>:... in interactive:Ghci... ---- -- GHC solves HasCallStack constraints in three steps: -- --
-- runST (writeSTRef _|_ v >>= f) = _|_ --data ST s a -- | forM_ is mapM_ with its arguments flipped. For a version -- that doesn't ignore the results see forM. -- -- forM_ is just like for_, but specialised to monadic -- actions. forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m () -- | A space-efficient representation of a Word8 vector, supporting -- many efficient operations. -- -- A ByteString contains 8-bit bytes, or by using the operations -- from Data.ByteString.Char8 it can be interpreted as containing -- 8-bit characters. data ByteString -- | A compact representation of a Word8 vector. -- -- It has a lower memory overhead than a ByteString and does not -- contribute to heap fragmentation. It can be converted to or from a -- ByteString (at the cost of copying the string data). It -- supports very few other operations. -- -- It is suitable for use as an internal representation for code that -- needs to keep many short strings in memory, but it should not -- be used as an interchange type. That is, it should not generally be -- used in public APIs. The ByteString type is usually more -- suitable for use in interfaces; it is more flexible and it supports a -- wide range of operations. data ShortByteString -- | Reverse order of bytes in Word16. byteSwap16 :: Word16 -> Word16 -- | Reverse order of bytes in Word32. byteSwap32 :: Word32 -> Word32 -- | Reverse order of bytes in Word64. byteSwap64 :: Word64 -> Word64 -- | A ThreadId is an abstract type representing a handle to a -- thread. ThreadId is an instance of Eq, Ord and -- Show, where the Ord instance implements an arbitrary -- total ordering over ThreadIds. The Show instance lets -- you convert an arbitrary-valued ThreadId to string form; -- showing a ThreadId value is occasionally useful when debugging -- or diagnosing the behaviour of a concurrent program. -- -- Note: in GHC, if you have a ThreadId, you essentially -- have a pointer to the thread itself. This means the thread itself -- can't be garbage collected until you drop the ThreadId. This -- misfeature will hopefully be corrected at a later date. data ThreadId -- | An MVar (pronounced "em-var") is a synchronising variable, used -- for communication between concurrent threads. It can be thought of as -- a box, which may be empty or full. data MVar a -- | The name and version of a package. data PackageIdentifier PackageIdentifier :: PackageName -> Version -> PackageIdentifier -- | The name of this package, eg. foo [pkgName] :: PackageIdentifier -> PackageName -- | the version of this package, eg 1.2 [pkgVersion] :: PackageIdentifier -> Version -- | A FlagName is the name of a user-defined configuration flag -- -- Use mkFlagName and unFlagName to convert from/to a -- String. -- -- This type is opaque since Cabal-2.0 data FlagName -- | A package name. -- -- Use mkPackageName and unPackageName to convert from/to a -- String. -- -- This type is opaque since Cabal-2.0 data PackageName -- | A Version represents the version of a software entity. -- -- Instances of Eq and Ord are provided, which gives exact -- equality and lexicographic ordering of the version number components -- (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2, etc.). -- -- This type is opaque and distinct from the Version type in -- Data.Version since Cabal-2.0. The difference extends -- to the Binary instance using a different (and more compact) -- encoding. data Version -- | deepseq: fully evaluates the first argument, before returning -- the second. -- -- The name deepseq is used to illustrate the relationship to -- seq: where seq is shallow in the sense that it only -- evaluates the top level of its argument, deepseq traverses the -- entire data structure evaluating it completely. -- -- deepseq can be useful for forcing pending exceptions, -- eradicating space leaks, or forcing lazy I/O to happen. It is also -- useful in conjunction with parallel Strategies (see the -- parallel package). -- -- There is no guarantee about the ordering of evaluation. The -- implementation may evaluate the components of the structure in any -- order or in parallel. To impose an actual order on evaluation, use -- pseq from Control.Parallel in the parallel -- package. deepseq :: NFData a => a -> b -> b -- | a variant of deepseq that is useful in some circumstances: -- --
-- force x = x `deepseq` x ---- -- force x fully evaluates x, and then returns it. Note -- that force x only performs evaluation when the value of -- force x itself is demanded, so essentially it turns shallow -- evaluation into deep evaluation. -- -- force can be conveniently used in combination with -- ViewPatterns: -- --
-- {-# LANGUAGE BangPatterns, ViewPatterns #-}
-- import Control.DeepSeq
--
-- someFun :: ComplexData -> SomeResult
-- someFun (force -> !arg) = {- 'arg' will be fully evaluated -}
--
--
-- Another useful application is to combine force with
-- evaluate in order to force deep evaluation relative to other
-- IO operations:
--
--
-- import Control.Exception (evaluate)
-- import Control.DeepSeq
--
-- main = do
-- result <- evaluate $ force $ pureComputation
-- {- 'result' will be fully evaluated at this point -}
-- return ()
--
--
-- Finally, here's an exception safe variant of the readFile'
-- example:
--
-- -- readFile' :: FilePath -> IO String -- readFile' fn = bracket (openFile fn ReadMode) hClose $ \h -> -- evaluate . force =<< hGetContents h --force :: NFData a => a -> a -- | A class of types that can be fully evaluated. class NFData a -- | rnf should reduce its argument to normal form (that is, fully -- evaluate all sub-components), and then return (). -- --
-- {-# LANGUAGE DeriveGeneric #-}
--
-- import GHC.Generics (Generic, Generic1)
-- import Control.DeepSeq
--
-- data Foo a = Foo a String
-- deriving (Eq, Generic, Generic1)
--
-- instance NFData a => NFData (Foo a)
-- instance NFData1 Foo
--
-- data Colour = Red | Green | Blue
-- deriving Generic
--
-- instance NFData Colour
--
--
-- Starting with GHC 7.10, the example above can be written more
-- concisely by enabling the new DeriveAnyClass extension:
--
--
-- {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
--
-- import GHC.Generics (Generic)
-- import Control.DeepSeq
--
-- data Foo a = Foo a String
-- deriving (Eq, Generic, Generic1, NFData, NFData1)
--
-- data Colour = Red | Green | Blue
-- deriving (Generic, NFData)
--
--
-- -- rnf a = seq a () ---- -- However, starting with deepseq-1.4.0.0, the default -- implementation is based on DefaultSignatures allowing for -- more accurate auto-derived NFData instances. If you need the -- previously used exact default rnf method implementation -- semantics, use -- --
-- instance NFData Colour where rnf x = seq x () ---- -- or alternatively -- --
-- instance NFData Colour where rnf = rwhnf ---- -- or -- --
-- {-# LANGUAGE BangPatterns #-}
-- instance NFData Colour where rnf !_ = ()
--
rnf :: NFData a => a -> ()
-- | A set of values a.
data Set a
-- | A Map from keys k to values a.
--
-- The Semigroup operation for Map is union, which
-- prefers values from the left operand. If m1 maps a key
-- k to a value a1, and m2 maps the same key
-- to a different value a2, then their union m1 <>
-- m2 maps k to a1.
data Map k a
-- | Boolean "or", lazy in the second argument
(||) :: Bool -> Bool -> Bool
infixr 2 ||
-- | Boolean "not"
not :: Bool -> Bool
-- | Boolean "and", lazy in the second argument
(&&) :: Bool -> Bool -> Bool
infixr 3 &&
-- | The SomeException type is the root of the exception type
-- hierarchy. When an exception of type e is thrown, behind the
-- scenes it is encapsulated in a SomeException.
data SomeException
SomeException :: e -> SomeException
-- | error stops execution and displays an error message.
error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
-- | A special case of error. It is expected that compilers will
-- recognize this and insert error messages which are more appropriate to
-- the context in which undefined appears.
undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
-- | Strict (call-by-value) application operator. It takes a function and
-- an argument, evaluates the argument to weak head normal form (WHNF),
-- then calls the function with that value.
($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
infixr 0 $!
-- | Function composition.
(.) :: (b -> c) -> (a -> b) -> a -> c
infixr 9 .
-- | Same as >>=, but with the arguments interchanged.
(=<<) :: Monad m => (a -> m b) -> m a -> m b
infixr 1 =<<
-- | asTypeOf is a type-restricted version of const. It is
-- usually used as an infix operator, and its typing forces its first
-- argument (which is usually overloaded) to have the same type as the
-- second.
asTypeOf :: a -> a -> a
-- | const x is a unary function which evaluates to x for
-- all inputs.
--
-- -- >>> const 42 "hello" -- 42 ---- --
-- >>> map (const 42) [0..3] -- [42,42,42,42] --const :: a -> b -> a -- | flip f takes its (first) two arguments in the reverse -- order of f. -- --
-- >>> flip (++) "hello" "world" -- "worldhello" --flip :: (a -> b -> c) -> b -> a -> c -- | Identity function. -- --
-- id x = x --id :: a -> a -- | Promote a function to a monad. liftM :: Monad m => (a1 -> r) -> m a1 -> m r -- | Promote a function to a monad, scanning the monadic arguments from -- left to right. For example, -- --
-- liftM2 (+) [0,1] [0,2] = [0,2,1,3] -- liftM2 (+) (Just 1) Nothing = Nothing --liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r -- | Conditional execution of Applicative expressions. For example, -- --
-- when debug (putStrLn "Debugging") ---- -- will output the string Debugging if the Boolean value -- debug is True, and otherwise do nothing. when :: Applicative f => Bool -> f () -> f () -- | A monoid on applicative functors. -- -- If defined, some and many should be the least solutions -- of the equations: -- -- class Applicative f => Alternative (f :: Type -> Type) -- | An associative binary operation (<|>) :: Alternative f => f a -> f a -> f a -- | One or more. some :: Alternative f => f a -> f [a] -- | Zero or more. many :: Alternative f => f a -> f [a] infixl 3 <|> -- | Monads that also support choice and failure. class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) -- | The identity of mplus. It should also satisfy the equations -- --
-- mzero >>= f = mzero -- v >> mzero = mzero ---- -- The default definition is -- --
-- mzero = empty --mzero :: MonadPlus m => m a -- | An associative operation. The default definition is -- --
-- mplus = (<|>) --mplus :: MonadPlus m => m a -> m a -> m a -- | the same as flip (-). -- -- Because - is treated specially in the Haskell grammar, -- (- e) is not a section, but an application of -- prefix negation. However, (subtract -- exp) is equivalent to the disallowed section. subtract :: Num a => a -> a -> a -- | curry converts an uncurried function to a curried function. -- --
-- >>> curry fst 1 2 -- 1 --curry :: ((a, b) -> c) -> a -> b -> c -- | uncurry converts a curried function to a function on pairs. -- --
-- >>> uncurry (+) (1,2) -- 3 ---- --
-- >>> uncurry ($) (show, 1) -- "1" ---- --
-- >>> map (uncurry max) [(1,2), (3,4), (6,8)] -- [2,4,8] --uncurry :: (a -> b -> c) -> (a, b) -> c -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- --
-- >>> void Nothing -- Nothing -- -- >>> void (Just 3) -- Just () ---- -- Replace the contents of an Either Int -- Int with unit, resulting in an Either -- Int (): -- --
-- >>> void (Left 8675309) -- Left 8675309 -- -- >>> void (Right 8675309) -- Right () ---- -- Replace every element of a list with unit: -- --
-- >>> void [1,2,3] -- [(),(),()] ---- -- Replace the second element of a pair with unit: -- --
-- >>> void (1,2) -- (1,()) ---- -- Discard the result of an IO action: -- --
-- >>> mapM print [1,2] -- 1 -- 2 -- [(),()] -- -- >>> void $ mapM print [1,2] -- 1 -- 2 --void :: Functor f => f a -> f () -- | on b u x y runs the binary function b -- on the results of applying unary function u to two -- arguments x and y. From the opposite perspective, it -- transforms two inputs and combines the outputs. -- --
-- ((+) `on` f) x y = f x + f y ---- -- Typical usage: sortBy (compare `on` -- fst). -- -- Algebraic properties: -- --
(*) `on` id = (*) -- (if (*) ∉ {⊥, const -- ⊥})
((*) `on` f) `on` g = (*) `on` (f . g)
flip on f . flip on g = flip on (g . -- f)
-- >>> catMaybes [Just 1, Nothing, Just 3] -- [1,3] ---- -- When constructing a list of Maybe values, catMaybes can -- be used to return all of the "success" results (if the list is the -- result of a map, then mapMaybe would be more -- appropriate): -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ] -- [Just 1,Nothing,Just 3] -- -- >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ] -- [1,3] --catMaybes :: [Maybe a] -> [a] -- | The fromMaybe function takes a default value and a Maybe -- value. If the Maybe is Nothing, it returns the default -- value; otherwise, it returns the value contained in the Maybe. -- --
-- >>> fromMaybe "" (Just "Hello, World!") -- "Hello, World!" ---- --
-- >>> fromMaybe "" Nothing -- "" ---- -- Read an integer from a string using readMaybe. If we fail to -- parse an integer, we want to return 0 by default: -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> fromMaybe 0 (readMaybe "5") -- 5 -- -- >>> fromMaybe 0 (readMaybe "") -- 0 --fromMaybe :: a -> Maybe a -> a -- | The isJust function returns True iff its argument is of -- the form Just _. -- --
-- >>> isJust (Just 3) -- True ---- --
-- >>> isJust (Just ()) -- True ---- --
-- >>> isJust Nothing -- False ---- -- Only the outer constructor is taken into consideration: -- --
-- >>> isJust (Just Nothing) -- True --isJust :: Maybe a -> Bool -- | The isNothing function returns True iff its argument is -- Nothing. -- --
-- >>> isNothing (Just 3) -- False ---- --
-- >>> isNothing (Just ()) -- False ---- --
-- >>> isNothing Nothing -- True ---- -- Only the outer constructor is taken into consideration: -- --
-- >>> isNothing (Just Nothing) -- False --isNothing :: Maybe a -> Bool -- | The listToMaybe function returns Nothing on an empty -- list or Just a where a is the first element -- of the list. -- --
-- >>> listToMaybe [] -- Nothing ---- --
-- >>> listToMaybe [9] -- Just 9 ---- --
-- >>> listToMaybe [1,2,3] -- Just 1 ---- -- Composing maybeToList with listToMaybe should be the -- identity on singleton/empty lists: -- --
-- >>> maybeToList $ listToMaybe [5] -- [5] -- -- >>> maybeToList $ listToMaybe [] -- [] ---- -- But not on lists with more than one element: -- --
-- >>> maybeToList $ listToMaybe [1,2,3] -- [1] --listToMaybe :: [a] -> Maybe a -- | The mapMaybe function is a version of map which can -- throw out elements. In particular, the functional argument returns -- something of type Maybe b. If this is Nothing, -- no element is added on to the result list. If it is Just -- b, then b is included in the result list. -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> let readMaybeInt = readMaybe :: String -> Maybe Int -- -- >>> mapMaybe readMaybeInt ["1", "Foo", "3"] -- [1,3] -- -- >>> catMaybes $ map readMaybeInt ["1", "Foo", "3"] -- [1,3] ---- -- If we map the Just constructor, the entire list should be -- returned: -- --
-- >>> mapMaybe Just [1,2,3] -- [1,2,3] --mapMaybe :: (a -> Maybe b) -> [a] -> [b] -- | The maybe function takes a default value, a function, and a -- Maybe value. If the Maybe value is Nothing, the -- function returns the default value. Otherwise, it applies the function -- to the value inside the Just and returns the result. -- --
-- >>> maybe False odd (Just 3) -- True ---- --
-- >>> maybe False odd Nothing -- False ---- -- Read an integer from a string using readMaybe. If we succeed, -- return twice the integer; that is, apply (*2) to it. If -- instead we fail to parse an integer, return 0 by default: -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> maybe 0 (*2) (readMaybe "5") -- 10 -- -- >>> maybe 0 (*2) (readMaybe "") -- 0 ---- -- Apply show to a Maybe Int. If we have Just n, -- we want to show the underlying Int n. But if we have -- Nothing, we return the empty string instead of (for example) -- "Nothing": -- --
-- >>> maybe "" show (Just 5) -- "5" -- -- >>> maybe "" show Nothing -- "" --maybe :: b -> (a -> b) -> Maybe a -> b -- | The maybeToList function returns an empty list when given -- Nothing or a singleton list when given Just. -- --
-- >>> maybeToList (Just 7) -- [7] ---- --
-- >>> maybeToList Nothing -- [] ---- -- One can use maybeToList to avoid pattern matching when combined -- with a function that (safely) works on lists: -- --
-- >>> import Text.Read ( readMaybe ) -- -- >>> sum $ maybeToList (readMaybe "3") -- 3 -- -- >>> sum $ maybeToList (readMaybe "") -- 0 --maybeToList :: Maybe a -> [a] -- | break, applied to a predicate p and a list -- xs, returns a tuple where first element is longest prefix -- (possibly empty) of xs of elements that do not satisfy -- p and second element is the remainder of the list: -- --
-- >>> break (> 3) [1,2,3,4,1,2,3,4] -- ([1,2,3],[4,1,2,3,4]) -- -- >>> break (< 9) [1,2,3] -- ([],[1,2,3]) -- -- >>> break (> 9) [1,2,3] -- ([1,2,3],[]) ---- -- break p is equivalent to span (not . -- p). break :: (a -> Bool) -> [a] -> ([a], [a]) -- | drop n xs returns the suffix of xs after the -- first n elements, or [] if n >= length -- xs. -- --
-- >>> drop 6 "Hello World!" -- "World!" -- -- >>> drop 3 [1,2,3,4,5] -- [4,5] -- -- >>> drop 3 [1,2] -- [] -- -- >>> drop 3 [] -- [] -- -- >>> drop (-1) [1,2] -- [1,2] -- -- >>> drop 0 [1,2] -- [1,2] ---- -- It is an instance of the more general genericDrop, in which -- n may be of any integral type. drop :: Int -> [a] -> [a] -- | dropWhile p xs returns the suffix remaining after -- takeWhile p xs. -- --
-- >>> dropWhile (< 3) [1,2,3,4,5,1,2,3] -- [3,4,5,1,2,3] -- -- >>> dropWhile (< 9) [1,2,3] -- [] -- -- >>> dropWhile (< 0) [1,2,3] -- [1,2,3] --dropWhile :: (a -> Bool) -> [a] -> [a] -- | <math>. lookup key assocs looks up a key in an -- association list. -- --
-- >>> lookup 2 [] -- Nothing -- -- >>> lookup 2 [(1, "first")] -- Nothing -- -- >>> lookup 2 [(1, "first"), (2, "second"), (3, "third")] -- Just "second" --lookup :: Eq a => a -> [(a, b)] -> Maybe b -- | replicate n x is a list of length n with -- x the value of every element. It is an instance of the more -- general genericReplicate, in which n may be of any -- integral type. -- --
-- >>> replicate 0 True -- [] -- -- >>> replicate (-1) True -- [] -- -- >>> replicate 4 True -- [True,True,True,True] --replicate :: Int -> a -> [a] -- | reverse xs returns the elements of xs in -- reverse order. xs must be finite. -- --
-- >>> reverse [] -- [] -- -- >>> reverse [42] -- [42] -- -- >>> reverse [2,5,7] -- [7,5,2] -- -- >>> reverse [1..] -- * Hangs forever * --reverse :: [a] -> [a] -- | span, applied to a predicate p and a list xs, -- returns a tuple where first element is longest prefix (possibly empty) -- of xs of elements that satisfy p and second element -- is the remainder of the list: -- --
-- >>> span (< 3) [1,2,3,4,1,2,3,4] -- ([1,2],[3,4,1,2,3,4]) -- -- >>> span (< 9) [1,2,3] -- ([1,2,3],[]) -- -- >>> span (< 0) [1,2,3] -- ([],[1,2,3]) ---- -- span p xs is equivalent to (takeWhile p xs, -- dropWhile p xs) span :: (a -> Bool) -> [a] -> ([a], [a]) -- | take n, applied to a list xs, returns the -- prefix of xs of length n, or xs itself if -- n >= length xs. -- --
-- >>> take 5 "Hello World!" -- "Hello" -- -- >>> take 3 [1,2,3,4,5] -- [1,2,3] -- -- >>> take 3 [1,2] -- [1,2] -- -- >>> take 3 [] -- [] -- -- >>> take (-1) [1,2] -- [] -- -- >>> take 0 [1,2] -- [] ---- -- It is an instance of the more general genericTake, in which -- n may be of any integral type. take :: Int -> [a] -> [a] -- | takeWhile, applied to a predicate p and a list -- xs, returns the longest prefix (possibly empty) of -- xs of elements that satisfy p. -- --
-- >>> takeWhile (< 3) [1,2,3,4,1,2,3,4] -- [1,2] -- -- >>> takeWhile (< 9) [1,2,3] -- [1,2,3] -- -- >>> takeWhile (< 0) [1,2,3] -- [] --takeWhile :: (a -> Bool) -> [a] -> [a] -- | <math>. zipWith generalises zip by zipping with -- the function given as the first argument, instead of a tupling -- function. -- --
-- zipWith (,) xs ys == zip xs ys -- zipWith f [x1,x2,x3..] [y1,y2,y3..] == [f x1 y1, f x2 y2, f x3 y3..] ---- -- For example, zipWith (+) is applied to two lists to -- produce the list of corresponding sums: -- --
-- >>> zipWith (+) [1, 2, 3] [4, 5, 6] -- [5,7,9] ---- -- zipWith is right-lazy: -- --
-- >>> let f = undefined -- -- >>> zipWith f [] undefined -- [] ---- -- zipWith is capable of list fusion, but it is restricted to its -- first list argument and its resulting list. zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] -- | raise a number to a non-negative integral power (^) :: (Num a, Integral b) => a -> b -> a infixr 8 ^ -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 ^^ even :: Integral a => a -> Bool -- | gcd x y is the non-negative factor of both x -- and y of which every common factor of x and -- y is also a factor; for example gcd 4 2 = 2, -- gcd (-4) 6 = 2, gcd 0 4 = 4. -- gcd 0 0 = 0. (That is, the common divisor -- that is "greatest" in the divisibility preordering.) -- -- Note: Since for signed fixed-width integer types, abs -- minBound < 0, the result may be negative if one of the -- arguments is minBound (and necessarily is if the other -- is 0 or minBound) for such types. gcd :: Integral a => a -> a -> a -- | lcm x y is the smallest positive integer that both -- x and y divide. lcm :: Integral a => a -> a -> a odd :: Integral a => a -> Bool -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the undefined :: a idiom. -- --
-- >>> Proxy :: Proxy (Void, Int -> Int) -- Proxy ---- -- Proxy can even hold types of higher kinds, -- --
-- >>> Proxy :: Proxy Either -- Proxy ---- --
-- >>> Proxy :: Proxy Functor -- Proxy ---- --
-- >>> Proxy :: Proxy complicatedStructure -- Proxy --data Proxy (t :: k) Proxy :: Proxy (t :: k) -- | Case analysis for the Either type. If the value is -- Left a, apply the first function to a; if it -- is Right b, apply the second function to b. -- --
-- >>> let s = Left "foo" :: Either String Int -- -- >>> let n = Right 3 :: Either String Int -- -- >>> either length (*2) s -- 3 -- -- >>> either length (*2) n -- 6 --either :: (a -> c) -> (b -> c) -> Either a b -> c -- | Partitions a list of Either into two lists. All the Left -- elements are extracted, in order, to the first component of the -- output. Similarly the Right elements are extracted to the -- second component of the output. -- --
-- >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ] -- -- >>> partitionEithers list -- (["foo","bar","baz"],[3,7]) ---- -- The pair returned by partitionEithers x should be the -- same pair as (lefts x, rights x): -- --
-- >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ] -- -- >>> partitionEithers list == (lefts list, rights list) -- True --partitionEithers :: [Either a b] -> ([a], [b]) -- | Parse a string using the Read instance. Succeeds if there is -- exactly one valid result. -- --
-- >>> readMaybe "123" :: Maybe Int -- Just 123 ---- --
-- >>> readMaybe "hello" :: Maybe Int -- Nothing --readMaybe :: Read a => String -> Maybe a -- |
-- comparing p x y = compare (p x) (p y) ---- -- Useful combinator for use in conjunction with the xxxBy -- family of functions from Data.List, for example: -- --
-- ... sortBy (comparing fst) ... --comparing :: Ord a => (b -> a) -> b -> b -> Ordering -- | Boolean monoid under disjunction (||). -- --
-- >>> getAny (Any True <> mempty <> Any False) -- True ---- --
-- >>> getAny (mconcat (map (\x -> Any (even x)) [2,4,6,7,8])) -- True --newtype Any Any :: Bool -> Any [getAny] :: Any -> Bool -- | lines breaks a string up into a list of strings at newline -- characters. The resulting strings do not contain newlines. -- -- Note that after splitting the string at newline characters, the last -- part of the string is considered a line even if it doesn't end with a -- newline. For example, -- --
-- >>> lines "" -- [] ---- --
-- >>> lines "\n" -- [""] ---- --
-- >>> lines "one" -- ["one"] ---- --
-- >>> lines "one\n" -- ["one"] ---- --
-- >>> lines "one\n\n" -- ["one",""] ---- --
-- >>> lines "one\ntwo" -- ["one","two"] ---- --
-- >>> lines "one\ntwo\n" -- ["one","two"] ---- -- Thus lines s contains at least as many elements as -- newlines in s. lines :: String -> [String] -- | unlines is an inverse operation to lines. It joins -- lines, after appending a terminating newline to each. -- --
-- >>> unlines ["Hello", "World", "!"] -- "Hello\nWorld\n!\n" --unlines :: [String] -> String -- | unwords is an inverse operation to words. It joins words -- with separating spaces. -- --
-- >>> unwords ["Lorem", "ipsum", "dolor"] -- "Lorem ipsum dolor" --unwords :: [String] -> String -- | words breaks a string up into a list of words, which were -- delimited by white space. -- --
-- >>> words "Lorem ipsum\ndolor" -- ["Lorem","ipsum","dolor"] --words :: String -> [String] -- | Determines whether all elements of the structure satisfy the -- predicate. -- --
-- >>> all (> 3) [] -- True ---- --
-- >>> all (> 3) [1,2] -- False ---- --
-- >>> all (> 3) [1,2,3,4,5] -- False ---- --
-- >>> all (> 3) [1..] -- False ---- --
-- >>> all (> 3) [4..] -- * Hangs forever * --all :: Foldable t => (a -> Bool) -> t a -> Bool -- | and returns the conjunction of a container of Bools. For the -- result to be True, the container must be finite; False, -- however, results from a False value finitely far from the left -- end. -- --
-- >>> and [] -- True ---- --
-- >>> and [True] -- True ---- --
-- >>> and [False] -- False ---- --
-- >>> and [True, True, False] -- False ---- --
-- >>> and (False : repeat True) -- Infinite list [False,True,True,True,... -- False ---- --
-- >>> and (repeat True) -- * Hangs forever * --and :: Foldable t => t Bool -> Bool -- | Determines whether any element of the structure satisfies the -- predicate. -- --
-- >>> any (> 3) [] -- False ---- --
-- >>> any (> 3) [1,2] -- False ---- --
-- >>> any (> 3) [1,2,3,4,5] -- True ---- --
-- >>> any (> 3) [1..] -- True ---- --
-- >>> any (> 3) [0, -1..] -- * Hangs forever * --any :: Foldable t => (a -> Bool) -> t a -> Bool -- | The concatenation of all the elements of a container of lists. -- --
-- >>> concat (Just [1, 2, 3]) -- [1,2,3] ---- --
-- >>> concat (Left 42) -- [] ---- --
-- >>> concat [[1, 2, 3], [4, 5], [6], []] -- [1,2,3,4,5,6] --concat :: Foldable t => t [a] -> [a] -- | Map a function over all the elements of a container and concatenate -- the resulting lists. -- --
-- >>> concatMap (take 3) [[1..], [10..], [100..], [1000..]] -- [1,2,3,10,11,12,100,101,102,1000,1001,1002] ---- --
-- >>> concatMap (take 3) (Just [1..]) -- [1,2,3] --concatMap :: Foldable t => (a -> [b]) -> t a -> [b] -- | for_ is traverse_ with its arguments flipped. For a -- version that doesn't ignore the results see for. This is -- forM_ generalised to Applicative actions. -- -- for_ is just like forM_, but generalised to -- Applicative actions. -- --
-- >>> for_ [1..4] print -- 1 -- 2 -- 3 -- 4 --for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () -- | notElem is the negation of elem. -- --
-- >>> 3 `notElem` [] -- True ---- --
-- >>> 3 `notElem` [1,2] -- True ---- --
-- >>> 3 `notElem` [1,2,3,4,5] -- False ---- -- For infinite structures, notElem terminates if the value exists -- at a finite distance from the left side of the structure: -- --
-- >>> 3 `notElem` [1..] -- False ---- --
-- >>> 3 `notElem` ([4..] ++ [3]) -- * Hangs forever * --notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 `notElem` -- | or returns the disjunction of a container of Bools. For the -- result to be False, the container must be finite; True, -- however, results from a True value finitely far from the left -- end. -- --
-- >>> or [] -- False ---- --
-- >>> or [True] -- True ---- --
-- >>> or [False] -- False ---- --
-- >>> or [True, True, False] -- True ---- --
-- >>> or (True : repeat False) -- Infinite list [True,False,False,False,... -- True ---- --
-- >>> or (repeat False) -- * Hangs forever * --or :: Foldable t => t Bool -> Bool -- | Evaluate each monadic action in the structure from left to right, and -- ignore the results. For a version that doesn't ignore the results see -- sequence. -- -- sequence_ is just like sequenceA_, but specialised to -- monadic actions. sequence_ :: (Foldable t, Monad m) => t (m a) -> m () -- | Map each element of a structure to an Applicative action, -- evaluate these actions from left to right, and ignore the results. For -- a version that doesn't ignore the results see traverse. -- -- traverse_ is just like mapM_, but generalised to -- Applicative actions. -- --
-- >>> traverse_ print ["Hello", "world", "!"] -- "Hello" -- "world" -- "!" --traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () -- | The Const functor. newtype Const a (b :: k) Const :: a -> Const a (b :: k) [getConst] :: Const a (b :: k) -> a -- | Any type that you wish to throw or catch as an exception must be an -- instance of the Exception class. The simplest case is a new -- exception type directly below the root: -- --
-- data MyException = ThisException | ThatException -- deriving Show -- -- instance Exception MyException ---- -- The default method definitions in the Exception class do what -- we need in this case. You can now throw and catch -- ThisException and ThatException as exceptions: -- --
-- *Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
-- Caught ThisException
--
--
-- In more complicated examples, you may wish to define a whole hierarchy
-- of exceptions:
--
-- -- --------------------------------------------------------------------- -- -- Make the root exception type for all the exceptions in a compiler -- -- data SomeCompilerException = forall e . Exception e => SomeCompilerException e -- -- instance Show SomeCompilerException where -- show (SomeCompilerException e) = show e -- -- instance Exception SomeCompilerException -- -- compilerExceptionToException :: Exception e => e -> SomeException -- compilerExceptionToException = toException . SomeCompilerException -- -- compilerExceptionFromException :: Exception e => SomeException -> Maybe e -- compilerExceptionFromException x = do -- SomeCompilerException a <- fromException x -- cast a -- -- --------------------------------------------------------------------- -- -- Make a subhierarchy for exceptions in the frontend of the compiler -- -- data SomeFrontendException = forall e . Exception e => SomeFrontendException e -- -- instance Show SomeFrontendException where -- show (SomeFrontendException e) = show e -- -- instance Exception SomeFrontendException where -- toException = compilerExceptionToException -- fromException = compilerExceptionFromException -- -- frontendExceptionToException :: Exception e => e -> SomeException -- frontendExceptionToException = toException . SomeFrontendException -- -- frontendExceptionFromException :: Exception e => SomeException -> Maybe e -- frontendExceptionFromException x = do -- SomeFrontendException a <- fromException x -- cast a -- -- --------------------------------------------------------------------- -- -- Make an exception type for a particular frontend compiler exception -- -- data MismatchedParentheses = MismatchedParentheses -- deriving Show -- -- instance Exception MismatchedParentheses where -- toException = frontendExceptionToException -- fromException = frontendExceptionFromException ---- -- We can now catch a MismatchedParentheses exception as -- MismatchedParentheses, SomeFrontendException or -- SomeCompilerException, but not other types, e.g. -- IOException: -- --
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
-- Caught MismatchedParentheses
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
-- Caught MismatchedParentheses
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
-- Caught MismatchedParentheses
-- *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
-- *** Exception: MismatchedParentheses
--
class (Typeable e, Show e) => Exception e
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e
-- | Render this exception value in a human-friendly manner.
--
-- Default implementation: show.
displayException :: Exception e => e -> String
-- | Exceptions that occur in the IO monad. An
-- IOException records a more specific error type, a descriptive
-- string and maybe the handle that was used when the error was flagged.
data IOException
-- | File and directory names are values of type String, whose
-- precise meaning is operating system dependent. Files can be opened,
-- yielding a handle which can then be used to operate on the contents of
-- that file.
type FilePath = String
-- | Defines the exit codes that a program can return.
data ExitCode
-- | indicates successful termination;
ExitSuccess :: ExitCode
-- | indicates program failure with an exit code. The exact interpretation
-- of the code is operating-system dependent. In particular, some values
-- may be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode
-- | Identity functor and monad. (a non-strict monad)
newtype Identity a
Identity :: a -> Identity a
[runIdentity] :: Identity a -> a
-- | One or none.
--
-- It is useful for modelling any computation that is allowed to fail.
--
-- -- >>> import Control.Monad.Except ---- --
-- >>> canFail = throwError "it failed" :: Except String Int -- -- >>> final = return 42 :: Except String Int ---- -- Can be combined by allowing the first function to fail: -- --
-- >>> runExcept $ canFail *> final -- Left "it failed" -- -- >>> runExcept $ optional canFail *> final -- Right 42 --optional :: Alternative f => f a -> f (Maybe a) -- | for is traverse with its arguments flipped. For a -- version that ignores the results see for_. for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b) -- | This generalizes the list-based filter function. filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a] -- | The foldM function is analogous to foldl, except that -- its result is encapsulated in a monad. Note that foldM works -- from left-to-right over the list arguments. This could be an issue -- where (>>) and the `folded function' are not -- commutative. -- --
-- foldM f a1 [x1, x2, ..., xm] -- -- == -- -- do -- a2 <- f a1 x1 -- a3 <- f a2 x2 -- ... -- f am xm ---- -- If right-to-left evaluation is required, the input list should be -- reversed. -- -- Note: foldM is the same as foldlM foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b -- | The reverse of when. unless :: Applicative f => Bool -> f () -> f () -- | Since Void values logically don't exist, this witnesses the -- logical reasoning tool of "ex falso quodlibet". -- --
-- >>> let x :: Either Void Int; x = Right 5
--
-- >>> :{
-- case x of
-- Right r -> r
-- Left l -> absurd l
-- :}
-- 5
--
absurd :: Void -> a
-- | Uninhabited data type
data Void
-- | Builders denote sequences of bytes. They are Monoids
-- where mempty is the zero-length sequence and mappend is
-- concatenation, which runs in O(1).
data Builder
-- | The class of types that can be converted to a hash value.
--
-- Minimal implementation: hashWithSalt.
--
-- Note: the hash is not guaranteed to be stable across library
-- versions, operating systems or architectures. For stable hashing use
-- named hashes: SHA256, CRC32 etc.
--
-- If you are looking for Hashable instance in time
-- package, check time-compat
class Eq a => Hashable a
-- | A space efficient, packed, unboxed Unicode text type.
data Text
-- | A map from keys to values. A map cannot contain duplicate keys; each
-- key can map to at most one value.
data HashMap k v
stdin :: Handle
stdout :: Handle
-- | Haskell defines operations to read and write characters from and to
-- files, represented by values of type Handle. Each value of
-- this type is a handle: a record used by the Haskell run-time
-- system to manage I/O with file system objects. A handle has at
-- least the following properties:
--
-- -- bimap id id ≡ id ---- -- If you supply first and second, ensure: -- --
-- first id ≡ id -- second id ≡ id ---- -- If you supply both, you should also ensure: -- --
-- bimap f g ≡ first f . second g ---- -- These ensure by parametricity: -- --
-- bimap (f . g) (h . i) ≡ bimap f h . bimap g i -- first (f . g) ≡ first f . first g -- second (f . g) ≡ second f . second g --class Bifunctor (p :: Type -> Type -> Type) -- | Map over both arguments at the same time. -- --
-- bimap f g ≡ first f . second g ---- --
-- >>> bimap toUpper (+1) ('j', 3)
-- ('J',4)
--
--
-- -- >>> bimap toUpper (+1) (Left 'j') -- Left 'J' ---- --
-- >>> bimap toUpper (+1) (Right 3) -- Right 4 --bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d -- | Map covariantly over the first argument. -- --
-- first f ≡ bimap f id ---- --
-- >>> first toUpper ('j', 3)
-- ('J',3)
--
--
-- -- >>> first toUpper (Left 'j') -- Left 'J' --first :: Bifunctor p => (a -> b) -> p a c -> p b c -- | Map covariantly over the second argument. -- --
-- second ≡ bimap id ---- --
-- >>> second (+1) ('j', 3)
-- ('j',4)
--
--
-- -- >>> second (+1) (Right 3) -- Right 4 --second :: Bifunctor p => (b -> c) -> p a b -> p a c -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and ignore the results. For a version that -- doesn't ignore the results see mapM. -- -- mapM_ is just like traverse_, but specialised to monadic -- actions. mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m () -- | A version of waitBoth that can be used inside an STM -- transaction. waitBothSTM :: Async a -> Async b -> STM (a, b) -- | A version of waitEither_ that can be used inside an STM -- transaction. waitEitherSTM_ :: Async a -> Async b -> STM () -- | A version of waitEither that can be used inside an STM -- transaction. waitEitherSTM :: Async a -> Async b -> STM (Either a b) -- | A version of waitEitherCatch that can be used inside an STM -- transaction. waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b)) -- | A version of waitAny that can be used inside an STM -- transaction. waitAnySTM :: [Async a] -> STM (Async a, a) -- | A version of waitAnyCatch that can be used inside an STM -- transaction. waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a) -- | A version of poll that can be used inside an STM transaction. pollSTM :: Async a -> STM (Maybe (Either SomeException a)) -- | A version of waitCatch that can be used inside an STM -- transaction. waitCatchSTM :: Async a -> STM (Either SomeException a) -- | A version of wait that can be used inside an STM transaction. waitSTM :: Async a -> STM a -- | An asynchronous action spawned by async or withAsync. -- Asynchronous actions are executed in a separate thread, and operations -- are provided for waiting for asynchronous actions to complete and -- obtaining their results (see e.g. wait). data Async a -- | The exception thrown by cancel to terminate a thread. data AsyncCancelled AsyncCancelled :: AsyncCancelled -- | Chan is an abstract type representing an unbounded FIFO -- channel. data Chan a -- | QSem is a quantity semaphore in which the resource is acquired -- and released in units of one. It provides guaranteed FIFO ordering for -- satisfying blocked waitQSem calls. -- -- The pattern -- --
-- bracket_ waitQSem signalQSem (...) ---- -- is safe; it never loses a unit of the resource. data QSem -- | QSemN is a quantity semaphore in which the resource is acquired -- and released in units of one. It provides guaranteed FIFO ordering for -- satisfying blocked waitQSemN calls. -- -- The pattern -- --
-- bracket_ (waitQSemN n) (signalQSemN n) (...) ---- -- is safe; it never loses any of the resource. data QSemN -- | Bitraversable identifies bifunctorial data structures whose -- elements can be traversed in order, performing Applicative or -- Monad actions at each element, and collecting a result -- structure with the same shape. -- -- As opposed to Traversable data structures, which have one -- variety of element on which an action can be performed, -- Bitraversable data structures have two such varieties of -- elements. -- -- A definition of bitraverse must satisfy the following laws: -- --
-- t :: (Applicative f, Applicative g) => f a -> g a ---- -- preserving the Applicative operations: -- --
-- t (pure x) = pure x -- t (f <*> x) = t f <*> t x ---- -- and the identity functor Identity and composition functors -- Compose are from Data.Functor.Identity and -- Data.Functor.Compose. -- -- Some simple examples are Either and (,): -- --
-- instance Bitraversable Either where -- bitraverse f _ (Left x) = Left <$> f x -- bitraverse _ g (Right y) = Right <$> g y -- -- instance Bitraversable (,) where -- bitraverse f g (x, y) = (,) <$> f x <*> g y ---- -- Bitraversable relates to its superclasses in the following -- ways: -- --
-- bimap f g ≡ runIdentity . bitraverse (Identity . f) (Identity . g) -- bifoldMap f g = getConst . bitraverse (Const . f) (Const . g) ---- -- These are available as bimapDefault and bifoldMapDefault -- respectively. class (Bifunctor t, Bifoldable t) => Bitraversable (t :: Type -> Type -> Type) -- | Evaluates the relevant functions at each element in the structure, -- running the action, and builds a new structure with the same shape, -- using the results produced from sequencing the actions. -- --
-- bitraverse f g ≡ bisequenceA . bimap f g ---- -- For a version that ignores the results, see bitraverse_. -- --
-- >>> bitraverse listToMaybe (find odd) (Left []) -- Nothing ---- --
-- >>> bitraverse listToMaybe (find odd) (Left [1, 2, 3]) -- Just (Left 1) ---- --
-- >>> bitraverse listToMaybe (find odd) (Right [4, 5]) -- Just (Right 5) ---- --
-- >>> bitraverse listToMaybe (find odd) ([1, 2, 3], [4, 5]) -- Just (1,5) ---- --
-- >>> bitraverse listToMaybe (find odd) ([], [4, 5]) -- Nothing --bitraverse :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d) -- | Sequences all the actions in a structure, building a new structure -- with the same shape using the results of the actions. For a version -- that ignores the results, see bisequence_. -- --
-- bisequence ≡ bitraverse id id ---- --
-- >>> bisequence (Just 4, Nothing) -- Nothing ---- --
-- >>> bisequence (Just 4, Just 5) -- Just (4,5) ---- --
-- >>> bisequence ([1, 2, 3], [4, 5]) -- [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)] --bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b) -- | The bimapAccumR function behaves like a combination of -- bimap and bifoldr; it traverses a structure from right -- to left, threading a state of type a and using the given -- actions to compute new elements for the structure. -- --
-- >>> bimapAccumR (\acc bool -> (acc + 1, show bool)) (\acc string -> (acc * 2, reverse string)) 3 (True, "foo")
-- (7,("True","oof"))
--
bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
-- | The bimapAccumL function behaves like a combination of
-- bimap and bifoldl; it traverses a structure from left to
-- right, threading a state of type a and using the given
-- actions to compute new elements for the structure.
--
--
-- >>> bimapAccumL (\acc bool -> (acc + 1, show bool)) (\acc string -> (acc * 2, reverse string)) 3 (True, "foo")
-- (8,("True","oof"))
--
bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
-- | bifor is bitraverse with the structure as the first
-- argument. For a version that ignores the results, see bifor_.
--
-- -- >>> bifor (Left []) listToMaybe (find even) -- Nothing ---- --
-- >>> bifor (Left [1, 2, 3]) listToMaybe (find even) -- Just (Left 1) ---- --
-- >>> bifor (Right [4, 5]) listToMaybe (find even) -- Just (Right 4) ---- --
-- >>> bifor ([1, 2, 3], [4, 5]) listToMaybe (find even) -- Just (1,4) ---- --
-- >>> bifor ([], [4, 5]) listToMaybe (find even) -- Nothing --bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d) -- | Bifoldable identifies foldable structures with two different -- varieties of elements (as opposed to Foldable, which has one -- variety of element). Common examples are Either and -- (,): -- --
-- instance Bifoldable Either where -- bifoldMap f _ (Left a) = f a -- bifoldMap _ g (Right b) = g b -- -- instance Bifoldable (,) where -- bifoldr f g z (a, b) = f a (g b z) ---- -- Some examples below also use the following BiList to showcase empty -- Bifoldable behaviors when relevant (Either and (,) -- containing always exactly resp. 1 and 2 elements): -- --
-- data BiList a b = BiList [a] [b] -- -- instance Bifoldable BiList where -- bifoldr f g z (BiList as bs) = foldr f (foldr g z bs) as ---- -- A minimal Bifoldable definition consists of either -- bifoldMap or bifoldr. When defining more than this -- minimal set, one should ensure that the following identities hold: -- --
-- bifold ≡ bifoldMap id id -- bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty -- bifoldr f g z t ≡ appEndo (bifoldMap (Endo . f) (Endo . g) t) z ---- -- If the type is also a Bifunctor instance, it should satisfy: -- --
-- bifoldMap f g ≡ bifold . bimap f g ---- -- which implies that -- --
-- bifoldMap f g . bimap h i ≡ bifoldMap (f . h) (g . i) --class Bifoldable (p :: TYPE LiftedRep -> TYPE LiftedRep -> Type) -- | Combines the elements of a structure using a monoid. -- --
-- bifold ≡ bifoldMap id id ---- --
-- >>> bifold (Right [1, 2, 3]) -- [1,2,3] ---- --
-- >>> bifold (Left [5, 6]) -- [5,6] ---- --
-- >>> bifold ([1, 2, 3], [4, 5]) -- [1,2,3,4,5] ---- --
-- >>> bifold (Product 6, Product 7)
-- Product {getProduct = 42}
--
--
--
-- >>> bifold (Sum 6, Sum 7)
-- Sum {getSum = 13}
--
bifold :: (Bifoldable p, Monoid m) => p m m -> m
-- | Combines the elements of a structure, given ways of mapping them to a
-- common monoid.
--
-- -- bifoldMap f g ≡ bifoldr (mappend . f) (mappend . g) mempty ---- --
-- >>> bifoldMap (take 3) (fmap digitToInt) ([1..], "89") -- [1,2,3,8,9] ---- --
-- >>> bifoldMap (take 3) (fmap digitToInt) (Left [1..]) -- [1,2,3] ---- --
-- >>> bifoldMap (take 3) (fmap digitToInt) (Right "89") -- [8,9] --bifoldMap :: (Bifoldable p, Monoid m) => (a -> m) -> (b -> m) -> p a b -> m -- | Combines the elements of a structure in a right associative manner. -- Given a hypothetical function toEitherList :: p a b -> [Either -- a b] yielding a list of all elements of a structure in order, the -- following would hold: -- --
-- bifoldr f g z ≡ foldr (either f g) z . toEitherList ---- --
-- > bifoldr (+) (*) 3 (5, 7) -- 26 -- 5 + (7 * 3) -- -- > bifoldr (+) (*) 3 (7, 5) -- 22 -- 7 + (5 * 3) -- -- > bifoldr (+) (*) 3 (Right 5) -- 15 -- 5 * 3 -- -- > bifoldr (+) (*) 3 (Left 5) -- 8 -- 5 + 3 --bifoldr :: Bifoldable p => (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c -- | Combines the elements of a structure in a left associative manner. -- Given a hypothetical function toEitherList :: p a b -> [Either -- a b] yielding a list of all elements of a structure in order, the -- following would hold: -- --
-- bifoldl f g z -- ≡ foldl (acc -> either (f acc) (g acc)) z . toEitherList ---- -- Note that if you want an efficient left-fold, you probably want to use -- bifoldl' instead of bifoldl. The reason is that the -- latter does not force the "inner" results, resulting in a thunk chain -- which then must be evaluated from the outside-in. -- --
-- > bifoldl (+) (*) 3 (5, 7) -- 56 -- (5 + 3) * 7 -- -- > bifoldl (+) (*) 3 (7, 5) -- 50 -- (7 + 3) * 5 -- -- > bifoldl (+) (*) 3 (Right 5) -- 15 -- 5 * 3 -- -- > bifoldl (+) (*) 3 (Left 5) -- 8 -- 5 + 3 --bifoldl :: Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c -- | Map each element of a structure using one of two actions, evaluate -- these actions from left to right, and ignore the results. For a -- version that doesn't ignore the results, see bitraverse. -- --
-- >>> bitraverse_ print (print . show) ("Hello", True)
-- "Hello"
-- "True"
--
--
-- -- >>> bitraverse_ print (print . show) (Right True) -- "True" ---- --
-- >>> bitraverse_ print (print . show) (Left "Hello") -- "Hello" --bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f () -- | The bisum function computes the sum of the numbers of a -- structure. -- --
-- >>> bisum (42, 17) -- 59 ---- --
-- >>> bisum (Right 42) -- 42 ---- --
-- >>> bisum (BiList [13, 29, 4] [18, 1, 7]) -- 72 ---- --
-- >>> bisum (BiList [13, 29, 4] []) -- 46 ---- --
-- >>> bisum (BiList [] []) -- 0 --bisum :: (Bifoldable t, Num a) => t a a -> a -- | Evaluate each action in the structure from left to right, and ignore -- the results. For a version that doesn't ignore the results, see -- bisequence. -- --
-- >>> bisequence_ (print "Hello", print "World") -- "Hello" -- "World" ---- --
-- >>> bisequence_ (Left (print "Hello")) -- "Hello" ---- --
-- >>> bisequence_ (Right (print "World")) -- "World" --bisequence_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f () -- | The biproduct function computes the product of the numbers of a -- structure. -- --
-- >>> biproduct (42, 17) -- 714 ---- --
-- >>> biproduct (Right 42) -- 42 ---- --
-- >>> biproduct (BiList [13, 29, 4] [18, 1, 7]) -- 190008 ---- --
-- >>> biproduct (BiList [13, 29, 4] []) -- 1508 ---- --
-- >>> biproduct (BiList [] []) -- 1 --biproduct :: (Bifoldable t, Num a) => t a a -> a -- | bior returns the disjunction of a container of Bools. For the -- result to be False, the container must be finite; True, -- however, results from a True value finitely far from the left -- end. -- --
-- >>> bior (True, False) -- True ---- --
-- >>> bior (False, False) -- False ---- --
-- >>> bior (Left True) -- True ---- -- Empty structures yield False: -- --
-- >>> bior (BiList [] []) -- False ---- -- A True value finitely far from the left end yields True -- (short circuit): -- --
-- >>> bior (BiList [False, False, True, False] (repeat False)) -- True ---- -- A True value infinitely far from the left end hangs: -- --
-- > bior (BiList (repeat False) [True]) -- * Hangs forever * ---- -- An infinitely False value hangs: -- --
-- > bior (BiList (repeat False) []) -- * Hangs forever * --bior :: Bifoldable t => t Bool Bool -> Bool -- | Test whether the structure is empty. -- --
-- >>> binull (18, 42) -- False ---- --
-- >>> binull (Right 42) -- False ---- --
-- >>> binull (BiList [] []) -- True --binull :: Bifoldable t => t a b -> Bool -- | binotElem is the negation of bielem. -- --
-- >>> binotElem 42 (17, 42) -- False ---- --
-- >>> binotElem 42 (17, 43) -- True ---- --
-- >>> binotElem 42 (Left 42) -- False ---- --
-- >>> binotElem 42 (Right 13) -- True ---- --
-- >>> binotElem 42 (BiList [1..5] [1..100]) -- False ---- --
-- >>> binotElem 42 (BiList [1..5] [1..41]) -- True --binotElem :: (Bifoldable t, Eq a) => a -> t a a -> Bool -- | The least element of a non-empty structure with respect to the given -- comparison function. -- --
-- >>> biminimumBy compare (42, 17) -- 17 ---- --
-- >>> biminimumBy compare (Left 17) -- 17 ---- --
-- >>> biminimumBy compare (BiList [42, 17, 23] [-5, 18]) -- -5 ---- -- On empty structures, this function throws an exception: -- --
-- >>> biminimumBy compare (BiList [] []) -- *** Exception: bifoldr1: empty structure -- ... --biminimumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a -- | The least element of a non-empty structure. -- --
-- >>> biminimum (42, 17) -- 17 ---- --
-- >>> biminimum (Right 42) -- 42 ---- --
-- >>> biminimum (BiList [13, 29, 4] [18, 1, 7]) -- 1 ---- --
-- >>> biminimum (BiList [13, 29, 4] []) -- 4 ---- -- On empty structures, this function throws an exception: -- --
-- >>> biminimum (BiList [] []) -- *** Exception: biminimum: empty structure -- ... --biminimum :: (Bifoldable t, Ord a) => t a a -> a -- | The largest element of a non-empty structure with respect to the given -- comparison function. -- --
-- >>> bimaximumBy compare (42, 17) -- 42 ---- --
-- >>> bimaximumBy compare (Left 17) -- 17 ---- --
-- >>> bimaximumBy compare (BiList [42, 17, 23] [-5, 18]) -- 42 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bimaximumBy compare (BiList [] []) -- *** Exception: bifoldr1: empty structure -- ... --bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a -- | The largest element of a non-empty structure. -- --
-- >>> bimaximum (42, 17) -- 42 ---- --
-- >>> bimaximum (Right 42) -- 42 ---- --
-- >>> bimaximum (BiList [13, 29, 4] [18, 1, 7]) -- 29 ---- --
-- >>> bimaximum (BiList [13, 29, 4] []) -- 29 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bimaximum (BiList [] []) -- *** Exception: bimaximum: empty structure -- ... --bimaximum :: (Bifoldable t, Ord a) => t a a -> a -- | Returns the size/length of a finite structure as an Int. -- --
-- >>> bilength (True, 42) -- 2 ---- --
-- >>> bilength (Right 42) -- 1 ---- --
-- >>> bilength (BiList [1,2,3] [4,5]) -- 5 ---- --
-- >>> bilength (BiList [] []) -- 0 ---- -- On infinite structures, this function hangs: -- --
-- > bilength (BiList [1..] []) -- * Hangs forever * --bilength :: Bifoldable t => t a b -> Int -- | As bitraverse_, but with the structure as the primary argument. -- For a version that doesn't ignore the results, see bifor. -- --
-- >>> bifor_ ("Hello", True) print (print . show)
-- "Hello"
-- "True"
--
--
-- -- >>> bifor_ (Right True) print (print . show) -- "True" ---- --
-- >>> bifor_ (Left "Hello") print (print . show) -- "Hello" --bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f () -- | Right associative monadic bifold over a structure. bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c -- | A variant of bifoldr that has no base case, and thus may only -- be applied to non-empty structures. -- --
-- >>> bifoldr1 (+) (5, 7) -- 12 ---- --
-- >>> bifoldr1 (+) (Right 7) -- 7 ---- --
-- >>> bifoldr1 (+) (Left 5) -- 5 ---- --
-- > bifoldr1 (+) (BiList [1, 2] [3, 4]) -- 10 -- 1 + (2 + (3 + 4)) ---- --
-- >>> bifoldr1 (+) (BiList [1, 2] []) -- 3 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bifoldr1 (+) (BiList [] []) -- *** Exception: bifoldr1: empty structure -- ... --bifoldr1 :: Bifoldable t => (a -> a -> a) -> t a a -> a -- | As bifoldr, but strict in the result of the reduction functions -- at each step. bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c -- | Left associative monadic bifold over a structure. -- --
-- >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 ("Hello", True)
-- "Hello"
-- "True"
-- 42
--
--
-- -- >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Right True) -- "True" -- 42 ---- --
-- >>> bifoldlM (\a b -> print b >> pure a) (\a c -> print (show c) >> pure a) 42 (Left "Hello") -- "Hello" -- 42 --bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a -- | A variant of bifoldl that has no base case, and thus may only -- be applied to non-empty structures. -- --
-- >>> bifoldl1 (+) (5, 7) -- 12 ---- --
-- >>> bifoldl1 (+) (Right 7) -- 7 ---- --
-- >>> bifoldl1 (+) (Left 5) -- 5 ---- --
-- > bifoldl1 (+) (BiList [1, 2] [3, 4]) -- 10 -- ((1 + 2) + 3) + 4 ---- --
-- >>> bifoldl1 (+) (BiList [1, 2] []) -- 3 ---- -- On empty structures, this function throws an exception: -- --
-- >>> bifoldl1 (+) (BiList [] []) -- *** Exception: bifoldl1: empty structure -- ... --bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> a -- | As bifoldl, but strict in the result of the reduction functions -- at each step. -- -- This ensures that each step of the bifold is forced to weak head -- normal form before being applied, avoiding the collection of thunks -- that would otherwise occur. This is often what you want to strictly -- reduce a finite structure to a single, monolithic result (e.g., -- bilength). bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a -- | The bifind function takes a predicate and a structure and -- returns the leftmost element of the structure matching the predicate, -- or Nothing if there is no such element. -- --
-- >>> bifind even (27, 53) -- Nothing ---- --
-- >>> bifind even (27, 52) -- Just 52 ---- --
-- >>> bifind even (26, 52) -- Just 26 ---- -- Empty structures always yield Nothing: -- --
-- >>> bifind even (BiList [] []) -- Nothing --bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a -- | Does the element occur in the structure? -- --
-- >>> bielem 42 (17, 42) -- True ---- --
-- >>> bielem 42 (17, 43) -- False ---- --
-- >>> bielem 42 (Left 42) -- True ---- --
-- >>> bielem 42 (Right 13) -- False ---- --
-- >>> bielem 42 (BiList [1..5] [1..100]) -- True ---- --
-- >>> bielem 42 (BiList [1..5] [1..41]) -- False --bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool -- | Given a means of mapping the elements of a structure to lists, -- computes the concatenation of all such lists in order. -- --
-- >>> biconcatMap (take 3) (fmap digitToInt) ([1..], "89") -- [1,2,3,8,9] ---- --
-- >>> biconcatMap (take 3) (fmap digitToInt) (Left [1..]) -- [1,2,3] ---- --
-- >>> biconcatMap (take 3) (fmap digitToInt) (Right "89") -- [8,9] --biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c] -- | Reduces a structure of lists to the concatenation of those lists. -- --
-- >>> biconcat ([1, 2, 3], [4, 5]) -- [1,2,3,4,5] ---- --
-- >>> biconcat (Left [1, 2, 3]) -- [1,2,3] ---- --
-- >>> biconcat (BiList [[1, 2, 3, 4, 5], [6, 7, 8]] [[9]]) -- [1,2,3,4,5,6,7,8,9] --biconcat :: Bifoldable t => t [a] [a] -> [a] -- | The sum of a collection of actions, generalizing biconcat. -- --
-- >>> biasum (Nothing, Nothing) -- Nothing ---- --
-- >>> biasum (Nothing, Just 42) -- Just 42 ---- --
-- >>> biasum (Just 18, Nothing) -- Just 18 ---- --
-- >>> biasum (Just 18, Just 42) -- Just 18 --biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a -- | Determines whether any element of the structure satisfies its -- appropriate predicate argument. Empty structures yield False. -- --
-- >>> biany even isDigit (27, 't') -- False ---- --
-- >>> biany even isDigit (27, '8') -- True ---- --
-- >>> biany even isDigit (26, 't') -- True ---- --
-- >>> biany even isDigit (Left 27) -- False ---- --
-- >>> biany even isDigit (Left 26) -- True ---- --
-- >>> biany even isDigit (BiList [27, 53] ['t', '8']) -- True ---- -- Empty structures yield False: -- --
-- >>> biany even isDigit (BiList [] []) -- False --biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool -- | biand returns the conjunction of a container of Bools. For the -- result to be True, the container must be finite; False, -- however, results from a False value finitely far from the left -- end. -- --
-- >>> biand (True, False) -- False ---- --
-- >>> biand (True, True) -- True ---- --
-- >>> biand (Left True) -- True ---- -- Empty structures yield True: -- --
-- >>> biand (BiList [] []) -- True ---- -- A False value finitely far from the left end yields -- False (short circuit): -- --
-- >>> biand (BiList [True, True, False, True] (repeat True)) -- False ---- -- A False value infinitely far from the left end hangs: -- --
-- > biand (BiList (repeat True) [False]) -- * Hangs forever * ---- -- An infinitely True value hangs: -- --
-- > biand (BiList (repeat True) []) -- * Hangs forever * --biand :: Bifoldable t => t Bool Bool -> Bool -- | Determines whether all elements of the structure satisfy their -- appropriate predicate argument. Empty structures yield True. -- --
-- >>> biall even isDigit (27, 't') -- False ---- --
-- >>> biall even isDigit (26, '8') -- True ---- --
-- >>> biall even isDigit (Left 27) -- False ---- --
-- >>> biall even isDigit (Left 26) -- True ---- --
-- >>> biall even isDigit (BiList [26, 52] ['3', '8']) -- True ---- -- Empty structures yield True: -- --
-- >>> biall even isDigit (BiList [] []) -- True --biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool -- | Collects the list of elements of a structure, from left to right. -- --
-- >>> biList (18, 42) -- [18,42] ---- --
-- >>> biList (Left 18) -- [18] --biList :: Bifoldable t => t a a -> [a] -- | Monads in which IO computations may be embedded. Any monad -- built by applying a sequence of monad transformers to the IO -- monad will be an instance of this class. -- -- Instances should satisfy the following laws, which state that -- liftIO is a transformer of monads: -- -- class Monad m => MonadIO (m :: Type -> Type) -- | Lift a computation from the IO monad. This allows us to run IO -- computations in any monadic stack, so long as it supports these kinds -- of operations (i.e. IO is the base monad for the stack). -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a -- | zipWithM_ is the extension of zipWithM which ignores the -- final result. zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m () -- | The zipWithM function generalizes zipWith to arbitrary -- applicative functors. zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c] -- | Like replicateM, but discards the result. -- --
-- >>> replicateM_ 3 (putStrLn "a") -- a -- a -- a --replicateM_ :: Applicative m => Int -> m a -> m () -- | Direct MonadPlus equivalent of filter. -- --
-- filter = ( mfilter :: (a -> Bool) -> [a] -> [a] ) ---- -- An example using mfilter with the Maybe monad: -- --
-- >>> mfilter odd (Just 1) -- Just 1 -- -- >>> mfilter odd (Just 2) -- Nothing --mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a -- | Repeat an action indefinitely. -- --
-- echoServer :: Socket -> IO () -- echoServer socket = forever $ do -- client <- accept socket -- forkFinally (echo client) (\_ -> hClose client) -- where -- echo :: Handle -> IO () -- echo client = forever $ -- hGetLine client >>= hPutStrLn client ---- -- Note that "forever" isn't necessarily non-terminating. If the action -- is in a MonadPlus and short-circuits after some number -- of iterations. then forever actually returns -- mzero, effectively short-circuiting its caller. forever :: Applicative f => f a -> f b -- | Like foldM, but discards the result. foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m () -- | Left-to-right composition of Kleisli arrows. -- -- '(bs >=> cs) a' can be understood as the -- do expression -- --
-- do b <- bs a -- cs b --(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 >=> -- | Right-to-left composition of Kleisli arrows. -- (>=>), with the arguments flipped. -- -- Note how this operator resembles function composition -- (.): -- --
-- (.) :: (b -> c) -> (a -> b) -> a -> c -- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c --(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c infixr 1 <=< -- | Strict version of <$>. (<$!>) :: Monad m => (a -> b) -> m a -> m b infixl 4 <$!> -- | forM is mapM with its arguments flipped. For a version -- that ignores the results see forM_. forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) -- | The basic arrow class. -- -- Instances should satisfy the following laws: -- --
arr id = id
arr (f >>> g) = arr f >>> -- arr g
first (arr f) = arr (first -- f)
first (f >>> g) = first f >>> -- first g
first f >>> arr fst = -- arr fst >>> f
first f >>> arr (id *** g) = -- arr (id *** g) >>> first f
first (first f) >>> arr assoc = -- arr assoc >>> first f
-- assoc ((a,b),c) = (a,(b,c)) ---- -- The other combinators have sensible default definitions, which may be -- overridden for efficiency. class Category a => Arrow (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) -- | Split the input between the two argument arrows and combine their -- output. Note that this is in general not a functor. -- -- The default definition may be overridden with a more efficient version -- if desired. (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') -- | Fanout: send the input to both argument arrows and combine their -- output. -- -- The default definition may be overridden with a more efficient version -- if desired. (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 *** infixr 3 &&& stderr :: Handle -- | Shared memory locations that support atomic memory transactions. data TVar a -- | A monad supporting atomic memory transactions. data STM a -- | Write the supplied value into a TVar. writeTVar :: TVar a -> a -> STM () -- | Return the current value stored in a TVar. readTVar :: TVar a -> STM a -- | Compose two alternative STM actions (GHC only). -- -- If the first action completes without retrying then it forms the -- result of the orElse. Otherwise, if the first action retries, -- then the second action is tried in its place. If both actions retry -- then the orElse as a whole retries. orElse :: STM a -> STM a -> STM a -- | Create a new TVar holding a value supplied newTVar :: a -> STM (TVar a) -- | Superclass for asynchronous exceptions. data SomeAsyncException SomeAsyncException :: e -> SomeAsyncException asyncExceptionToException :: Exception e => e -> SomeException asyncExceptionFromException :: Exception e => SomeException -> Maybe e -- | Three kinds of buffering are supported: line-buffering, -- block-buffering or no-buffering. These modes have the following -- effects. For output, items are written out, or flushed, from -- the internal buffer according to the buffer mode: -- --
-- >>> sequenceA_ [print "Hello", print "world", print "!"] -- "Hello" -- "world" -- "!" --sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f () -- | The sum of a collection of actions, generalizing concat. -- -- msum is just like asum, but specialised to -- MonadPlus. msum :: (Foldable t, MonadPlus m) => t (m a) -> m a -- | The sum of a collection of actions, generalizing concat. -- -- asum is just like msum, but generalised to -- Alternative. -- --
-- >>> asum [Just "Hello", Nothing, Just "World"] -- Just "Hello" --asum :: (Foldable t, Alternative f) => t (f a) -> f a -- | Maybe monoid returning the leftmost non-Nothing value. -- -- First a is isomorphic to Alt Maybe -- a, but precedes it historically. -- --
-- >>> getFirst (First (Just "hello") <> First Nothing <> First (Just "world")) -- Just "hello" --newtype First a First :: Maybe a -> First a [getFirst] :: First a -> Maybe a -- | Monoid under addition. -- --
-- >>> getSum (Sum 1 <> Sum 2 <> mempty) -- 3 --newtype Sum a Sum :: a -> Sum a [getSum] :: Sum a -> a -- | The monoid of endomorphisms under composition. -- --
-- >>> let computation = Endo ("Hello, " ++) <> Endo (++ "!")
--
-- >>> appEndo computation "Haskell"
-- "Hello, Haskell!"
--
newtype Endo a
Endo :: (a -> a) -> Endo a
[appEndo] :: Endo a -> a -> a
-- | The Down type allows you to reverse sort order conveniently. A
-- value of type Down a contains a value of type
-- a (represented as Down a).
--
-- If a has an Ord instance associated with it
-- then comparing two values thus wrapped will give you the opposite of
-- their normal sort order. This is particularly useful when sorting in
-- generalised list comprehensions, as in: then sortWith by
-- Down x.
--
-- -- >>> compare True False -- GT ---- --
-- >>> compare (Down True) (Down False) -- LT ---- -- If a has a Bounded instance then the wrapped -- instance also respects the reversed ordering by exchanging the values -- of minBound and maxBound. -- --
-- >>> minBound :: Int -- -9223372036854775808 ---- --
-- >>> minBound :: Down Int -- Down 9223372036854775807 ---- -- All other instances of Down a behave as they do for -- a. newtype Down a Down :: a -> Down a [getDown] :: Down a -> a -- | The member functions of this class facilitate writing values of -- primitive types to raw memory (which may have been allocated with the -- above mentioned routines) and reading values from blocks of raw -- memory. The class, furthermore, includes support for computing the -- storage requirements and alignment restrictions of storable types. -- -- Memory addresses are represented as values of type Ptr -- a, for some a which is an instance of class -- Storable. The type argument to Ptr helps provide some -- valuable type safety in FFI code (you can't mix pointers of different -- types without an explicit cast), while helping the Haskell type system -- figure out which marshalling method is needed for a given pointer. -- -- All marshalling between Haskell and a foreign language ultimately -- boils down to translating Haskell data structures into the binary -- representation of a corresponding data structure of the foreign -- language and vice versa. To code this marshalling in Haskell, it is -- necessary to manipulate primitive data types stored in unstructured -- memory blocks. The class Storable facilitates this manipulation -- on all types for which it is instantiated, which are the standard -- basic types of Haskell, the fixed size Int types -- (Int8, Int16, Int32, Int64), the fixed -- size Word types (Word8, Word16, Word32, -- Word64), StablePtr, all types from -- Foreign.C.Types, as well as Ptr. class Storable a -- | Extracts from a list of Either all the Right elements. -- All the Right elements are extracted in order. -- --
-- >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ] -- -- >>> rights list -- [3,7] --rights :: [Either a b] -> [b] -- | Extracts from a list of Either all the Left elements. -- All the Left elements are extracted in order. -- --
-- >>> let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ] -- -- >>> lefts list -- ["foo","bar","baz"] --lefts :: [Either a b] -> [a] -- | Return True if the given value is a Right-value, -- False otherwise. -- --
-- >>> isRight (Left "foo") -- False -- -- >>> isRight (Right 3) -- True ---- -- Assuming a Left value signifies some sort of error, we can use -- isRight to write a very simple reporting function that only -- outputs "SUCCESS" when a computation has succeeded. -- -- This example shows how isRight might be used to avoid pattern -- matching when one does not care about the value contained in the -- constructor: -- --
-- >>> import Control.Monad ( when ) -- -- >>> let report e = when (isRight e) $ putStrLn "SUCCESS" -- -- >>> report (Left "parse error") -- -- >>> report (Right 1) -- SUCCESS --isRight :: Either a b -> Bool -- | Return True if the given value is a Left-value, -- False otherwise. -- --
-- >>> isLeft (Left "foo") -- True -- -- >>> isLeft (Right 3) -- False ---- -- Assuming a Left value signifies some sort of error, we can use -- isLeft to write a very simple error-reporting function that -- does absolutely nothing in the case of success, and outputs "ERROR" if -- any error occurred. -- -- This example shows how isLeft might be used to avoid pattern -- matching when one does not care about the value contained in the -- constructor: -- --
-- >>> import Control.Monad ( when ) -- -- >>> let report e = when (isLeft e) $ putStrLn "ERROR" -- -- >>> report (Right 1) -- -- >>> report (Left "parse error") -- ERROR --isLeft :: Either a b -> Bool -- | Return the contents of a Right-value or a default value -- otherwise. -- --
-- >>> fromRight 1 (Right 3) -- 3 -- -- >>> fromRight 1 (Left "foo") -- 1 --fromRight :: b -> Either a b -> b -- | Return the contents of a Left-value or a default value -- otherwise. -- --
-- >>> fromLeft 1 (Left 3) -- 3 -- -- >>> fromLeft 1 (Right "foo") -- 1 --fromLeft :: a -> Either a b -> a -- | A class for categories. Instances should satisfy the laws -- --
-- >>> bool "foo" "bar" True -- "bar" -- -- >>> bool "foo" "bar" False -- "foo" ---- -- Confirm that bool x y p and if p then y else -- x are equivalent: -- --
-- >>> let p = True; x = "bar"; y = "foo" -- -- >>> bool x y p == if p then y else x -- True -- -- >>> let p = False -- -- >>> bool x y p == if p then y else x -- True --bool :: a -> a -> Bool -> a -- | fix f is the least fixed point of the function -- f, i.e. the least defined x such that f x = -- x. -- -- For example, we can write the factorial function using direct -- recursion as -- --
-- >>> let fac n = if n <= 1 then 1 else n * fac (n-1) in fac 5 -- 120 ---- -- This uses the fact that Haskell’s let introduces recursive -- bindings. We can rewrite this definition using fix, -- --
-- >>> fix (\rec n -> if n <= 1 then 1 else n * rec (n-1)) 5 -- 120 ---- -- Instead of making a recursive call, we introduce a dummy parameter -- rec; when used within fix, this parameter then refers -- to fix’s argument, hence the recursion is reintroduced. fix :: (a -> a) -> a -- | & is a reverse application operator. This provides -- notational convenience. Its precedence is one higher than that of the -- forward application operator $, which allows & to be -- nested in $. -- --
-- >>> 5 & (+1) & show -- "6" --(&) :: a -> (a -> b) -> b infixl 1 & -- | Flipped version of <$>. -- --
-- (<&>) = flip fmap ---- --
-- >>> Just 2 <&> (+1) -- Just 3 ---- --
-- >>> [1,2,3] <&> (+1) -- [2,3,4] ---- --
-- >>> Right 3 <&> (+1) -- Right 4 --(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 <&> -- | Flipped version of <$. -- --
-- >>> Nothing $> "foo" -- Nothing -- -- >>> Just 90210 $> "foo" -- Just "foo" ---- -- Replace the contents of an Either Int -- Int with a constant String, resulting in an -- Either Int String: -- --
-- >>> Left 8675309 $> "foo" -- Left 8675309 -- -- >>> Right 8675309 $> "foo" -- Right "foo" ---- -- Replace each element of a list with a constant String: -- --
-- >>> [1,2,3] $> "foo" -- ["foo","foo","foo"] ---- -- Replace the second element of a pair with a constant String: -- --
-- >>> (1,2) $> "foo" -- (1,"foo") --($>) :: Functor f => f a -> b -> f b infixl 4 $> -- | Lift a ternary function to actions. liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d -- | Lift a function to actions. Equivalent to Functor's fmap but -- implemented using only Applicative's methods: `liftA f a = pure -- f * a` -- -- As such this function may be used to implement a Functor -- instance from an Applicative one. liftA :: Applicative f => (a -> b) -> f a -> f b -- | Request a CallStack. -- -- NOTE: The implicit parameter ?callStack :: CallStack is an -- implementation detail and should not be considered part of the -- CallStack API, we may decide to change the implementation in -- the future. type HasCallStack = ?callStack :: CallStack -- | O(n). Convert a ShortByteString into a -- ByteString. fromShort :: ShortByteString -> ByteString -- | O(n). Convert a ByteString into a -- ShortByteString. -- -- This makes a copy, so does not retain the input string. toShort :: ByteString -> ShortByteString -- | The reader monad transformer, which adds a read-only environment to -- the given monad. -- -- The return function ignores the environment, while -- >>= passes the inherited environment to both -- subcomputations. newtype ReaderT r (m :: Type -> Type) a ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a [runReaderT] :: ReaderT r (m :: Type -> Type) a -> r -> m a -- | Run a pipeline until processing completes. -- -- Since 1.2.1 runConduit :: Monad m => ConduitT () Void m r -> m r -- | Combine two Conduits together into a new Conduit -- (aka fuse). -- -- Output from the upstream (left) conduit will be fed into the -- downstream (right) conduit. Processing will terminate when downstream -- (right) returns. Leftover data returned from the right -- Conduit will be discarded. -- -- Equivalent to fuse and =$=, however the latter is -- deprecated and will be removed in a future version. -- -- Note that, while this operator looks like categorical composition -- (from Control.Category), there are a few reasons it's -- different: -- --
unliftIO u . return = return
unliftIO u (m >>= f) = unliftIO u m >>= unliftIO -- u . f
askUnliftIO >>= \u -> (liftIO . unliftIO u) m = -- m
-- throwM e >> x = throwM e ---- -- In other words, throwing an exception short-circuits the rest of the -- monadic computation. class Monad m => MonadThrow (m :: Type -> Type) -- | Throw an exception. Note that this throws when this action is run in -- the monad m, not when it is applied. It is a generalization -- of Control.Exception's throwIO. -- -- Should satisfy the law: -- --
-- throwM e >> f = throwM e --throwM :: (MonadThrow m, Exception e) => e -> m a -- | A map of integers to values a. data IntMap a -- | A set of integers. data IntSet -- | General-purpose finite sequences. data Seq a -- | the deep analogue of $!. In the expression f $!! x, -- x is fully evaluated before the function f is -- applied to it. ($!!) :: NFData a => (a -> b) -> a -> b infixr 0 $!! -- | Generalized version of Handler data Handler (m :: Type -> Type) a Handler :: (e -> m a) -> Handler (m :: Type -> Type) a -- | lens creates a Lens from a getter and a setter. The -- resulting lens isn't the most effective one (because of having to -- traverse the structure twice when modifying), but it shouldn't matter -- much. -- -- A (partial) lens for list indexing: -- --
-- ix :: Int -> Lens' [a] a -- ix i = lens (!! i) -- getter -- (\s b -> take i s ++ b : drop (i+1) s) -- setter ---- -- Usage: -- --
-- >>> [1..9] ^. ix 3 -- 4 -- -- >>> [1..9] & ix 3 %~ negate -- [1,2,3,-4,5,6,7,8,9] ---- -- When getting, the setter is completely unused; when setting, the -- getter is unused. Both are used only when the value is being modified. -- For instance, here we define a lens for the 1st element of a list, but -- instead of a legitimate getter we use undefined. Then we use -- the resulting lens for setting and it works, which proves that -- the getter wasn't used: -- --
-- >>> [1,2,3] & lens undefined (\s b -> b : tail s) .~ 10 -- [10,2,3] --lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b -- | s ^? t returns the 1st element t returns, or -- Nothing if t doesn't return anything. It's trivially -- implemented by passing the First monoid to the getter. -- -- Safe head: -- --
-- >>> [] ^? each -- Nothing ---- --
-- >>> [1..3] ^? each -- Just 1 ---- -- Converting Either to Maybe: -- --
-- >>> Left 1 ^? _Right -- Nothing ---- --
-- >>> Right 1 ^? _Right -- Just 1 ---- -- A non-operator version of (^?) is called preview, and -- – like view – it's a bit more general than (^?) (it -- works in MonadReader). If you need the general version, you -- can get it from microlens-mtl; otherwise there's preview -- available in Lens.Micro.Extras. (^?) :: s -> Getting (First a) s a -> Maybe a infixl 8 ^? -- | s ^.. t returns the list of all values that t gets -- from s. -- -- A Maybe contains either 0 or 1 values: -- --
-- >>> Just 3 ^.. _Just -- [3] ---- -- Gathering all values in a list of tuples: -- --
-- >>> [(1,2),(3,4)] ^.. each.each -- [1,2,3,4] --(^..) :: s -> Getting (Endo [a]) s a -> [a] infixl 8 ^.. -- | to creates a getter from any function: -- --
-- a ^. to f = f a ---- -- It's most useful in chains, because it lets you mix lenses and -- ordinary functions. Suppose you have a record which comes from some -- third-party library and doesn't have any lens accessors. You want to -- do something like this: -- --
-- value ^. _1 . field . at 2 ---- -- However, field isn't a getter, and you have to do this -- instead: -- --
-- field (value ^. _1) ^. at 2 ---- -- but now value is in the middle and it's hard to read the -- resulting code. A variant with to is prettier and more -- readable: -- --
-- value ^. _1 . to field . at 2 --to :: (s -> a) -> SimpleGetter s a -- | (^.) applies a getter to a value; in other words, it gets a -- value out of a structure using a getter (which can be a lens, -- traversal, fold, etc.). -- -- Getting 1st field of a tuple: -- --
-- (^. _1) :: (a, b) -> a -- (^. _1) = fst ---- -- When (^.) is used with a traversal, it combines all results -- using the Monoid instance for the resulting type. For instance, -- for lists it would be simple concatenation: -- --
-- >>> ("str","ing") ^. each
-- "string"
--
--
-- The reason for this is that traversals use Applicative, and the
-- Applicative instance for Const uses monoid concatenation
-- to combine “effects” of Const.
--
-- A non-operator version of (^.) is called view, and
-- it's a bit more general than (^.) (it works in
-- MonadReader). If you need the general version, you can get it
-- from microlens-mtl; otherwise there's view available in
-- Lens.Micro.Extras.
(^.) :: s -> Getting a s a -> a
infixl 8 ^.
-- | set is a synonym for (.~).
--
-- Setting the 1st component of a pair:
--
-- -- set _1 :: x -> (a, b) -> (x, b) -- set _1 = \x t -> (x, snd t) ---- -- Using it to rewrite (<$): -- --
-- set mapped :: Functor f => a -> f b -> f a -- set mapped = (<$) --set :: ASetter s t a b -> b -> s -> t -- | (.~) assigns a value to the target. It's the same thing as -- using (%~) with const: -- --
-- l .~ x = l %~ const x ---- -- See set if you want a non-operator synonym. -- -- Here it is used to change 2 fields of a 3-tuple: -- --
-- >>> (0,0,0) & _1 .~ 1 & _3 .~ 3 -- (1,0,3) --(.~) :: ASetter s t a b -> b -> s -> t infixr 4 .~ -- | over is a synonym for (%~). -- -- Getting fmap in a roundabout way: -- --
-- over mapped :: Functor f => (a -> b) -> f a -> f b -- over mapped = fmap ---- -- Applying a function to both components of a pair: -- --
-- over both :: (a -> b) -> (a, a) -> (b, b) -- over both = \f t -> (f (fst t), f (snd t)) ---- -- Using over _2 as a replacement for -- second: -- --
-- >>> over _2 show (10,20) -- (10,"20") --over :: ASetter s t a b -> (a -> b) -> s -> t -- | (%~) applies a function to the target; an alternative -- explanation is that it is an inverse of sets, which turns a -- setter into an ordinary function. mapped %~ -- reverse is the same thing as fmap -- reverse. -- -- See over if you want a non-operator synonym. -- -- Negating the 1st element of a pair: -- --
-- >>> (1,2) & _1 %~ negate -- (-1,2) ---- -- Turning all Lefts in a list to upper case: -- --
-- >>> (mapped._Left.mapped %~ toUpper) [Left "foo", Right "bar"] -- [Left "FOO",Right "bar"] --(%~) :: ASetter s t a b -> (a -> b) -> s -> t infixr 4 %~ -- | sets creates an ASetter from an ordinary function. (The -- only thing it does is wrapping and unwrapping Identity.) sets :: ((a -> b) -> s -> t) -> ASetter s t a b -- | ASetter s t a b is something that turns a function modifying -- a value into a function modifying a structure. If you ignore -- Identity (as Identity a is the same thing as -- a), the type is: -- --
-- type ASetter s t a b = (a -> b) -> s -> t ---- -- The reason Identity is used here is for ASetter to be -- composable with other types, such as Lens. -- -- Technically, if you're writing a library, you shouldn't use this type -- for setters you are exporting from your library; the right type to use -- is Setter, but it is not provided by this package -- (because then it'd have to depend on distributive). It's -- completely alright, however, to export functions which take an -- ASetter as an argument. type ASetter s t a b = a -> Identity b -> s -> Identity t -- | This is a type alias for monomorphic setters which don't change the -- type of the container (or of the value inside). It's useful more often -- than the same type in lens, because we can't provide real setters and -- so it does the job of both ASetter' and -- Setter'. type ASetter' s a = ASetter s s a a -- | A SimpleGetter s a extracts a from s; so, -- it's the same thing as (s -> a), but you can use it in -- lens chains because its type looks like this: -- --
-- type SimpleGetter s a = -- forall r. (a -> Const r a) -> s -> Const r s ---- -- Since Const r is a functor, SimpleGetter has the same -- shape as other lens types and can be composed with them. To get (s -- -> a) out of a SimpleGetter, choose r ~ a and -- feed Const :: a -> Const a a to the getter: -- --
-- -- the actual signature is more permissive: -- -- view :: Getting a s a -> s -> a -- view :: SimpleGetter s a -> s -> a -- view getter = getConst . getter Const ---- -- The actual Getter from lens is more general: -- --
-- type Getter s a = -- forall f. (Contravariant f, Functor f) => (a -> f a) -> s -> f s ---- -- I'm not currently aware of any functions that take lens's -- Getter but won't accept SimpleGetter, but you should -- try to avoid exporting SimpleGetters anyway to minimise -- confusion. Alternatively, look at microlens-contra, which -- provides a fully lens-compatible Getter. -- -- Lens users: you can convert a SimpleGetter to Getter -- by applying to . view to it. type SimpleGetter s a = forall r. () => Getting r s a -- | Functions that operate on getters and folds – such as (^.), -- (^..), (^?) – use Getter r s a (with different -- values of r) to describe what kind of result they need. For -- instance, (^.) needs the getter to be able to return a single -- value, and so it accepts a getter of type Getting a s a. -- (^..) wants the getter to gather values together, so it uses -- Getting (Endo [a]) s a (it could've used Getting [a] s -- a instead, but it's faster with Endo). The choice of -- r depends on what you want to do with elements you're -- extracting from s. type Getting r s a = a -> Const r a -> s -> Const r s -- | Lens s t a b is the lowest common denominator of a setter and -- a getter, something that has the power of both; it has a -- Functor constraint, and since both Const and -- Identity are functors, it can be used whenever a getter or a -- setter is needed. -- --
-- >>> preview each [1..5] -- Just 1 --preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a) -- | view is a synonym for (^.), generalised for -- MonadReader (we are able to use it instead of (^.) since -- functions are instances of the MonadReader class): -- --
-- >>> view _1 (1, 2) -- 1 ---- -- When you're using Reader for config and your config type has -- lenses generated for it, most of the time you'll be using view -- instead of asks: -- --
-- doSomething :: (MonadReader Config m) => m Int -- doSomething = do -- thingy <- view setting1 -- same as “asks (^. setting1)” -- anotherThingy <- view setting2 -- ... --view :: MonadReader s m => Getting a s a -> m a -- | Runs a Reader and extracts the final value from it. (The -- inverse of reader.) runReader :: Reader r a -> r -> a -- | Use a snapshot cache, which caches which modules are in which packages -- in a given snapshot. This is mostly intended for usage by Stack. withSnapshotCache :: (HasPantryConfig env, HasLogFunc env) => SnapshotCacheHash -> RIO env (Map PackageName (Set ModuleName)) -> ((ModuleName -> RIO env [PackageName]) -> RIO env a) -> RIO env a -- | Partition a map of global packages with its versions into a Set of -- replaced packages and its dependencies and a map of remaining -- (untouched) packages. partitionReplacedDependencies :: Ord id => Map PackageName a -> (a -> PackageName) -> (a -> id) -> (a -> [id]) -> Set PackageName -> (Map PackageName [PackageName], Map PackageName a) -- | Load the global hints from GitHub. loadGlobalHints :: (HasTerm env, HasPantryConfig env) => WantedCompiler -> RIO env (Maybe (Map PackageName Version)) -- | Like runPantryApp, but uses an empty pantry directory instead -- of sharing with Stack. Useful for testing. runPantryAppClean :: MonadIO m => RIO PantryApp a -> m a -- | Run some code against pantry using basic sane settings. -- -- For testing, see runPantryAppClean. runPantryAppWith :: MonadIO m => Int -> CasaRepoPrefix -> Int -> RIO PantryApp a -> m a -- | Run some code against pantry using basic sane settings. -- -- For testing, see runPantryAppClean. runPantryApp :: MonadIO m => RIO PantryApp a -> m a -- | Lens to view or modify the HpackExecutable of a -- PantryConfig hpackExecutableL :: Lens' PantryConfig HpackExecutable -- | Get the TreeKey of the package at the given location. getPackageLocationTreeKey :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env TreeKey -- | Get the TreeKey of the package at the given location. getRawPackageLocationTreeKey :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env TreeKey -- | Get the PackageIdentifier of the package at the given location. getRawPackageLocationIdent :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageIdentifier -- | Get version of the package at the given location. packageLocationVersion :: PackageLocationImmutable -> Version -- | Get the PackageIdentifier of the package at the given location. packageLocationIdent :: PackageLocationImmutable -> PackageIdentifier -- | Get the PackageName of the package at the given location. getPackageLocationName :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env PackageName -- | Parse a SnapshotLayer value from a SnapshotLocation. -- -- Returns a Left value if provided an SLCompiler -- constructor. Otherwise, returns a Right value providing both -- the Snapshot and a hash of the input configuration file. loadSnapshotLayer :: (HasPantryConfig env, HasLogFunc env) => SnapshotLocation -> RIO env (Either WantedCompiler RawSnapshotLayer) -- | Parse a SnapshotLayer value from a SnapshotLocation. -- -- Returns a Left value if provided an SLCompiler -- constructor. Otherwise, returns a Right value providing both -- the Snapshot and a hash of the input configuration file. loadRawSnapshotLayer :: (HasPantryConfig env, HasLogFunc env) => RawSnapshotLocation -> RIO env (Either WantedCompiler (RawSnapshotLayer, CompletedSL)) -- | Add more packages to a snapshot -- -- Note that any settings on a parent flag which is being replaced will -- be ignored. For example, if package foo is in the parent and -- has flag bar set, and foo also appears in new -- packages, then bar will no longer be set. -- -- Returns any of the AddPackagesConfig values not used. addPackagesToSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Utf8Builder -> [RawPackageLocationImmutable] -> AddPackagesConfig -> Map PackageName RawSnapshotPackage -> RIO env (Map PackageName RawSnapshotPackage, AddPackagesConfig) -- | As for loadAndCompleteSnapshotRaw but allows toggling of the -- debug output of the raw snapshot layer. loadAndCompleteSnapshotRaw' :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Bool -> RawSnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI]) -- | Parse a Snapshot (all layers) from a RawSnapshotLocation -- completing any incomplete package locations. Debug output will include -- the raw snapshot layer. loadAndCompleteSnapshotRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawSnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI]) -- | As for loadAndCompleteSnapshot but allows toggling of the debug -- output of the raw snapshot layer. loadAndCompleteSnapshot' :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Bool -> SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI]) -- | Parse a Snapshot (all layers) from a SnapshotLocation -- noting any incomplete package locations. Debug output will include the -- raw snapshot layer. loadAndCompleteSnapshot :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => SnapshotLocation -> Map RawSnapshotLocation SnapshotLocation -> Map RawPackageLocationImmutable PackageLocationImmutable -> RIO env (Snapshot, [CompletedSL], [CompletedPLI]) -- | Add in hashes to make a SnapshotLocation reproducible. completeSnapshotLocation :: (HasPantryConfig env, HasLogFunc env) => RawSnapshotLocation -> RIO env SnapshotLocation -- | Fill in optional fields in a PackageLocationImmutable for more -- reproducible builds. completePackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env CompletePackageLocation -- | Maybe load the package from Casa. tryLoadPackageRawViaCasa :: (HasLogFunc env, HasPantryConfig env, HasProcessContext env) => RawPackageLocationImmutable -> TreeKey -> RIO env (Maybe Package) -- | Load a Package from a RawPackageLocationImmutable. -- -- Load the package either from the local DB, Casa, or as a last resort, -- the third party (hackage, archive or repo). loadPackageRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env Package -- | Load a Package from a PackageLocationImmutable. loadPackage :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env Package -- | Get the Version from a GenericPackageDescription. gpdVersion :: GenericPackageDescription -> Version -- | Get the PackageName from a GenericPackageDescription. gpdPackageName :: GenericPackageDescription -> PackageName -- | Get the PackageIdentifier from a -- GenericPackageDescription. gpdPackageIdentifier :: GenericPackageDescription -> PackageIdentifier -- | Get the file name for the Cabal file in the given directory. -- -- If no Cabal file is present, or more than one is present, an exception -- is thrown via throwM. -- -- If the directory contains a file named package.yaml, Hpack is used to -- generate a Cabal file from it. findOrGenerateCabalFile :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> Path Abs Dir -> RIO env (PackageName, Path Abs File) -- | Parse the Cabal file for the package inside the given directory. -- Performs various sanity checks, such as the file name being correct -- and having only a single Cabal file. loadCabalFilePath :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> Path Abs Dir -> RIO env (PrintWarnings -> IO GenericPackageDescription, PackageName, Path Abs File) -- | Same as loadCabalFileImmutable, but takes a -- PackageLocation. Never prints warnings, see -- loadCabalFilePath for that. loadCabalFile :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> PackageLocation -> RIO env GenericPackageDescription -- | Same as loadCabalFileRawImmutable, but takes a -- RawPackageLocation. Never prints warnings, see -- loadCabalFilePath for that. loadCabalFileRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe Text -> RawPackageLocation -> RIO env GenericPackageDescription -- | Load the cabal file for the given RawPackageLocationImmutable. -- -- This function ignores all warnings. -- -- Note that, for now, this will not allow support for hpack files in -- these package locations. Instead, all -- PackageLocationImmutables will require a .cabal file. This -- may be relaxed in the future. loadCabalFileRawImmutable :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RawPackageLocationImmutable -> RIO env GenericPackageDescription -- | Load the cabal file for the given PackageLocationImmutable. -- -- This function ignores all warnings. loadCabalFileImmutable :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => PackageLocationImmutable -> RIO env GenericPackageDescription -- | Unpack a given PackageLocationImmutable into the given -- directory. Does not generate any extra subdirectories. unpackPackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Path Abs Dir -> PackageLocationImmutable -> RIO env () -- | Unpack a given RawPackageLocationImmutable into the given -- directory. Does not generate any extra subdirectories. unpackPackageLocationRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Path Abs Dir -> RawPackageLocationImmutable -> RIO env () -- | Download all of the packages provided into the local cache without -- performing any unpacking. Can be useful for build tools wanting to -- prefetch or provide an offline mode. fetchPackages :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env, Foldable f) => f PackageLocationImmutable -> RIO env () -- | Returns the latest revision of the given package version available -- from Hackage. getLatestHackageRevision :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RequireHackageIndex -> PackageName -> Version -> RIO env (Maybe (Revision, BlobKey, TreeKey)) -- | Returns location of the latest version of the given package available -- from Hackage. getLatestHackageLocation :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => RequireHackageIndex -> PackageName -> UsePreferredVersions -> RIO env (Maybe PackageLocationImmutable) -- | Returns the latest version of the given package available from -- Hackage. getLatestHackageVersion :: (HasPantryConfig env, HasLogFunc env) => RequireHackageIndex -> PackageName -> UsePreferredVersions -> RIO env (Maybe PackageIdentifierRevision) -- | The download prefix for the official Hackage server. defaultDownloadPrefix :: Text -- | Default PackageIndexConfig value using the official Hackage -- server. defaultPackageIndexConfig :: PackageIndexConfig -- | Default max keys to pull per request. defaultCasaMaxPerRequest :: Int -- | Default pull URL for Casa. defaultCasaRepoPrefix :: CasaRepoPrefix -- | Create a new PantryConfig with the given settings. -- -- For something easier to use in simple cases, see runPantryApp. withPantryConfig :: HasLogFunc env => Path Abs Dir -> PackageIndexConfig -> HpackExecutable -> Int -> CasaRepoPrefix -> Int -> (SnapName -> RawSnapshotLocation) -> (PantryConfig -> RIO env a) -> RIO env a -- | Complete package location, plus whether the package has a cabal file. -- This is relevant to reproducibility, see -- https://tech.fpcomplete.com/blog/storing-generated-cabal-files data CompletePackageLocation CompletePackageLocation :: !PackageLocationImmutable -> !Bool -> CompletePackageLocation [cplComplete] :: CompletePackageLocation -> !PackageLocationImmutable [cplHasCabalFile] :: CompletePackageLocation -> !Bool -- | A completed package location, including the original raw and completed -- information. data CompletedPLI CompletedPLI :: !RawPackageLocationImmutable -> !PackageLocationImmutable -> CompletedPLI -- | A completed snapshot location, including the original raw and -- completed information. data CompletedSL CompletedSL :: !RawSnapshotLocation -> !SnapshotLocation -> CompletedSL -- | Package settings to be passed to addPackagesToSnapshot. data AddPackagesConfig AddPackagesConfig :: !Set PackageName -> !Map PackageName (Map FlagName Bool) -> !Map PackageName Bool -> !Map PackageName [Text] -> AddPackagesConfig [apcDrop] :: AddPackagesConfig -> !Set PackageName [apcFlags] :: AddPackagesConfig -> !Map PackageName (Map FlagName Bool) [apcHiddens] :: AddPackagesConfig -> !Map PackageName Bool [apcGhcOptions] :: AddPackagesConfig -> !Map PackageName [Text] -- | Convenient data type that allows you to work with pantry more easily -- than using withPantryConfig directly. Uses basically sane -- settings, like sharing a pantry directory with Stack. -- -- You can use runPantryApp to use this. data PantryApp -- | Clone the repository and execute the action with the working directory -- set to the repository root. withRepo :: (HasLogFunc env, HasProcessContext env) => SimpleRepo -> RIO env a -> RIO env a -- | Fetch the given repositories at once and populate the pantry database. fetchRepos :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, PackageMetadata)] -> RIO env () -- | Like fetchRepos, except with RawPackageMetadata instead -- of PackageMetadata. fetchReposRaw :: (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => [(Repo, RawPackageMetadata)] -> RIO env () -- | Returns the versions of the package available on Hackage. getHackagePackageVersions :: (HasPantryConfig env, HasLogFunc env) => RequireHackageIndex -> UsePreferredVersions -> PackageName -> RIO env (Map Version (Map Revision BlobKey)) -- | Try to come up with typo corrections for given package identifier -- using Hackage package names. This can provide more user-friendly -- information in error messages. getHackageTypoCorrections :: (HasPantryConfig env, HasLogFunc env) => PackageName -> RIO env [PackageName] -- | Download the most recent 01-index.tar file from Hackage and update the -- database tables. -- -- This function will only perform an update once per PantryConfig -- for user sanity. See the return value to find out if it happened. updateHackageIndex :: (HasPantryConfig env, HasLogFunc env) => Maybe Utf8Builder -> RIO env DidUpdateOccur -- | Where does pantry download its 01-index.tar file from Hackage? hackageIndexTarballL :: HasPantryConfig env => SimpleGetter env (Path Abs File) -- | Did an update occur when running updateHackageIndex? data DidUpdateOccur UpdateOccurred :: DidUpdateOccur NoUpdateOccurred :: DidUpdateOccur -- | Should we pay attention to Hackage's preferred versions? data UsePreferredVersions UsePreferredVersions :: UsePreferredVersions IgnorePreferredVersions :: UsePreferredVersions -- | Require that the Hackage index is populated. data RequireHackageIndex -- | If there is nothing in the Hackage index, then perform an update YesRequireHackageIndex :: RequireHackageIndex -- | Do not perform an update NoRequireHackageIndex :: RequireHackageIndex -- | Warn if the package uses PCHpack. warnMissingCabalFile :: HasLogFunc env => RawPackageLocationImmutable -> RIO env () -- | Convert snapshot layer into its "raw" equivalent. toRawSnapshotLayer :: SnapshotLayer -> RawSnapshotLayer -- | Convert snapshot location to its "raw" equivalent. toRawSL :: SnapshotLocation -> RawSnapshotLocation -- | Parse the short representation of a SnapName. parseSnapName :: MonadThrow m => Text -> m SnapName -- | Default location of snapshot synonyms , i.e. commercialhaskell's -- GitHub repository. defaultSnapshotLocation :: SnapName -> RawSnapshotLocation -- | Parse a Text into an Unresolved -- RawSnapshotLocation. parseRawSnapshotLocation :: Text -> Unresolved RawSnapshotLocation -- | Parse a Text into a WantedCompiler value. parseWantedCompiler :: Text -> Either PantryException WantedCompiler -- | Unwrap the CabalString from the keys in a Map to use a -- FromJSON instance. unCabalStringMap :: Map (CabalString a) v -> Map a v -- | Wrap the keys in a Map with a CabalString to get a -- ToJSON instance. toCabalStringMap :: Map a v -> Map (CabalString a) v -- | Render a module name as a Value. moduleNameString :: ModuleName -> String -- | Render a flag name as a Value. flagNameString :: FlagName -> String -- | Render a version as a Value. versionString :: Version -> String -- | Render a package identifier as a Value. packageIdentifierString :: PackageIdentifier -> String -- | Render a package name as a Value. packageNameString :: PackageName -> String -- | Parse a flag name from a Value. parseFlagName :: String -> Maybe FlagName -- | Parse a package version from a Value throwing on failure parseVersionThrowing :: MonadThrow m => String -> m Version -- | Parse a version from a Value. parseVersion :: String -> Maybe Version -- | Parse a package name from a Value throwing on failure parsePackageNameThrowing :: MonadThrow m => String -> m PackageName -- | Parse a package name from a Value. parsePackageName :: String -> Maybe PackageName -- | This is almost a copy of Cabal's parser for package identifiers, the -- main difference is in the fact that Stack requires version to be -- present while Cabal uses "null version" as a default value parsePackageIdentifier :: String -> Maybe PackageIdentifier -- | Parse a PackageIdentifierRevision parsePackageIdentifierRevision :: Text -> Either PantryException PackageIdentifierRevision -- | Parse a hackage text. parseHackageText :: Text -> Either PantryException (PackageIdentifier, BlobKey) -- | Default HackageSecurityConfig value using the official Hackage -- server. The value of the hscIgnoreExpiry field is True. defaultHackageSecurityConfig :: HackageSecurityConfig -- | Convert PackageLocation to its "raw" equivalent toRawPL :: PackageLocation -> RawPackageLocation -- | Resolve all of the file paths in an Unresolved relative to the -- given directory. resolvePaths :: MonadIO m => Maybe (Path Abs Dir) -> Unresolved a -> m a -- | Get the location of a snapshot synonym from the PantryConfig. snapshotLocation :: HasPantryConfig env => SnapName -> RIO env RawSnapshotLocation -- | The revision number of a package from Hackage, counting upwards from 0 -- (the original cabal file). -- -- See caveats on CFIRevision. newtype Revision Revision :: Word -> Revision -- | Configuration value used by the entire pantry package. Create one -- using withPantryConfig. See also PantryApp for a -- convenience approach to using pantry. data PantryConfig -- | Should we print warnings when loading a cabal file? data PrintWarnings YesPrintWarnings :: PrintWarnings NoPrintWarnings :: PrintWarnings -- | Wraps a value which potentially contains relative paths. Needs to be -- provided with a base directory to resolve these paths. -- -- Unwrap this using resolvePaths. data Unresolved a -- | A combination of the relative path provided in a config file, together -- with the resolved absolute path. data ResolvedPath t ResolvedPath :: !RelFilePath -> !Path Abs t -> ResolvedPath t -- | Original value parsed from a config file. [resolvedRelative] :: ResolvedPath t -> !RelFilePath -- | Absolute path resolved against base directory loaded from. [resolvedAbsolute] :: ResolvedPath t -> !Path Abs t -- | Location to load a package from. Can either be immutable (see -- PackageLocationImmutable) or a local directory which is -- expected to change over time. Raw version doesn't include exact -- package version (e.g. could refer to the latest revision on Hackage) data RawPackageLocation RPLImmutable :: !RawPackageLocationImmutable -> RawPackageLocation RPLMutable :: !ResolvedPath Dir -> RawPackageLocation -- | Location to load a package from. Can either be immutable (see -- PackageLocationImmutable) or a local directory which is -- expected to change over time. data PackageLocation PLImmutable :: !PackageLocationImmutable -> PackageLocation PLMutable :: !ResolvedPath Dir -> PackageLocation -- | Location for remote packages or archives assumed to be immutable. as -- user specifies it i.e. not an exact location data RawPackageLocationImmutable RPLIHackage :: !PackageIdentifierRevision -> !Maybe TreeKey -> RawPackageLocationImmutable RPLIArchive :: !RawArchive -> !RawPackageMetadata -> RawPackageLocationImmutable RPLIRepo :: !Repo -> !RawPackageMetadata -> RawPackageLocationImmutable -- | Location for remote packages or archives assumed to be immutable. data PackageLocationImmutable PLIHackage :: !PackageIdentifier -> !BlobKey -> !TreeKey -> PackageLocationImmutable PLIArchive :: !Archive -> !PackageMetadata -> PackageLocationImmutable PLIRepo :: !Repo -> !PackageMetadata -> PackageLocationImmutable -- | A raw package archive, specified by a user, could have no hash and -- file size information. data RawArchive RawArchive :: !ArchiveLocation -> !Maybe SHA256 -> !Maybe FileSize -> !Text -> RawArchive -- | Location of the archive [raLocation] :: RawArchive -> !ArchiveLocation -- | Cryptographic hash of the archive file [raHash] :: RawArchive -> !Maybe SHA256 -- | Size of the archive file [raSize] :: RawArchive -> !Maybe FileSize -- | Subdirectory within the archive to get the package from. [raSubdir] :: RawArchive -> !Text -- | A package archive, could be from a URL or a local file path. Local -- file path archives are assumed to be unchanging over time, and so are -- allowed in custom snapshots. data Archive Archive :: !ArchiveLocation -> !SHA256 -> !FileSize -> !Text -> Archive -- | Location of the archive [archiveLocation] :: Archive -> !ArchiveLocation -- | Cryptographic hash of the archive file [archiveHash] :: Archive -> !SHA256 -- | Size of the archive file [archiveSize] :: Archive -> !FileSize -- | Subdirectory within the archive to get the package from. [archiveSubdir] :: Archive -> !Text -- | The type of a source control repository. data RepoType RepoGit :: RepoType RepoHg :: RepoType -- | Information on packages stored in a source control repository. data Repo Repo :: !Text -> !Text -> !RepoType -> !Text -> Repo -- | Location of the repo [repoUrl] :: Repo -> !Text -- | Commit to use from the repo. It's strongly recommended to use a hash -- instead of a tag or branch name. [repoCommit] :: Repo -> !Text -- | The type of the repo [repoType] :: Repo -> !RepoType -- | Subdirectory within the archive to get the package from. [repoSubdir] :: Repo -> !Text -- | Repository without subdirectory information. data SimpleRepo SimpleRepo :: !Text -> !Text -> !RepoType -> SimpleRepo [sRepoUrl] :: SimpleRepo -> !Text [sRepoCommit] :: SimpleRepo -> !Text [sRepoType] :: SimpleRepo -> !RepoType -- | Configuration to securely download package metadata and contents. For -- most purposes, you'll want to use the default Hackage settings via -- defaultPackageIndexConfig. -- -- NOTE It's highly recommended to only use the official Hackage -- server or a mirror. See -- https://github.com/commercialhaskell/stack/issues/4137. data PackageIndexConfig PackageIndexConfig :: !Text -> !HackageSecurityConfig -> PackageIndexConfig [picDownloadPrefix] :: PackageIndexConfig -> !Text [picHackageSecurityConfig] :: PackageIndexConfig -> !HackageSecurityConfig -- | Configuration for Hackage Security to securely download package -- metadata and contents. For most purposes, you'll want to use the -- default Hackage settings via defaultHackageSecurityConfig. -- -- NOTE It's highly recommended to only use the official Hackage -- server or a mirror. See -- https://github.com/commercialhaskell/stack/issues/4137. data HackageSecurityConfig HackageSecurityConfig :: ![Text] -> !Int -> !Bool -> HackageSecurityConfig [hscKeyIds] :: HackageSecurityConfig -> ![Text] [hscKeyThreshold] :: HackageSecurityConfig -> !Int [hscIgnoreExpiry] :: HackageSecurityConfig -> !Bool -- | An environment which contains a PantryConfig. class HasPantryConfig env -- | Lens to get or set the PantryConfig pantryConfigL :: HasPantryConfig env => Lens' env PantryConfig -- | File size in bytes newtype FileSize FileSize :: Word -> FileSize -- | A key for looking up a blob, which combines the SHA256 hash of the -- contents and the file size. -- -- The file size may seem redundant with the hash. However, it is -- necessary for safely downloading blobs from an untrusted source. See -- https://www.fpcomplete.com/blog/2018/07/pantry-part-2-trees-keys. data BlobKey BlobKey :: !SHA256 -> !FileSize -> BlobKey -- | How to choose a cabal file for a package from Hackage. This is to work -- with Hackage cabal file revisions, which makes -- PackageIdentifier insufficient for specifying a package from -- Hackage. data CabalFileInfo -- | Take the latest revision of the cabal file available. This isn't -- reproducible at all, but the running assumption (not necessarily true) -- is that cabal file revisions do not change semantics of the build. CFILatest :: CabalFileInfo -- | Identify by contents of the cabal file itself. Only reason for -- Maybe on FileSize is for compatibility with input -- that doesn't include the file size. CFIHash :: !SHA256 -> !Maybe FileSize -> CabalFileInfo -- | Identify by revision number, with 0 being the original and counting -- upward. This relies on Hackage providing consistent versioning. -- CFIHash should be preferred wherever possible for -- reproducibility. CFIRevision :: !Revision -> CabalFileInfo -- | A full specification for a package from Hackage, including the package -- name, version, and how to load up the correct cabal file revision. data PackageIdentifierRevision PackageIdentifierRevision :: !PackageName -> !Version -> !CabalFileInfo -> PackageIdentifierRevision -- | Things that can go wrong in pantry. Note two things: -- --
-- import Say -- -- action :: Int -> IO Int -- action n = do -- tid <- myThreadId -- sayString $ show tid -- threadDelay (2 * 10^6) -- 2 seconds -- return n -- -- main :: IO () -- main = do -- yx <- pooledMapConcurrentlyN 5 (\x -> action x) [1..5] -- print yx ---- -- On executing you can see that five threads have been spawned: -- --
-- $ ./pool -- ThreadId 36 -- ThreadId 38 -- ThreadId 40 -- ThreadId 42 -- ThreadId 44 -- [1,2,3,4,5] ---- -- Let's modify the above program such that there are less threads than -- the number of items in the list: -- --
-- import Say -- -- action :: Int -> IO Int -- action n = do -- tid <- myThreadId -- sayString $ show tid -- threadDelay (2 * 10^6) -- 2 seconds -- return n -- -- main :: IO () -- main = do -- yx <- pooledMapConcurrentlyN 3 (\x -> action x) [1..5] -- print yx ---- -- On executing you can see that only three threads are active totally: -- --
-- $ ./pool -- ThreadId 35 -- ThreadId 37 -- ThreadId 39 -- ThreadId 35 -- ThreadId 39 -- [1,2,3,4,5] --pooledMapConcurrentlyN :: (MonadUnliftIO m, Traversable t) => Int -> (a -> m b) -> t a -> m (t b) -- | Similar to pooledMapConcurrentlyN but with number of threads -- set from getNumCapabilities. Usually this is useful for CPU -- bound tasks. pooledMapConcurrently :: (MonadUnliftIO m, Traversable t) => (a -> m b) -> t a -> m (t b) -- | Similar to pooledMapConcurrentlyN but with flipped arguments. pooledForConcurrentlyN :: (MonadUnliftIO m, Traversable t) => Int -> t a -> (a -> m b) -> m (t b) -- | Similar to pooledForConcurrentlyN but with number of threads -- set from getNumCapabilities. Usually this is useful for CPU -- bound tasks. pooledForConcurrently :: (MonadUnliftIO m, Traversable t) => t a -> (a -> m b) -> m (t b) -- | Like pooledMapConcurrentlyN but with the return value -- discarded. pooledMapConcurrentlyN_ :: (MonadUnliftIO m, Foldable f) => Int -> (a -> m b) -> f a -> m () -- | Like pooledMapConcurrently but with the return value discarded. pooledMapConcurrently_ :: (MonadUnliftIO m, Foldable f) => (a -> m b) -> f a -> m () -- | Like pooledMapConcurrently_ but with flipped arguments. pooledForConcurrently_ :: (MonadUnliftIO m, Foldable f) => f a -> (a -> m b) -> m () -- | Like pooledMapConcurrentlyN_ but with flipped arguments. pooledForConcurrentlyN_ :: (MonadUnliftIO m, Foldable t) => Int -> t a -> (a -> m b) -> m () -- | Pooled version of replicateConcurrently. Performs the action in -- the pooled threads. pooledReplicateConcurrentlyN :: MonadUnliftIO m => Int -> Int -> m a -> m [a] -- | Similar to pooledReplicateConcurrentlyN but with number of -- threads set from getNumCapabilities. Usually this is useful for -- CPU bound tasks. pooledReplicateConcurrently :: MonadUnliftIO m => Int -> m a -> m [a] -- | Pooled version of replicateConcurrently_. Performs the action -- in the pooled threads. pooledReplicateConcurrentlyN_ :: MonadUnliftIO m => Int -> Int -> m a -> m () -- | Similar to pooledReplicateConcurrently_ but with number of -- threads set from getNumCapabilities. Usually this is useful for -- CPU bound tasks. pooledReplicateConcurrently_ :: MonadUnliftIO m => Int -> m a -> m () -- | Lifted newEmptyMVar. newEmptyMVar :: MonadIO m => m (MVar a) -- | Lifted newMVar. newMVar :: MonadIO m => a -> m (MVar a) -- | Lifted takeMVar. takeMVar :: MonadIO m => MVar a -> m a -- | Lifted putMVar. putMVar :: MonadIO m => MVar a -> a -> m () -- | Lifted readMVar. readMVar :: MonadIO m => MVar a -> m a -- | Lifted swapMVar. swapMVar :: MonadIO m => MVar a -> a -> m a -- | Lifted tryTakeMVar. tryTakeMVar :: MonadIO m => MVar a -> m (Maybe a) -- | Lifted tryPutMVar. tryPutMVar :: MonadIO m => MVar a -> a -> m Bool -- | Lifted isEmptyMVar. isEmptyMVar :: MonadIO m => MVar a -> m Bool -- | Lifted tryReadMVar. tryReadMVar :: MonadIO m => MVar a -> m (Maybe a) -- | Unlifted withMVar. withMVar :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b -- | Unlifted withMVarMasked. withMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b -- | Unlifted modifyMVar_. modifyMVar_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m () -- | Unlifted modifyMVar. modifyMVar :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b -- | Unlifted modifyMVarMasked_. modifyMVarMasked_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m () -- | Unlifted modifyMVarMasked. modifyMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b -- | Unlifted mkWeakMVar. mkWeakMVar :: MonadUnliftIO m => MVar a -> m () -> m (Weak (MVar a)) -- | A "run once" value, with results saved. Extract the value with -- runMemoized. For single-threaded usage, you can use -- memoizeRef to create a value. If you need guarantees that only -- one thread will run the action at a time, use memoizeMVar. -- -- Note that this type provides a Show instance for convenience, -- but not useful information can be provided. data Memoized a -- | Extract a value from a Memoized, running an action if no cached -- value is available. runMemoized :: MonadIO m => Memoized a -> m a -- | Create a new Memoized value using an IORef under the -- surface. Note that the action may be run in multiple threads -- simultaneously, so this may not be thread safe (depending on the -- underlying action). Consider using memoizeMVar. memoizeRef :: MonadUnliftIO m => m a -> m (Memoized a) -- | Same as memoizeRef, but uses an MVar to ensure that an -- action is only run once, even in a multithreaded application. memoizeMVar :: MonadUnliftIO m => m a -> m (Memoized a) -- | Lifted newQSem. newQSem :: MonadIO m => Int -> m QSem -- | Lifted waitQSem. waitQSem :: MonadIO m => QSem -> m () -- | Lifted signalQSem. signalQSem :: MonadIO m => QSem -> m () -- | withQSem is an exception-safe wrapper for performing the -- provided operation while holding a unit of value from the semaphore. -- It ensures the semaphore cannot be leaked if there are exceptions. withQSem :: MonadUnliftIO m => QSem -> m a -> m a -- | Lifted newQSemN. newQSemN :: MonadIO m => Int -> m QSemN -- | Lifted waitQSemN. waitQSemN :: MonadIO m => QSemN -> Int -> m () -- | Lifted signalQSemN. signalQSemN :: MonadIO m => QSemN -> Int -> m () -- | withQSemN is an exception-safe wrapper for performing the -- provided operation while holding N unit of value from the semaphore. -- It ensures the semaphore cannot be leaked if there are exceptions. withQSemN :: MonadUnliftIO m => QSemN -> Int -> m a -> m a -- | Lifted version of atomically atomically :: MonadIO m => STM a -> m a -- | Renamed retry for unqualified export retrySTM :: STM a -- | Renamed check for unqualified export checkSTM :: Bool -> STM () -- | Lifted version of newTVarIO newTVarIO :: MonadIO m => a -> m (TVar a) -- | Lifted version of readTVarIO readTVarIO :: MonadIO m => TVar a -> m a -- | Lifted version of registerDelay registerDelay :: MonadIO m => Int -> m (TVar Bool) -- | Lifted version of mkWeakTVar mkWeakTVar :: MonadUnliftIO m => TVar a -> m () -> m (Weak (TVar a)) -- | Lifted version of newTMVarIO newTMVarIO :: MonadIO m => a -> m (TMVar a) -- | Lifted version of newEmptyTMVarIO newEmptyTMVarIO :: MonadIO m => m (TMVar a) -- | Lifted version of mkWeakTMVar mkWeakTMVar :: MonadUnliftIO m => TMVar a -> m () -> m (Weak (TMVar a)) -- | Lifted version of newTChanIO newTChanIO :: MonadIO m => m (TChan a) -- | Lifted version of newBroadcastTChanIO newBroadcastTChanIO :: MonadIO m => m (TChan a) -- | Lifted version of newTQueueIO newTQueueIO :: MonadIO m => m (TQueue a) -- | Lifted version of newTBQueueIO newTBQueueIO :: MonadIO m => Natural -> m (TBQueue a) -- | Create and use a temporary file in the system standard temporary -- directory. -- -- Behaves exactly the same as withTempFile, except that the -- parent temporary directory will be that returned by -- getCanonicalTemporaryDirectory. withSystemTempFile :: MonadUnliftIO m => String -> (FilePath -> Handle -> m a) -> m a -- | Create and use a temporary directory in the system standard temporary -- directory. -- -- Behaves exactly the same as withTempDirectory, except that the -- parent temporary directory will be that returned by -- getCanonicalTemporaryDirectory. withSystemTempDirectory :: MonadUnliftIO m => String -> (FilePath -> m a) -> m a -- | Use a temporary filename that doesn't already exist. -- -- Creates a new temporary file inside the given directory, making use of -- the template. The temp file is deleted after use. For example: -- --
-- withTempFile "src" "sdist." $ \tmpFile hFile -> do ... ---- -- The tmpFile will be file in the given directory, e.g. -- src/sdist.342. withTempFile :: MonadUnliftIO m => FilePath -> String -> (FilePath -> Handle -> m a) -> m a -- | Create and use a temporary directory. -- -- Creates a new temporary directory inside the given directory, making -- use of the template. The temp directory is deleted after use. For -- example: -- --
-- withTempDirectory "src" "sdist." $ \tmpDir -> do ... ---- -- The tmpDir will be a new subdirectory of the given directory, -- e.g. src/sdist.342. withTempDirectory :: MonadUnliftIO m => FilePath -> String -> (FilePath -> m a) -> m a -- | Unlifted timeout. timeout :: MonadUnliftIO m => Int -> m a -> m (Maybe a) -- | A helper function for implementing MonadUnliftIO instances. -- Useful for the common case where you want to simply delegate to the -- underlying transformer. -- --
-- newtype AppT m a = AppT { unAppT :: ReaderT Int (ResourceT m) a }
-- deriving (Functor, Applicative, Monad, MonadIO)
-- -- Unfortunately, deriving MonadUnliftIO does not work.
--
-- instance MonadUnliftIO m => MonadUnliftIO (AppT m) where
-- withRunInIO = wrappedWithRunInIO AppT unAppT
--
wrappedWithRunInIO :: MonadUnliftIO n => (n b -> m b) -> (forall a. () => m a -> n a) -> ((forall a. () => m a -> IO a) -> IO b) -> m b
-- | Convert an action in m to an action in IO.
toIO :: MonadUnliftIO m => m a -> m (IO a)
-- | Convenience function for capturing the monadic context and running an
-- IO action. The UnliftIO newtype wrapper is rarely
-- needed, so prefer withRunInIO to this function.
withUnliftIO :: MonadUnliftIO m => (UnliftIO m -> IO a) -> m a
-- | Same as askUnliftIO, but returns a monomorphic function instead
-- of a polymorphic newtype wrapper. If you only need to apply the
-- transformation on one concrete type, this function can be more
-- convenient.
askRunInIO :: MonadUnliftIO m => m (m a -> IO a)
-- | Capture the current monadic context, providing the ability to run
-- monadic actions in IO.
--
-- See UnliftIO for an explanation of why we need a helper
-- datatype here.
--
-- Prior to version 0.2.0.0 of this library, this was a method in the
-- MonadUnliftIO type class. It was moved out due to
-- https://github.com/fpco/unliftio/issues/55.
askUnliftIO :: MonadUnliftIO m => m (UnliftIO m)
-- | The ability to run any monadic action m a as IO a.
--
-- This is more precisely a natural transformation. We need to new
-- datatype (instead of simply using a forall) due to lack of
-- support in GHC for impredicative types.
newtype UnliftIO (m :: Type -> Type)
UnliftIO :: (forall a. () => m a -> IO a) -> UnliftIO (m :: Type -> Type)
[unliftIO] :: UnliftIO (m :: Type -> Type) -> forall a. () => m a -> IO a
-- | Efficiently read the entire contents of a TBQueue into a list.
-- This function never retries.
flushTBQueue :: TBQueue a -> STM [a]
-- | Returns True if the supplied TBQueue is empty.
isEmptyTBQueue :: TBQueue a -> STM Bool
-- | Returns True if the supplied TBQueue is full.
isFullTBQueue :: TBQueue a -> STM Bool
-- | Return the length of a TBQueue.
lengthTBQueue :: TBQueue a -> STM Natural
-- | Builds and returns a new instance of TBQueue.
newTBQueue :: Natural -> STM (TBQueue a)
-- | Get the next value from the TBQueue without removing it,
-- retrying if the channel is empty.
peekTBQueue :: TBQueue a -> STM a
-- | Read the next value from the TBQueue.
readTBQueue :: TBQueue a -> STM a
-- | A version of peekTBQueue which does not retry. Instead it
-- returns Nothing if no value is available.
tryPeekTBQueue :: TBQueue a -> STM (Maybe a)
-- | A version of readTBQueue which does not retry. Instead it
-- returns Nothing if no value is available.
tryReadTBQueue :: TBQueue a -> STM (Maybe a)
-- | Put a data item back onto a channel, where it will be the next item
-- read. Blocks if the queue is full.
unGetTBQueue :: TBQueue a -> a -> STM ()
-- | Write a value to a TBQueue; blocks if the queue is full.
writeTBQueue :: TBQueue a -> a -> STM ()
-- | TBQueue is an abstract type representing a bounded FIFO
-- channel.
data TBQueue a
-- | Clone a TChan: similar to dupTChan, but the cloned channel
-- starts with the same content available as the original channel.
cloneTChan :: TChan a -> STM (TChan a)
-- | Duplicate a TChan: the duplicate channel begins empty, but data
-- written to either channel from then on will be available from both.
-- Hence this creates a kind of broadcast channel, where data written by
-- anyone is seen by everyone else.
dupTChan :: TChan a -> STM (TChan a)
-- | Returns True if the supplied TChan is empty.
isEmptyTChan :: TChan a -> STM Bool
-- | Create a write-only TChan. More precisely, readTChan
-- will retry even after items have been written to the channel.
-- The only way to read a broadcast channel is to duplicate it with
-- dupTChan.
--
-- Consider a server that broadcasts messages to clients:
--
-- -- serve :: TChan Message -> Client -> IO loop -- serve broadcastChan client = do -- myChan <- dupTChan broadcastChan -- forever $ do -- message <- readTChan myChan -- send client message ---- -- The problem with using newTChan to create the broadcast channel -- is that if it is only written to and never read, items will pile up in -- memory. By using newBroadcastTChan to create the broadcast -- channel, items can be garbage collected after clients have seen them. newBroadcastTChan :: STM (TChan a) -- | Build and return a new instance of TChan newTChan :: STM (TChan a) -- | Get the next value from the TChan without removing it, -- retrying if the channel is empty. peekTChan :: TChan a -> STM a -- | Read the next value from the TChan. readTChan :: TChan a -> STM a -- | A version of peekTChan which does not retry. Instead it returns -- Nothing if no value is available. tryPeekTChan :: TChan a -> STM (Maybe a) -- | A version of readTChan which does not retry. Instead it returns -- Nothing if no value is available. tryReadTChan :: TChan a -> STM (Maybe a) -- | Put a data item back onto a channel, where it will be the next item -- read. unGetTChan :: TChan a -> a -> STM () -- | Write a value to a TChan. writeTChan :: TChan a -> a -> STM () -- | TChan is an abstract type representing an unbounded FIFO -- channel. data TChan a -- | Check whether a given TMVar is empty. isEmptyTMVar :: TMVar a -> STM Bool -- | Create a TMVar which is initially empty. newEmptyTMVar :: STM (TMVar a) -- | Create a TMVar which contains the supplied value. newTMVar :: a -> STM (TMVar a) -- | Put a value into a TMVar. If the TMVar is currently -- full, putTMVar will retry. putTMVar :: TMVar a -> a -> STM () -- | This is a combination of takeTMVar and putTMVar; ie. it -- takes the value from the TMVar, puts it back, and also returns -- it. readTMVar :: TMVar a -> STM a -- | Swap the contents of a TMVar for a new value. swapTMVar :: TMVar a -> a -> STM a -- | Return the contents of the TMVar. If the TMVar is -- currently empty, the transaction will retry. After a -- takeTMVar, the TMVar is left empty. takeTMVar :: TMVar a -> STM a -- | A version of putTMVar that does not retry. The -- tryPutTMVar function attempts to put the value a into -- the TMVar, returning True if it was successful, or -- False otherwise. tryPutTMVar :: TMVar a -> a -> STM Bool -- | A version of readTMVar which does not retry. Instead it returns -- Nothing if no value is available. tryReadTMVar :: TMVar a -> STM (Maybe a) -- | A version of takeTMVar that does not retry. The -- tryTakeTMVar function returns Nothing if the -- TMVar was empty, or Just a if the TMVar -- was full with contents a. After tryTakeTMVar, the -- TMVar is left empty. tryTakeTMVar :: TMVar a -> STM (Maybe a) -- | A TMVar is a synchronising variable, used for communication -- between concurrent threads. It can be thought of as a box, which may -- be empty or full. data TMVar a -- | Returns True if the supplied TQueue is empty. isEmptyTQueue :: TQueue a -> STM Bool -- | Build and returns a new instance of TQueue newTQueue :: STM (TQueue a) -- | Get the next value from the TQueue without removing it, -- retrying if the channel is empty. peekTQueue :: TQueue a -> STM a -- | Read the next value from the TQueue. readTQueue :: TQueue a -> STM a -- | A version of peekTQueue which does not retry. Instead it -- returns Nothing if no value is available. tryPeekTQueue :: TQueue a -> STM (Maybe a) -- | A version of readTQueue which does not retry. Instead it -- returns Nothing if no value is available. tryReadTQueue :: TQueue a -> STM (Maybe a) -- | Put a data item back onto a channel, where it will be the next item -- read. unGetTQueue :: TQueue a -> a -> STM () -- | Write a value to a TQueue. writeTQueue :: TQueue a -> a -> STM () -- | TQueue is an abstract type representing an unbounded FIFO -- channel. data TQueue a -- | Mutate the contents of a TVar. N.B., this version is -- non-strict. modifyTVar :: TVar a -> (a -> a) -> STM () -- | Strict version of modifyTVar. modifyTVar' :: TVar a -> (a -> a) -> STM () -- | Swap the contents of a TVar for a new value. swapTVar :: TVar a -> a -> STM a -- | Wrap up a synchronous exception to be treated as an asynchronous -- exception -- -- This is intended to be created via toAsyncException data AsyncExceptionWrapper AsyncExceptionWrapper :: e -> AsyncExceptionWrapper -- | Wrap up an asynchronous exception to be treated as a synchronous -- exception -- -- This is intended to be created via toSyncException data SyncExceptionWrapper SyncExceptionWrapper :: e -> SyncExceptionWrapper traceDisplayStack :: Display a => a -> b -> b traceDisplayMarkerIO :: (Display a, MonadIO m) => a -> m () traceDisplayMarker :: Display a => a -> b -> b traceDisplayEventIO :: (Display a, MonadIO m) => a -> m () traceDisplayEvent :: Display a => a -> b -> b traceDisplayM :: (Display a, Applicative f) => a -> f () traceDisplayIO :: (Display a, MonadIO m) => a -> m () traceDisplayId :: Display a => a -> a traceDisplay :: Display a => a -> b -> b traceShowStack :: Show a => a -> b -> b traceShowMarkerIO :: (Show a, MonadIO m) => a -> m () traceShowMarker :: Show a => a -> b -> b traceShowEventIO :: (Show a, MonadIO m) => a -> m () traceShowEvent :: Show a => a -> b -> b traceShowM :: (Show a, Applicative f) => a -> f () traceShowIO :: (Show a, MonadIO m) => a -> m () traceShowId :: Show a => a -> a traceShow :: Show a => a -> b -> b traceStack :: Text -> a -> a traceMarkerIO :: MonadIO m => Text -> m () traceMarker :: Text -> a -> a traceEventIO :: MonadIO m => Text -> m () traceEvent :: Text -> a -> a traceM :: Applicative f => Text -> f () traceIO :: MonadIO m => Text -> m () traceId :: Text -> Text trace :: Text -> a -> a -- | Run with a default configured SimpleApp, consisting of: -- --
-- >>> :set -XTypeApplications -- -- >>> import qualified RIO.Vector.Unboxed as U -- -- >>> d <- newDeque @U.MVector @Int -- -- >>> mapM_ (pushFrontDeque d) [0..10] -- -- >>> freezeDeque @U.Vector d -- [10,9,8,7,6,5,4,3,2,1,0] --freezeDeque :: (Vector v a, PrimMonad m) => Deque (Mutable v) (PrimState m) a -> m (v a) -- | Convert to an immutable vector of any type. If resulting pure vector -- corresponds to the mutable one used by the Deque, it will be -- more efficient to use freezeDeque instead. -- --
-- >>> :set -XTypeApplications -- -- >>> import qualified RIO.Vector.Unboxed as U -- -- >>> import qualified RIO.Vector.Storable as S -- -- >>> d <- newDeque @U.MVector @Int -- -- >>> mapM_ (pushFrontDeque d) [0..10] -- -- >>> dequeToVector @S.Vector d -- [10,9,8,7,6,5,4,3,2,1,0] --dequeToVector :: forall v' a (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) m. (Vector v' a, MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m (v' a) -- | Convert a Deque into a list. Does not modify the Deque. dequeToList :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m. (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m [a] -- | Fold over a Deque, starting at the end. Does not modify the -- Deque. foldrDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m acc. (MVector v a, PrimMonad m) => (a -> acc -> m acc) -> acc -> Deque v (PrimState m) a -> m acc -- | Fold over a Deque, starting at the beginning. Does not modify -- the Deque. foldlDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m acc. (MVector v a, PrimMonad m) => (acc -> a -> m acc) -> acc -> Deque v (PrimState m) a -> m acc -- | Push a new value to the end of the Deque pushBackDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m. (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> a -> m () -- | Push a new value to the beginning of the Deque pushFrontDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m. (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> a -> m () -- | Pop the first value from the end of the Deque popBackDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m. (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m (Maybe a) -- | Pop the first value from the beginning of the Deque popFrontDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m. (MVector v a, PrimMonad m) => Deque v (PrimState m) a -> m (Maybe a) -- | O(1) - Get the number of elements that is currently in the -- Deque getDequeSize :: forall m (v :: Type -> Type -> Type) a. PrimMonad m => Deque v (PrimState m) a -> m Int -- | Create a new, empty Deque newDeque :: forall (v :: Type -> TYPE LiftedRep -> TYPE LiftedRep) a m. (MVector v a, PrimMonad m) => m (Deque v (PrimState m) a) -- | Helper function to assist with type inference, forcing usage of a -- boxed vector. asBDeque :: BDeque s a -> BDeque s a -- | Helper function to assist with type inference, forcing usage of a -- storable vector. asSDeque :: SDeque s a -> SDeque s a -- | Helper function to assist with type inference, forcing usage of an -- unboxed vector. asUDeque :: UDeque s a -> UDeque s a -- | A double-ended queue supporting any underlying vector type and any -- monad. -- -- This implements a circular double-ended queue with exponential growth. data Deque (v :: Type -> Type -> Type) s a -- | A Deque specialized to unboxed vectors. type UDeque = Deque MVector -- | A Deque specialized to storable vectors. type SDeque = Deque MVector -- | A Deque specialized to boxed vectors. type BDeque = Deque MVector -- | Read a file in UTF8 encoding, throwing an exception on invalid -- character encoding. -- -- This function will use OS-specific line ending handling. readFileUtf8 :: MonadIO m => FilePath -> m Text -- | Same as writeFile, but generalized to MonadIO writeFileBinary :: MonadIO m => FilePath -> ByteString -> m () -- | Same as readFile, but generalized to MonadIO readFileBinary :: MonadIO m => FilePath -> m ByteString hPutBuilder :: MonadIO m => Handle -> Builder -> m () -- | Write a file in UTF8 encoding -- -- This function will use OS-specific line ending handling. writeFileUtf8 :: MonadIO m => FilePath -> Text -> m () -- | Lazily read a file in UTF8 encoding. withLazyFileUtf8 :: MonadUnliftIO m => FilePath -> (Text -> m a) -> m a -- | Lazily get the contents of a file. Unlike readFile, this -- ensures that if an exception is thrown, the file handle is closed -- immediately. withLazyFile :: MonadUnliftIO m => FilePath -> (ByteString -> m a) -> m a -- | Make a GLogFunc via classic LogFunc. Use this if you'd -- like to log your generic data type via the classic RIO terminal -- logger. gLogFuncClassic :: (HasLogLevel msg, HasLogSource msg, Display msg) => LogFunc -> GLogFunc msg -- | Log a value generically. glog :: (MonadIO m, HasCallStack, HasGLogFunc env, MonadReader env m) => GMsg env -> m () -- | Make a custom generic logger. With this you could, for example, write -- to a database or a log digestion service. For example: -- --
-- mkGLogFunc (\stack msg -> send (Data.Aeson.encode (JsonLog stack msg))) --mkGLogFunc :: (CallStack -> msg -> IO ()) -> GLogFunc msg -- | A contramap. Use this to wrap sub-loggers via mapRIO. -- -- If you are on base > 4.12.0, you can just use contramap. contramapGLogFunc :: (a -> b) -> GLogFunc b -> GLogFunc a -- | A vesion of contramapMaybeGLogFunc which supports filering. contramapMaybeGLogFunc :: (a -> Maybe b) -> GLogFunc b -> GLogFunc a -- | Disable logging capabilities in a given sub-routine -- -- Intended to skip logging in general purpose implementations, where -- secrets might be logged accidently. noLogging :: (HasLogFunc env, MonadReader env m) => m a -> m a -- | What accent colors, indexed by Int, is the log func configured -- to use? -- -- Intended for use by code which wants to optionally add additional -- color to its log messages. logFuncAccentColorsL :: HasLogFunc env => SimpleGetter env (Int -> Utf8Builder) -- | What color is the log func configured to use for secondary content? -- -- Intended for use by code which wants to optionally add additional -- color to its log messages. logFuncSecondaryColorL :: HasLogFunc env => SimpleGetter env Utf8Builder -- | What color is the log func configured to use for each LogLevel? -- -- Intended for use by code which wants to optionally add additional -- color to its log messages. logFuncLogLevelColorsL :: HasLogFunc env => SimpleGetter env (LogLevel -> Utf8Builder) -- | Is the log func configured to use color output? -- -- Intended for use by code which wants to optionally add additional -- color to its log messages. logFuncUseColorL :: HasLogFunc env => SimpleGetter env Bool -- | Convert a CallStack value into a Utf8Builder indicating -- the first source location. -- -- TODO Consider showing the entire call stack instead. displayCallStack :: CallStack -> Utf8Builder -- | Set format method for messages -- -- Default: id setLogFormat :: (Utf8Builder -> Utf8Builder) -> LogOptions -> LogOptions -- | Use code location in the log output. -- -- Default: True if in verbose mode, False otherwise. setLogUseLoc :: Bool -> LogOptions -> LogOptions -- | ANSI color codes for accents in the log output. Accent colors are -- indexed by Int. -- -- Default: const "\ESC[92m" -- Bright green, for all indicies setLogAccentColors :: (Int -> Utf8Builder) -> LogOptions -> LogOptions -- | ANSI color codes for secondary content in the log output. -- -- Default: "\ESC[90m" -- Bright black (gray) setLogSecondaryColor :: Utf8Builder -> LogOptions -> LogOptions -- | ANSI color codes for LogLevel in the log output. -- -- Default: LevelDebug = "\ESC[32m" -- Green LevelInfo = -- "\ESC[34m" -- Blue LevelWarn = "\ESC[33m" -- Yellow -- LevelError = "\ESC[31m" -- Red LevelOther _ = "\ESC[35m" -- -- Magenta setLogLevelColors :: (LogLevel -> Utf8Builder) -> LogOptions -> LogOptions -- | Use ANSI color codes in the log output. -- -- Default: True if in verbose mode and the Handle -- is a terminal device. setLogUseColor :: Bool -> LogOptions -> LogOptions -- | Include the time when printing log messages. -- -- Default: True in debug mode, False otherwise. setLogUseTime :: Bool -> LogOptions -> LogOptions -- | Do we treat output as a terminal. If True, we will enable -- sticky logging functionality. -- -- Default: checks if the Handle provided to -- logOptionsHandle is a terminal with hIsTerminalDevice. setLogTerminal :: Bool -> LogOptions -> LogOptions -- | Refer to setLogVerboseFormat. This modifier allows to alter the -- verbose format value dynamically at runtime. -- -- Default: follows the value of the verbose flag. setLogVerboseFormatIO :: IO Bool -> LogOptions -> LogOptions -- | Use the verbose format for printing log messages. -- -- Default: follows the value of the verbose flag. setLogVerboseFormat :: Bool -> LogOptions -> LogOptions -- | Refer to setLogMinLevel. This modifier allows to alter the -- verbose format value dynamically at runtime. -- -- Default: in verbose mode, LevelDebug. Otherwise, -- LevelInfo. setLogMinLevelIO :: IO LogLevel -> LogOptions -> LogOptions -- | Set the minimum log level. Messages below this level will not be -- printed. -- -- Default: in verbose mode, LevelDebug. Otherwise, -- LevelInfo. setLogMinLevel :: LogLevel -> LogOptions -> LogOptions -- | Given a LogOptions value, run the given function with the -- specified LogFunc. A common way to use this function is: -- --
-- let isVerbose = False -- get from the command line instead
-- logOptions' <- logOptionsHandle stderr isVerbose
-- let logOptions = setLogUseTime True logOptions'
-- withLogFunc logOptions $ \lf -> do
-- let app = App -- application specific environment
-- { appLogFunc = lf
-- , appOtherStuff = ...
-- }
-- runRIO app $ do
-- logInfo "Starting app"
-- myApp
--
withLogFunc :: MonadUnliftIO m => LogOptions -> (LogFunc -> m a) -> m a
-- | Given a LogOptions value, returns both a new LogFunc and
-- a sub-routine that disposes it.
--
-- Intended for use if you want to deal with the teardown of
-- LogFunc yourself, otherwise prefer the withLogFunc
-- function instead.
newLogFunc :: (MonadIO n, MonadIO m) => LogOptions -> n (LogFunc, m ())
-- | Create a LogOptions value from the given Handle and
-- whether to perform verbose logging or not. Individiual settings can be
-- overridden using appropriate set functions. Logging output is
-- guaranteed to be non-interleaved only for a UTF-8 Handle in a
-- multi-thread environment.
--
-- When Verbose Flag is True, the following happens:
--
-- -- forMaybeM == flip mapMaybeM --forMaybeM :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b] -- | Monadic mapMaybe. mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b] -- |
-- forMaybeA == flip mapMaybeA --forMaybeA :: Applicative f => [a] -> (a -> f (Maybe b)) -> f [b] -- | Applicative mapMaybe. mapMaybeA :: Applicative f => (a -> f (Maybe b)) -> [a] -> f [b] -- | Get a First value with a default fallback fromFirst :: a -> First a -> a -- | Apply a function to a Left constructor mapLeft :: (a1 -> a2) -> Either a1 b -> Either a2 b -- | Lifted version of "System.Exit.exitWith". -- -- @since 0.1.9.0. exitWith :: MonadIO m => ExitCode -> m a -- | Lifted version of "System.Exit.exitSuccess". -- -- @since 0.1.9.0. exitSuccess :: MonadIO m => m a -- | Lifted version of "System.Exit.exitFailure". -- -- @since 0.1.9.0. exitFailure :: MonadIO m => m a -- | Write the given Utf8Builder value to a file. writeFileUtf8Builder :: MonadIO m => FilePath -> Utf8Builder -> m () -- | Convert a Utf8Builder value into a lazy Text. utf8BuilderToLazyText :: Utf8Builder -> Text -- | Convert a Utf8Builder value into a strict Text. utf8BuilderToText :: Utf8Builder -> Text -- | Convert a ByteString into a Utf8Builder. -- -- NOTE This function performs no checks to ensure that the data -- is, in fact, UTF8 encoded. If you provide non-UTF8 data, later -- functions may fail. displayBytesUtf8 :: ByteString -> Utf8Builder -- | Use the Show instance for a value to convert it to a -- Utf8Builder. displayShow :: Show a => a -> Utf8Builder -- | A builder of binary data, with the invariant that the underlying data -- is supposed to be UTF-8 encoded. newtype Utf8Builder Utf8Builder :: Builder -> Utf8Builder [getUtf8Builder] :: Utf8Builder -> Builder -- | A typeclass for values which can be converted to a Utf8Builder. -- The intention of this typeclass is to provide a human-friendly display -- of the data. class Display a display :: Display a => a -> Utf8Builder -- | Display data as Text, which will also be used for -- display if it is not overriden. textDisplay :: Display a => a -> Text -- | Boxed vectors, supporting efficient slicing. data Vector a class (Vector Vector a, MVector MVector a) => Unbox a -- | A set of values. A set cannot contain duplicate values. data HashSet a -- | Unlifted version of withBinaryFile. withBinaryFile :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m a) -> m a -- | After a file is closed, this function opens it again and executes -- fsync() internally on both the file and the directory that -- contains it. Note that this function is intended to work around the -- non-durability of existing file APIs, as opposed to being necessary -- for the API functions provided in this module. -- -- The effectiveness of calling this function is debatable, as it -- relies on internal implementation details at the Kernel level that -- might change. We argue that, despite this fact, calling this function -- may bring benefits in terms of durability. -- -- This function does not provide the same guarantee as if you would open -- and modify a file using withBinaryFileDurable or -- writeBinaryFileDurable, since they ensure that the -- fsync() is called before the file is closed, so if possible -- use those instead. -- --
-- #!/usr/bin/env stack ---- -- Additional arguments can be specified in a haskell comment following -- the #! line. The contents inside the comment must be a single -- valid stack command line, starting with stack as the command -- and followed by the options to use for executing this file. -- -- The comment must be on the line immediately following the #! -- line. The comment must start in the first column of the line. When -- using a block style comment the command can be split on multiple -- lines. -- -- Here is an example of a single line comment: -- --
-- #!/usr/bin/env stack -- -- stack --resolver lts-3.14 --install-ghc runghc --package random ---- -- Here is an example of a multi line block comment: -- --
-- #!/usr/bin/env stack
-- {- stack
-- --resolver lts-3.14
-- --install-ghc
-- runghc
-- --package random
-- -}
--
--
-- When the #! line is not present, the file can still be
-- executed using stack <file name> command if the file
-- starts with a valid stack interpreter comment. This can be used to
-- execute the file on Windows for example.
--
-- Nested block comments are not supported.
module Data.Attoparsec.Interpreter
-- | Parser to extract the Stack command line embedded inside a comment
-- after validating the placement and formatting rules for a valid
-- interpreter specification.
interpreterArgsParser :: Bool -> String -> Parser String
-- | Extract Stack arguments from a correctly placed and correctly
-- formatted comment when it is being used as an interpreter
getInterpreterArgs :: String -> IO [String]
module Control.Concurrent.Execute
data ActionType
-- | Action for building a package's library and executables. If
-- taskAllInOne is True, then this will also build
-- benchmarks and tests. It is False when then library's
-- benchmarks or test-suites have cyclic dependencies.
ATBuild :: ActionType
-- | Task for building the package's benchmarks and test-suites. Requires
-- that the library was already built.
ATBuildFinal :: ActionType
-- | Task for running the package's test-suites.
ATRunTests :: ActionType
-- | Task for running the package's benchmarks.
ATRunBenchmarks :: ActionType
data ActionId
ActionId :: !PackageIdentifier -> !ActionType -> ActionId
data ActionContext
ActionContext :: !Set ActionId -> [Action] -> !Concurrency -> ActionContext
-- | Does not include the current action
[acRemaining] :: ActionContext -> !Set ActionId
-- | Actions which depend on the current action
[acDownstream] :: ActionContext -> [Action]
-- | Whether this action may be run concurrently with others
[acConcurrency] :: ActionContext -> !Concurrency
data Action
Action :: !ActionId -> !Set ActionId -> !ActionContext -> IO () -> !Concurrency -> Action
[actionId] :: Action -> !ActionId
[actionDeps] :: Action -> !Set ActionId
[actionDo] :: Action -> !ActionContext -> IO ()
[actionConcurrency] :: Action -> !Concurrency
data Concurrency
ConcurrencyAllowed :: Concurrency
ConcurrencyDisallowed :: Concurrency
runActions :: Int -> Bool -> [Action] -> (TVar Int -> TVar (Set ActionId) -> IO ()) -> IO [SomeException]
instance GHC.Show.Show Control.Concurrent.Execute.ExecuteException
instance GHC.Classes.Ord Control.Concurrent.Execute.ActionType
instance GHC.Classes.Eq Control.Concurrent.Execute.ActionType
instance GHC.Show.Show Control.Concurrent.Execute.ActionType
instance GHC.Classes.Ord Control.Concurrent.Execute.ActionId
instance GHC.Classes.Eq Control.Concurrent.Execute.ActionId
instance GHC.Show.Show Control.Concurrent.Execute.ActionId
instance GHC.Classes.Eq Control.Concurrent.Execute.Concurrency
instance GHC.Exception.Type.Exception Control.Concurrent.Execute.ExecuteException
module Stack.Types.CompilerBuild
data CompilerBuild
CompilerBuildStandard :: CompilerBuild
CompilerBuildSpecialized :: String -> CompilerBuild
-- | Descriptive name for compiler build
compilerBuildName :: CompilerBuild -> String
-- | Suffix to use for filenames/directories constructed with compiler
-- build
compilerBuildSuffix :: CompilerBuild -> String
-- | Parse compiler build from a String.
parseCompilerBuild :: MonadThrow m => String -> m CompilerBuild
instance GHC.Show.Show Stack.Types.CompilerBuild.CompilerBuild
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.CompilerBuild.CompilerBuild
module Stack.Options.GhcBuildParser
-- | GHC build parser
ghcBuildParser :: Bool -> Parser CompilerBuild
-- | Configuration options for building.
module Stack.Types.Config.Build
-- | Build options that is interpreted by the build command. This is built
-- up from BuildOptsCLI and BuildOptsMonoid
data BuildOpts
BuildOpts :: !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !HaddockOpts -> !Bool -> !Maybe Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Maybe Bool -> !Bool -> !Bool -> !Bool -> !TestOpts -> !Bool -> !BenchmarkOpts -> !Bool -> !CabalVerbosity -> !Bool -> ![Text] -> !Bool -> !Maybe Text -> BuildOpts
[boptsLibProfile] :: BuildOpts -> !Bool
[boptsExeProfile] :: BuildOpts -> !Bool
[boptsLibStrip] :: BuildOpts -> !Bool
[boptsExeStrip] :: BuildOpts -> !Bool
-- | Build haddocks?
[boptsHaddock] :: BuildOpts -> !Bool
-- | Options to pass to haddock
[boptsHaddockOpts] :: BuildOpts -> !HaddockOpts
-- | Open haddocks in the browser?
[boptsOpenHaddocks] :: BuildOpts -> !Bool
-- | Build haddocks for dependencies?
[boptsHaddockDeps] :: BuildOpts -> !Maybe Bool
-- | Build haddocks for all symbols and packages, like cabal haddock
-- --internal
[boptsHaddockInternal] :: BuildOpts -> !Bool
-- | Build hyperlinked source if possible. Fallback to hscolour.
-- Disable for no sources.
[boptsHaddockHyperlinkSource] :: BuildOpts -> !Bool
-- | Install executables to user path after building?
[boptsInstallExes] :: BuildOpts -> !Bool
-- | Install executables to compiler tools path after building?
[boptsInstallCompilerTool] :: BuildOpts -> !Bool
-- | Fetch all packages immediately ^ Watch files for changes and
-- automatically rebuild
[boptsPreFetch] :: BuildOpts -> !Bool
-- | Keep building/running after failure
[boptsKeepGoing] :: BuildOpts -> !Maybe Bool
-- | Keep intermediate files and build directories
[boptsKeepTmpFiles] :: BuildOpts -> !Bool
-- | Force treating all local packages as having dirty files
[boptsForceDirty] :: BuildOpts -> !Bool
-- | Turn on tests for local targets
[boptsTests] :: BuildOpts -> !Bool
-- | Additional test arguments
[boptsTestOpts] :: BuildOpts -> !TestOpts
-- | Turn on benchmarks for local targets
[boptsBenchmarks] :: BuildOpts -> !Bool
-- | Additional test arguments ^ Commands (with arguments) to run after a
-- successful build ^ Only perform the configure step when building
[boptsBenchmarkOpts] :: BuildOpts -> !BenchmarkOpts
-- | Perform the configure step even if already configured
[boptsReconfigure] :: BuildOpts -> !Bool
-- | Ask Cabal to be verbose in its builds
[boptsCabalVerbose] :: BuildOpts -> !CabalVerbosity
-- | Whether to enable split-objs.
[boptsSplitObjs] :: BuildOpts -> !Bool
-- | Which components to skip when building
[boptsSkipComponents] :: BuildOpts -> ![Text]
-- | Should we use the interleaved GHC output when building multiple
-- packages?
[boptsInterleavedOutput] :: BuildOpts -> !Bool
[boptsDdumpDir] :: BuildOpts -> !Maybe Text
-- | Command sum type for conditional arguments.
data BuildCommand
Build :: BuildCommand
Test :: BuildCommand
Haddock :: BuildCommand
Bench :: BuildCommand
Install :: BuildCommand
defaultBuildOpts :: BuildOpts
defaultBuildOptsCLI :: BuildOptsCLI
-- | Build options that may only be specified from the CLI
data BuildOptsCLI
BuildOptsCLI :: ![Text] -> !Bool -> ![Text] -> !Map ApplyCLIFlag (Map FlagName Bool) -> !BuildSubset -> !FileWatchOpts -> !Bool -> ![(String, [String])] -> !Bool -> !BuildCommand -> !Bool -> BuildOptsCLI
[boptsCLITargets] :: BuildOptsCLI -> ![Text]
[boptsCLIDryrun] :: BuildOptsCLI -> !Bool
[boptsCLIGhcOptions] :: BuildOptsCLI -> ![Text]
[boptsCLIFlags] :: BuildOptsCLI -> !Map ApplyCLIFlag (Map FlagName Bool)
[boptsCLIBuildSubset] :: BuildOptsCLI -> !BuildSubset
[boptsCLIFileWatch] :: BuildOptsCLI -> !FileWatchOpts
[boptsCLIWatchAll] :: BuildOptsCLI -> !Bool
[boptsCLIExec] :: BuildOptsCLI -> ![(String, [String])]
[boptsCLIOnlyConfigure] :: BuildOptsCLI -> !Bool
[boptsCLICommand] :: BuildOptsCLI -> !BuildCommand
[boptsCLIInitialBuildSteps] :: BuildOptsCLI -> !Bool
-- | Build options that may be specified in the stack.yaml or from the CLI
data BuildOptsMonoid
BuildOptsMonoid :: !Any -> !Any -> !Any -> !FirstFalse -> !FirstFalse -> !FirstTrue -> !FirstTrue -> !FirstFalse -> !HaddockOptsMonoid -> !FirstFalse -> !First Bool -> !FirstFalse -> !FirstTrue -> !FirstFalse -> !FirstFalse -> !FirstFalse -> !First Bool -> !FirstFalse -> !FirstFalse -> !FirstFalse -> !TestOptsMonoid -> !FirstFalse -> !BenchmarkOptsMonoid -> !FirstFalse -> !First CabalVerbosity -> !FirstFalse -> ![Text] -> !FirstTrue -> !First Text -> BuildOptsMonoid
[buildMonoidTrace] :: BuildOptsMonoid -> !Any
[buildMonoidProfile] :: BuildOptsMonoid -> !Any
[buildMonoidNoStrip] :: BuildOptsMonoid -> !Any
[buildMonoidLibProfile] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidExeProfile] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidLibStrip] :: BuildOptsMonoid -> !FirstTrue
[buildMonoidExeStrip] :: BuildOptsMonoid -> !FirstTrue
[buildMonoidHaddock] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidHaddockOpts] :: BuildOptsMonoid -> !HaddockOptsMonoid
[buildMonoidOpenHaddocks] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidHaddockDeps] :: BuildOptsMonoid -> !First Bool
[buildMonoidHaddockInternal] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidHaddockHyperlinkSource] :: BuildOptsMonoid -> !FirstTrue
[buildMonoidInstallExes] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidInstallCompilerTool] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidPreFetch] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidKeepGoing] :: BuildOptsMonoid -> !First Bool
[buildMonoidKeepTmpFiles] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidForceDirty] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidTests] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidTestOpts] :: BuildOptsMonoid -> !TestOptsMonoid
[buildMonoidBenchmarks] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidBenchmarkOpts] :: BuildOptsMonoid -> !BenchmarkOptsMonoid
[buildMonoidReconfigure] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidCabalVerbose] :: BuildOptsMonoid -> !First CabalVerbosity
[buildMonoidSplitObjs] :: BuildOptsMonoid -> !FirstFalse
[buildMonoidSkipComponents] :: BuildOptsMonoid -> ![Text]
[buildMonoidInterleavedOutput] :: BuildOptsMonoid -> !FirstTrue
[buildMonoidDdumpDir] :: BuildOptsMonoid -> !First Text
-- | Options for the FinalAction DoTests
data TestOpts
TestOpts :: !Bool -> ![String] -> !Bool -> !Bool -> !Maybe Int -> !Bool -> TestOpts
-- | Whether successful tests will be run gain
[toRerunTests] :: TestOpts -> !Bool
-- | Arguments passed to the test program
[toAdditionalArgs] :: TestOpts -> ![String]
-- | Generate a code coverage report
[toCoverage] :: TestOpts -> !Bool
-- | Disable running of tests
[toDisableRun] :: TestOpts -> !Bool
-- | test suite timeout in seconds
[toMaximumTimeSeconds] :: TestOpts -> !Maybe Int
-- | Whether to allow standard input
[toAllowStdin] :: TestOpts -> !Bool
defaultTestOpts :: TestOpts
data TestOptsMonoid
TestOptsMonoid :: !FirstTrue -> ![String] -> !FirstFalse -> !FirstFalse -> !First (Maybe Int) -> !FirstTrue -> TestOptsMonoid
[toMonoidRerunTests] :: TestOptsMonoid -> !FirstTrue
[toMonoidAdditionalArgs] :: TestOptsMonoid -> ![String]
[toMonoidCoverage] :: TestOptsMonoid -> !FirstFalse
[toMonoidDisableRun] :: TestOptsMonoid -> !FirstFalse
[toMonoidMaximumTimeSeconds] :: TestOptsMonoid -> !First (Maybe Int)
[toMonoidAllowStdin] :: TestOptsMonoid -> !FirstTrue
-- | Haddock Options
newtype HaddockOpts
HaddockOpts :: [String] -> HaddockOpts
-- | Arguments passed to haddock program
[hoAdditionalArgs] :: HaddockOpts -> [String]
defaultHaddockOpts :: HaddockOpts
newtype HaddockOptsMonoid
HaddockOptsMonoid :: [String] -> HaddockOptsMonoid
[hoMonoidAdditionalArgs] :: HaddockOptsMonoid -> [String]
-- | Options for the FinalAction DoBenchmarks
data BenchmarkOpts
BenchmarkOpts :: !Maybe String -> !Bool -> BenchmarkOpts
-- | Arguments passed to the benchmark program
[beoAdditionalArgs] :: BenchmarkOpts -> !Maybe String
-- | Disable running of benchmarks
[beoDisableRun] :: BenchmarkOpts -> !Bool
defaultBenchmarkOpts :: BenchmarkOpts
data BenchmarkOptsMonoid
BenchmarkOptsMonoid :: !First String -> !First Bool -> BenchmarkOptsMonoid
[beoMonoidAdditionalArgs] :: BenchmarkOptsMonoid -> !First String
[beoMonoidDisableRun] :: BenchmarkOptsMonoid -> !First Bool
data FileWatchOpts
NoFileWatch :: FileWatchOpts
FileWatch :: FileWatchOpts
FileWatchPoll :: FileWatchOpts
-- | Which subset of packages to build
data BuildSubset
BSAll :: BuildSubset
-- | Only install packages in the snapshot database, skipping packages
-- intended for the local database.
BSOnlySnapshot :: BuildSubset
BSOnlyDependencies :: BuildSubset
-- | Refuse to build anything in the snapshot database, see
-- https://github.com/commercialhaskell/stack/issues/5272
BSOnlyLocals :: BuildSubset
-- | How to apply a CLI flag
data ApplyCLIFlag
-- | Apply to all project packages which have such a flag name available.
ACFAllProjectPackages :: ApplyCLIFlag
-- | Apply to the specified package only.
ACFByName :: !PackageName -> ApplyCLIFlag
-- | Only flags set via ACFByName
boptsCLIFlagsByName :: BuildOptsCLI -> Map PackageName (Map FlagName Bool)
newtype CabalVerbosity
CabalVerbosity :: Verbosity -> CabalVerbosity
toFirstCabalVerbosity :: FirstFalse -> First CabalVerbosity
instance GHC.Classes.Ord Stack.Types.Config.Build.ApplyCLIFlag
instance GHC.Classes.Eq Stack.Types.Config.Build.ApplyCLIFlag
instance GHC.Show.Show Stack.Types.Config.Build.ApplyCLIFlag
instance GHC.Show.Show Stack.Types.Config.Build.BuildCommand
instance GHC.Classes.Eq Stack.Types.Config.Build.BuildCommand
instance GHC.Classes.Eq Stack.Types.Config.Build.BuildSubset
instance GHC.Show.Show Stack.Types.Config.Build.BuildSubset
instance GHC.Show.Show Stack.Types.Config.Build.TestOpts
instance GHC.Classes.Eq Stack.Types.Config.Build.TestOpts
instance GHC.Generics.Generic Stack.Types.Config.Build.TestOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.TestOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.HaddockOpts
instance GHC.Classes.Eq Stack.Types.Config.Build.HaddockOpts
instance GHC.Generics.Generic Stack.Types.Config.Build.HaddockOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.HaddockOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.BenchmarkOpts
instance GHC.Classes.Eq Stack.Types.Config.Build.BenchmarkOpts
instance GHC.Generics.Generic Stack.Types.Config.Build.BenchmarkOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.BenchmarkOptsMonoid
instance GHC.Classes.Eq Stack.Types.Config.Build.FileWatchOpts
instance GHC.Show.Show Stack.Types.Config.Build.FileWatchOpts
instance GHC.Show.Show Stack.Types.Config.Build.BuildOptsCLI
instance GHC.Show.Show Stack.Types.Config.Build.CabalVerbosity
instance GHC.Classes.Eq Stack.Types.Config.Build.CabalVerbosity
instance GHC.Generics.Generic Stack.Types.Config.Build.BuildOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.BuildOptsMonoid
instance GHC.Show.Show Stack.Types.Config.Build.BuildOpts
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.Build.BuildOptsMonoid)
instance GHC.Base.Semigroup Stack.Types.Config.Build.BuildOptsMonoid
instance GHC.Base.Monoid Stack.Types.Config.Build.BuildOptsMonoid
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.Build.CabalVerbosity
instance Distribution.Parsec.Parsec Stack.Types.Config.Build.CabalVerbosity
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.Build.BenchmarkOptsMonoid)
instance GHC.Base.Semigroup Stack.Types.Config.Build.BenchmarkOptsMonoid
instance GHC.Base.Monoid Stack.Types.Config.Build.BenchmarkOptsMonoid
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.Build.HaddockOptsMonoid)
instance GHC.Base.Semigroup Stack.Types.Config.Build.HaddockOptsMonoid
instance GHC.Base.Monoid Stack.Types.Config.Build.HaddockOptsMonoid
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.Build.TestOptsMonoid)
instance GHC.Base.Semigroup Stack.Types.Config.Build.TestOptsMonoid
instance GHC.Base.Monoid Stack.Types.Config.Build.TestOptsMonoid
module Stack.Options.PackageParser
-- | Parser for package:[-]flag
readFlag :: ReadM (Map ApplyCLIFlag (Map FlagName Bool))
-- | A ghc-pkg id.
module Stack.Types.GhcPkgId
-- | A ghc-pkg package identifier.
data GhcPkgId
-- | Get a text value of GHC package id
unGhcPkgId :: GhcPkgId -> Text
-- | A parser for a package-version-hash pair.
ghcPkgIdParser :: Parser GhcPkgId
-- | Convenient way to parse a package name from a Text.
parseGhcPkgId :: MonadThrow m => Text -> m GhcPkgId
-- | Get a string representation of GHC package id.
ghcPkgIdString :: GhcPkgId -> String
instance GHC.Show.Show Stack.Types.GhcPkgId.GhcPkgIdParseFail
instance Database.Persist.Sql.Class.PersistFieldSql Stack.Types.GhcPkgId.GhcPkgId
instance Database.Persist.Class.PersistField.PersistField Stack.Types.GhcPkgId.GhcPkgId
instance GHC.Generics.Generic Stack.Types.GhcPkgId.GhcPkgId
instance Data.Data.Data Stack.Types.GhcPkgId.GhcPkgId
instance GHC.Classes.Ord Stack.Types.GhcPkgId.GhcPkgId
instance GHC.Classes.Eq Stack.Types.GhcPkgId.GhcPkgId
instance Data.Hashable.Class.Hashable Stack.Types.GhcPkgId.GhcPkgId
instance Control.DeepSeq.NFData Stack.Types.GhcPkgId.GhcPkgId
instance GHC.Show.Show Stack.Types.GhcPkgId.GhcPkgId
instance GHC.Read.Read Stack.Types.GhcPkgId.GhcPkgId
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.GhcPkgId.GhcPkgId
instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.GhcPkgId.GhcPkgId
instance GHC.Exception.Type.Exception Stack.Types.GhcPkgId.GhcPkgIdParseFail
module Stack.Types.NamedComponent
-- | A single, fully resolved component of a package
data NamedComponent
CLib :: NamedComponent
CInternalLib :: !Text -> NamedComponent
CExe :: !Text -> NamedComponent
CTest :: !Text -> NamedComponent
CBench :: !Text -> NamedComponent
renderComponent :: NamedComponent -> Text
renderPkgComponents :: [(PackageName, NamedComponent)] -> Text
renderPkgComponent :: (PackageName, NamedComponent) -> Text
exeComponents :: Set NamedComponent -> Set Text
testComponents :: Set NamedComponent -> Set Text
benchComponents :: Set NamedComponent -> Set Text
internalLibComponents :: Set NamedComponent -> Set Text
isCLib :: NamedComponent -> Bool
isCInternalLib :: NamedComponent -> Bool
isCExe :: NamedComponent -> Bool
isCTest :: NamedComponent -> Bool
isCBench :: NamedComponent -> Bool
instance GHC.Classes.Ord Stack.Types.NamedComponent.NamedComponent
instance GHC.Classes.Eq Stack.Types.NamedComponent.NamedComponent
instance GHC.Show.Show Stack.Types.NamedComponent.NamedComponent
-- | Nix types.
module Stack.Types.Nix
-- | Nix configuration. Parameterize by resolver type to avoid cyclic
-- dependency.
data NixOpts
NixOpts :: !Bool -> !Bool -> ![Text] -> !Maybe FilePath -> ![Text] -> !Bool -> NixOpts
[nixEnable] :: NixOpts -> !Bool
[nixPureShell] :: NixOpts -> !Bool
-- | The system packages to be installed in the environment before it runs
[nixPackages] :: NixOpts -> ![Text]
-- | The path of a file containing preconfiguration of the environment (e.g
-- shell.nix)
[nixInitFile] :: NixOpts -> !Maybe FilePath
-- | Options to be given to the nix-shell command line
[nixShellOptions] :: NixOpts -> ![Text]
-- | Should we register gc roots so running nix-collect-garbage doesn't
-- remove nix dependencies
[nixAddGCRoots] :: NixOpts -> !Bool
-- | An uninterpreted representation of nix options. Configurations may be
-- "cascaded" using mappend (left-biased).
data NixOptsMonoid
NixOptsMonoid :: !First Bool -> !First Bool -> !First [Text] -> !First FilePath -> !First [Text] -> !First [Text] -> !FirstFalse -> NixOptsMonoid
-- | Is using nix-shell enabled?
[nixMonoidEnable] :: NixOptsMonoid -> !First Bool
-- | Should the nix-shell be pure
[nixMonoidPureShell] :: NixOptsMonoid -> !First Bool
-- | System packages to use (given to nix-shell)
[nixMonoidPackages] :: NixOptsMonoid -> !First [Text]
-- | The path of a file containing preconfiguration of the environment (e.g
-- shell.nix)
[nixMonoidInitFile] :: NixOptsMonoid -> !First FilePath
-- | Options to be given to the nix-shell command line
[nixMonoidShellOptions] :: NixOptsMonoid -> !First [Text]
-- | Override parts of NIX_PATH (notably nixpkgs)
[nixMonoidPath] :: NixOptsMonoid -> !First [Text]
-- | Should we register gc roots so running nix-collect-garbage doesn't
-- remove nix dependencies
[nixMonoidAddGCRoots] :: NixOptsMonoid -> !FirstFalse
-- | Add GC roots arg name
nixAddGCRootsArgName :: Text
-- | Nix enable argument name.
nixEnableArgName :: Text
-- | shell.nix file path argument name.
nixInitFileArgName :: Text
-- | Nix packages (build inputs) argument name.
nixPackagesArgName :: Text
-- | NIX_PATH override argument name
nixPathArgName :: Text
-- | Nix run in pure shell argument name.
nixPureShellArgName :: Text
-- | Extra options for the nix-shell command argument name.
nixShellOptsArgName :: Text
instance GHC.Show.Show Stack.Types.Nix.NixOpts
instance GHC.Show.Show Stack.Types.Nix.NixOptsMonoid
instance GHC.Generics.Generic Stack.Types.Nix.NixOptsMonoid
instance GHC.Classes.Eq Stack.Types.Nix.NixOptsMonoid
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Nix.NixOptsMonoid)
instance GHC.Base.Semigroup Stack.Types.Nix.NixOptsMonoid
instance GHC.Base.Monoid Stack.Types.Nix.NixOptsMonoid
-- | Names for packages.
module Stack.Types.PackageName
-- | An argument which accepts a template name of the format
-- foo.hsfiles.
packageNameArgument :: Mod ArgumentFields PackageName -> Parser PackageName
module Stack.Types.Resolver
-- | Either an actual resolver value, or an abstract description of one
-- (e.g., latest nightly).
data AbstractResolver
ARLatestNightly :: AbstractResolver
ARLatestLTS :: AbstractResolver
ARLatestLTSMajor :: !Int -> AbstractResolver
ARResolver :: !RawSnapshotLocation -> AbstractResolver
ARGlobal :: AbstractResolver
readAbstractResolver :: ReadM (Unresolved AbstractResolver)
-- | Most recent Nightly and newest LTS version per major release.
data Snapshots
Snapshots :: !Day -> !IntMap Int -> Snapshots
[snapshotsNightly] :: Snapshots -> !Day
[snapshotsLts] :: Snapshots -> !IntMap Int
instance GHC.Show.Show Stack.Types.Resolver.TypesResolverException
instance GHC.Show.Show Stack.Types.Resolver.Snapshots
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Resolver.Snapshots
instance GHC.Show.Show Stack.Types.Resolver.AbstractResolver
instance RIO.Prelude.Display.Display Stack.Types.Resolver.AbstractResolver
instance GHC.Exception.Type.Exception Stack.Types.Resolver.TypesResolverException
module Stack.Options.ResolverParser
-- | Parser for the resolver
abstractResolverOptsParser :: Bool -> Parser (Unresolved AbstractResolver)
compilerOptsParser :: Bool -> Parser WantedCompiler
readCompilerVersion :: ReadM WantedCompiler
-- | Utils for the other Stack.Storage modules
module Stack.Storage.Util
handleMigrationException :: HasLogFunc env => RIO env a -> RIO env a
-- | Efficiently update a list of values stored in a database table.
updateList :: (PersistEntityBackend record ~ BaseBackend backend, PersistField parentid, Ord value, PersistEntity record, MonadIO m, PersistQueryWrite backend) => (parentid -> Int -> value -> record) -> EntityField record parentid -> parentid -> EntityField record Int -> [value] -> [value] -> ReaderT backend m ()
-- | Efficiently update a set of values stored in a database table
updateSet :: (PersistEntityBackend record ~ BaseBackend backend, PersistField parentid, PersistField value, Ord value, PersistEntity record, MonadIO m, PersistQueryWrite backend) => (parentid -> value -> record) -> EntityField record parentid -> parentid -> EntityField record value -> Set value -> Set value -> ReaderT backend m ()
-- | Template name handling.
module Stack.Types.TemplateName
-- | A template name.
data TemplateName
-- | Details for how to access a template from a remote repo.
data RepoTemplatePath
RepoTemplatePath :: RepoService -> Text -> Text -> RepoTemplatePath
[rtpService] :: RepoTemplatePath -> RepoService
[rtpUser] :: RepoTemplatePath -> Text
[rtpTemplate] :: RepoTemplatePath -> Text
-- | Services from which templates can be retrieved from a repository.
data RepoService
GitHub :: RepoService
GitLab :: RepoService
Bitbucket :: RepoService
data TemplatePath
-- | an absolute path on the filesystem
AbsPath :: Path Abs File -> TemplatePath
-- | a relative path on the filesystem, or relative to the template
-- repository. To avoid path separator conversion on Windows, the raw
-- command-line parameter passed is also given as the first field
-- (possibly with .hsfiles appended).
RelPath :: String -> Path Rel File -> TemplatePath
-- | a full URL
UrlPath :: String -> TemplatePath
RepoPath :: RepoTemplatePath -> TemplatePath
-- | Get a text representation of the template name.
templateName :: TemplateName -> Text
-- | Get the path of the template.
templatePath :: TemplateName -> TemplatePath
-- | Parse a template name from a string.
parseTemplateNameFromString :: String -> Either String TemplateName
-- | Parses a template path of the form user/template, given a
-- service
parseRepoPathWithService :: RepoService -> Text -> Maybe RepoTemplatePath
-- | An argument which accepts a template name of the format
-- foo.hsfiles or foo, ultimately normalized to
-- foo.
templateNameArgument :: Mod ArgumentFields TemplateName -> Parser TemplateName
-- | An argument which accepts a key:value pair for specifying
-- parameters.
templateParamArgument :: Mod OptionFields (Text, Text) -> Parser (Text, Text)
-- | The default template name you can use if you don't have one.
defaultTemplateName :: TemplateName
instance GHC.Show.Show Stack.Types.TemplateName.TypeTemplateNameException
instance GHC.Show.Show Stack.Types.TemplateName.RepoService
instance GHC.Classes.Ord Stack.Types.TemplateName.RepoService
instance GHC.Classes.Eq Stack.Types.TemplateName.RepoService
instance GHC.Show.Show Stack.Types.TemplateName.RepoTemplatePath
instance GHC.Classes.Ord Stack.Types.TemplateName.RepoTemplatePath
instance GHC.Classes.Eq Stack.Types.TemplateName.RepoTemplatePath
instance GHC.Show.Show Stack.Types.TemplateName.TemplatePath
instance GHC.Classes.Ord Stack.Types.TemplateName.TemplatePath
instance GHC.Classes.Eq Stack.Types.TemplateName.TemplatePath
instance GHC.Show.Show Stack.Types.TemplateName.TemplateName
instance GHC.Classes.Eq Stack.Types.TemplateName.TemplateName
instance GHC.Classes.Ord Stack.Types.TemplateName.TemplateName
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.TemplateName.TemplateName
instance GHC.Exception.Type.Exception Stack.Types.TemplateName.TypeTemplateNameException
-- | Versions for packages.
module Stack.Types.Version
data VersionRange
newtype IntersectingVersionRange
IntersectingVersionRange :: VersionRange -> IntersectingVersionRange
[getIntersectingVersionRange] :: IntersectingVersionRange -> VersionRange
data VersionCheck
MatchMinor :: VersionCheck
MatchExact :: VersionCheck
NewerMinor :: VersionCheck
-- | Display a version range
versionRangeText :: VersionRange -> Text
-- | Does this version fall within the given range?
--
-- This is the evaluation function for the VersionRange type.
withinRange :: Version -> VersionRange -> Bool
-- | A modified intersection which also simplifies, for better display.
intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange
-- | Returns the first two components, defaulting to 0 if not present
toMajorVersion :: Version -> Version
-- | Given a version range and a set of versions, find the latest version
-- from the set that is within the range.
latestApplicableVersion :: VersionRange -> Set Version -> Maybe Version
checkVersion :: VersionCheck -> Version -> Version -> Bool
-- | Get the next major version number for the given version
nextMajorVersion :: Version -> Version
-- | Get minor version (excludes any patchlevel)
minorVersion :: Version -> Version
-- | Current Stack version
stackVersion :: Version
-- | Current Stack version in the same format as yielded by
-- showVersion.
showStackVersion :: String
-- | Current Stack major version. Returns the first two components,
-- defaulting to 0 if not present
stackMajorVersion :: Version
-- | Current Stack minor version (excludes patchlevel)
stackMinorVersion :: Version
instance GHC.Show.Show Stack.Types.Version.IntersectingVersionRange
instance GHC.Show.Show Stack.Types.Version.VersionCheck
instance GHC.Classes.Ord Stack.Types.Version.VersionCheck
instance GHC.Classes.Eq Stack.Types.Version.VersionCheck
instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Version.VersionCheck
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Version.VersionCheck
instance GHC.Base.Semigroup Stack.Types.Version.IntersectingVersionRange
instance GHC.Base.Monoid Stack.Types.Version.IntersectingVersionRange
-- | Docker types.
module Stack.Types.Docker
-- | Type representing exceptions thrown by functions exported by the
-- Stack.Docker module.
data DockerException
-- | Docker must be enabled to use the command.
DockerMustBeEnabledException :: DockerException
-- | Command must be run on host OS (not in a container).
OnlyOnHostException :: DockerException
-- | docker inspect failed.
InspectFailedException :: String -> DockerException
-- | Image does not exist.
NotPulledException :: String -> DockerException
-- | Invalid output from docker images.
InvalidImagesOutputException :: String -> DockerException
-- | Invalid output from docker ps.
InvalidPSOutputException :: String -> DockerException
-- | Invalid output from docker inspect.
InvalidInspectOutputException :: String -> DockerException
-- | Could not pull a Docker image.
PullFailedException :: String -> DockerException
-- | Installed version of docker below minimum version.
DockerTooOldException :: Version -> Version -> DockerException
-- | Installed version of docker is prohibited.
DockerVersionProhibitedException :: [Version] -> Version -> DockerException
-- | Installed version of docker is out of range specified in
-- config file.
BadDockerVersionException :: VersionRange -> Version -> DockerException
-- | Invalid output from docker --version.
InvalidVersionOutputException :: DockerException
-- | Version of stack on host is too old for version in image.
HostStackTooOldException :: Version -> Maybe Version -> DockerException
-- | Version of stack in container/image is too old for version on
-- host.
ContainerStackTooOldException :: Version -> Version -> DockerException
-- | Can't determine the project root (where to put docker sandbox).
CannotDetermineProjectRootException :: DockerException
-- | docker --version failed.
DockerNotInstalledException :: DockerException
-- | Using host stack-exe on unsupported platform.
UnsupportedStackExeHostPlatformException :: DockerException
-- | stack-exe option fails to parse.
DockerStackExeParseException :: String -> DockerException
-- | Options for Docker repository or image.
data DockerMonoidRepoOrImage
DockerMonoidRepo :: String -> DockerMonoidRepoOrImage
DockerMonoidImage :: String -> DockerMonoidRepoOrImage
-- | Docker configuration.
data DockerOpts
DockerOpts :: !Bool -> !Either SomeException String -> !Bool -> !Maybe String -> !Maybe String -> !Bool -> !Bool -> !Bool -> !Maybe String -> !Maybe String -> ![String] -> ![Mount] -> !Maybe String -> ![String] -> !Maybe DockerStackExe -> !Maybe Bool -> !VersionRange -> DockerOpts
-- | Is using Docker enabled?
[dockerEnable] :: DockerOpts -> !Bool
-- | Exact Docker image tag or ID. Overrides docker-repo-*/tag.
[dockerImage] :: DockerOpts -> !Either SomeException String
-- | Does registry require login for pulls?
[dockerRegistryLogin] :: DockerOpts -> !Bool
-- | Optional username for Docker registry.
[dockerRegistryUsername] :: DockerOpts -> !Maybe String
-- | Optional password for Docker registry.
[dockerRegistryPassword] :: DockerOpts -> !Maybe String
-- | Automatically pull new images.
[dockerAutoPull] :: DockerOpts -> !Bool
-- | Whether to run a detached container
[dockerDetach] :: DockerOpts -> !Bool
-- | Create a persistent container (don't remove it when finished). Implied
-- by dockerDetach.
[dockerPersist] :: DockerOpts -> !Bool
-- | Container name to use, only makes sense from command-line with
-- dockerPersist or dockerDetach.
[dockerContainerName] :: DockerOpts -> !Maybe String
-- | The network docker uses.
[dockerNetwork] :: DockerOpts -> !Maybe String
-- | Arguments to pass directly to docker run.
[dockerRunArgs] :: DockerOpts -> ![String]
-- | Volumes to mount in the container.
[dockerMount] :: DockerOpts -> ![Mount]
-- | Volume mount mode
[dockerMountMode] :: DockerOpts -> !Maybe String
-- | Environment variables to set in the container.
[dockerEnv] :: DockerOpts -> ![String]
-- | Location of container-compatible Stack executable
[dockerStackExe] :: DockerOpts -> !Maybe DockerStackExe
-- | Set in-container user to match host's
[dockerSetUser] :: DockerOpts -> !Maybe Bool
-- | Require a version of Docker within this range.
[dockerRequireDockerVersion] :: DockerOpts -> !VersionRange
-- | An uninterpreted representation of docker options. Configurations may
-- be "cascaded" using mappend (left-biased).
data DockerOptsMonoid
DockerOptsMonoid :: !Any -> !First Bool -> !First DockerMonoidRepoOrImage -> !First Bool -> !First String -> !First String -> !FirstTrue -> !FirstFalse -> !FirstFalse -> !First String -> !First String -> ![String] -> ![Mount] -> !First String -> ![String] -> !First DockerStackExe -> !First Bool -> !IntersectingVersionRange -> DockerOptsMonoid
-- | Should Docker be defaulted to enabled (does docker: section
-- exist in the config)?
[dockerMonoidDefaultEnable] :: DockerOptsMonoid -> !Any
-- | Is using Docker enabled?
[dockerMonoidEnable] :: DockerOptsMonoid -> !First Bool
-- | Docker repository name (e.g. fpco/stack-build or
-- fpco/stack-full:lts-2.8)
[dockerMonoidRepoOrImage] :: DockerOptsMonoid -> !First DockerMonoidRepoOrImage
-- | Does registry require login for pulls?
[dockerMonoidRegistryLogin] :: DockerOptsMonoid -> !First Bool
-- | Optional username for Docker registry.
[dockerMonoidRegistryUsername] :: DockerOptsMonoid -> !First String
-- | Optional password for Docker registry.
[dockerMonoidRegistryPassword] :: DockerOptsMonoid -> !First String
-- | Automatically pull new images.
[dockerMonoidAutoPull] :: DockerOptsMonoid -> !FirstTrue
-- | Whether to run a detached container
[dockerMonoidDetach] :: DockerOptsMonoid -> !FirstFalse
-- | Create a persistent container (don't remove it when finished). Implied
-- by dockerDetach.
[dockerMonoidPersist] :: DockerOptsMonoid -> !FirstFalse
-- | Container name to use, only makes sense from command-line with
-- dockerPersist or dockerDetach.
[dockerMonoidContainerName] :: DockerOptsMonoid -> !First String
-- | See: dockerNetwork
[dockerMonoidNetwork] :: DockerOptsMonoid -> !First String
-- | Arguments to pass directly to docker run
[dockerMonoidRunArgs] :: DockerOptsMonoid -> ![String]
-- | Volumes to mount in the container
[dockerMonoidMount] :: DockerOptsMonoid -> ![Mount]
-- | Volume mount mode
[dockerMonoidMountMode] :: DockerOptsMonoid -> !First String
-- | Environment variables to set in the container
[dockerMonoidEnv] :: DockerOptsMonoid -> ![String]
-- | Location of container-compatible Stack executable
[dockerMonoidStackExe] :: DockerOptsMonoid -> !First DockerStackExe
-- | Set in-container user to match host's
[dockerMonoidSetUser] :: DockerOptsMonoid -> !First Bool
-- | See: dockerRequireDockerVersion
[dockerMonoidRequireDockerVersion] :: DockerOptsMonoid -> !IntersectingVersionRange
-- | Where to get the stack executable to run in Docker containers
data DockerStackExe
-- | Download from official bindist
DockerStackExeDownload :: DockerStackExe
-- | Host's stack (linux-x86_64 only)
DockerStackExeHost :: DockerStackExe
-- | Docker image's stack (versions must match)
DockerStackExeImage :: DockerStackExe
-- | Executable at given path
DockerStackExePath :: Path Abs File -> DockerStackExe
-- | Docker volume mount.
data Mount
Mount :: String -> String -> Mount
-- | Newtype for non-orphan FromJSON instance.
newtype VersionRangeJSON
VersionRangeJSON :: VersionRange -> VersionRangeJSON
[unVersionRangeJSON] :: VersionRangeJSON -> VersionRange
-- | Docker auto-pull argument name.
dockerAutoPullArgName :: Text
-- | Command-line argument for "docker"
dockerCmdName :: String
-- | Docker container name argument name.
dockerContainerNameArgName :: Text
-- | Platform that Docker containers run
dockerContainerPlatform :: Platform
-- | Docker detach argument name.
dockerDetachArgName :: Text
-- | Docker enable argument name.
dockerEnableArgName :: Text
-- | Argument name used to pass docker entrypoint data (only used
-- internally)
dockerEntrypointArgName :: String
-- | Docker environment variable argument name.
dockerEnvArgName :: Text
dockerHelpOptName :: String
-- | Docker image argument name.
dockerImageArgName :: Text
-- | Docker mount argument name.
dockerMountArgName :: Text
-- | Docker mount mode argument name.
dockerMountModeArgName :: Text
-- | Docker container name argument name.
dockerNetworkArgName :: Text
-- | Docker persist argument name.
dockerPersistArgName :: Text
-- | Command-line argument for docker pull.
dockerPullCmdName :: String
-- | Docker registry login argument name.
dockerRegistryLoginArgName :: Text
-- | Docker registry password argument name.
dockerRegistryPasswordArgName :: Text
-- | Docker registry username argument name.
dockerRegistryUsernameArgName :: Text
-- | Docker repo arg argument name.
dockerRepoArgName :: Text
-- | Docker require-version argument name
dockerRequireDockerVersionArgName :: Text
-- | Docker run args argument name.
dockerRunArgsArgName :: Text
-- | Docker set-user argument name
dockerSetUserArgName :: Text
-- | Docker Stack executable argument name.
dockerStackExeArgName :: Text
-- | Value for --docker-stack-exe=download
dockerStackExeDownloadVal :: String
-- | Value for --docker-stack-exe=host
dockerStackExeHostVal :: String
-- | Value for --docker-stack-exe=image
dockerStackExeImageVal :: String
-- | Parse DockerStackExe.
parseDockerStackExe :: MonadThrow m => String -> m DockerStackExe
-- | Command-line option for --internal-re-exec-version.
reExecArgName :: String
instance GHC.Show.Show Stack.Types.Docker.DockerException
instance GHC.Show.Show Stack.Types.Docker.DockerStackExe
instance GHC.Show.Show Stack.Types.Docker.DockerOpts
instance GHC.Show.Show Stack.Types.Docker.DockerMonoidRepoOrImage
instance GHC.Generics.Generic Stack.Types.Docker.DockerOptsMonoid
instance GHC.Show.Show Stack.Types.Docker.DockerOptsMonoid
instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Docker.DockerOptsMonoid)
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Docker.VersionRangeJSON
instance GHC.Base.Semigroup Stack.Types.Docker.DockerOptsMonoid
instance GHC.Base.Monoid Stack.Types.Docker.DockerOptsMonoid
instance GHC.Read.Read Stack.Types.Docker.Mount
instance GHC.Show.Show Stack.Types.Docker.Mount
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Docker.Mount
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Docker.DockerStackExe
instance GHC.Exception.Type.Exception Stack.Types.Docker.DockerException
module Stack.Types.Compiler
-- | Specifies a compiler and its version number(s).
--
-- Note that despite having this datatype, Stack isn't in a hurry to
-- support compilers other than GHC.
data ActualCompiler
ACGhc :: !Version -> ActualCompiler
ACGhcGit :: !Text -> !Text -> ActualCompiler
-- | Variety of compiler to use.
data WhichCompiler
Ghc :: WhichCompiler
-- | Repository containing the compiler sources
newtype CompilerRepository
CompilerRepository :: Text -> CompilerRepository
-- | Type representing exceptions thrown by functions exported by the
-- Stack.Types.Compiler module.
data CompilerException
GhcjsNotSupported :: CompilerException
PantryException :: PantryException -> CompilerException
defaultCompilerRepository :: CompilerRepository
getGhcVersion :: ActualCompiler -> Version
whichCompiler :: ActualCompiler -> WhichCompiler
compilerVersionText :: ActualCompiler -> Text
compilerVersionString :: ActualCompiler -> String
isWantedCompiler :: VersionCheck -> WantedCompiler -> ActualCompiler -> Bool
wantedToActual :: WantedCompiler -> Either CompilerException ActualCompiler
actualToWanted :: ActualCompiler -> WantedCompiler
parseActualCompiler :: Text -> Either CompilerException ActualCompiler
instance GHC.Show.Show Stack.Types.Compiler.CompilerException
instance GHC.Classes.Ord Stack.Types.Compiler.WhichCompiler
instance GHC.Classes.Eq Stack.Types.Compiler.WhichCompiler
instance GHC.Show.Show Stack.Types.Compiler.WhichCompiler
instance Data.Data.Data Stack.Types.Compiler.ActualCompiler
instance GHC.Classes.Ord Stack.Types.Compiler.ActualCompiler
instance GHC.Classes.Eq Stack.Types.Compiler.ActualCompiler
instance GHC.Show.Show Stack.Types.Compiler.ActualCompiler
instance GHC.Generics.Generic Stack.Types.Compiler.ActualCompiler
instance GHC.Show.Show Stack.Types.Compiler.CompilerRepository
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Compiler.CompilerRepository
instance Control.DeepSeq.NFData Stack.Types.Compiler.ActualCompiler
instance RIO.Prelude.Display.Display Stack.Types.Compiler.ActualCompiler
instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Compiler.ActualCompiler
instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Compiler.ActualCompiler
instance Data.Aeson.Types.FromJSON.FromJSONKey Stack.Types.Compiler.ActualCompiler
instance Database.Persist.Class.PersistField.PersistField Stack.Types.Compiler.ActualCompiler
instance Database.Persist.Sql.Class.PersistFieldSql Stack.Types.Compiler.ActualCompiler
instance GHC.Exception.Type.Exception Stack.Types.Compiler.CompilerException
-- | A sourcemap maps a package name to how it should be built, including
-- source code, flags, options, etc. This module contains various stages
-- of source map construction. See the build_overview.md doc for
-- details on these stages.
module Stack.Types.SourceMap
-- | A source map with information on the wanted (but not actual) compiler.
-- This is derived by parsing the stack.yaml file for
-- packages, extra-deps, their configuration (e.g.,
-- flags and options), and parsing the snapshot it refers to. It does not
-- include global packages or any information from the command line.
--
-- Invariant: a PackageName appears in either smwProject
-- or smwDeps, but not both.
data SMWanted
SMWanted :: !WantedCompiler -> !Map PackageName ProjectPackage -> !Map PackageName DepPackage -> !RawSnapshotLocation -> SMWanted
[smwCompiler] :: SMWanted -> !WantedCompiler
[smwProject] :: SMWanted -> !Map PackageName ProjectPackage
[smwDeps] :: SMWanted -> !Map PackageName DepPackage
-- | Where this snapshot is loaded from.
[smwSnapshotLocation] :: SMWanted -> !RawSnapshotLocation
-- | Adds in actual compiler information to SMWanted, in particular
-- the contents of the global package database.
--
-- Invariant: a PackageName appears in only one of the
-- Maps.
data SMActual global
SMActual :: !ActualCompiler -> !Map PackageName ProjectPackage -> !Map PackageName DepPackage -> !Map PackageName global -> SMActual global
[smaCompiler] :: SMActual global -> !ActualCompiler
[smaProject] :: SMActual global -> !Map PackageName ProjectPackage
[smaDeps] :: SMActual global -> !Map PackageName DepPackage
[smaGlobal] :: SMActual global -> !Map PackageName global
-- | How a package is intended to be built
data Target
-- | Build all of the default components.
TargetAll :: !PackageType -> Target
-- | Only build specific components
TargetComps :: !Set NamedComponent -> Target
data PackageType
PTProject :: PackageType
PTDependency :: PackageType
-- | Builds on an SMActual by resolving the targets specified on the
-- command line, potentially adding in new dependency packages in the
-- process.
data SMTargets
SMTargets :: !Map PackageName Target -> !Map PackageName DepPackage -> SMTargets
[smtTargets] :: SMTargets -> !Map PackageName Target
[smtDeps] :: SMTargets -> !Map PackageName DepPackage
-- | The final source map, taking an SMTargets and applying all
-- command line flags and GHC options.
data SourceMap
SourceMap :: !SMTargets -> !ActualCompiler -> !Map PackageName ProjectPackage -> !Map PackageName DepPackage -> !Map PackageName GlobalPackage -> SourceMap
-- | Doesn't need to be included in the hash, does not affect the source
-- map.
[smTargets] :: SourceMap -> !SMTargets
-- | Need to hash the compiler version _and_ its installation path. Ideally
-- there would be some kind of output from GHC telling us some unique ID
-- for the compiler itself.
[smCompiler] :: SourceMap -> !ActualCompiler
-- | Doesn't need to be included in hash, doesn't affect any of the
-- packages that get stored in the snapshot database.
[smProject] :: SourceMap -> !Map PackageName ProjectPackage
-- | Need to hash all of the immutable dependencies, can ignore the mutable
-- dependencies.
[smDeps] :: SourceMap -> !Map PackageName DepPackage
-- | Doesn't actually need to be hashed, implicitly captured by smCompiler.
-- Can be broken if someone installs new global packages. We can document
-- that as not supported, _or_ we could actually include all of this in
-- the hash and make Stack more resilient.
[smGlobal] :: SourceMap -> !Map PackageName GlobalPackage
-- | Flag showing if package comes from a snapshot needed to ignore
-- dependency bounds between such packages
data FromSnapshot
FromSnapshot :: FromSnapshot
NotFromSnapshot :: FromSnapshot
-- | A view of a dependency package, specified in stack.yaml
data DepPackage
DepPackage :: !CommonPackage -> !PackageLocation -> !Bool -> !FromSnapshot -> DepPackage
[dpCommon] :: DepPackage -> !CommonPackage
[dpLocation] :: DepPackage -> !PackageLocation
-- | Should the package be hidden after registering? Affects the script
-- interpreter's module name import parser.
[dpHidden] :: DepPackage -> !Bool
-- | Needed to ignore bounds between snapshot packages See
-- https://github.com/commercialhaskell/stackage/issues/3185
[dpFromSnapshot] :: DepPackage -> !FromSnapshot
-- | A view of a project package needed for resolving components
data ProjectPackage
ProjectPackage :: !CommonPackage -> !Path Abs File -> !ResolvedPath Dir -> ProjectPackage
[ppCommon] :: ProjectPackage -> !CommonPackage
[ppCabalFP] :: ProjectPackage -> !Path Abs File
[ppResolvedDir] :: ProjectPackage -> !ResolvedPath Dir
-- | Common settings for both dependency and project package.
data CommonPackage
CommonPackage :: !IO GenericPackageDescription -> !PackageName -> !Map FlagName Bool -> ![Text] -> ![Text] -> !Bool -> CommonPackage
[cpGPD] :: CommonPackage -> !IO GenericPackageDescription
[cpName] :: CommonPackage -> !PackageName
-- | overrides default flags
[cpFlags] :: CommonPackage -> !Map FlagName Bool
[cpGhcOptions] :: CommonPackage -> ![Text]
[cpCabalConfigOpts] :: CommonPackage -> ![Text]
[cpHaddocks] :: CommonPackage -> !Bool
newtype GlobalPackageVersion
GlobalPackageVersion :: Version -> GlobalPackageVersion
-- | A view of a package installed in the global package database also
-- could include marker for a replaced global package (could be replaced
-- because of a replaced dependency)
data GlobalPackage
GlobalPackage :: !Version -> GlobalPackage
ReplacedGlobalPackage :: ![PackageName] -> GlobalPackage
isReplacedGlobal :: GlobalPackage -> Bool
-- | A unique hash for the immutable portions of a SourceMap.
newtype SourceMapHash
SourceMapHash :: SHA256 -> SourceMapHash
-- | Returns relative directory name with source map's hash
smRelDir :: MonadThrow m => SourceMapHash -> m (Path Rel Dir)
instance GHC.Show.Show Stack.Types.SourceMap.FromSnapshot
instance GHC.Classes.Eq Stack.Types.SourceMap.GlobalPackage
instance GHC.Show.Show Stack.Types.SourceMap.PackageType
instance GHC.Classes.Eq Stack.Types.SourceMap.PackageType
module Stack.Unpack
-- | Intended to work for the command line command.
unpackPackages :: forall env. (HasPantryConfig env, HasLogFunc env, HasProcessContext env) => Maybe RawSnapshot -> Path Abs Dir -> [String] -> RIO env ()
instance GHC.Show.Show Stack.Unpack.UnpackException
instance GHC.Exception.Type.Exception Stack.Unpack.UnpackException
module System.Info.ShortPathName
getShortPathName :: FilePath -> IO FilePath
module System.Permissions
setScriptPerms :: MonadIO m => FilePath -> m ()
-- | True if using Windows OS.
osIsWindows :: Bool
setFileExecutable :: MonadIO m => FilePath -> m ()
-- | Constants used throughout the project.
module Stack.Constants
-- | Path where build plans are stored.
buildPlanDir :: Path Abs Dir -> Path Abs Dir
-- | Path where binary caches of the build plans are stored.
buildPlanCacheDir :: Path Abs Dir -> Path Abs Dir
-- | Extensions used for Haskell modules. Excludes preprocessor ones.
haskellFileExts :: [Text]
-- | Extensions for modules that are preprocessed by common preprocessors.
haskellDefaultPreprocessorExts :: [Text]
-- | The filename used for the Stack project-level configuration file.
stackDotYaml :: Path Rel File
-- | Environment variable used to override the '.stack-work' relative dir.
stackWorkEnvVar :: String
-- | Environment variable used to override the '~/.stack' location.
stackRootEnvVar :: String
-- | Environment variable used to indicate XDG directories should be used.
stackXdgEnvVar :: String
-- | Option name for the global Stack root.
stackRootOptionName :: String
-- | Option name for the global Stack configuration file.
stackGlobalConfigOptionName :: String
-- | Environment variable used to override the location of the Pantry store
pantryRootEnvVar :: String
-- | Deprecated option name for the global Stack root.
--
-- Deprecated since stack-1.1.0.
--
-- TODO: Remove occurrences of this variable and use
-- stackRootOptionName only after an appropriate deprecation
-- period.
deprecatedStackRootOptionName :: String
-- | Environment variable used to indicate Stack is running in container.
inContainerEnvVar :: String
-- | Environment variable used to indicate Stack is running in container.
-- although we already have STACK_IN_NIX_EXTRA_ARGS that is set in the
-- same conditions, it can happen that STACK_IN_NIX_EXTRA_ARGS is set to
-- empty.
inNixShellEnvVar :: String
-- | Name of the stack program, uppercased
stackProgNameUpper :: String
-- | The comment to 'see
-- https://downloads.haskell.org/~ghc/7.10.1/docs/html/libraries/ghc/src/Module.html#integerPackageKey\'
-- appears to be out of date.
--
-- See 'Note [About units]' and 'Wired-in units' at
-- https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/Unit.hs.
--
-- The 'wired-in packages' appear to have been replaced by those that
-- have (e.g)
--
-- -- ghc-options: -this-unit-id ghc-prim ---- -- in their Cabal file because they are 'magic'. wiredInPackages :: Set PackageName -- | Just to avoid repetition and magic strings. cabalPackageName :: PackageName -- | Deprecated implicit global project directory used when outside of a -- project. implicitGlobalProjectDirDeprecated :: Path Abs Dir -> Path Abs Dir -- | Implicit global project directory used when outside of a project. -- Normally, getImplicitGlobalProjectDir should be used instead. implicitGlobalProjectDir :: Path Abs Dir -> Path Abs Dir -- | Deprecated default global config path. defaultUserConfigPathDeprecated :: Path Abs Dir -> Path Abs File -- | Default global config path. Normally, -- getDefaultUserConfigPath should be used instead. defaultUserConfigPath :: Path Abs Dir -> Path Abs File -- | Deprecated default global config path. Note that this will be -- Nothing on Windows, which is by design. defaultGlobalConfigPathDeprecated :: Maybe (Path Abs File) -- | Default global config path. Normally, -- getDefaultGlobalConfigPath should be used instead. Note that -- this will be Nothing on Windows, which is by design. defaultGlobalConfigPath :: Maybe (Path Abs File) -- | Environment variable that stores a variant to append to -- platform-specific directory names. Used to ensure incompatible -- binaries aren't shared between Docker builds and host platformVariantEnvVar :: String -- | Provides --ghc-options for Ghc compilerOptionsCabalFlag :: WhichCompiler -> String -- | The flag to pass to GHC when we want to force its output to be -- colorized. ghcColorForceFlag :: String -- | The minimum allowed terminal width. Used for pretty-printing. minTerminalWidth :: Int -- | The maximum allowed terminal width. Used for pretty-printing. maxTerminalWidth :: Int -- | The default terminal width. Used for pretty-printing when we can't -- automatically detect it and when the user doesn't supply one. defaultTerminalWidth :: Int -- | True if using Windows OS. osIsWindows :: Bool relFileSetupHs :: Path Rel File relFileSetupLhs :: Path Rel File relFileHpackPackageConfig :: Path Rel File relDirGlobalAutogen :: Path Rel Dir relDirAutogen :: Path Rel Dir relDirLogs :: Path Rel Dir relFileCabalMacrosH :: Path Rel File relDirBuild :: Path Rel Dir relDirBin :: Path Rel Dir relDirPantry :: Path Rel Dir relDirPrograms :: Path Rel Dir relDirUpperPrograms :: Path Rel Dir relDirStackProgName :: Path Rel Dir relDirStackWork :: Path Rel Dir relFileReadmeTxt :: Path Rel File relDirScript :: Path Rel Dir relFileConfigYaml :: Path Rel File relDirSnapshots :: Path Rel Dir relDirGlobalHints :: Path Rel Dir relFileGlobalHintsYaml :: Path Rel File relDirInstall :: Path Rel Dir relDirCompilerTools :: Path Rel Dir relDirHoogle :: Path Rel Dir relFileDatabaseHoo :: Path Rel File relDirPkgdb :: Path Rel Dir relFileStorage :: Path Rel File relDirLoadedSnapshotCache :: Path Rel Dir -- | Suffix applied to an installation root to get the bin dir bindirSuffix :: Path Rel Dir -- | Suffix applied to an installation root to get the doc dir docDirSuffix :: Path Rel Dir relDirHpc :: Path Rel Dir relDirLib :: Path Rel Dir relDirShare :: Path Rel Dir relDirLibexec :: Path Rel Dir relDirEtc :: Path Rel Dir setupGhciShimCode :: Builder relDirSetupExeCache :: Path Rel Dir relDirSetupExeSrc :: Path Rel Dir relFileConfigure :: Path Rel File relDirDist :: Path Rel Dir relFileSetupMacrosH :: Path Rel File relDirSetup :: Path Rel Dir relFileSetupLower :: Path Rel File relDirMingw :: Path Rel Dir relDirMingw32 :: Path Rel Dir relDirMingw64 :: Path Rel Dir relDirLocal :: Path Rel Dir relDirUsr :: Path Rel Dir relDirInclude :: Path Rel Dir relFileIndexHtml :: Path Rel File relDirAll :: Path Rel Dir relFilePackageCache :: Path Rel File relFileDockerfile :: Path Rel File relDirHaskellStackGhci :: Path Rel Dir relFileGhciScript :: Path Rel File relDirCombined :: Path Rel Dir relFileHpcIndexHtml :: Path Rel File relDirCustom :: Path Rel Dir relDirPackageConfInplace :: Path Rel Dir relDirExtraTixFiles :: Path Rel Dir relDirInstalledPackages :: Path Rel Dir backupUrlRelPath :: Path Rel File relDirDotLocal :: Path Rel Dir relDirDotSsh :: Path Rel Dir relDirDotStackProgName :: Path Rel Dir relDirUnderHome :: Path Rel Dir relDirSrc :: Path Rel Dir relFileLibtinfoSo5 :: Path Rel File relFileLibtinfoSo6 :: Path Rel File relFileLibncurseswSo6 :: Path Rel File relFileLibgmpSo10 :: Path Rel File relFileLibgmpSo3 :: Path Rel File relDirNewCabal :: Path Rel Dir relFileSetupExe :: Path Rel File relFileSetupUpper :: Path Rel File relFile7zexe :: Path Rel File relFile7zdll :: Path Rel File relFileMainHs :: Path Rel File relFileStack :: Path Rel File relFileStackDotExe :: Path Rel File relFileStackDotTmpDotExe :: Path Rel File relFileStackDotTmp :: Path Rel File ghcShowOptionsOutput :: [String] -- | Relative paths inside a GHC repo to the Hadrian build batch script. -- The second path is maintained for compatibility with older GHC -- versions. hadrianScriptsWindows :: [Path Rel File] -- | Relative paths inside a GHC repo to the Hadrian build shell script The -- second path is maintained for compatibility with older GHC versions. hadrianScriptsPosix :: [Path Rel File] -- | Used in Stack.Setup for detecting libtinfo, see comments at use site usrLibDirs :: [Path Abs Dir] -- | Relative file path for a temporary GHC environment file for tests testGhcEnvRelFile :: Path Rel File -- | File inside a dist directory to use for locking relFileBuildLock :: Path Rel File -- | What should the default be for stack-developer-mode stackDeveloperModeDefault :: Bool -- | The footer to the help for Stack's subcommands globalFooter :: String instance GHC.Show.Show Stack.Constants.ConstantsException instance GHC.Exception.Type.Exception Stack.Constants.ConstantsException -- | The Config type. module Stack.Types.Config -- | Class for environment values which have a Platform class HasPlatform env platformL :: HasPlatform env => Lens' env Platform platformL :: (HasPlatform env, HasConfig env) => Lens' env Platform platformVariantL :: HasPlatform env => Lens' env PlatformVariant platformVariantL :: (HasPlatform env, HasConfig env) => Lens' env PlatformVariant -- | A variant of the platform, used to differentiate Docker builds from -- host data PlatformVariant PlatformVariantNone :: PlatformVariant PlatformVariant :: String -> PlatformVariant -- | Class for environment values which have a Runner. class (HasProcessContext env, HasLogFunc env) => HasRunner env runnerL :: HasRunner env => Lens' env Runner -- | The base environment that almost everything in Stack runs in, based -- off of parsing command line options in GlobalOpts. Provides -- logging and process execution. data Runner Runner :: !GlobalOpts -> !Bool -> !LogFunc -> !Int -> !ProcessContext -> Runner [runnerGlobalOpts] :: Runner -> !GlobalOpts [runnerUseColor] :: Runner -> !Bool [runnerLogFunc] :: Runner -> !LogFunc [runnerTermWidth] :: Runner -> !Int [runnerProcessContext] :: Runner -> !ProcessContext data ColorWhen ColorNever :: ColorWhen ColorAlways :: ColorWhen ColorAuto :: ColorWhen -- | See globalTerminal terminalL :: HasRunner env => Lens' env Bool -- | See globalReExecVersion reExecL :: HasRunner env => SimpleGetter env Bool -- | The top-level Stackage configuration. data Config Config :: !Path Rel Dir -> !Path Abs File -> !BuildOpts -> !DockerOpts -> !NixOpts -> !EnvSettings -> IO ProcessContext -> !Path Abs Dir -> !Path Abs Dir -> !Bool -> !Bool -> !Platform -> !PlatformVariant -> !Maybe GHCVariant -> !Maybe CompilerBuild -> !Text -> !Bool -> !Bool -> !Bool -> !Bool -> !VersionCheck -> !CompilerRepository -> !Path Abs Dir -> !VersionRange -> !Int -> !Maybe (Path Abs File) -> ![FilePath] -> ![FilePath] -> ![Text] -> !Bool -> !Map Text Text -> !Maybe SCM -> !Map PackageName [Text] -> !Map ApplyGhcOptions [Text] -> !Map CabalConfigKey [Text] -> ![String] -> !SetupInfo -> !PvpBounds -> !Bool -> !Bool -> !ApplyGhcOptions -> !Bool -> !Maybe [PackageName] -> !Maybe TemplateName -> !Bool -> !DumpLogs -> !ProjectConfig (Project, Path Abs File) -> !Bool -> !Bool -> !Text -> !Runner -> !PantryConfig -> !Path Abs Dir -> !Maybe AbstractResolver -> !UserStorage -> !Bool -> !Bool -> !Bool -> !Bool -> Config -- | this allows to override .stack-work directory [configWorkDir] :: Config -> !Path Rel Dir -- | Path to user configuration file (usually ~.stackconfig.yaml) [configUserConfigPath] :: Config -> !Path Abs File -- | Build configuration [configBuild] :: Config -> !BuildOpts -- | Docker configuration [configDocker] :: Config -> !DockerOpts -- | Execution environment (e.g nix-shell) configuration [configNix] :: Config -> !NixOpts -- | Environment variables to be passed to external tools [configProcessContextSettings] :: Config -> !EnvSettings -> IO ProcessContext -- | Non-platform-specific path containing local installations [configLocalProgramsBase] :: Config -> !Path Abs Dir -- | Path containing local installations (mainly GHC) [configLocalPrograms] :: Config -> !Path Abs Dir -- | Hide the Template Haskell "Loading package ..." messages from the -- console [configHideTHLoading] :: Config -> !Bool -- | Prefix build output with timestamps for each line. [configPrefixTimestamps] :: Config -> !Bool -- | The platform we're building for, used in many directory names [configPlatform] :: Config -> !Platform -- | Variant of the platform, also used in directory names [configPlatformVariant] :: Config -> !PlatformVariant -- | The variant of GHC requested by the user. [configGHCVariant] :: Config -> !Maybe GHCVariant -- | Override build of the compiler distribution (e.g. standard, gmp4, -- tinfo6) [configGHCBuild] :: Config -> !Maybe CompilerBuild -- | URL of a JSON file providing the latest LTS and Nightly snapshots. [configLatestSnapshot] :: Config -> !Text -- | Should we use the system-installed GHC (on the PATH) if available? Can -- be overridden by command line options. [configSystemGHC] :: Config -> !Bool -- | Should we automatically install GHC if missing or the wrong version is -- available? Can be overridden by command line options. [configInstallGHC] :: Config -> !Bool -- | Don't bother checking the GHC version or architecture. [configSkipGHCCheck] :: Config -> !Bool -- | On Windows: don't use a sandboxed MSYS [configSkipMsys] :: Config -> !Bool -- | Specifies which versions of the compiler are acceptable. [configCompilerCheck] :: Config -> !VersionCheck -- | Specifies the repository containing the compiler sources [configCompilerRepository] :: Config -> !CompilerRepository -- | Directory we should install executables into [configLocalBin] :: Config -> !Path Abs Dir -- | Require a version of Stack within this range. [configRequireStackVersion] :: Config -> !VersionRange -- | How many concurrent jobs to run, defaults to number of capabilities [configJobs] :: Config -> !Int -- | Optional gcc override path [configOverrideGccPath] :: Config -> !Maybe (Path Abs File) -- |
-- ".stack-work" --workDirL :: HasConfig env => Lens' env (Path Rel Dir) -- |
-- STACK_ROOT/hooks/ghc-install.sh --ghcInstallHook :: HasConfig env => RIO env (Path Abs File) type AddCommand = ExceptT (RIO Runner ()) (Writer (Mod CommandFields (RIO Runner (), GlobalOptsMonoid))) () data EvalOpts EvalOpts :: !String -> !ExecOptsExtra -> EvalOpts [evalArg] :: EvalOpts -> !String [evalExtra] :: EvalOpts -> !ExecOptsExtra data ExecOpts ExecOpts :: !SpecialExecCmd -> ![String] -> !ExecOptsExtra -> ExecOpts [eoCmd] :: ExecOpts -> !SpecialExecCmd [eoArgs] :: ExecOpts -> ![String] [eoExtra] :: ExecOpts -> !ExecOptsExtra data SpecialExecCmd ExecCmd :: String -> SpecialExecCmd ExecRun :: SpecialExecCmd ExecGhc :: SpecialExecCmd ExecRunGhc :: SpecialExecCmd data ExecOptsExtra ExecOptsExtra :: !EnvSettings -> ![String] -> ![String] -> !Maybe FilePath -> ExecOptsExtra [eoEnvSettings] :: ExecOptsExtra -> !EnvSettings [eoPackages] :: ExecOptsExtra -> ![String] [eoRtsOptions] :: ExecOptsExtra -> ![String] [eoCwd] :: ExecOptsExtra -> !Maybe FilePath -- | Build of the compiler distribution (e.g. standard, gmp4, tinfo6) | -- Information for a file to download. data DownloadInfo DownloadInfo :: Text -> Maybe Int -> Maybe ByteString -> Maybe ByteString -> DownloadInfo -- | URL or absolute file path [downloadInfoUrl] :: DownloadInfo -> Text [downloadInfoContentLength] :: DownloadInfo -> Maybe Int [downloadInfoSha1] :: DownloadInfo -> Maybe ByteString [downloadInfoSha256] :: DownloadInfo -> Maybe ByteString data VersionedDownloadInfo VersionedDownloadInfo :: Version -> DownloadInfo -> VersionedDownloadInfo [vdiVersion] :: VersionedDownloadInfo -> Version [vdiDownloadInfo] :: VersionedDownloadInfo -> DownloadInfo data GHCDownloadInfo GHCDownloadInfo :: [Text] -> Map Text Text -> DownloadInfo -> GHCDownloadInfo [gdiConfigureOpts] :: GHCDownloadInfo -> [Text] [gdiConfigureEnv] :: GHCDownloadInfo -> Map Text Text [gdiDownloadInfo] :: GHCDownloadInfo -> DownloadInfo data SetupInfo SetupInfo :: Maybe DownloadInfo -> Maybe DownloadInfo -> Map Text VersionedDownloadInfo -> Map Text (Map Version GHCDownloadInfo) -> Map Text (Map Version DownloadInfo) -> SetupInfo [siSevenzExe] :: SetupInfo -> Maybe DownloadInfo [siSevenzDll] :: SetupInfo -> Maybe DownloadInfo [siMsys2] :: SetupInfo -> Map Text VersionedDownloadInfo [siGHCs] :: SetupInfo -> Map Text (Map Version GHCDownloadInfo) [siStack] :: SetupInfo -> Map Text (Map Version DownloadInfo) -- | Data passed into Docker container for the Docker entrypoint's use newtype DockerEntrypoint DockerEntrypoint :: Maybe DockerUser -> DockerEntrypoint -- | UIDGIDetc of host user, if we wish to perform UID/GID switch in -- container [deUser] :: DockerEntrypoint -> Maybe DockerUser -- | Docker host user info data DockerUser DockerUser :: UserID -> GroupID -> [GroupID] -> FileMode -> DockerUser -- | uid [duUid] :: DockerUser -> UserID -- | gid [duGid] :: DockerUser -> GroupID -- | Supplemental groups [duGroups] :: DockerUser -> [GroupID] -- | File creation mask } [duUmask] :: DockerUser -> FileMode -- | The compiler specified by the SnapshotDef. This may be -- different from the actual compiler used! wantedCompilerVersionL :: HasBuildConfig s => Getting r s WantedCompiler -- | The version of the compiler which will actually be used. May be -- different than that specified in the SnapshotDef and returned -- by wantedCompilerVersionL. actualCompilerVersionL :: HasSourceMap env => SimpleGetter env ActualCompiler -- | An environment which ensures that the given compiler is available on -- the PATH class HasCompiler env compilerPathsL :: HasCompiler env => SimpleGetter env CompilerPaths -- | Dump information for a single package data DumpPackage DumpPackage :: !GhcPkgId -> !PackageIdentifier -> !Maybe PackageIdentifier -> !Maybe License -> ![FilePath] -> ![Text] -> !Bool -> !Set ModuleName -> ![GhcPkgId] -> ![FilePath] -> !Maybe FilePath -> !Bool -> DumpPackage [dpGhcPkgId] :: DumpPackage -> !GhcPkgId [dpPackageIdent] :: DumpPackage -> !PackageIdentifier [dpParentLibIdent] :: DumpPackage -> !Maybe PackageIdentifier [dpLicense] :: DumpPackage -> !Maybe License [dpLibDirs] :: DumpPackage -> ![FilePath] [dpLibraries] :: DumpPackage -> ![Text] [dpHasExposedModules] :: DumpPackage -> !Bool [dpExposedModules] :: DumpPackage -> !Set ModuleName [dpDepends] :: DumpPackage -> ![GhcPkgId] [dpHaddockInterfaces] :: DumpPackage -> ![FilePath] [dpHaddockHtml] :: DumpPackage -> !Maybe FilePath [dpIsExposed] :: DumpPackage -> !Bool -- | Paths on the filesystem for the compiler we're using data CompilerPaths CompilerPaths :: !ActualCompiler -> !Arch -> !CompilerBuild -> !Path Abs File -> !GhcPkgExe -> !Path Abs File -> !Path Abs File -> !Bool -> !Version -> !Path Abs Dir -> !ByteString -> !Map PackageName DumpPackage -> CompilerPaths [cpCompilerVersion] :: CompilerPaths -> !ActualCompiler [cpArch] :: CompilerPaths -> !Arch [cpBuild] :: CompilerPaths -> !CompilerBuild [cpCompiler] :: CompilerPaths -> !Path Abs File -- | ghc-pkg or equivalent [cpPkg] :: CompilerPaths -> !GhcPkgExe -- | runghc [cpInterpreter] :: CompilerPaths -> !Path Abs File -- | haddock, in IO to allow deferring the lookup [cpHaddock] :: CompilerPaths -> !Path Abs File -- | Is this a Stack-sandboxed installation? [cpSandboxed] :: CompilerPaths -> !Bool -- | This is the version of Cabal that Stack will use to compile Setup.hs -- files in the build process. -- -- Note that this is not necessarily the same version as the one that -- Stack depends on as a library and which is displayed when running -- stack ls dependencies | grep Cabal in the Stack project. [cpCabalVersion] :: CompilerPaths -> !Version -- | Global package database [cpGlobalDB] :: CompilerPaths -> !Path Abs Dir -- | Output of ghc --info [cpGhcInfo] :: CompilerPaths -> !ByteString [cpGlobalDump] :: CompilerPaths -> !Map PackageName DumpPackage -- | Location of the ghc-pkg executable newtype GhcPkgExe GhcPkgExe :: Path Abs File -> GhcPkgExe -- | Get the GhcPkgExe from a HasCompiler environment getGhcPkgExe :: HasCompiler env => RIO env GhcPkgExe cpWhich :: (MonadReader env m, HasCompiler env) => m WhichCompiler data ExtraDirs ExtraDirs :: ![Path Abs Dir] -> ![Path Abs Dir] -> ![Path Abs Dir] -> ExtraDirs [edBins] :: ExtraDirs -> ![Path Abs Dir] [edInclude] :: ExtraDirs -> ![Path Abs Dir] [edLib] :: ExtraDirs -> ![Path Abs Dir] buildOptsL :: HasConfig s => Lens' s BuildOpts globalOptsL :: HasRunner env => Lens' env GlobalOpts buildOptsInstallExesL :: Lens' BuildOpts Bool buildOptsMonoidHaddockL :: Lens' BuildOptsMonoid (Maybe Bool) buildOptsMonoidTestsL :: Lens' BuildOptsMonoid (Maybe Bool) buildOptsMonoidBenchmarksL :: Lens' BuildOptsMonoid (Maybe Bool) buildOptsMonoidInstallExesL :: Lens' BuildOptsMonoid (Maybe Bool) buildOptsHaddockL :: Lens' BuildOpts Bool globalOptsBuildOptsMonoidL :: Lens' GlobalOpts BuildOptsMonoid stackRootL :: HasConfig s => Lens' s (Path Abs Dir) stackGlobalConfigL :: HasConfig s => Lens' s (Path Abs File) cabalVersionL :: HasCompiler env => SimpleGetter env Version whichCompilerL :: Getting r ActualCompiler WhichCompiler envOverrideSettingsL :: HasConfig env => Lens' env (EnvSettings -> IO ProcessContext) shouldForceGhcColorFlag :: (HasRunner env, HasEnvConfig env) => RIO env Bool appropriateGhcColorFlag :: (HasRunner env, HasEnvConfig env) => RIO env (Maybe String) -- | In dev mode, print as a warning, otherwise as debug prettyStackDevL :: HasConfig env => [StyleDoc] -> RIO env () -- | view is a synonym for (^.), generalised for -- MonadReader (we are able to use it instead of (^.) since -- functions are instances of the MonadReader class): -- --
-- >>> view _1 (1, 2) -- 1 ---- -- When you're using Reader for config and your config type has -- lenses generated for it, most of the time you'll be using view -- instead of asks: -- --
-- doSomething :: (MonadReader Config m) => m Int -- doSomething = do -- thingy <- view setting1 -- same as “asks (^. setting1)” -- anotherThingy <- view setting2 -- ... --view :: MonadReader s m => Getting a s a -> m a -- | to creates a getter from any function: -- --
-- a ^. to f = f a ---- -- It's most useful in chains, because it lets you mix lenses and -- ordinary functions. Suppose you have a record which comes from some -- third-party library and doesn't have any lens accessors. You want to -- do something like this: -- --
-- value ^. _1 . field . at 2 ---- -- However, field isn't a getter, and you have to do this -- instead: -- --
-- field (value ^. _1) ^. at 2 ---- -- but now value is in the middle and it's hard to read the -- resulting code. A variant with to is prettier and more -- readable: -- --
-- value ^. _1 . to field . at 2 --to :: (s -> a) -> SimpleGetter s a instance GHC.Show.Show Stack.Types.Config.ConfigException instance GHC.Show.Show Stack.Types.Config.ConfigPrettyException instance GHC.Show.Show Stack.Types.Config.ParseAbsolutePathException instance GHC.Generics.Generic Stack.Types.Config.ColorWhen instance GHC.Show.Show Stack.Types.Config.ColorWhen instance GHC.Classes.Eq Stack.Types.Config.ColorWhen instance GHC.Classes.Ord Stack.Types.Config.CabalConfigKey instance GHC.Classes.Eq Stack.Types.Config.CabalConfigKey instance GHC.Read.Read Stack.Types.Config.CabalConfigKey instance GHC.Show.Show Stack.Types.Config.CabalConfigKey instance GHC.Enum.Bounded Stack.Types.Config.ApplyGhcOptions instance GHC.Enum.Enum Stack.Types.Config.ApplyGhcOptions instance GHC.Classes.Ord Stack.Types.Config.ApplyGhcOptions instance GHC.Classes.Eq Stack.Types.Config.ApplyGhcOptions instance GHC.Read.Read Stack.Types.Config.ApplyGhcOptions instance GHC.Show.Show Stack.Types.Config.ApplyGhcOptions instance GHC.Generics.Generic Stack.Types.Config.AllowNewerDeps instance GHC.Classes.Ord Stack.Types.Config.AllowNewerDeps instance GHC.Classes.Eq Stack.Types.Config.AllowNewerDeps instance GHC.Read.Read Stack.Types.Config.AllowNewerDeps instance GHC.Show.Show Stack.Types.Config.AllowNewerDeps instance GHC.Enum.Bounded Stack.Types.Config.DumpLogs instance GHC.Enum.Enum Stack.Types.Config.DumpLogs instance GHC.Classes.Ord Stack.Types.Config.DumpLogs instance GHC.Classes.Eq Stack.Types.Config.DumpLogs instance GHC.Read.Read Stack.Types.Config.DumpLogs instance GHC.Show.Show Stack.Types.Config.DumpLogs instance GHC.Classes.Ord Stack.Types.Config.EnvSettings instance GHC.Classes.Eq Stack.Types.Config.EnvSettings instance GHC.Show.Show Stack.Types.Config.EnvSettings instance GHC.Classes.Eq Stack.Types.Config.SpecialExecCmd instance GHC.Show.Show Stack.Types.Config.SpecialExecCmd instance GHC.Show.Show Stack.Types.Config.ExecOptsExtra instance GHC.Show.Show Stack.Types.Config.ExecOpts instance GHC.Show.Show Stack.Types.Config.EvalOpts instance GHC.Show.Show Stack.Types.Config.StackYamlLoc instance GHC.Enum.Bounded Stack.Types.Config.LockFileBehavior instance GHC.Enum.Enum Stack.Types.Config.LockFileBehavior instance GHC.Show.Show Stack.Types.Config.LockFileBehavior instance GHC.Show.Show Stack.Types.Config.Curator instance GHC.Show.Show Stack.Types.Config.Project instance GHC.Show.Show Stack.Types.Config.SCM instance GHC.Show.Show Stack.Types.Config.GHCVariant instance GHC.Show.Show Stack.Types.Config.DownloadInfo instance GHC.Show.Show Stack.Types.Config.VersionedDownloadInfo instance GHC.Show.Show Stack.Types.Config.GHCDownloadInfo instance GHC.Show.Show Stack.Types.Config.SetupInfo instance GHC.Enum.Bounded Stack.Types.Config.PvpBoundsType instance GHC.Enum.Enum Stack.Types.Config.PvpBoundsType instance GHC.Classes.Ord Stack.Types.Config.PvpBoundsType instance GHC.Classes.Eq Stack.Types.Config.PvpBoundsType instance GHC.Read.Read Stack.Types.Config.PvpBoundsType instance GHC.Show.Show Stack.Types.Config.PvpBoundsType instance GHC.Classes.Ord Stack.Types.Config.PvpBounds instance GHC.Classes.Eq Stack.Types.Config.PvpBounds instance GHC.Read.Read Stack.Types.Config.PvpBounds instance GHC.Show.Show Stack.Types.Config.PvpBounds instance GHC.Generics.Generic Stack.Types.Config.ConfigMonoid instance GHC.Show.Show Stack.Types.Config.ConfigMonoid instance GHC.Show.Show Stack.Types.Config.DockerUser instance GHC.Read.Read Stack.Types.Config.DockerUser instance GHC.Show.Show Stack.Types.Config.DockerEntrypoint instance GHC.Read.Read Stack.Types.Config.DockerEntrypoint instance GHC.Generics.Generic Stack.Types.Config.GlobalOptsMonoid instance GHC.Show.Show Stack.Types.Config.GlobalOpts instance GHC.Classes.Ord Stack.Types.Config.GhcOptionKey instance GHC.Classes.Eq Stack.Types.Config.GhcOptionKey instance GHC.Show.Show Stack.Types.Config.GhcPkgExe instance GHC.Classes.Eq Stack.Types.Config.DumpPackage instance GHC.Read.Read Stack.Types.Config.DumpPackage instance GHC.Show.Show Stack.Types.Config.DumpPackage instance GHC.Show.Show Stack.Types.Config.CompilerPaths instance GHC.Generics.Generic Stack.Types.Config.ExtraDirs instance GHC.Show.Show Stack.Types.Config.ExtraDirs instance Stack.Types.Config.HasPlatform (Distribution.System.Platform, Stack.Types.Config.PlatformVariant) instance Stack.Types.Config.HasPlatform Stack.Types.Config.Config instance Stack.Types.Config.HasPlatform Stack.Types.Config.BuildConfig instance Stack.Types.Config.HasPlatform Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasGHCVariant Stack.Types.Config.GHCVariant instance Stack.Types.Config.HasGHCVariant Stack.Types.Config.Config instance Stack.Types.Config.HasGHCVariant Stack.Types.Config.BuildConfig instance Stack.Types.Config.HasGHCVariant Stack.Types.Config.EnvConfig instance RIO.Process.HasProcessContext Stack.Types.Config.BuildConfig instance RIO.Process.HasProcessContext Stack.Types.Config.EnvConfig instance Pantry.Types.HasPantryConfig Stack.Types.Config.BuildConfig instance Pantry.Types.HasPantryConfig Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasConfig Stack.Types.Config.Config instance Stack.Types.Config.HasConfig Stack.Types.Config.BuildConfig instance Stack.Types.Config.HasConfig Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasBuildConfig Stack.Types.Config.BuildConfig instance Stack.Types.Config.HasBuildConfig Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasEnvConfig Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasRunner Stack.Types.Config.BuildConfig instance Stack.Types.Config.HasRunner Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasSourceMap Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasCompiler Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasCompiler Stack.Types.Config.CompilerPaths instance GHC.Base.Semigroup Stack.Types.Config.ExtraDirs instance GHC.Base.Monoid Stack.Types.Config.ExtraDirs instance RIO.Prelude.Logger.HasLogFunc Stack.Types.Config.EnvConfig instance RIO.PrettyPrint.StylesUpdate.HasStylesUpdate Stack.Types.Config.EnvConfig instance RIO.PrettyPrint.HasTerm Stack.Types.Config.EnvConfig instance Stack.Types.Config.HasRunner Stack.Types.Config.Runner instance RIO.Process.HasProcessContext Stack.Types.Config.Config instance Stack.Types.Config.HasRunner Stack.Types.Config.Config instance RIO.Prelude.Logger.HasLogFunc Stack.Types.Config.Config instance RIO.Prelude.Logger.HasLogFunc Stack.Types.Config.BuildConfig instance RIO.PrettyPrint.StylesUpdate.HasStylesUpdate Stack.Types.Config.Config instance RIO.PrettyPrint.StylesUpdate.HasStylesUpdate Stack.Types.Config.BuildConfig instance RIO.PrettyPrint.HasTerm Stack.Types.Config.Config instance RIO.PrettyPrint.HasTerm Stack.Types.Config.BuildConfig instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.GhcOptions instance Data.Aeson.Types.FromJSON.FromJSONKey Stack.Types.Config.GhcOptionKey instance Pantry.Types.HasPantryConfig Stack.Types.Config.Config instance RIO.Prelude.Logger.HasLogFunc Stack.Types.Config.Runner instance RIO.Process.HasProcessContext Stack.Types.Config.Runner instance RIO.PrettyPrint.StylesUpdate.HasStylesUpdate Stack.Types.Config.Runner instance RIO.PrettyPrint.HasTerm Stack.Types.Config.Runner instance GHC.Base.Semigroup Stack.Types.Config.GlobalOptsMonoid instance GHC.Base.Monoid Stack.Types.Config.GlobalOptsMonoid instance GHC.Base.Semigroup Stack.Types.Config.ConfigMonoid instance GHC.Base.Monoid Stack.Types.Config.ConfigMonoid instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Config.PvpBounds instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.PvpBounds instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.SetupInfo) instance GHC.Base.Semigroup Stack.Types.Config.SetupInfo instance GHC.Base.Monoid Stack.Types.Config.SetupInfo instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.GHCDownloadInfo) instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.VersionedDownloadInfo) instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.DownloadInfo) instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.GHCVariant instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.SCM instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Config.SCM instance Stack.Types.Config.IsPath Path.Posix.Abs Path.Posix.Dir instance Stack.Types.Config.IsPath Path.Posix.Rel Path.Posix.Dir instance Stack.Types.Config.IsPath Path.Posix.Abs Path.Posix.File instance Stack.Types.Config.IsPath Path.Posix.Rel Path.Posix.File instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Config.Project instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Config.Curator instance Data.Aeson.Types.FromJSON.FromJSON (Pantry.Internal.AesonExtended.WithJSONWarnings Stack.Types.Config.Curator) instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.DumpLogs instance GHC.Base.Semigroup Stack.Types.Config.AllowNewerDeps instance GHC.Base.Monoid Stack.Types.Config.AllowNewerDeps instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.AllowNewerDeps instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.ApplyGhcOptions instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.CabalConfigKey instance Data.Aeson.Types.FromJSON.FromJSONKey Stack.Types.Config.CabalConfigKey instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Config.ColorWhen instance GHC.Exception.Type.Exception Stack.Types.Config.ParseAbsolutePathException instance Text.PrettyPrint.Leijen.Extended.Pretty Stack.Types.Config.ConfigPrettyException instance GHC.Exception.Type.Exception Stack.Types.Config.ConfigPrettyException instance GHC.Exception.Type.Exception Stack.Types.Config.ConfigException module Stack.Types.Package -- | GHC options based on cabal information and ghc-options. data BuildInfoOpts BuildInfoOpts :: [String] -> [String] -> [String] -> Path Abs File -> BuildInfoOpts [bioOpts] :: BuildInfoOpts -> [String] [bioOneWordOpts] :: BuildInfoOpts -> [String] -- | These options can safely have nubOrd applied to them, as there -- are no multi-word options (see -- https://github.com/commercialhaskell/stack/issues/1255) [bioPackageFlags] :: BuildInfoOpts -> [String] [bioCabalMacros] :: BuildInfoOpts -> Path Abs File -- | Name of an executable. newtype ExeName ExeName :: Text -> ExeName [unExeName] :: ExeName -> Text newtype FileCacheInfo FileCacheInfo :: SHA256 -> FileCacheInfo [fciHash] :: FileCacheInfo -> SHA256 -- | Files that the package depends on, relative to package directory. -- Argument is the location of the Cabal file newtype GetPackageOpts GetPackageOpts :: (forall env. HasEnvConfig env => InstallMap -> InstalledMap -> [PackageName] -> [PackageName] -> Path Abs File -> RIO env (Map NamedComponent (Map ModuleName (Path Abs File)), Map NamedComponent [DotCabalPath], Map NamedComponent BuildInfoOpts)) -> GetPackageOpts [getPackageOpts] :: GetPackageOpts -> forall env. HasEnvConfig env => InstallMap -> InstalledMap -> [PackageName] -> [PackageName] -> Path Abs File -> RIO env (Map NamedComponent (Map ModuleName (Path Abs File)), Map NamedComponent [DotCabalPath], Map NamedComponent BuildInfoOpts) -- | A location to install a package into, either snapshot or local data InstallLocation Snap :: InstallLocation Local :: InstallLocation type InstallMap = Map PackageName (InstallLocation, Version) data Installed Library :: PackageIdentifier -> GhcPkgId -> Maybe (Either License License) -> Installed Executable :: PackageIdentifier -> Installed data InstalledPackageLocation InstalledTo :: InstallLocation -> InstalledPackageLocation ExtraGlobal :: InstalledPackageLocation type InstalledMap = Map PackageName (InstallLocation, Installed) -- | Information on a locally available package of source code data LocalPackage LocalPackage :: !Package -> !Set NamedComponent -> !Set NamedComponent -> !Bool -> !Maybe Package -> !Path Abs File -> !Bool -> !Bool -> !MemoizedWith EnvConfig (Maybe (Set FilePath)) -> !MemoizedWith EnvConfig (Map NamedComponent (Map FilePath FileCacheInfo)) -> !MemoizedWith EnvConfig (Map NamedComponent (Set (Path Abs File))) -> LocalPackage -- | The Package info itself, after resolution with package flags, -- with tests and benchmarks disabled [lpPackage] :: LocalPackage -> !Package -- | Components to build, not including the library component. [lpComponents] :: LocalPackage -> !Set NamedComponent -- | Components explicitly requested for build, that are marked "buildable: -- false". [lpUnbuildable] :: LocalPackage -> !Set NamedComponent -- | Whether this package is wanted as a target. [lpWanted] :: LocalPackage -> !Bool -- | This stores the Package with tests and benchmarks enabled, if -- either is asked for by the user. [lpTestBench] :: LocalPackage -> !Maybe Package -- | The Cabal file [lpCabalFile] :: LocalPackage -> !Path Abs File [lpBuildHaddocks] :: LocalPackage -> !Bool [lpForceDirty] :: LocalPackage -> !Bool -- | Nothing == not dirty, Just == dirty. Note that the Set may be empty if -- we forced the build to treat packages as dirty. Also, the Set may not -- include all modified files. [lpDirtyFiles] :: LocalPackage -> !MemoizedWith EnvConfig (Maybe (Set FilePath)) -- | current state of the files [lpNewBuildCaches] :: LocalPackage -> !MemoizedWith EnvConfig (Map NamedComponent (Map FilePath FileCacheInfo)) -- | all files used by this package [lpComponentFiles] :: LocalPackage -> !MemoizedWith EnvConfig (Map NamedComponent (Set (Path Abs File))) newtype MemoizedWith env a MemoizedWith :: RIO env a -> MemoizedWith env a [unMemoizedWith] :: MemoizedWith env a -> RIO env a -- | Some package info. data Package Package :: !PackageName -> !Version -> !Either License License -> !GetPackageFiles -> !Map PackageName DepValue -> !Set ExeName -> !Set PackageName -> ![Text] -> ![Text] -> !Map FlagName Bool -> !Map FlagName Bool -> !PackageLibraries -> !Set Text -> !Map Text TestSuiteInterface -> !Set Text -> !Set Text -> !GetPackageOpts -> !Bool -> !BuildType -> !Maybe (Map PackageName VersionRange) -> !CabalSpecVersion -> Package -- | Name of the package. [packageName] :: Package -> !PackageName -- | Version of the package [packageVersion] :: Package -> !Version -- | The license the package was released under. [packageLicense] :: Package -> !Either License License -- | Get all files of the package. [packageFiles] :: Package -> !GetPackageFiles -- | Packages that the package depends on, both as libraries and build -- tools. [packageDeps] :: Package -> !Map PackageName DepValue -- | Build tools specified in the legacy manner (build-tools:) that failed -- the hard-coded lookup. [packageUnknownTools] :: Package -> !Set ExeName -- | Original dependencies (not sieved). [packageAllDeps] :: Package -> !Set PackageName -- | Ghc options used on package. [packageGhcOptions] :: Package -> ![Text] -- | Additional options passed to ./Setup.hs configure [packageCabalConfigOpts] :: Package -> ![Text] -- | Flags used on package. [packageFlags] :: Package -> !Map FlagName Bool -- | Defaults for unspecified flags. [packageDefaultFlags] :: Package -> !Map FlagName Bool -- | does the package have a buildable library stanza? [packageLibraries] :: Package -> !PackageLibraries -- | names of internal libraries [packageInternalLibraries] :: Package -> !Set Text -- | names and interfaces of test suites [packageTests] :: Package -> !Map Text TestSuiteInterface -- | names of benchmarks [packageBenchmarks] :: Package -> !Set Text -- | names of executables [packageExes] :: Package -> !Set Text -- | Args to pass to GHC. [packageOpts] :: Package -> !GetPackageOpts -- | Does the package have exposed modules? [packageHasExposedModules] :: Package -> !Bool -- | Package build-type. [packageBuildType] :: Package -> !BuildType -- | If present: custom-setup dependencies [packageSetupDeps] :: Package -> !Maybe (Map PackageName VersionRange) -- | Cabal spec range [packageCabalSpec] :: Package -> !CabalSpecVersion -- | Package build configuration data PackageConfig PackageConfig :: !Bool -> !Bool -> !Map FlagName Bool -> ![Text] -> ![Text] -> ActualCompiler -> !Platform -> PackageConfig -- | Are tests enabled? [packageConfigEnableTests] :: PackageConfig -> !Bool -- | Are benchmarks enabled? [packageConfigEnableBenchmarks] :: PackageConfig -> !Bool -- | Configured flags. [packageConfigFlags] :: PackageConfig -> !Map FlagName Bool -- | Configured ghc options. [packageConfigGhcOptions] :: PackageConfig -> ![Text] -- | ./Setup.hs configure options [packageConfigCabalConfigOpts] :: PackageConfig -> ![Text] -- | GHC version [packageConfigCompilerVersion] :: PackageConfig -> ActualCompiler -- | host platform [packageConfigPlatform] :: PackageConfig -> !Platform -- | Type representing exceptions thrown by functions exported by the -- Stack.Package module. data PackageException PackageInvalidCabalFile :: !Either PackageIdentifierRevision (Path Abs File) -> !Maybe Version -> ![PError] -> ![PWarning] -> PackageException MismatchedCabalIdentifier :: !PackageIdentifierRevision -> !PackageIdentifier -> PackageException CabalFileNameParseFail :: FilePath -> PackageException CabalFileNameInvalidPackageName :: FilePath -> PackageException ComponentNotParsedBug :: PackageException -- | Libraries in a package. Since Cabal 2.0, internal libraries are a -- thing. data PackageLibraries NoLibraries :: PackageLibraries -- | the foreign library names, sub libraries get built automatically -- without explicit component name passing HasLibraries :: !Set Text -> PackageLibraries -- | Where the package's source is located: local directory or package -- index data PackageSource -- | Package which exist on the filesystem PSFilePath :: LocalPackage -> PackageSource -- | Package which is downloaded remotely. PSRemote :: PackageLocationImmutable -> Version -> FromSnapshot -> CommonPackage -> PackageSource -- | Get the c file path. dotCabalCFilePath :: DotCabalPath -> Maybe (Path Abs File) -- | Get the path. dotCabalGetPath :: DotCabalPath -> Path Abs File -- | Maybe get the main name from the .cabal descriptor. dotCabalMain :: DotCabalDescriptor -> Maybe FilePath -- | Get the main path. dotCabalMainPath :: DotCabalPath -> Maybe (Path Abs File) -- | Maybe get the module name from the .cabal descriptor. dotCabalModule :: DotCabalDescriptor -> Maybe ModuleName -- | Get the module path. dotCabalModulePath :: DotCabalPath -> Maybe (Path Abs File) installedPackageIdentifier :: Installed -> PackageIdentifier -- | Get the installed Version. installedVersion :: Installed -> Version lpFiles :: HasEnvConfig env => LocalPackage -> RIO env (Set (Path Abs File)) lpFilesForComponents :: HasEnvConfig env => Set NamedComponent -> LocalPackage -> RIO env (Set (Path Abs File)) memoizeRefWith :: MonadIO m => RIO env a -> m (MemoizedWith env a) packageDefinedFlags :: Package -> Set FlagName packageIdent :: Package -> PackageIdentifier packageIdentifier :: Package -> PackageIdentifier psVersion :: PackageSource -> Version runMemoizedWith :: (HasEnvConfig env, MonadReader env m, MonadIO m) => MemoizedWith EnvConfig a -> m a instance GHC.Show.Show Stack.Types.Package.PackageException instance GHC.Show.Show Stack.Types.Package.PackageLibraries instance Data.Data.Data Stack.Types.Package.ExeName instance Control.DeepSeq.NFData Stack.Types.Package.ExeName instance GHC.Generics.Generic Stack.Types.Package.ExeName instance Data.String.IsString Stack.Types.Package.ExeName instance Data.Hashable.Class.Hashable Stack.Types.Package.ExeName instance GHC.Classes.Ord Stack.Types.Package.ExeName instance GHC.Classes.Eq Stack.Types.Package.ExeName instance GHC.Show.Show Stack.Types.Package.ExeName instance GHC.Show.Show Stack.Types.Package.BuildInfoOpts instance GHC.Show.Show Stack.Types.Package.PackageConfig instance GHC.Base.Monad (Stack.Types.Package.MemoizedWith env) instance GHC.Base.Applicative (Stack.Types.Package.MemoizedWith env) instance GHC.Base.Functor (Stack.Types.Package.MemoizedWith env) instance GHC.Classes.Eq Stack.Types.Package.InstallLocation instance GHC.Show.Show Stack.Types.Package.InstallLocation instance GHC.Classes.Eq Stack.Types.Package.InstalledPackageLocation instance GHC.Show.Show Stack.Types.Package.InstalledPackageLocation instance GHC.Classes.Eq Stack.Types.Package.FileCacheInfo instance GHC.Show.Show Stack.Types.Package.FileCacheInfo instance GHC.Generics.Generic Stack.Types.Package.FileCacheInfo instance GHC.Classes.Eq Stack.Types.Package.Installed instance GHC.Show.Show Stack.Types.Package.Installed instance GHC.Show.Show Stack.Types.Package.Package instance GHC.Show.Show Stack.Types.Package.LocalPackage instance GHC.Show.Show Stack.Types.Package.PackageSource instance GHC.Classes.Ord Stack.Types.Package.Package instance GHC.Classes.Eq Stack.Types.Package.Package instance GHC.Show.Show Stack.Types.Package.GetPackageOpts instance Control.DeepSeq.NFData Stack.Types.Package.FileCacheInfo instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Package.FileCacheInfo instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Package.FileCacheInfo instance GHC.Base.Semigroup Stack.Types.Package.InstallLocation instance GHC.Base.Monoid Stack.Types.Package.InstallLocation instance GHC.Show.Show (Stack.Types.Package.MemoizedWith env a) instance GHC.Exception.Type.Exception Stack.Types.Package.PackageException module Stack.Options.TestParser -- | Parser for test arguments. FIXME hide args testOptsParser :: Bool -> Parser TestOptsMonoid module Stack.Options.HaddockParser -- | Parser for haddock arguments. haddockOptsParser :: Bool -> Parser HaddockOptsMonoid module Stack.Options.GhcVariantParser -- | GHC variant parser ghcVariantParser :: Bool -> Parser GHCVariant module Stack.Options.BenchParser -- | Parser for bench arguments. FIXME hiding options benchOptsParser :: Bool -> Parser BenchmarkOptsMonoid -- | Functions for IDEs. module Stack.IDE data OutputStream OutputLogInfo :: OutputStream OutputStdout :: OutputStream data ListPackagesCmd ListPackageNames :: ListPackagesCmd ListPackageCabalFiles :: ListPackagesCmd -- | List the packages inside the current project. listPackages :: HasBuildConfig env => OutputStream -> ListPackagesCmd -> RIO env () -- | List the targets in the current project. listTargets :: forall env. HasBuildConfig env => OutputStream -> RIO env () module Stack.DefaultColorWhen -- | The default adopts the standard proposed at -- http://no-color.org/, that color should not be added by default -- if the NO_COLOR environment variable is present. defaultColorWhen :: IO ColorWhen -- | Docker configuration module Stack.Config.Docker -- | Type representing exceptions thrown by functions exported by the -- Stack.Config.Docker module. data ConfigDockerException -- | Only LTS resolvers are supported for default image tag. ResolverNotSupportedException :: !Maybe Project -> !Maybe AbstractResolver -> ConfigDockerException -- | Add a default Docker tag name to a given base image. addDefaultTag :: MonadThrow m => String -> Maybe Project -> Maybe AbstractResolver -> m String -- | Interprets DockerOptsMonoid options. dockerOptsFromMonoid :: MonadThrow m => Maybe Project -> Maybe AbstractResolver -> DockerOptsMonoid -> m DockerOpts instance GHC.Show.Show Stack.Config.Docker.ConfigDockerException instance GHC.Exception.Type.Exception Stack.Config.Docker.ConfigDockerException -- | Build configuration module Stack.Config.Build benchmarkOptsFromMonoid :: BenchmarkOptsMonoid -> Maybe [String] -> BenchmarkOpts -- | Interprets BuildOptsMonoid options. buildOptsFromMonoid :: BuildOptsMonoid -> BuildOpts haddockOptsFromMonoid :: HaddockOptsMonoid -> HaddockOpts testOptsFromMonoid :: TestOptsMonoid -> Maybe [String] -> TestOpts module Path.CheckInstall -- | Checks if the installed executable will be available on the user's -- PATH. This doesn't use envSearchPath menv because it includes -- paths only visible when running in the Stack environment. warnInstallSearchPathIssues :: HasConfig env => FilePath -> [Text] -> RIO env () -- | Simple interface to complicated program arguments. -- -- This is a "fork" of the optparse-simple package that has some -- workarounds for optparse-applicative issues that become problematic -- with programs that have many options and subcommands. Because it makes -- the interface more complex, these workarounds are not suitable for -- pushing upstream to optparse-applicative. module Options.Applicative.Complicated -- | Add a command to the options dispatcher. addCommand :: String -> String -> String -> (opts -> RIO Runner ()) -> (opts -> GlobalOptsMonoid -> GlobalOptsMonoid) -> Parser GlobalOptsMonoid -> Parser opts -> AddCommand -- | Add a command that takes sub-commands to the options dispatcher. addSubCommands :: String -> String -> String -> Parser GlobalOptsMonoid -> AddCommand -> AddCommand -- | Generate and execute a complicated options parser. complicatedOptions :: Version -> Maybe String -> String -> String -> String -> String -> Parser GlobalOptsMonoid -> Maybe (ParserFailure ParserHelp -> [String] -> IO (GlobalOptsMonoid, (RIO Runner (), GlobalOptsMonoid))) -> AddCommand -> IO (GlobalOptsMonoid, RIO Runner ()) -- | Generate a complicated options parser. complicatedParser :: String -> Parser GlobalOptsMonoid -> AddCommand -> Parser (GlobalOptsMonoid, (RIO Runner (), GlobalOptsMonoid)) -- | Build-specific types. module Stack.Types.Build -- | Type representing exceptions thrown by functions exported by modules -- with names beginning Stack.Build. data BuildException Couldn'tFindPkgId :: PackageName -> BuildException CompilerVersionMismatch :: Maybe (ActualCompiler, Arch) -> (WantedCompiler, Arch) -> GHCVariant -> CompilerBuild -> VersionCheck -> Maybe (Path Abs File) -> Text -> BuildException Couldn'tParseTargets :: [Text] -> BuildException UnknownTargets :: Set PackageName -> Map PackageName Version -> Path Abs File -> BuildException TestSuiteFailure :: PackageIdentifier -> Map Text (Maybe ExitCode) -> Maybe (Path Abs File) -> ByteString -> BuildException TestSuiteTypeUnsupported :: TestSuiteInterface -> BuildException LocalPackageDoesn'tMatchTarget :: PackageName -> Version -> Version -> BuildException NoSetupHsFound :: Path Abs Dir -> BuildException InvalidFlagSpecification :: Set UnusedFlags -> BuildException InvalidGhcOptionsSpecification :: [PackageName] -> BuildException TargetParseException :: [Text] -> BuildException SomeTargetsNotBuildable :: [(PackageName, NamedComponent)] -> BuildException TestSuiteExeMissing :: Bool -> String -> String -> String -> BuildException CabalCopyFailed :: Bool -> String -> BuildException LocalPackagesPresent :: [PackageIdentifier] -> BuildException CouldNotLockDistDir :: !Path Abs File -> BuildException TaskCycleBug :: PackageIdentifier -> BuildException PackageIdMissingBug :: PackageIdentifier -> BuildException AllInOneBuildBug :: BuildException MulipleResultsBug :: PackageName -> [DumpPackage] -> BuildException TemplateHaskellNotFoundBug :: BuildException HaddockIndexNotFound :: BuildException ShowBuildErrorBug :: BuildException data BuildPrettyException ConstructPlanFailed :: [ConstructPlanException] -> Path Abs File -> Path Abs Dir -> ParentMap -> Set PackageName -> Map PackageName [PackageName] -> BuildPrettyException ExecutionFailure :: [SomeException] -> BuildPrettyException CabalExitedUnsuccessfully :: ExitCode -> PackageIdentifier -> Path Abs File -> [String] -> Maybe (Path Abs File) -> [Text] -> BuildPrettyException SetupHsBuildFailure :: ExitCode -> Maybe PackageIdentifier -> Path Abs File -> [String] -> Maybe (Path Abs File) -> [Text] -> BuildPrettyException data ConstructPlanException DependencyCycleDetected :: [PackageName] -> ConstructPlanException DependencyPlanFailures :: Package -> Map PackageName (VersionRange, LatestApplicableVersion, BadDependency) -> ConstructPlanException -- | Recommend adding to extra-deps, give a helpful version number? UnknownPackage :: PackageName -> ConstructPlanException -- | Reason why a dependency was not used data BadDependency NotInBuildPlan :: BadDependency Couldn'tResolveItsDependencies :: Version -> BadDependency DependencyMismatch :: Version -> BadDependency -- | See description of DepType HasNoLibrary :: BadDependency BDDependencyCycleDetected :: ![PackageName] -> BadDependency type ParentMap = MonoidMap PackageName (First Version, [(PackageIdentifier, VersionRange)]) data FlagSource FSCommandLine :: FlagSource FSStackYaml :: FlagSource data UnusedFlags UFNoPackage :: FlagSource -> PackageName -> UnusedFlags UFFlagsNotDefined :: FlagSource -> PackageName -> Set FlagName -> Set FlagName -> UnusedFlags UFSnapshot :: PackageName -> UnusedFlags -- | A location to install a package into, either snapshot or local data InstallLocation Snap :: InstallLocation Local :: InstallLocation data Installed Library :: PackageIdentifier -> GhcPkgId -> Maybe (Either License License) -> Installed Executable :: PackageIdentifier -> Installed psVersion :: PackageSource -> Version -- | A task to perform when building data Task Task :: !PackageIdentifier -> !TaskType -> !TaskConfigOpts -> !Bool -> !Map PackageIdentifier GhcPkgId -> !Bool -> !CachePkgSrc -> !Bool -> !Bool -> Task -- | the package/version to be built [taskProvides] :: Task -> !PackageIdentifier -- | the task type, telling us how to build this [taskType] :: Task -> !TaskType [taskConfigOpts] :: Task -> !TaskConfigOpts [taskBuildHaddock] :: Task -> !Bool -- | GhcPkgIds of already-installed dependencies [taskPresent] :: Task -> !Map PackageIdentifier GhcPkgId -- | indicates that the package can be built in one step [taskAllInOne] :: Task -> !Bool [taskCachePkgSrc] :: Task -> !CachePkgSrc -- | Were any of the dependencies missing? The reason this is necessary -- is... hairy. And as you may expect, a bug in Cabal. See: -- https://github.com/haskell/cabal/issues/4728#issuecomment-337937673. -- The problem is that Cabal may end up generating the same package ID -- for a dependency, even if the ABI has changed. As a result, without -- this field, Stack would think that a reconfigure is unnecessary, when -- in fact we _do_ need to reconfigure. The details here suck. We really -- need proper hashes for package identifiers. [taskAnyMissing] :: Task -> !Bool -- | Is the build type of this package Configure. Check out -- ensureConfigureScript in Stack.Build.Execute for the motivation [taskBuildTypeConfig] :: Task -> !Bool taskIsTarget :: Task -> Bool taskLocation :: Task -> InstallLocation taskTargetIsMutable :: Task -> IsMutable -- | Information on a locally available package of source code data LocalPackage LocalPackage :: !Package -> !Set NamedComponent -> !Set NamedComponent -> !Bool -> !Maybe Package -> !Path Abs File -> !Bool -> !Bool -> !MemoizedWith EnvConfig (Maybe (Set FilePath)) -> !MemoizedWith EnvConfig (Map NamedComponent (Map FilePath FileCacheInfo)) -> !MemoizedWith EnvConfig (Map NamedComponent (Set (Path Abs File))) -> LocalPackage -- | The Package info itself, after resolution with package flags, -- with tests and benchmarks disabled [lpPackage] :: LocalPackage -> !Package -- | Components to build, not including the library component. [lpComponents] :: LocalPackage -> !Set NamedComponent -- | Components explicitly requested for build, that are marked "buildable: -- false". [lpUnbuildable] :: LocalPackage -> !Set NamedComponent -- | Whether this package is wanted as a target. [lpWanted] :: LocalPackage -> !Bool -- | This stores the Package with tests and benchmarks enabled, if -- either is asked for by the user. [lpTestBench] :: LocalPackage -> !Maybe Package -- | The Cabal file [lpCabalFile] :: LocalPackage -> !Path Abs File [lpBuildHaddocks] :: LocalPackage -> !Bool [lpForceDirty] :: LocalPackage -> !Bool -- | Nothing == not dirty, Just == dirty. Note that the Set may be empty if -- we forced the build to treat packages as dirty. Also, the Set may not -- include all modified files. [lpDirtyFiles] :: LocalPackage -> !MemoizedWith EnvConfig (Maybe (Set FilePath)) -- | current state of the files [lpNewBuildCaches] :: LocalPackage -> !MemoizedWith EnvConfig (Map NamedComponent (Map FilePath FileCacheInfo)) -- | all files used by this package [lpComponentFiles] :: LocalPackage -> !MemoizedWith EnvConfig (Map NamedComponent (Set (Path Abs File))) -- | Basic information used to calculate what the configure options are data BaseConfigOpts BaseConfigOpts :: !Path Abs Dir -> !Path Abs Dir -> !Path Abs Dir -> !Path Abs Dir -> !BuildOpts -> !BuildOptsCLI -> ![Path Abs Dir] -> BaseConfigOpts [bcoSnapDB] :: BaseConfigOpts -> !Path Abs Dir [bcoLocalDB] :: BaseConfigOpts -> !Path Abs Dir [bcoSnapInstallRoot] :: BaseConfigOpts -> !Path Abs Dir [bcoLocalInstallRoot] :: BaseConfigOpts -> !Path Abs Dir [bcoBuildOpts] :: BaseConfigOpts -> !BuildOpts [bcoBuildOptsCLI] :: BaseConfigOpts -> !BuildOptsCLI [bcoExtraDBs] :: BaseConfigOpts -> ![Path Abs Dir] -- | A complete plan of what needs to be built and how to do it data Plan Plan :: !Map PackageName Task -> !Map PackageName Task -> !Map GhcPkgId (PackageIdentifier, Text) -> !Map Text InstallLocation -> Plan [planTasks] :: Plan -> !Map PackageName Task -- | Final actions to be taken (test, benchmark, etc) [planFinals] :: Plan -> !Map PackageName Task -- | Text is reason we're unregistering, for display only [planUnregisterLocal] :: Plan -> !Map GhcPkgId (PackageIdentifier, Text) -- | Executables that should be installed after successful building [planInstallExes] :: Plan -> !Map Text InstallLocation -- | Options for the FinalAction DoTests data TestOpts TestOpts :: !Bool -> ![String] -> !Bool -> !Bool -> !Maybe Int -> !Bool -> TestOpts -- | Whether successful tests will be run gain [toRerunTests] :: TestOpts -> !Bool -- | Arguments passed to the test program [toAdditionalArgs] :: TestOpts -> ![String] -- | Generate a code coverage report [toCoverage] :: TestOpts -> !Bool -- | Disable running of tests [toDisableRun] :: TestOpts -> !Bool -- | test suite timeout in seconds [toMaximumTimeSeconds] :: TestOpts -> !Maybe Int -- | Whether to allow standard input [toAllowStdin] :: TestOpts -> !Bool -- | Options for the FinalAction DoBenchmarks data BenchmarkOpts BenchmarkOpts :: !Maybe String -> !Bool -> BenchmarkOpts -- | Arguments passed to the benchmark program [beoAdditionalArgs] :: BenchmarkOpts -> !Maybe String -- | Disable running of benchmarks [beoDisableRun] :: BenchmarkOpts -> !Bool data FileWatchOpts NoFileWatch :: FileWatchOpts FileWatch :: FileWatchOpts FileWatchPoll :: FileWatchOpts -- | Build options that is interpreted by the build command. This is built -- up from BuildOptsCLI and BuildOptsMonoid data BuildOpts BuildOpts :: !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !HaddockOpts -> !Bool -> !Maybe Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Bool -> !Maybe Bool -> !Bool -> !Bool -> !Bool -> !TestOpts -> !Bool -> !BenchmarkOpts -> !Bool -> !CabalVerbosity -> !Bool -> ![Text] -> !Bool -> !Maybe Text -> BuildOpts [boptsLibProfile] :: BuildOpts -> !Bool [boptsExeProfile] :: BuildOpts -> !Bool [boptsLibStrip] :: BuildOpts -> !Bool [boptsExeStrip] :: BuildOpts -> !Bool -- | Build haddocks? [boptsHaddock] :: BuildOpts -> !Bool -- | Options to pass to haddock [boptsHaddockOpts] :: BuildOpts -> !HaddockOpts -- | Open haddocks in the browser? [boptsOpenHaddocks] :: BuildOpts -> !Bool -- | Build haddocks for dependencies? [boptsHaddockDeps] :: BuildOpts -> !Maybe Bool -- | Build haddocks for all symbols and packages, like cabal haddock -- --internal [boptsHaddockInternal] :: BuildOpts -> !Bool -- | Build hyperlinked source if possible. Fallback to hscolour. -- Disable for no sources. [boptsHaddockHyperlinkSource] :: BuildOpts -> !Bool -- | Install executables to user path after building? [boptsInstallExes] :: BuildOpts -> !Bool -- | Install executables to compiler tools path after building? [boptsInstallCompilerTool] :: BuildOpts -> !Bool -- | Fetch all packages immediately ^ Watch files for changes and -- automatically rebuild [boptsPreFetch] :: BuildOpts -> !Bool -- | Keep building/running after failure [boptsKeepGoing] :: BuildOpts -> !Maybe Bool -- | Keep intermediate files and build directories [boptsKeepTmpFiles] :: BuildOpts -> !Bool -- | Force treating all local packages as having dirty files [boptsForceDirty] :: BuildOpts -> !Bool -- | Turn on tests for local targets [boptsTests] :: BuildOpts -> !Bool -- | Additional test arguments [boptsTestOpts] :: BuildOpts -> !TestOpts -- | Turn on benchmarks for local targets [boptsBenchmarks] :: BuildOpts -> !Bool -- | Additional test arguments ^ Commands (with arguments) to run after a -- successful build ^ Only perform the configure step when building [boptsBenchmarkOpts] :: BuildOpts -> !BenchmarkOpts -- | Perform the configure step even if already configured [boptsReconfigure] :: BuildOpts -> !Bool -- | Ask Cabal to be verbose in its builds [boptsCabalVerbose] :: BuildOpts -> !CabalVerbosity -- | Whether to enable split-objs. [boptsSplitObjs] :: BuildOpts -> !Bool -- | Which components to skip when building [boptsSkipComponents] :: BuildOpts -> ![Text] -- | Should we use the interleaved GHC output when building multiple -- packages? [boptsInterleavedOutput] :: BuildOpts -> !Bool [boptsDdumpDir] :: BuildOpts -> !Maybe Text -- | Which subset of packages to build data BuildSubset BSAll :: BuildSubset -- | Only install packages in the snapshot database, skipping packages -- intended for the local database. BSOnlySnapshot :: BuildSubset BSOnlyDependencies :: BuildSubset -- | Refuse to build anything in the snapshot database, see -- https://github.com/commercialhaskell/stack/issues/5272 BSOnlyLocals :: BuildSubset defaultBuildOpts :: BuildOpts -- | The type of a task, either building local code or something from the -- package index (upstream) data TaskType TTLocalMutable :: LocalPackage -> TaskType TTRemotePackage :: IsMutable -> Package -> PackageLocationImmutable -> TaskType data IsMutable Mutable :: IsMutable Immutable :: IsMutable installLocationIsMutable :: InstallLocation -> IsMutable -- | Given the IDs of any missing packages, produce the configure options data TaskConfigOpts TaskConfigOpts :: !Set PackageIdentifier -> !Map PackageIdentifier GhcPkgId -> ConfigureOpts -> TaskConfigOpts -- | Dependencies for which we don't yet have an GhcPkgId [tcoMissing] :: TaskConfigOpts -> !Set PackageIdentifier -- | Produce the list of options given the missing GhcPkgIds [tcoOpts] :: TaskConfigOpts -> !Map PackageIdentifier GhcPkgId -> ConfigureOpts -- | Stored on disk to know whether the files have changed. newtype BuildCache BuildCache :: Map FilePath FileCacheInfo -> BuildCache -- | Modification times of files. [buildCacheTimes] :: BuildCache -> Map FilePath FileCacheInfo -- | Stored on disk to know whether the flags have changed. data ConfigCache ConfigCache :: !ConfigureOpts -> !Set GhcPkgId -> !Set ByteString -> !Bool -> !CachePkgSrc -> !Text -> ConfigCache -- | All options used for this package. [configCacheOpts] :: ConfigCache -> !ConfigureOpts -- | The GhcPkgIds of all of the dependencies. Since Cabal doesn't take the -- complete GhcPkgId (only a PackageIdentifier) in the configure options, -- just using the previous value is insufficient to know if dependencies -- have changed. [configCacheDeps] :: ConfigCache -> !Set GhcPkgId -- | The components to be built. It's a bit of a hack to include this in -- here, as it's not a configure option (just a build option), but this -- is a convenient way to force compilation when the components change. [configCacheComponents] :: ConfigCache -> !Set ByteString -- | Are haddocks to be built? [configCacheHaddock] :: ConfigCache -> !Bool [configCachePkgSrc] :: ConfigCache -> !CachePkgSrc -- | Value of the PATH env var, see -- https://github.com/commercialhaskell/stack/issues/3138 [configCachePathEnvVar] :: ConfigCache -> !Text -- | Render a BaseConfigOpts to an actual list of options configureOpts :: EnvConfig -> BaseConfigOpts -> Map PackageIdentifier GhcPkgId -> Bool -> IsMutable -> Package -> ConfigureOpts data CachePkgSrc CacheSrcUpstream :: CachePkgSrc CacheSrcLocal :: FilePath -> CachePkgSrc toCachePkgSrc :: PackageSource -> CachePkgSrc isStackOpt :: Text -> Bool -- | Get set of wanted package names from locals. wantedLocalPackages :: [LocalPackage] -> Set PackageName newtype FileCacheInfo FileCacheInfo :: SHA256 -> FileCacheInfo [fciHash] :: FileCacheInfo -> SHA256 -- | Configure options to be sent to Setup.hs configure data ConfigureOpts ConfigureOpts :: ![String] -> ![String] -> ConfigureOpts -- | Options related to various paths. We separate these out since they do -- not have an impact on the contents of the compiled binary for checking -- if we can use an existing precompiled cache. [coDirs] :: ConfigureOpts -> ![String] [coNoDirs] :: ConfigureOpts -> ![String] -- | Information on a compiled package: the library conf file (if -- relevant), the sublibraries (if present) and all of the executable -- paths. data PrecompiledCache base PrecompiledCache :: !Maybe (Path base File) -> ![Path base File] -> ![Path base File] -> PrecompiledCache base -- | .conf file inside the package database [pcLibrary] :: PrecompiledCache base -> !Maybe (Path base File) -- | .conf file inside the package database, for each of the sublibraries [pcSubLibs] :: PrecompiledCache base -> ![Path base File] -- | Full paths to executables [pcExes] :: PrecompiledCache base -> ![Path base File] instance GHC.Show.Show Stack.Types.Build.BadDependency instance GHC.Classes.Ord Stack.Types.Build.BadDependency instance GHC.Classes.Eq Stack.Types.Build.BadDependency instance GHC.Show.Show Stack.Types.Build.ConstructPlanException instance GHC.Classes.Eq Stack.Types.Build.ConstructPlanException instance GHC.Show.Show Stack.Types.Build.BuildPrettyException instance GHC.Show.Show Stack.Types.Build.DepsPath instance GHC.Classes.Ord Stack.Types.Build.DepsPath instance GHC.Classes.Eq Stack.Types.Build.DepsPath instance GHC.Classes.Ord Stack.Types.Build.FlagSource instance GHC.Classes.Eq Stack.Types.Build.FlagSource instance GHC.Show.Show Stack.Types.Build.FlagSource instance GHC.Classes.Ord Stack.Types.Build.UnusedFlags instance GHC.Classes.Eq Stack.Types.Build.UnusedFlags instance GHC.Show.Show Stack.Types.Build.UnusedFlags instance GHC.Show.Show Stack.Types.Build.BuildException instance Control.DeepSeq.NFData Stack.Types.Build.PkgDepsOracle instance GHC.Classes.Eq Stack.Types.Build.PkgDepsOracle instance GHC.Show.Show Stack.Types.Build.PkgDepsOracle instance Data.Aeson.Types.FromJSON.FromJSON Stack.Types.Build.BuildCache instance Data.Aeson.Types.ToJSON.ToJSON Stack.Types.Build.BuildCache instance GHC.Show.Show Stack.Types.Build.BuildCache instance GHC.Classes.Eq Stack.Types.Build.BuildCache instance GHC.Generics.Generic Stack.Types.Build.BuildCache instance Data.Data.Data Stack.Types.Build.CachePkgSrc instance GHC.Show.Show Stack.Types.Build.CachePkgSrc instance GHC.Read.Read Stack.Types.Build.CachePkgSrc instance GHC.Classes.Eq Stack.Types.Build.CachePkgSrc instance GHC.Generics.Generic Stack.Types.Build.CachePkgSrc instance GHC.Show.Show Stack.Types.Build.IsMutable instance GHC.Classes.Eq Stack.Types.Build.IsMutable instance GHC.Show.Show Stack.Types.Build.TaskType instance GHC.Show.Show Stack.Types.Build.BaseConfigOpts instance Data.Data.Data Stack.Types.Build.ConfigureOpts instance GHC.Generics.Generic Stack.Types.Build.ConfigureOpts instance GHC.Classes.Eq Stack.Types.Build.ConfigureOpts instance GHC.Show.Show Stack.Types.Build.ConfigureOpts instance GHC.Show.Show Stack.Types.Build.Task instance GHC.Show.Show Stack.Types.Build.Plan instance Data.Data.Data Stack.Types.Build.ConfigCache instance GHC.Show.Show Stack.Types.Build.ConfigCache instance GHC.Classes.Eq Stack.Types.Build.ConfigCache instance GHC.Generics.Generic Stack.Types.Build.ConfigCache instance GHC.Generics.Generic (Stack.Types.Build.PrecompiledCache base) instance GHC.Classes.Eq (Stack.Types.Build.PrecompiledCache base) instance GHC.Show.Show (Stack.Types.Build.PrecompiledCache base) instance Control.DeepSeq.NFData (Stack.Types.Build.PrecompiledCache Path.Posix.Abs) instance Control.DeepSeq.NFData (Stack.Types.Build.PrecompiledCache Path.Posix.Rel) instance Control.DeepSeq.NFData Stack.Types.Build.ConfigCache instance GHC.Show.Show Stack.Types.Build.TaskConfigOpts instance Control.DeepSeq.NFData Stack.Types.Build.ConfigureOpts instance GHC.Base.Semigroup Stack.Types.Build.IsMutable instance GHC.Base.Monoid Stack.Types.Build.IsMutable instance Control.DeepSeq.NFData Stack.Types.Build.CachePkgSrc instance Database.Persist.Class.PersistField.PersistField Stack.Types.Build.CachePkgSrc instance Database.Persist.Sql.Class.PersistFieldSql Stack.Types.Build.CachePkgSrc instance Control.DeepSeq.NFData Stack.Types.Build.BuildCache instance GHC.Exception.Type.Exception Stack.Types.Build.BuildException instance Text.PrettyPrint.Leijen.Extended.Pretty Stack.Types.Build.BuildPrettyException instance GHC.Exception.Type.Exception Stack.Types.Build.BuildPrettyException -- | Work with SQLite database used for caches across an entire user -- account. module Stack.Storage.User -- | Initialize the database. initUserStorage :: HasLogFunc env => Path Abs File -> (UserStorage -> RIO env a) -> RIO env a -- | Key used to retrieve the precompiled cache type PrecompiledCacheKey = Unique PrecompiledCacheParent -- | Build key used to retrieve the precompiled cache precompiledCacheKey :: Path Rel Dir -> ActualCompiler -> Version -> Text -> ByteString -> Bool -> PrecompiledCacheKey -- | Load PrecompiledCache from the database. loadPrecompiledCache :: (HasConfig env, HasLogFunc env) => PrecompiledCacheKey -> RIO env (Maybe (PrecompiledCache Rel)) -- | Insert or update PrecompiledCache to the database. savePrecompiledCache :: (HasConfig env, HasLogFunc env) => PrecompiledCacheKey -> PrecompiledCache Rel -> RIO env () -- | Get the record of whether an executable is compatible with a Docker -- image loadDockerImageExeCache :: (HasConfig env, HasLogFunc env) => Text -> Path Abs File -> UTCTime -> RIO env (Maybe Bool) -- | Sets the record of whether an executable is compatible with a Docker -- image saveDockerImageExeCache :: (HasConfig env, HasLogFunc env) => Text -> Path Abs File -> UTCTime -> Bool -> RIO env () -- | Load compiler information, if available, and confirm that the -- referenced files are unchanged. May throw exceptions! loadCompilerPaths :: HasConfig env => Path Abs File -> CompilerBuild -> Bool -> RIO env (Maybe CompilerPaths) -- | Save compiler information. May throw exceptions! saveCompilerPaths :: HasConfig env => CompilerPaths -> RIO env () -- | How many upgrade checks have occurred since the given timestamp? upgradeChecksSince :: HasConfig env => UTCTime -> RIO env Int -- | Log in the database that an upgrade check occurred at the given time. logUpgradeCheck :: HasConfig env => UTCTime -> RIO env () instance GHC.Show.Show Stack.Storage.User.PrecompiledCacheParent instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance GHC.Show.Show Stack.Storage.User.PrecompiledCacheSubLib instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance GHC.Show.Show Stack.Storage.User.PrecompiledCacheExe instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance GHC.Show.Show Stack.Storage.User.DockerImageExeCache instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.User.LastPerformed instance Database.Persist.Class.PersistField.PersistField Stack.Storage.User.LastPerformed instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.User.LastPerformed instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.User.LastPerformed instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.User.LastPerformed instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.User.LastPerformed instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.User.LastPerformed (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.LastPerformed) instance Database.Persist.Class.PersistEntity.SymbolToField "action" Stack.Storage.User.LastPerformed Stack.Types.Cache.Action instance Database.Persist.Class.PersistEntity.SymbolToField "timestamp" Stack.Storage.User.LastPerformed Data.Time.Clock.Internal.UTCTime.UTCTime instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.User.CompilerCache instance Database.Persist.Class.PersistField.PersistField Stack.Storage.User.CompilerCache instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.User.CompilerCache instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.User.CompilerCache instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.User.CompilerCache instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.User.CompilerCache instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.User.CompilerCache (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.CompilerCache) instance Database.Persist.Class.PersistEntity.SymbolToField "actualVersion" Stack.Storage.User.CompilerCache Stack.Types.Compiler.ActualCompiler instance Database.Persist.Class.PersistEntity.SymbolToField "arch" Stack.Storage.User.CompilerCache Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "ghcPath" Stack.Storage.User.CompilerCache GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "ghcSize" Stack.Storage.User.CompilerCache GHC.Int.Int64 instance Database.Persist.Class.PersistEntity.SymbolToField "ghcModified" Stack.Storage.User.CompilerCache GHC.Int.Int64 instance Database.Persist.Class.PersistEntity.SymbolToField "ghcPkgPath" Stack.Storage.User.CompilerCache GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "runghcPath" Stack.Storage.User.CompilerCache GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "haddockPath" Stack.Storage.User.CompilerCache GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "cabalVersion" Stack.Storage.User.CompilerCache Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "globalDb" Stack.Storage.User.CompilerCache GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "globalDbCacheSize" Stack.Storage.User.CompilerCache GHC.Int.Int64 instance Database.Persist.Class.PersistEntity.SymbolToField "globalDbCacheModified" Stack.Storage.User.CompilerCache GHC.Int.Int64 instance Database.Persist.Class.PersistEntity.SymbolToField "info" Stack.Storage.User.CompilerCache Data.ByteString.Internal.ByteString instance Database.Persist.Class.PersistEntity.SymbolToField "globalDump" Stack.Storage.User.CompilerCache Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.User.DockerImageExeCache instance Database.Persist.Class.PersistField.PersistField Stack.Storage.User.DockerImageExeCache instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.User.DockerImageExeCache instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.User.DockerImageExeCache instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.User.DockerImageExeCache instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.User.DockerImageExeCache instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.User.DockerImageExeCache (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.DockerImageExeCache) instance Database.Persist.Class.PersistEntity.SymbolToField "imageHash" Stack.Storage.User.DockerImageExeCache Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "exePath" Stack.Storage.User.DockerImageExeCache GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "exeTimestamp" Stack.Storage.User.DockerImageExeCache Data.Time.Clock.Internal.UTCTime.UTCTime instance Database.Persist.Class.PersistEntity.SymbolToField "compatible" Stack.Storage.User.DockerImageExeCache GHC.Types.Bool instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.User.PrecompiledCacheExe instance Database.Persist.Class.PersistField.PersistField Stack.Storage.User.PrecompiledCacheExe instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.User.PrecompiledCacheExe instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.User.PrecompiledCacheExe instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.User.PrecompiledCacheExe instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.User.PrecompiledCacheExe instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.User.PrecompiledCacheExe (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheExe) instance Database.Persist.Class.PersistEntity.SymbolToField "parent" Stack.Storage.User.PrecompiledCacheExe Stack.Storage.User.PrecompiledCacheParentId instance Database.Persist.Class.PersistEntity.SymbolToField "value" Stack.Storage.User.PrecompiledCacheExe GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.User.PrecompiledCacheSubLib instance Database.Persist.Class.PersistField.PersistField Stack.Storage.User.PrecompiledCacheSubLib instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.User.PrecompiledCacheSubLib instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.User.PrecompiledCacheSubLib instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.User.PrecompiledCacheSubLib instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.User.PrecompiledCacheSubLib instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.User.PrecompiledCacheSubLib (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheSubLib) instance Database.Persist.Class.PersistEntity.SymbolToField "parent" Stack.Storage.User.PrecompiledCacheSubLib Stack.Storage.User.PrecompiledCacheParentId instance Database.Persist.Class.PersistEntity.SymbolToField "value" Stack.Storage.User.PrecompiledCacheSubLib GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.User.PrecompiledCacheParent instance Database.Persist.Class.PersistField.PersistField Stack.Storage.User.PrecompiledCacheParent instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.User.PrecompiledCacheParent instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.User.PrecompiledCacheParent instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.User.PrecompiledCacheParent instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.User.PrecompiledCacheParent instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.User.PrecompiledCacheParent (Database.Persist.Class.PersistEntity.Key Stack.Storage.User.PrecompiledCacheParent) instance Database.Persist.Class.PersistEntity.SymbolToField "platformGhcDir" Stack.Storage.User.PrecompiledCacheParent GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "compiler" Stack.Storage.User.PrecompiledCacheParent Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "cabalVersion" Stack.Storage.User.PrecompiledCacheParent Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "packageKey" Stack.Storage.User.PrecompiledCacheParent Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "optionsHash" Stack.Storage.User.PrecompiledCacheParent Data.ByteString.Internal.ByteString instance Database.Persist.Class.PersistEntity.SymbolToField "haddock" Stack.Storage.User.PrecompiledCacheParent GHC.Types.Bool instance Database.Persist.Class.PersistEntity.SymbolToField "library" Stack.Storage.User.PrecompiledCacheParent (GHC.Maybe.Maybe GHC.IO.FilePath) instance GHC.Show.Show Stack.Storage.User.StorageUserException instance GHC.Exception.Type.Exception Stack.Storage.User.StorageUserException -- | Work with SQLite database used for caches across a single project. module Stack.Storage.Project -- | Initialize the database. initProjectStorage :: HasLogFunc env => Path Abs File -> (ProjectStorage -> RIO env a) -> RIO env a -- | Key used to retrieve configuration or flag cache type ConfigCacheKey = Unique ConfigCacheParent -- | Build key used to retrieve configuration or flag cache configCacheKey :: Path Abs Dir -> ConfigCacheType -> ConfigCacheKey -- | Load ConfigCache from the database. loadConfigCache :: (HasBuildConfig env, HasLogFunc env) => ConfigCacheKey -> RIO env (Maybe ConfigCache) -- | Insert or update ConfigCache to the database. saveConfigCache :: (HasBuildConfig env, HasLogFunc env) => ConfigCacheKey -> ConfigCache -> RIO env () -- | Mark ConfigCache as inactive in the database. We use a flag -- instead of deleting the records since, in most cases, the same cache -- will be written again within in a few seconds (after `cabal -- configure`), so this avoids unnecessary database churn. deactiveConfigCache :: HasBuildConfig env => ConfigCacheKey -> RIO env () instance GHC.Show.Show Stack.Storage.Project.ConfigCacheParent instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance GHC.Show.Show Stack.Storage.Project.ConfigCacheDirOption instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance GHC.Show.Show Stack.Storage.Project.ConfigCacheNoDirOption instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance GHC.Show.Show Stack.Storage.Project.ConfigCacheDep instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance GHC.Show.Show Stack.Storage.Project.ConfigCacheComponent instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance GHC.Classes.Ord (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance GHC.Classes.Eq (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance GHC.Read.Read (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance GHC.Show.Show (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.Project.ConfigCacheComponent instance Database.Persist.Class.PersistField.PersistField Stack.Storage.Project.ConfigCacheComponent instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.Project.ConfigCacheComponent instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.Project.ConfigCacheComponent instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.Project.ConfigCacheComponent instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.Project.ConfigCacheComponent instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.Project.ConfigCacheComponent (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheComponent) instance Database.Persist.Class.PersistEntity.SymbolToField "parent" Stack.Storage.Project.ConfigCacheComponent Stack.Storage.Project.ConfigCacheParentId instance Database.Persist.Class.PersistEntity.SymbolToField "value" Stack.Storage.Project.ConfigCacheComponent Data.ByteString.Internal.ByteString instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.Project.ConfigCacheDep instance Database.Persist.Class.PersistField.PersistField Stack.Storage.Project.ConfigCacheDep instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.Project.ConfigCacheDep instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.Project.ConfigCacheDep instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.Project.ConfigCacheDep instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.Project.ConfigCacheDep instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.Project.ConfigCacheDep (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDep) instance Database.Persist.Class.PersistEntity.SymbolToField "parent" Stack.Storage.Project.ConfigCacheDep Stack.Storage.Project.ConfigCacheParentId instance Database.Persist.Class.PersistEntity.SymbolToField "value" Stack.Storage.Project.ConfigCacheDep Stack.Types.GhcPkgId.GhcPkgId instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.Project.ConfigCacheNoDirOption instance Database.Persist.Class.PersistField.PersistField Stack.Storage.Project.ConfigCacheNoDirOption instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.Project.ConfigCacheNoDirOption instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.Project.ConfigCacheNoDirOption instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.Project.ConfigCacheNoDirOption instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.Project.ConfigCacheNoDirOption instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.Project.ConfigCacheNoDirOption (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheNoDirOption) instance Database.Persist.Class.PersistEntity.SymbolToField "parent" Stack.Storage.Project.ConfigCacheNoDirOption Stack.Storage.Project.ConfigCacheParentId instance Database.Persist.Class.PersistEntity.SymbolToField "index" Stack.Storage.Project.ConfigCacheNoDirOption GHC.Types.Int instance Database.Persist.Class.PersistEntity.SymbolToField "value" Stack.Storage.Project.ConfigCacheNoDirOption GHC.Base.String instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.Project.ConfigCacheDirOption instance Database.Persist.Class.PersistField.PersistField Stack.Storage.Project.ConfigCacheDirOption instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.Project.ConfigCacheDirOption instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.Project.ConfigCacheDirOption instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.Project.ConfigCacheDirOption instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.Project.ConfigCacheDirOption instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.Project.ConfigCacheDirOption (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheDirOption) instance Database.Persist.Class.PersistEntity.SymbolToField "parent" Stack.Storage.Project.ConfigCacheDirOption Stack.Storage.Project.ConfigCacheParentId instance Database.Persist.Class.PersistEntity.SymbolToField "index" Stack.Storage.Project.ConfigCacheDirOption GHC.Types.Int instance Database.Persist.Class.PersistEntity.SymbolToField "value" Stack.Storage.Project.ConfigCacheDirOption GHC.Base.String instance Database.Persist.Class.PersistEntity.PersistEntity Stack.Storage.Project.ConfigCacheParent instance Database.Persist.Class.PersistField.PersistField Stack.Storage.Project.ConfigCacheParent instance Database.Persist.Sql.Class.PersistFieldSql Stack.Storage.Project.ConfigCacheParent instance Database.Persist.Class.PersistStore.ToBackendKey Database.Persist.SqlBackend.Internal.SqlBackend Stack.Storage.Project.ConfigCacheParent instance Database.Persist.Class.PersistUnique.OnlyOneUniqueKey Stack.Storage.Project.ConfigCacheParent instance Database.Persist.Class.PersistUnique.AtLeastOneUniqueKey Stack.Storage.Project.ConfigCacheParent instance Database.Persist.Class.PersistEntity.SymbolToField "id" Stack.Storage.Project.ConfigCacheParent (Database.Persist.Class.PersistEntity.Key Stack.Storage.Project.ConfigCacheParent) instance Database.Persist.Class.PersistEntity.SymbolToField "directory" Stack.Storage.Project.ConfigCacheParent GHC.IO.FilePath instance Database.Persist.Class.PersistEntity.SymbolToField "type" Stack.Storage.Project.ConfigCacheParent Stack.Types.Cache.ConfigCacheType instance Database.Persist.Class.PersistEntity.SymbolToField "pkgSrc" Stack.Storage.Project.ConfigCacheParent Stack.Types.Build.CachePkgSrc instance Database.Persist.Class.PersistEntity.SymbolToField "active" Stack.Storage.Project.ConfigCacheParent GHC.Types.Bool instance Database.Persist.Class.PersistEntity.SymbolToField "pathEnvVar" Stack.Storage.Project.ConfigCacheParent Data.Text.Internal.Text instance Database.Persist.Class.PersistEntity.SymbolToField "haddock" Stack.Storage.Project.ConfigCacheParent GHC.Types.Bool module Stack.Setup.Installed getCompilerVersion :: (HasProcessContext env, HasLogFunc env) => WhichCompiler -> Path Abs File -> RIO env ActualCompiler markInstalled :: (MonadIO m, MonadThrow m) => Path Abs Dir -> Tool -> m () unmarkInstalled :: MonadIO m => Path Abs Dir -> Tool -> m () listInstalled :: (MonadIO m, MonadThrow m) => Path Abs Dir -> m [Tool] data Tool -- | e.g. ghc-7.8.4, msys2-20150512 Tool :: PackageIdentifier -> Tool -- | e.g. ghc-git-COMMIT_ID-FLAVOUR ToolGhcGit :: !Text -> !Text -> Tool toolString :: Tool -> String toolNameString :: Tool -> String parseToolText :: Text -> Maybe Tool filterTools :: PackageName -> (Version -> Bool) -> [Tool] -> [PackageIdentifier] -- | Binary directories for the given installed package extraDirs :: HasConfig env => Tool -> RIO env ExtraDirs installDir :: (MonadReader env m, MonadThrow m) => Path Abs Dir -> Tool -> m (Path Abs Dir) tempInstallDir :: (MonadReader env m, MonadThrow m) => Path Abs Dir -> Tool -> m (Path Abs Dir) instance GHC.Classes.Eq Stack.Setup.Installed.Tool instance GHC.Classes.Ord Stack.Setup.Installed.Tool -- | Functions for the GHC package database. module Stack.GhcPkg -- | Create a package database in the given directory, if it doesn't exist. createDatabase :: (HasProcessContext env, HasLogFunc env) => GhcPkgExe -> Path Abs Dir -> RIO env () -- | Get the value of a field of the package. findGhcPkgField :: (HasProcessContext env, HasLogFunc env) => GhcPkgExe -> [Path Abs Dir] -> String -> Text -> RIO env (Maybe Text) -- | Get the global package database getGlobalDB :: (HasProcessContext env, HasLogFunc env) => GhcPkgExe -> RIO env (Path Abs Dir) -- | Get the environment variable to use for the package DB paths. ghcPkgPathEnvVar :: WhichCompiler -> Text -- | Get the value for GHC_PACKAGE_PATH mkGhcPackagePath :: Bool -> Path Abs Dir -> Path Abs Dir -> [Path Abs Dir] -> Path Abs Dir -> Text -- | unregister list of package ghcids, batching available from GHC 8.2.1, -- see -- https://github.com/commercialhaskell/stack/issues/2662#issuecomment-460342402 -- using GHC package id where available (from GHC 7.9) unregisterGhcPkgIds :: (HasProcessContext env, HasLogFunc env) => GhcPkgExe -> Path Abs Dir -> NonEmpty (Either PackageIdentifier GhcPkgId) -> RIO env () module Stack.PackageDump -- | A single line of input, not including line endings type Line = Text -- | Apply the given Sink to each section of output, broken by a single -- line containing --- eachSection :: Monad m => ConduitM Line Void m a -> ConduitM Text a m () -- | Grab each key/value pair eachPair :: Monad m => (Text -> ConduitM Line Void m a) -> ConduitM Line a m () -- | Dump information for a single package data DumpPackage DumpPackage :: !GhcPkgId -> !PackageIdentifier -> !Maybe PackageIdentifier -> !Maybe License -> ![FilePath] -> ![Text] -> !Bool -> !Set ModuleName -> ![GhcPkgId] -> ![FilePath] -> !Maybe FilePath -> !Bool -> DumpPackage [dpGhcPkgId] :: DumpPackage -> !GhcPkgId [dpPackageIdent] :: DumpPackage -> !PackageIdentifier [dpParentLibIdent] :: DumpPackage -> !Maybe PackageIdentifier [dpLicense] :: DumpPackage -> !Maybe License [dpLibDirs] :: DumpPackage -> ![FilePath] [dpLibraries] :: DumpPackage -> ![Text] [dpHasExposedModules] :: DumpPackage -> !Bool [dpExposedModules] :: DumpPackage -> !Set ModuleName [dpDepends] :: DumpPackage -> ![GhcPkgId] [dpHaddockInterfaces] :: DumpPackage -> ![FilePath] [dpHaddockHtml] :: DumpPackage -> !Maybe FilePath [dpIsExposed] :: DumpPackage -> !Bool -- | Convert a stream of bytes into a stream of DumpPackages conduitDumpPackage :: MonadThrow m => ConduitM Text DumpPackage m () -- | Call ghc-pkg dump with appropriate flags and stream to the given -- Sink, for a single database ghcPkgDump :: (HasProcessContext env, HasLogFunc env) => GhcPkgExe -> [Path Abs Dir] -> ConduitM Text Void (RIO env) a -> RIO env a -- | Call ghc-pkg describe with appropriate flags and stream to the given -- Sink, for a single database ghcPkgDescribe :: (HasProcessContext env, HasLogFunc env, HasCompiler env) => GhcPkgExe -> PackageName -> [Path Abs Dir] -> ConduitM Text Void (RIO env) a -> RIO env a -- | Find the package IDs matching the given constraints with all -- dependencies installed. Packages not mentioned in the provided -- Map are allowed to be present too. sinkMatching :: Monad m => Map PackageName Version -> ConduitM DumpPackage o m (Map PackageName DumpPackage) -- | Prune a list of possible packages down to those whose dependencies are -- met. -- --