Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport batch 3 3.2 #6461

Merged
merged 5 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cabal/Distribution/Fields/Field.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fieldLineBS (FieldLine _ bs) = bs
-- | Section arguments, e.g. name of the library
data SectionArg ann
= SecArgName !ann !ByteString
-- ^ identifier, or omething which loos like number. Also many dot numbers, i.e. "7.6.3"
-- ^ identifier, or something which looks like number. Also many dot numbers, i.e. "7.6.3"
| SecArgStr !ann !ByteString
-- ^ quoted string
| SecArgOther !ann !ByteString
Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import Distribution.Types.CondTree
import Distribution.Types.ExeDependency
import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
import Distribution.Utils.Generic (isAscii, safeInit)
import Distribution.Utils.Generic (isAscii)
import Distribution.Verbosity
import Distribution.Version
import Language.Haskell.Extension
Expand Down
1 change: 0 additions & 1 deletion Cabal/Distribution/Simple/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ module Distribution.Simple.Compiler (

import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.Generic(safeLast)
import Distribution.Pretty

import Distribution.Compiler
Expand Down
3 changes: 1 addition & 2 deletions Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ import Distribution.Backpack.DescribeUnitId
import Distribution.Backpack.PreExistingComponent
import Distribution.Backpack.ConfiguredComponent (newPackageDepsBehaviour)
import Distribution.Backpack.Id
import Distribution.Utils.Generic
import Distribution.Utils.LogProgress

import qualified Distribution.Simple.GHC as GHC
Expand Down Expand Up @@ -972,7 +971,7 @@ dependencySatisfiable
-- Reinterpret the "package name" as an unqualified component
-- name
= LSubLibName $ packageNameToUnqualComponentName depName
-- Check whether a libray exists and is visible.
-- Check whether a library exists and is visible.
-- We don't disambiguate between dependency on non-existent or private
-- library yet, so we just return a bool and later report a generic error.
visible lib = maybe
Expand Down
1 change: 0 additions & 1 deletion Cabal/Distribution/Simple/HaskellSuite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo
import Distribution.System (Platform)
import Distribution.Compat.Exception
import Distribution.Utils.Generic
import Language.Haskell.Extension
import Distribution.Simple.Program.Builtin

Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Simple/Test/Log.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ summarizePackage verbosity packageLog = do
where
addTriple (p1, f1, e1) (p2, f2, e2) = (p1 + p2, f1 + f2, e1 + e2)

-- | Print a summary of a single test case's result to the console, supressing
-- | Print a summary of a single test case's result to the console, suppressing
-- output for certain verbosity or test filter levels.
summarizeTest :: Verbosity -> TestShowDetails -> TestLogs -> IO ()
summarizeTest _ _ (GroupLogs {}) = return ()
Expand Down
2 changes: 2 additions & 0 deletions Cabal/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ module Distribution.Simple.Utils (
ordNubRight,
safeHead,
safeTail,
safeLast,
safeInit,
unintersperse,
wrapText,
wrapLine,
Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Types/BuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ data BuildInfo = BuildInfo {
-- Example 2: a library that is being built by a foreing tool (e.g. rust)
-- and copied and registered together with this library. The
-- logic on how this library is built will have to be encoded in a
-- custom Setup for now. Oherwise cabal would need to lear how to
-- custom Setup for now. Otherwise cabal would need to lear how to
-- call arbitrary library builders.
extraLibFlavours :: [String], -- ^ Hidden Flag. This set of strings, will be appended to all libraries when
-- copying. E.g. [libHS<name>_<flavour> | flavour <- extraLibFlavours]. This
Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Types/PackageDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,6 @@ instance L.HasBuildInfos PackageDescription where
<*> (traverse . L.buildInfo) f x6 -- benchmarks
<*> pure a20 -- data files
<*> pure a21 -- data dir
<*> pure a22 -- exta src files
<*> pure a22 -- extra src files
<*> pure a23 -- extra temp files
<*> pure a24 -- extra doc files
8 changes: 8 additions & 0 deletions Cabal/Distribution/Utils/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -369,21 +369,29 @@ listUnionRight a b = ordNubRight (filter (`Set.notMember` bSet) a) ++ b
bSet = Set.fromList b

-- | A total variant of 'head'.
--
-- @since 3.2.0.0
safeHead :: [a] -> Maybe a
safeHead [] = Nothing
safeHead (x:_) = Just x

-- | A total variant of 'tail'.
--
-- @since 3.2.0.0
safeTail :: [a] -> [a]
safeTail [] = []
safeTail (_:xs) = xs

-- | A total variant of 'last'.
--
-- @since 3.2.0.0
safeLast :: [a] -> Maybe a
safeLast [] = Nothing
safeLast (x:xs) = Just (foldl (\_ a -> a) x xs)

-- | A total variant of 'init'.
--
-- @since 3.2.0.0
safeInit :: [a] -> [a]
safeInit [] = []
safeInit [_] = []
Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Utils/IOData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ instance KnownIODataMode LBS.ByteString where
-- This is the dual operation ot 'hGetIODataContents',
-- and consequently the handle is closed with `hClose`.
--
-- /Note:/ this performes lazy-IO.
-- /Note:/ this performs lazy-IO.
--
-- @since 2.2
hPutContents :: System.IO.Handle -> IOData -> Prelude.IO ()
Expand Down
12 changes: 11 additions & 1 deletion Cabal/Distribution/Utils/Structured.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ module Distribution.Utils.Structured (
-- | These functions operate like @binary@'s counterparts,
-- but the serialised version has a structure hash in front.
structuredEncode,
structuredEncodeFile,
structuredDecode,
structuredDecodeOrFailIO,
structuredDecodeFileOrFail,
-- * Structured class
Structured (structure),
MD5,
Expand Down Expand Up @@ -178,7 +180,7 @@ typeName f (Structure t v n s) = fmap (\n' -> Structure t v n' s) (f n)
-- | Flatten 'Structure' into something we can calculate hash of.
--
-- As 'Structure' can be potentially infinite. For mutually recursive types,
-- we keep track of 'TypeRep's, and put just 'TypeRep' name when it's occured
-- we keep track of 'TypeRep's, and put just 'TypeRep' name when it's occurred
-- another time.
structureBuilder :: Structure -> Builder.Builder
structureBuilder s0 = State.evalState (go s0) Map.empty where
Expand Down Expand Up @@ -262,6 +264,10 @@ structuredEncode
=> a -> LBS.ByteString
structuredEncode x = Binary.encode (Tag :: Tag a, x)

-- | Lazily serialise a value to a file
structuredEncodeFile :: (Binary.Binary a, Structured a) => FilePath -> a -> IO ()
structuredEncodeFile f = LBS.writeFile f . structuredEncode

-- | Structured 'Binary.decode'.
-- Decode a value from a lazy 'LBS.ByteString', reconstructing the original structure.
-- Throws pure exception on invalid inputs.
Expand All @@ -280,6 +286,10 @@ structuredDecodeOrFailIO bs =
handler (ErrorCall str) = return $ Left str
#endif

-- | Lazily reconstruct a value previously written to a file.
structuredDecodeFileOrFail :: (Binary.Binary a, Structured a) => FilePath -> IO (Either String a)
structuredDecodeFileOrFail f = structuredDecodeOrFailIO =<< LBS.readFile f

-------------------------------------------------------------------------------
-- Helper data
-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Cabal/doc/hcar/Cabal-201604.tex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ \subsubsection*{Looking Forward}
\item Further work on nix-style local builds, perhaps making that code path the
default.
\item Enabling Hackage Security by default.
\item Native suport for
\item Native support for
\href{https://github.com/haskell/cabal/pull/2540}{``foreign libraries''}:
Haskell libraries that are intended to be used by non-Haskell code.
\item New Parsec-based parser for \texttt{.cabal} files.
Expand Down
31 changes: 28 additions & 3 deletions Cabal/doc/installing-packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The name of the repository is given on the first line, and can be
anything; packages downloaded from this repository will be cached under
``~/.cabal/packages/hackage.haskell.org`` (or whatever name you specify;
you can change the prefix by changing the value of
``remote-repo-cache``). If you want, you can configure multiple
:cfg-field:`remote-repo-cache`). If you want, you can configure multiple
repositories, and ``cabal`` will combine them and be able to download
packages from any of them.

Expand Down Expand Up @@ -97,7 +97,32 @@ received were the right ones. How that is done is however outside the
scope of ``cabal`` proper.

More information about the security infrastructure can be found at
https://github.com/well-typed/hackage-security.
https://github.com/haskell/hackage-security.

Local no-index repositories
^^^^^^^^^^^^^^^^^^^^^^^^^^^

It's possible to use a directory of `.tar.gz` package files as a local package
repository.

::

repository my-local-repository
url: file+noindex:///absolute/path/to/directory

``cabal`` will construct the index automatically from the
``package-name-version.tar.gz`` files in the directory, and will use optional
corresponding ``package-name-version.cabal`` files as new revisions.

The index is cached inside the given directory. If the directory is not
writable, you can append ``#shared-cache`` fragment to the URI,
then the cache will be stored inside the :cfg-field:`remote-repo-cache` directory.
The part of the path will be used to determine the cache key part.

.. note::
The URI scheme ``file:`` is interpreted as a remote repository,
as described in the previous sections, thus requiring manual construction
of ``01-index.tar`` file.

Legacy repositories
^^^^^^^^^^^^^^^^^^^
Expand All @@ -120,7 +145,7 @@ although, in (and only in) the specific case of Hackage, the URL
``http://hackage.haskell.org/packages/archive`` will be silently
translated to ``http://hackage.haskell.org/``.

The second kind of legacy repositories are so-called “local”
The second kind of legacy repositories are so-called “(legacy) local”
repositories:

::
Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests/errors/big-version.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cabal-version: 3.0
name: big-vesion
name: big-version
-- 10 digits
version: 1234567890

Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests/regressions/big-version.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cabal-version: 3.0
name: big-vesion
name: big-version
-- 9 digits
version: 123456789

Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests/regressions/big-version.expr
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ GenericPackageDescription
licenseRaw = Left NONE,
maintainer = "",
package = PackageIdentifier
{pkgName = `PackageName "big-vesion"`,
{pkgName = `PackageName "big-version"`,
pkgVersion = `mkVersion [123456789]`},
pkgUrl = "",
setupBuildInfo = Nothing,
Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/ParserTests/regressions/big-version.format
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cabal-version: 3.0
name: big-vesion
name: big-version
version: 123456789

library
Expand Down
2 changes: 1 addition & 1 deletion Cabal/tests/Test/Laws.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ monoid_2 :: (Eq a, Data.Monoid.Monoid a) => a -> a -> a -> Bool
monoid_2 x y z = (x `mappend` y) `mappend` z
== x `mappend` (y `mappend` z)

-- | The 'mconcat' definition. It can be overidden for the sake of effeciency
-- | The 'mconcat' definition. It can be overidden for the sake of efficiency
-- but it must still satisfy the property given by the default definition:
--
-- > mconcat = foldr mappend mempty
Expand Down
4 changes: 2 additions & 2 deletions cabal-dev-scripts/cabal-dev-scripts.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ executable gen-spdx
, lens ^>=4.18.1
, optparse-applicative ^>=0.15.1.0
, text
, zinza ^>=0.1
, zinza ^>=0.2

executable gen-spdx-exc
default-language: Haskell2010
Expand All @@ -54,4 +54,4 @@ executable gen-spdx-exc
, lens ^>=4.18.1
, optparse-applicative ^>=0.15.1.0
, text
, zinza ^>=0.1
, zinza ^>=0.2
1 change: 0 additions & 1 deletion cabal-dev-scripts/src/GenSPDX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Data.List (sortOn)
import Data.Semigroup ((<>))
import Data.Text (Text)
import Data.Traversable (for)
import GHC.Generics (Generic)

import qualified Data.ByteString.Lazy as LBS
import qualified Data.Set as Set
Expand Down
10 changes: 6 additions & 4 deletions cabal-dev-scripts/src/GenUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ data Input = Input
deriving (Show, Generic)

instance Z.Zinza Input where
toType = Z.genericToTypeSFP
toValue = Z.genericToValueSFP
toType = Z.genericToTypeSFP
toValue = Z.genericToValueSFP
fromValue = Z.genericFromValueSFP

data InputLicense = InputLicense
{ ilConstructor :: Text
Expand All @@ -157,5 +158,6 @@ data InputLicense = InputLicense
deriving (Show, Generic)

instance Z.Zinza InputLicense where
toType = Z.genericToTypeSFP
toValue = Z.genericToValueSFP
toType = Z.genericToTypeSFP
toValue = Z.genericToValueSFP
fromValue = Z.genericFromValueSFP
3 changes: 3 additions & 0 deletions cabal-dev-scripts/src/Preprocessor.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{- cabal:
build-depends: base, containers
-}
{-# LANGUAGE DeriveFunctor #-}
module Main (main) where

Expand Down
Loading