packages feed

Cabal-syntax 3.10.3.0 → 3.16.1.0

raw patch · 145 files changed

Files

Cabal-syntax.cabal view
@@ -1,7 +1,7 @@-cabal-version: 2.2+cabal-version: 3.6 name:          Cabal-syntax-version:       3.10.3.0-copyright:     2003-2023, Cabal Development Team (see AUTHORS file)+version:       3.16.1.0+copyright:     2003-2025, Cabal Development Team (see AUTHORS file) license:       BSD-3-Clause license-file:  LICENSE author:        Cabal Development Team <cabal-devel@haskell.org>@@ -28,29 +28,30 @@   hs-source-dirs: src    build-depends:-    array      >= 0.4.0.1  && < 0.6,-    base       >= 4.9      && < 5,-    binary     >= 0.7      && < 0.9,-    bytestring >= 0.10.0.0 && < 0.13,-    containers >= 0.5.0.0  && < 0.8,-    deepseq    >= 1.3.0.1  && < 1.6,-    directory  >= 1.2      && < 1.4,-    filepath   >= 1.3.0.1  && < 1.6,-    mtl        >= 2.1      && < 2.4,-    parsec     >= 3.1.13.0 && < 3.2,-    pretty     >= 1.1.1    && < 1.2,-    text       (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2),-    time       >= 1.4.0.1  && < 1.13,+    , array      >= 0.4.0.1  && < 0.6+    , base       >= 4.13     && < 5+    , binary     >= 0.7      && < 0.9+    , bytestring >= 0.10.0.0 && < 0.13+    , containers >= 0.5.0.0  && < 0.9+    , deepseq    >= 1.3.0.1  && < 1.7+    , directory  >= 1.2      && < 1.4+    , filepath   >= 1.3.0.1  && < 1.6+    , mtl        >= 2.1      && < 2.4+    , parsec     >= 3.1.13.0 && < 3.2+    , pretty     >= 1.1.1    && < 1.2+    , text       (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2)+    , time       >= 1.4.0.1  && < 1.16     -- transformers-0.4.0.0 doesn't have record syntax e.g. for Identity     -- See also https://github.com/ekmett/transformers-compat/issues/35-    transformers (>= 0.3      && < 0.4) || (>=0.4.1.0 && <0.7)--  if os(windows)-    build-depends: Win32 >= 2.3.0.0 && < 2.14-  else-    build-depends: unix  >= 2.6.0.0 && < 2.9+    , transformers (>= 0.3      && < 0.4) || (>=0.4.1.0 && <0.7) -  ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates+  ghc-options:+    -Wall+    -fno-ignore-asserts+    -Wtabs+    -Wincomplete-uni-patterns+    -Wincomplete-record-updates+    -Wno-unticked-promoted-constructors    if impl(ghc >= 8.0)     ghc-options: -Wcompat -Wnoncanonical-monad-instances@@ -58,6 +59,8 @@   if impl(ghc >= 8.0) && impl(ghc < 8.8)     ghc-options: -Wnoncanonical-monadfail-instances +  build-tool-depends: alex:alex+   exposed-modules:     Distribution.Backpack     Distribution.CabalSpecVersion@@ -73,7 +76,6 @@     Distribution.Compat.Parsing     Distribution.Compat.Prelude     Distribution.Compat.Semigroup-    Distribution.Compat.Typeable     Distribution.Compiler     Distribution.FieldGrammar     Distribution.FieldGrammar.Class@@ -133,6 +135,7 @@     Distribution.Types.ConfVar     Distribution.Types.Dependency     Distribution.Types.DependencyMap+    Distribution.Types.DependencySatisfaction     Distribution.Types.ExeDependency     Distribution.Types.Executable     Distribution.Types.Executable.Lens@@ -156,6 +159,8 @@     Distribution.Types.Library.Lens     Distribution.Types.LibraryName     Distribution.Types.LibraryVisibility+    Distribution.Types.MissingDependency+    Distribution.Types.MissingDependencyReason     Distribution.Types.Mixin     Distribution.Types.Module     Distribution.Types.ModuleReexport
ChangeLog.md view
@@ -1,1 +1,1 @@-Please see See https://github.com/haskell/cabal/blob/master/release-notes/Cabal-3.10.3.0.md+Please see https://github.com/haskell/cabal/blob/master/release-notes/Cabal-3.16.1.0.md
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2003-2023, Cabal Development Team.+Copyright (c) 2003-2025, Cabal Development Team. See the AUTHORS file for the full list of copyright holders.  See */LICENSE for the copyright holders of the subcomponents.
Setup.hs view
@@ -1,3 +1,4 @@ import Distribution.Simple+ main :: IO () main = defaultMain
src/Distribution/Backpack.hs view
@@ -1,51 +1,48 @@-{-# LANGUAGE DeriveDataTypeable         #-}-{-# LANGUAGE DeriveGeneric              #-}-{-# LANGUAGE FlexibleInstances          #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE PatternGuards              #-}-{-# LANGUAGE RankNTypes                 #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE RankNTypes #-}  -- | This module defines the core data types for Backpack.  For more -- details, see: -- --  <https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst>--module Distribution.Backpack (-    -- * OpenUnitId-    OpenUnitId(..),-    openUnitIdFreeHoles,-    mkOpenUnitId,+module Distribution.Backpack+  ( -- * OpenUnitId+    OpenUnitId (..)+  , openUnitIdFreeHoles+  , mkOpenUnitId      -- * DefUnitId-    DefUnitId,-    unDefUnitId,-    mkDefUnitId,+  , DefUnitId+  , unDefUnitId+  , mkDefUnitId      -- * OpenModule-    OpenModule(..),-    openModuleFreeHoles,+  , OpenModule (..)+  , openModuleFreeHoles      -- * OpenModuleSubst-    OpenModuleSubst,-    dispOpenModuleSubst,-    dispOpenModuleSubstEntry,-    parsecOpenModuleSubst,-    parsecOpenModuleSubstEntry,-    openModuleSubstFreeHoles,+  , OpenModuleSubst+  , dispOpenModuleSubst+  , dispOpenModuleSubstEntry+  , parsecOpenModuleSubst+  , parsecOpenModuleSubstEntry+  , openModuleSubstFreeHoles      -- * Conversions to 'UnitId'-    abstractUnitId,-    hashModuleSubst,-) where+  , abstractUnitId+  , hashModuleSubst+  ) where  import Distribution.Compat.Prelude hiding (mod) import Distribution.Parsec import Distribution.Pretty+import Text.PrettyPrint (hcat) import Prelude ()-import Text.PrettyPrint            (hcat)  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp  import Distribution.ModuleName import Distribution.Types.ComponentId@@ -71,7 +68,7 @@ -- represent it as a 'DefiniteUnitId uid'. -- -- For a source component using Backpack, however, there is more--- structure as components may be parametrized over some signatures, and+-- structure as components may be parameterized over some signatures, and -- these \"holes\" may be partially or wholly filled. -- -- OpenUnitId plays an important role when we are mix-in linking,@@ -81,52 +78,53 @@ -- -- For more details see the Backpack spec -- <https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst>---- data OpenUnitId-    -- | Identifies a component which may have some unfilled holes;+  = -- | Identifies a component which may have some unfilled holes;     -- specifying its 'ComponentId' and its 'OpenModuleSubst'.     -- TODO: Invariant that 'OpenModuleSubst' is non-empty?     -- See also the Text instance.-    = IndefFullUnitId ComponentId OpenModuleSubst-    -- | Identifies a fully instantiated component, which has+    IndefFullUnitId ComponentId OpenModuleSubst+  | -- | Identifies a fully instantiated component, which has     -- been compiled and abbreviated as a hash.  The embedded 'UnitId'     -- MUST NOT be for an indefinite component; an 'OpenUnitId'     -- is guaranteed not to have any holes.-    | DefiniteUnitId DefUnitId-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+    DefiniteUnitId DefUnitId+  deriving (Generic, Read, Show, Eq, Ord, Data)+ -- TODO: cache holes?  instance Binary OpenUnitId instance Structured OpenUnitId instance NFData OpenUnitId where-    rnf (IndefFullUnitId cid subst) = rnf cid `seq` rnf subst-    rnf (DefiniteUnitId uid) = rnf uid+  rnf (IndefFullUnitId cid subst) = rnf cid `seq` rnf subst+  rnf (DefiniteUnitId uid) = rnf uid  instance Pretty OpenUnitId where-    pretty (IndefFullUnitId cid insts)-        -- TODO: arguably a smart constructor to enforce invariant would be-        -- better-        | Map.null insts = pretty cid-        | otherwise      = pretty cid <<>> Disp.brackets (dispOpenModuleSubst insts)-    pretty (DefiniteUnitId uid) = pretty uid+  pretty (IndefFullUnitId cid insts)+    -- TODO: arguably a smart constructor to enforce invariant would be+    -- better+    | Map.null insts = pretty cid+    | otherwise = pretty cid <<>> Disp.brackets (dispOpenModuleSubst insts)+  pretty (DefiniteUnitId uid) = pretty uid  -- | -- -- >>> eitherParsec "foobar" :: Either String OpenUnitId---Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"}))+-- Right (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "foobar"})) -- -- >>> eitherParsec "foo[Str=text-1.2.3:Data.Text.Text]" :: Either String OpenUnitId -- Right (IndefFullUnitId (ComponentId "foo") (fromList [(ModuleName "Str",OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "text-1.2.3"})) (ModuleName "Data.Text.Text"))]))--- instance Parsec OpenUnitId where-    parsec = P.try parseOpenUnitId <|> fmap DefiniteUnitId parsec-      where-        parseOpenUnitId = do-            cid <- parsec-            insts <- P.between (P.char '[') (P.char ']')-                       parsecOpenModuleSubst-            return (IndefFullUnitId cid insts)+  parsec = P.try parseOpenUnitId <|> fmap DefiniteUnitId parsec+    where+      parseOpenUnitId = do+        cid <- parsec+        insts <-+          P.between+            (P.char '[')+            (P.char ']')+            parsecOpenModuleSubst+        return (IndefFullUnitId cid insts)  -- | Get the set of holes ('ModuleVar') embedded in a 'UnitId'. openUnitIdFreeHoles :: OpenUnitId -> Set ModuleName@@ -137,9 +135,9 @@ -- is if the instantiation is provided. mkOpenUnitId :: UnitId -> ComponentId -> OpenModuleSubst -> OpenUnitId mkOpenUnitId uid cid insts =-    if Set.null (openModuleSubstFreeHoles insts)-        then DefiniteUnitId (unsafeMkDefUnitId uid) -- invariant holds!-        else IndefFullUnitId cid insts+  if Set.null (openModuleSubstFreeHoles insts)+    then DefiniteUnitId (unsafeMkDefUnitId uid) -- invariant holds!+    else IndefFullUnitId cid insts  ----------------------------------------------------------------------- -- DefUnitId@@ -148,10 +146,13 @@ -- with no holes. mkDefUnitId :: ComponentId -> Map ModuleName Module -> DefUnitId mkDefUnitId cid insts =-    unsafeMkDefUnitId (mkUnitId-        (unComponentId cid ++ maybe "" ("+"++) (hashModuleSubst insts)))-        -- impose invariant!+  unsafeMkDefUnitId+    ( mkUnitId+        (unComponentId cid ++ maybe "" ("+" ++) (hashModuleSubst insts))+    ) +-- impose invariant!+ ----------------------------------------------------------------------- -- OpenModule @@ -160,42 +161,41 @@ -- hole that needs to be filled in.  Substitutions are over -- module variables. data OpenModule-    = OpenModule OpenUnitId ModuleName-    | OpenModuleVar ModuleName-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+  = OpenModule OpenUnitId ModuleName+  | OpenModuleVar ModuleName+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary OpenModule instance Structured OpenModule  instance NFData OpenModule where-    rnf (OpenModule uid mod_name) = rnf uid `seq` rnf mod_name-    rnf (OpenModuleVar mod_name) = rnf mod_name+  rnf (OpenModule uid mod_name) = rnf uid `seq` rnf mod_name+  rnf (OpenModuleVar mod_name) = rnf mod_name  instance Pretty OpenModule where-    pretty (OpenModule uid mod_name) =-        hcat [pretty uid, Disp.text ":", pretty mod_name]-    pretty (OpenModuleVar mod_name) =-        hcat [Disp.char '<', pretty mod_name, Disp.char '>']+  pretty (OpenModule uid mod_name) =+    hcat [pretty uid, Disp.text ":", pretty mod_name]+  pretty (OpenModuleVar mod_name) =+    hcat [Disp.char '<', pretty mod_name, Disp.char '>']  -- | -- -- >>> eitherParsec "Includes2-0.1.0.0-inplace-mysql:Database.MySQL" :: Either String OpenModule -- Right (OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "Includes2-0.1.0.0-inplace-mysql"})) (ModuleName "Database.MySQL"))--- instance Parsec OpenModule where-    parsec = parsecModuleVar <|> parsecOpenModule-      where-        parsecOpenModule = do-            uid <- parsec-            _ <- P.char ':'-            mod_name <- parsec-            return (OpenModule uid mod_name)+  parsec = parsecModuleVar <|> parsecOpenModule+    where+      parsecOpenModule = do+        uid <- parsec+        _ <- P.char ':'+        mod_name <- parsec+        return (OpenModule uid mod_name) -        parsecModuleVar = do-            _ <- P.char '<'-            mod_name <- parsec-            _ <- P.char '>'-            return (OpenModuleVar mod_name)+      parsecModuleVar = do+        _ <- P.char '<'+        mod_name <- parsec+        _ <- P.char '>'+        return (OpenModuleVar mod_name)  -- | Get the set of holes ('ModuleVar') embedded in a 'Module'. openModuleFreeHoles :: OpenModule -> Set ModuleName@@ -214,8 +214,8 @@ -- | Pretty-print the entries of a module substitution, suitable -- for embedding into a 'OpenUnitId' or passing to GHC via @--instantiate-with@. dispOpenModuleSubst :: OpenModuleSubst -> Disp.Doc-dispOpenModuleSubst subst-    = Disp.hcat+dispOpenModuleSubst subst =+  Disp.hcat     . Disp.punctuate Disp.comma     $ map dispOpenModuleSubstEntry (Map.toAscList subst) @@ -227,19 +227,21 @@ -- -- @since 2.2 parsecOpenModuleSubst :: CabalParsing m => m OpenModuleSubst-parsecOpenModuleSubst = fmap Map.fromList-      . flip P.sepBy (P.char ',')-      $ parsecOpenModuleSubstEntry+parsecOpenModuleSubst =+  fmap Map.fromList+    . flip P.sepBy (P.char ',')+    $ parsecOpenModuleSubstEntry  -- | Inverse to 'dispModSubstEntry'. -- -- @since 2.2 parsecOpenModuleSubstEntry :: CabalParsing m => m (ModuleName, OpenModule) parsecOpenModuleSubstEntry =-    do k <- parsec-       _ <- P.char '='-       v <- parsec-       return (k, v)+  do+    k <- parsec+    _ <- P.char '='+    v <- parsec+    return (k, v)  -- | Get the set of holes ('ModuleVar') embedded in a 'OpenModuleSubst'. -- This is NOT the domain of the substitution.@@ -265,5 +267,7 @@   | Map.null subst = Nothing   | otherwise =       Just . hashToBase62 $-        concat [ prettyShow mod_name ++ "=" ++ prettyShow m ++ "\n"-               | (mod_name, m) <- Map.toList subst]+        concat+          [ prettyShow mod_name ++ "=" ++ prettyShow m ++ "\n"+          | (mod_name, m) <- Map.toList subst+          ]
src/Distribution/CabalSpecVersion.hs view
@@ -1,37 +1,42 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+ module Distribution.CabalSpecVersion where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  -- | Different Cabal-the-spec versions. -- -- We branch based on this at least in the parser.--- data CabalSpecVersion-    = CabalSpecV1_0 -- ^ this is older than 'CabalSpecV1_2'-    | CabalSpecV1_2 -- ^ new syntax (sections)-    | CabalSpecV1_4-    | CabalSpecV1_6-    | CabalSpecV1_8-    | CabalSpecV1_10-    | CabalSpecV1_12-    -- 1.16 -- 1.14: no changes-    | CabalSpecV1_18-    | CabalSpecV1_20-    | CabalSpecV1_22-    | CabalSpecV1_24-    | CabalSpecV2_0-    | CabalSpecV2_2-    | CabalSpecV2_4-    | CabalSpecV3_0-    -- 3.2: no changes-    | CabalSpecV3_4-    | CabalSpecV3_6-    | CabalSpecV3_8-    -- 3.10: no changes-  deriving (Eq, Ord, Show, Read, Enum, Bounded, Typeable, Data, Generic)+  = -- | this is older than 'CabalSpecV1_2'+    CabalSpecV1_0+  | -- | new syntax (sections)+    CabalSpecV1_2+  | CabalSpecV1_4+  | CabalSpecV1_6+  | CabalSpecV1_8+  | CabalSpecV1_10+  | CabalSpecV1_12+  | -- 1.16 -- 1.14: no changes+    CabalSpecV1_18+  | CabalSpecV1_20+  | CabalSpecV1_22+  | CabalSpecV1_24+  | CabalSpecV2_0+  | CabalSpecV2_2+  | CabalSpecV2_4+  | CabalSpecV3_0+  | -- 3.2: no changes+    CabalSpecV3_4+  | CabalSpecV3_6+  | CabalSpecV3_8+  | -- 3.10: no changes+    CabalSpecV3_12+  | CabalSpecV3_14+  | CabalSpecV3_16+  deriving (Eq, Ord, Show, Read, Enum, Bounded, Data, Generic)  instance Binary CabalSpecVersion instance Structured CabalSpecVersion@@ -41,74 +46,82 @@ -- -- @since 3.0.0.0 showCabalSpecVersion :: CabalSpecVersion -> String-showCabalSpecVersion CabalSpecV3_8  = "3.8"-showCabalSpecVersion CabalSpecV3_6  = "3.6"-showCabalSpecVersion CabalSpecV3_4  = "3.4"-showCabalSpecVersion CabalSpecV3_0  = "3.0"-showCabalSpecVersion CabalSpecV2_4  = "2.4"-showCabalSpecVersion CabalSpecV2_2  = "2.2"-showCabalSpecVersion CabalSpecV2_0  = "2.0"+showCabalSpecVersion CabalSpecV3_16 = "3.16"+showCabalSpecVersion CabalSpecV3_14 = "3.14"+showCabalSpecVersion CabalSpecV3_12 = "3.12"+showCabalSpecVersion CabalSpecV3_8 = "3.8"+showCabalSpecVersion CabalSpecV3_6 = "3.6"+showCabalSpecVersion CabalSpecV3_4 = "3.4"+showCabalSpecVersion CabalSpecV3_0 = "3.0"+showCabalSpecVersion CabalSpecV2_4 = "2.4"+showCabalSpecVersion CabalSpecV2_2 = "2.2"+showCabalSpecVersion CabalSpecV2_0 = "2.0" showCabalSpecVersion CabalSpecV1_24 = "1.24" showCabalSpecVersion CabalSpecV1_22 = "1.22" showCabalSpecVersion CabalSpecV1_20 = "1.20" showCabalSpecVersion CabalSpecV1_18 = "1.18" showCabalSpecVersion CabalSpecV1_12 = "1.12" showCabalSpecVersion CabalSpecV1_10 = "1.10"-showCabalSpecVersion CabalSpecV1_8  = "1.8"-showCabalSpecVersion CabalSpecV1_6  = "1.6"-showCabalSpecVersion CabalSpecV1_4  = "1.4"-showCabalSpecVersion CabalSpecV1_2  = "1.2"-showCabalSpecVersion CabalSpecV1_0  = "1.0"+showCabalSpecVersion CabalSpecV1_8 = "1.8"+showCabalSpecVersion CabalSpecV1_6 = "1.6"+showCabalSpecVersion CabalSpecV1_4 = "1.4"+showCabalSpecVersion CabalSpecV1_2 = "1.2"+showCabalSpecVersion CabalSpecV1_0 = "1.0"  cabalSpecLatest :: CabalSpecVersion-cabalSpecLatest = CabalSpecV3_8+cabalSpecLatest = CabalSpecV3_16  -- | Parse 'CabalSpecVersion' from version digits. -- -- It may fail if for recent versions the version is not exact.--- cabalSpecFromVersionDigits :: [Int] -> Maybe CabalSpecVersion cabalSpecFromVersionDigits v-    | v == [3,8]  = Just CabalSpecV3_8-    | v == [3,6]  = Just CabalSpecV3_6-    | v == [3,4]  = Just CabalSpecV3_4-    | v == [3,0]  = Just CabalSpecV3_0-    | v == [2,4]  = Just CabalSpecV2_4-    | v == [2,2]  = Just CabalSpecV2_2-    | v == [2,0]  = Just CabalSpecV2_0-    | v >= [1,25] = Nothing-    | v >= [1,23] = Just CabalSpecV1_24-    | v >= [1,21] = Just CabalSpecV1_22-    | v >= [1,19] = Just CabalSpecV1_20-    | v >= [1,17] = Just CabalSpecV1_18-    | v >= [1,11] = Just CabalSpecV1_12-    | v >= [1,9]  = Just CabalSpecV1_10-    | v >= [1,7]  = Just CabalSpecV1_8-    | v >= [1,5]  = Just CabalSpecV1_6-    | v >= [1,3]  = Just CabalSpecV1_4-    | v >= [1,1]  = Just CabalSpecV1_2-    | otherwise   = Just CabalSpecV1_0+  | v == [3, 16] = Just CabalSpecV3_16+  | v == [3, 14] = Just CabalSpecV3_14+  | v == [3, 12] = Just CabalSpecV3_12+  | v == [3, 8] = Just CabalSpecV3_8+  | v == [3, 6] = Just CabalSpecV3_6+  | v == [3, 4] = Just CabalSpecV3_4+  | v == [3, 0] = Just CabalSpecV3_0+  | v == [2, 4] = Just CabalSpecV2_4+  | v == [2, 2] = Just CabalSpecV2_2+  | v == [2, 0] = Just CabalSpecV2_0+  | v >= [1, 25] = Nothing+  | v >= [1, 23] = Just CabalSpecV1_24+  | v >= [1, 21] = Just CabalSpecV1_22+  | v >= [1, 19] = Just CabalSpecV1_20+  | v >= [1, 17] = Just CabalSpecV1_18+  | v >= [1, 11] = Just CabalSpecV1_12+  | v >= [1, 9] = Just CabalSpecV1_10+  | v >= [1, 7] = Just CabalSpecV1_8+  | v >= [1, 5] = Just CabalSpecV1_6+  | v >= [1, 3] = Just CabalSpecV1_4+  | v >= [1, 1] = Just CabalSpecV1_2+  | otherwise = Just CabalSpecV1_0  -- | @since 3.4.0.0 cabalSpecToVersionDigits :: CabalSpecVersion -> [Int]-cabalSpecToVersionDigits CabalSpecV3_8   = [3,8]-cabalSpecToVersionDigits CabalSpecV3_6   = [3,6]-cabalSpecToVersionDigits CabalSpecV3_4   = [3,4]-cabalSpecToVersionDigits CabalSpecV3_0   = [3,0]-cabalSpecToVersionDigits CabalSpecV2_4   = [2,4]-cabalSpecToVersionDigits CabalSpecV2_2   = [2,2]-cabalSpecToVersionDigits CabalSpecV2_0   = [2,0]-cabalSpecToVersionDigits CabalSpecV1_24  = [1,24]-cabalSpecToVersionDigits CabalSpecV1_22  = [1,22]-cabalSpecToVersionDigits CabalSpecV1_20  = [1,20]-cabalSpecToVersionDigits CabalSpecV1_18  = [1,18]-cabalSpecToVersionDigits CabalSpecV1_12  = [1,12]-cabalSpecToVersionDigits CabalSpecV1_10  = [1,10]-cabalSpecToVersionDigits CabalSpecV1_8   = [1,8]-cabalSpecToVersionDigits CabalSpecV1_6   = [1,6]-cabalSpecToVersionDigits CabalSpecV1_4   = [1,4]-cabalSpecToVersionDigits CabalSpecV1_2   = [1,2]-cabalSpecToVersionDigits CabalSpecV1_0   = [1,0]+cabalSpecToVersionDigits CabalSpecV3_16 = [3, 16]+cabalSpecToVersionDigits CabalSpecV3_14 = [3, 14]+cabalSpecToVersionDigits CabalSpecV3_12 = [3, 12]+cabalSpecToVersionDigits CabalSpecV3_8 = [3, 8]+cabalSpecToVersionDigits CabalSpecV3_6 = [3, 6]+cabalSpecToVersionDigits CabalSpecV3_4 = [3, 4]+cabalSpecToVersionDigits CabalSpecV3_0 = [3, 0]+cabalSpecToVersionDigits CabalSpecV2_4 = [2, 4]+cabalSpecToVersionDigits CabalSpecV2_2 = [2, 2]+cabalSpecToVersionDigits CabalSpecV2_0 = [2, 0]+cabalSpecToVersionDigits CabalSpecV1_24 = [1, 24]+cabalSpecToVersionDigits CabalSpecV1_22 = [1, 22]+cabalSpecToVersionDigits CabalSpecV1_20 = [1, 20]+cabalSpecToVersionDigits CabalSpecV1_18 = [1, 18]+cabalSpecToVersionDigits CabalSpecV1_12 = [1, 12]+cabalSpecToVersionDigits CabalSpecV1_10 = [1, 10]+cabalSpecToVersionDigits CabalSpecV1_8 = [1, 8]+cabalSpecToVersionDigits CabalSpecV1_6 = [1, 6]+cabalSpecToVersionDigits CabalSpecV1_4 = [1, 4]+cabalSpecToVersionDigits CabalSpecV1_2 = [1, 2]+cabalSpecToVersionDigits CabalSpecV1_0 = [1, 0]  -- | What is the minimum Cabal library version which knows how handle -- this spec version.@@ -124,20 +137,20 @@ -- -- @since 3.4.0.0 cabalSpecMinimumLibraryVersion :: CabalSpecVersion -> [Int]-cabalSpecMinimumLibraryVersion CabalSpecV1_0 = [1,0]+cabalSpecMinimumLibraryVersion CabalSpecV1_0 = [1, 0] cabalSpecMinimumLibraryVersion csv = case cabalSpecToVersionDigits (pred csv) of-    [x,y] -> [x, y+1]-    xs    -> xs+  [x, y] -> [x, y + 1]+  xs -> xs  specHasCommonStanzas :: CabalSpecVersion -> HasCommonStanzas specHasCommonStanzas v =-    if v >= CabalSpecV2_2+  if v >= CabalSpecV2_2     then HasCommonStanzas     else NoCommonStanzas  specHasElif :: CabalSpecVersion -> HasElif specHasElif v =-    if v >= CabalSpecV2_2+  if v >= CabalSpecV2_2     then HasElif     else NoElif 
src/Distribution/Compat/Binary.hs view
@@ -1,11 +1,8 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE PatternSynonyms #-}- module Distribution.Compat.Binary-       ( decodeOrFailIO-       , decodeFileOrFail'-       , module Data.Binary-       ) where+  ( decodeOrFailIO+  , decodeFileOrFail'+  , module Data.Binary+  ) where  import Control.Exception (ErrorCall (..), catch, evaluate) import Data.ByteString.Lazy (ByteString)@@ -18,6 +15,6 @@  decodeOrFailIO :: Binary a => ByteString -> IO (Either String a) decodeOrFailIO bs =-    catch (evaluate (decode bs) >>= return . Right) handler+  catch (evaluate (decode bs) >>= return . Right) handler   where-    handler (ErrorCallWithLocation str _) = return $ Left str+    handler (ErrorCall str) = return $ Left str
src/Distribution/Compat/CharParsing.hs view
@@ -1,8 +1,12 @@-{-# LANGUAGE GADTs #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -fspec-constr -fspec-constr-count=8 #-}+ -----------------------------------------------------------------------------++-----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Compat.CharParsing -- Copyright   :  (c) Edward Kmett 2011@@ -15,28 +19,27 @@ -- Parsers for character streams -- -- Originally in @parsers@ package.--------------------------------------------------------------------------------- module Distribution.Compat.CharParsing-  (-  -- * Combinators-    oneOf        -- :: CharParsing m => [Char] -> m Char-  , noneOf       -- :: CharParsing m => [Char] -> m Char-  , spaces       -- :: CharParsing m => m ()-  , space        -- :: CharParsing m => m Char-  , newline      -- :: CharParsing m => m Char-  , tab          -- :: CharParsing m => m Char-  , upper        -- :: CharParsing m => m Char-  , lower        -- :: CharParsing m => m Char-  , alphaNum     -- :: CharParsing m => m Char-  , letter       -- :: CharParsing m => m Char-  , digit        -- :: CharParsing m => m Char-  , hexDigit     -- :: CharParsing m => m Char-  , octDigit     -- :: CharParsing m => m Char+  ( -- * Combinators+    oneOf -- :: CharParsing m => [Char] -> m Char+  , noneOf -- :: CharParsing m => [Char] -> m Char+  , spaces -- :: CharParsing m => m ()+  , space -- :: CharParsing m => m Char+  , newline -- :: CharParsing m => m Char+  , tab -- :: CharParsing m => m Char+  , upper -- :: CharParsing m => m Char+  , lower -- :: CharParsing m => m Char+  , alphaNum -- :: CharParsing m => m Char+  , letter -- :: CharParsing m => m Char+  , digit -- :: CharParsing m => m Char+  , hexDigit -- :: CharParsing m => m Char+  , octDigit -- :: CharParsing m => m Char   , satisfyRange -- :: CharParsing m => Char -> Char -> m Char-  -- * Class-  , CharParsing(..)-  -- * Cabal additions++    -- * Class+  , CharParsing (..)++    -- * Cabal additions   , integral   , signedIntegral   , munch1@@ -45,18 +48,18 @@   , module Distribution.Compat.Parsing   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Control.Monad.Trans.Class (lift)+import Control.Monad.Trans.Identity (IdentityT (..))+import Control.Monad.Trans.RWS.Lazy as Lazy+import Control.Monad.Trans.RWS.Strict as Strict+import Control.Monad.Trans.Reader (ReaderT (..)) import Control.Monad.Trans.State.Lazy as Lazy import Control.Monad.Trans.State.Strict as Strict import Control.Monad.Trans.Writer.Lazy as Lazy import Control.Monad.Trans.Writer.Strict as Strict-import Control.Monad.Trans.RWS.Lazy as Lazy-import Control.Monad.Trans.RWS.Strict as Strict-import Control.Monad.Trans.Reader (ReaderT (..))-import Control.Monad.Trans.Identity (IdentityT (..)) import Data.Char import Data.Text (Text, unpack) @@ -194,13 +197,13 @@ instance (CharParsing m, MonadPlus m) => CharParsing (Lazy.StateT s m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -208,13 +211,13 @@ instance (CharParsing m, MonadPlus m) => CharParsing (Strict.StateT s m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -222,13 +225,13 @@ instance (CharParsing m, MonadPlus m) => CharParsing (ReaderT e m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -236,13 +239,13 @@ instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Strict.WriterT w m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -250,13 +253,13 @@ instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Lazy.WriterT w m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -264,13 +267,13 @@ instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Lazy.RWST r w s m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -278,13 +281,13 @@ instance (CharParsing m, MonadPlus m, Monoid w) => CharParsing (Strict.RWST r w s m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}@@ -292,23 +295,23 @@ instance (CharParsing m, MonadPlus m) => CharParsing (IdentityT m) where   satisfy = lift . satisfy   {-# INLINE satisfy #-}-  char    = lift . char+  char = lift . char   {-# INLINE char #-}   notChar = lift . notChar   {-# INLINE notChar #-}   anyChar = lift anyChar   {-# INLINE anyChar #-}-  string  = lift . string+  string = lift . string   {-# INLINE string #-}   text = lift . text   {-# INLINE text #-}  instance Parsec.Stream s m Char => CharParsing (Parsec.ParsecT s u m) where-  satisfy   = Parsec.satisfy-  char      = Parsec.char+  satisfy = Parsec.satisfy+  char = Parsec.char   notChar c = Parsec.satisfy (/= c)-  anyChar   = Parsec.anyChar-  string    = Parsec.string+  anyChar = Parsec.anyChar+  string = Parsec.string  ------------------------------------------------------------------------------- -- Our additions@@ -329,7 +332,7 @@     f '7' = 7     f '8' = 8     f '9' = 9-    f _   = error "panic! integral"+    f _ = error "panic! integral" {-# INLINE integral #-}  -- | Accepts negative (starting with @-@) and positive (without sign) integral
src/Distribution/Compat/DList.hs view
@@ -1,4 +1,5 @@ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Compat.DList -- Copyright   :  (c) Ben Gamari 2015-2019@@ -9,18 +10,18 @@ -- Portability :  portable -- -- A very simple difference list.-module Distribution.Compat.DList (-    DList,-    runDList,-    empty,-    singleton,-    fromList,-    toList,-    snoc,-) where+module Distribution.Compat.DList+  ( DList+  , runDList+  , empty+  , singleton+  , fromList+  , toList+  , snoc+  ) where +import Distribution.Compat.Prelude hiding (empty, toList) import Prelude ()-import Distribution.Compat.Prelude hiding (toList, empty)  -- | Difference list. newtype DList a = DList ([a] -> [a])@@ -30,7 +31,7 @@  -- | Make 'DList' containing single element. singleton :: a -> DList a-singleton a = DList (a:)+singleton a = DList (a :)  -- | @since 3.4.0.0 empty :: DList a@@ -46,7 +47,7 @@ snoc xs x = xs <> singleton x  instance Monoid (DList a) where-  mempty  = empty+  mempty = empty   mappend = (<>)  instance Semigroup (DList a) where
src/Distribution/Compat/Exception.hs view
@@ -1,14 +1,13 @@-{-# LANGUAGE CPP #-}-module Distribution.Compat.Exception (-  catchIO,-  catchExit,-  tryIO,-  displayException,+module Distribution.Compat.Exception+  ( catchIO+  , catchExit+  , tryIO+  , displayException   ) where -import System.Exit-import qualified Control.Exception as Exception import Control.Exception (displayException)+import qualified Control.Exception as Exception+import System.Exit  -- | Try 'IOException'. tryIO :: IO a -> IO (Either Exception.IOException a)
src/Distribution/Compat/Graph.hs view
@@ -1,12 +1,10 @@-{-# LANGUAGE BangPatterns         #-}-{-# LANGUAGE CPP                  #-}-{-# LANGUAGE DeriveDataTypeable   #-}-{-# LANGUAGE FlexibleContexts     #-}-{-# LANGUAGE ScopedTypeVariables  #-}-{-# LANGUAGE TypeFamilies         #-}-{-# LANGUAGE TypeOperators        #-}+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-}------------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Compat.Graph -- Copyright   :  (c) Edward Z. Yang 2016@@ -38,81 +36,86 @@ -- vertices of a graph using 'broken' (and should, e.g., to ensure that -- a closure of a graph is well-formed.)  It's possible to take a closed -- subset of a broken graph and get a well-formed graph.---------------------------------------------------------------------------------+module Distribution.Compat.Graph+  ( -- * Graph type+    Graph+  , IsNode (..) -module Distribution.Compat.Graph (-    -- * Graph type-    Graph,-    IsNode(..),     -- * Query-    null,-    size,-    member,-    lookup,+  , null+  , size+  , member+  , lookup+     -- * Construction-    empty,-    insert,-    deleteKey,-    deleteLookup,+  , empty+  , insert+  , deleteKey+  , deleteLookup+     -- * Combine-    unionLeft,-    unionRight,+  , unionLeft+  , unionRight+     -- * Graph algorithms-    stronglyConnComp,-    SCC(..),-    cycles,-    broken,-    neighbors,-    revNeighbors,-    closure,-    revClosure,-    topSort,-    revTopSort,+  , stronglyConnComp+  , SCC (..)+  , cycles+  , broken+  , neighbors+  , revNeighbors+  , closure+  , revClosure+  , topSort+  , revTopSort+     -- * Conversions+     -- ** Maps-    toMap,+  , toMap+     -- ** Lists-    fromDistinctList,-    toList,-    keys,+  , fromDistinctList+  , toList+  , keys+     -- ** Sets-    keysSet,+  , keysSet+     -- ** Graphs-    toGraph,+  , toGraph+     -- * Node type-    Node(..),-    nodeValue,-) where+  , Node (..)+  , nodeValue+  ) where  import Distribution.Compat.Prelude hiding (empty, lookup, null, toList) import Prelude () -import Data.Array                    ((!))-import Data.Graph                    (SCC (..))+import Data.Array ((!))+import Data.Graph (SCC (..)) import Distribution.Utils.Structured (Structure (..), Structured (..)) -import qualified Data.Array                  as Array-import qualified Data.Foldable               as Foldable-import qualified Data.Graph                  as G-import qualified Data.Map.Strict             as Map-import qualified Data.Set                    as Set-import qualified Data.Tree                   as Tree+import qualified Data.Array as Array+import qualified Data.Foldable as Foldable+import qualified Data.Graph as G+import qualified Data.Map.Strict as Map+import qualified Data.Set as Set+import qualified Data.Tree as Tree import qualified Distribution.Compat.Prelude as Prelude  -- | A graph of nodes @a@.  The nodes are expected to have instance -- of class 'IsNode'.-data Graph a-    = Graph {-        graphMap          :: !(Map (Key a) a),-        -- Lazily cached graph representation-        graphForward      :: G.Graph,-        graphAdjoint      :: G.Graph,-        graphVertexToNode :: G.Vertex -> a,-        graphKeyToVertex  :: Key a -> Maybe G.Vertex,-        graphBroken       :: [(a, [Key a])]-    }-    deriving (Typeable)+data Graph a = Graph+  { graphMap :: !(Map (Key a) a)+  , -- Lazily cached graph representation+    graphForward :: G.Graph+  , graphAdjoint :: G.Graph+  , graphVertexToNode :: G.Vertex -> a+  , graphKeyToVertex :: Key a -> Maybe G.Vertex+  , graphBroken :: [(a, [Key a])]+  }  -- NB: Not a Functor! (or Traversable), because you need -- to restrict Key a ~ Key b.  We provide our own mapping@@ -122,50 +125,47 @@ -- Map representation.  instance Show a => Show (Graph a) where-    show = show . toList+  show = show . toList  instance (IsNode a, Read a, Show (Key a)) => Read (Graph a) where-    readsPrec d s = map (\(a,r) -> (fromDistinctList a, r)) (readsPrec d s)+  readsPrec d s = map (\(a, r) -> (fromDistinctList a, r)) (readsPrec d s)  instance (IsNode a, Binary a, Show (Key a)) => Binary (Graph a) where-    put x = put (toList x)-    get = fmap fromDistinctList get+  put x = put (toList x)+  get = fmap fromDistinctList get  instance Structured a => Structured (Graph a) where-    structure p = Nominal (typeRep p) 0 "Graph" [structure (Proxy :: Proxy a)]+  structure p = Nominal (typeRep p) 0 "Graph" [structure (Proxy :: Proxy a)]  instance (Eq (Key a), Eq a) => Eq (Graph a) where-    g1 == g2 = graphMap g1 == graphMap g2+  g1 == g2 = graphMap g1 == graphMap g2  instance Foldable.Foldable Graph where-    fold = Foldable.fold . graphMap-    foldr f z = Foldable.foldr f z . graphMap-    foldl f z = Foldable.foldl f z . graphMap-    foldMap f = Foldable.foldMap f . graphMap-    foldl' f z = Foldable.foldl' f z . graphMap-    foldr' f z = Foldable.foldr' f z . graphMap-#ifdef MIN_VERSION_base-#if MIN_VERSION_base(4,8,0)-    length = Foldable.length . graphMap-    null   = Foldable.null   . graphMap-    toList = Foldable.toList . graphMap-    elem x = Foldable.elem x . graphMap-    maximum = Foldable.maximum . graphMap-    minimum = Foldable.minimum . graphMap-    sum     = Foldable.sum     . graphMap-    product = Foldable.product . graphMap-#endif-#endif+  elem x = Foldable.elem x . graphMap+  fold = Foldable.fold . graphMap+  foldl f z = Foldable.foldl f z . graphMap+  foldl' f z = Foldable.foldl' f z . graphMap+  foldr f z = Foldable.foldr f z . graphMap+  foldr' f z = Foldable.foldr' f z . graphMap+  foldMap f = Foldable.foldMap f . graphMap+  length = Foldable.length . graphMap+  maximum = Foldable.maximum . graphMap+  minimum = Foldable.minimum . graphMap+  null = Foldable.null . graphMap+  product = Foldable.product . graphMap+  sum = Foldable.sum . graphMap+  toList = Foldable.toList . graphMap  instance (NFData a, NFData (Key a)) => NFData (Graph a) where-    rnf Graph {-        graphMap = m,-        graphForward = gf,-        graphAdjoint = ga,-        graphVertexToNode = vtn,-        graphKeyToVertex = ktv,-        graphBroken = b-    } = gf `seq` ga `seq` vtn `seq` ktv `seq` b `seq` rnf m+  rnf+    Graph+      { graphMap = m+      , graphForward = gf+      , graphAdjoint = ga+      , graphVertexToNode = vtn+      , graphKeyToVertex = ktv+      , graphBroken = b+      } = gf `seq` ga `seq` vtn `seq` ktv `seq` b `seq` rnf m  -- TODO: Data instance? @@ -174,32 +174,32 @@ -- type @'Key' a@; given a node we can determine its key ('nodeKey') -- and the keys of its neighbors ('nodeNeighbors'). class Ord (Key a) => IsNode a where-    type Key a-    nodeKey :: a -> Key a-    nodeNeighbors :: a -> [Key a]+  type Key a+  nodeKey :: a -> Key a+  nodeNeighbors :: a -> [Key a]  instance (IsNode a, IsNode b, Key a ~ Key b) => IsNode (Either a b) where-    type Key (Either a b) = Key a-    nodeKey (Left x)  = nodeKey x-    nodeKey (Right x) = nodeKey x-    nodeNeighbors (Left x)  = nodeNeighbors x-    nodeNeighbors (Right x) = nodeNeighbors x+  type Key (Either a b) = Key a+  nodeKey (Left x) = nodeKey x+  nodeKey (Right x) = nodeKey x+  nodeNeighbors (Left x) = nodeNeighbors x+  nodeNeighbors (Right x) = nodeNeighbors x  -- | A simple, trivial data type which admits an 'IsNode' instance. data Node k a = N a k [k]-    deriving (Show, Eq)+  deriving (Show, Eq)  -- | Get the value from a 'Node'. nodeValue :: Node k a -> a nodeValue (N a _ _) = a  instance Functor (Node k) where-    fmap f (N a k ks) = N (f a) k ks+  fmap f (N a k ks) = N (f a) k ks  instance Ord k => IsNode (Node k a) where-    type Key (Node k a) = k-    nodeKey (N _ k _) = k-    nodeNeighbors (N _ _ ks) = ks+  type Key (Node k a) = k+  nodeKey (N _ k _) = k+  nodeNeighbors (N _ _ ks) = ks  -- TODO: Maybe introduce a typeclass for items which just -- keys (so, Key associated type, and nodeKey method).  But@@ -241,8 +241,8 @@ -- value if it existed. deleteLookup :: IsNode a => Key a -> Graph a -> (Maybe a, Graph a) deleteLookup k g =-    let (r, m') = Map.updateLookupWithKey (\_ _ -> Nothing) k (toMap g)-    in (r, fromMap m')+  let (r, m') = Map.updateLookupWithKey (\_ _ -> Nothing) k (toMap g)+   in (r, fromMap m')  -- Combining @@ -266,18 +266,20 @@   where     forest = G.scc (graphForward g)     decode (Tree.Node v [])-        | mentions_itself v = CyclicSCC  [graphVertexToNode g v]-        | otherwise         = AcyclicSCC (graphVertexToNode g v)+      | mentions_itself v = CyclicSCC [graphVertexToNode g v]+      | otherwise = AcyclicSCC (graphVertexToNode g v)     decode other = CyclicSCC (dec other [])-        where dec (Tree.Node v ts) vs-                = graphVertexToNode g v : foldr dec vs ts+      where+        dec (Tree.Node v ts) vs =+          graphVertexToNode g v : foldr dec vs ts     mentions_itself v = v `elem` (graphForward g ! v)+ -- Implementation copied from 'stronglyConnCompR' in 'Data.Graph'.  -- | /Ω(V + E)/. Compute the cycles of a graph. -- Requires amortized construction of graph. cycles :: Graph a -> [[a]]-cycles g = [ vs | CyclicSCC vs <- stronglyConnComp g ]+cycles g = [vs | CyclicSCC vs <- stronglyConnComp g]  -- | /O(1)/.  Return a list of nodes paired with their broken -- neighbors (i.e., neighbor keys which are not in the graph).@@ -289,15 +291,15 @@ -- Requires amortized construction of graph. neighbors :: Graph a -> Key a -> Maybe [a] neighbors g k = do-    v <- graphKeyToVertex g k-    return (map (graphVertexToNode g) (graphForward g ! v))+  v <- graphKeyToVertex g k+  return (map (graphVertexToNode g) (graphForward g ! v))  -- | Lookup the immediate reverse neighbors from a key in the graph. -- Requires amortized construction of graph. revNeighbors :: Graph a -> Key a -> Maybe [a] revNeighbors g k = do-    v <- graphKeyToVertex g k-    return (map (graphVertexToNode g) (graphAdjoint g ! v))+  v <- graphKeyToVertex g k+  return (map (graphVertexToNode g) (graphAdjoint g ! v))  -- | Compute the subgraph which is the closure of some set of keys. -- Returns @Nothing@ if one (or more) keys are not present in@@ -305,8 +307,8 @@ -- Requires amortized construction of graph. closure :: Graph a -> [Key a] -> Maybe [a] closure g ks = do-    vs <- traverse (graphKeyToVertex g) ks-    return (decodeVertexForest g (G.dfs (graphForward g) vs))+  vs <- traverse (graphKeyToVertex g) ks+  return (decodeVertexForest g (G.dfs (graphForward g) vs))  -- | Compute the reverse closure of a graph from some set -- of keys.  Returns @Nothing@ if one (or more) keys are not present in@@ -314,8 +316,8 @@ -- Requires amortized construction of graph. revClosure :: Graph a -> [Key a] -> Maybe [a] revClosure g ks = do-    vs <- traverse (graphKeyToVertex g) ks-    return (decodeVertexForest g (G.dfs (graphAdjoint g) vs))+  vs <- traverse (graphKeyToVertex g) ks+  return (decodeVertexForest g (G.dfs (graphAdjoint g) vs))  flattenForest :: Tree.Forest a -> [a] flattenForest = concatMap Tree.flatten@@ -342,44 +344,49 @@ -- instead.  The values of the map are assumed to already -- be in WHNF. fromMap :: IsNode a => Map (Key a) a -> Graph a-fromMap m-    = Graph { graphMap = m-            -- These are lazily computed!-            , graphForward = g-            , graphAdjoint = G.transposeG g-            , graphVertexToNode = vertex_to_node-            , graphKeyToVertex = key_to_vertex-            , graphBroken = broke-            }+fromMap m =+  Graph+    { graphMap = m+    , -- These are lazily computed!+      graphForward = g+    , graphAdjoint = G.transposeG g+    , graphVertexToNode = vertex_to_node+    , graphKeyToVertex = key_to_vertex+    , graphBroken = broke+    }   where     try_key_to_vertex k = maybe (Left k) Right (key_to_vertex k) -    (brokenEdges, edges)-        = unzip-        $ [ partitionEithers (map try_key_to_vertex (nodeNeighbors n))-          | n <- ns ]+    (brokenEdges, edges) =+      unzip $+        [ partitionEithers (map try_key_to_vertex (nodeNeighbors n))+        | n <- ns+        ]     broke = filter (not . Prelude.null . snd) (zip ns brokenEdges)      g = Array.listArray bounds edges -    ns              = Map.elems m -- sorted ascending-    vertices        = zip (map nodeKey ns) [0..]-    vertex_map      = Map.fromAscList vertices+    ns = Map.elems m -- sorted ascending+    vertices = zip (map nodeKey ns) [0 ..]+    vertex_map = Map.fromAscList vertices     key_to_vertex k = Map.lookup k vertex_map      vertex_to_node vertex = nodeTable ! vertex -    nodeTable   = Array.listArray bounds ns+    nodeTable = Array.listArray bounds ns     bounds = (0, Map.size m - 1)  -- | /O(V log V)/. Convert a list of nodes (with distinct keys) into a graph. fromDistinctList :: (IsNode a, Show (Key a)) => [a] -> Graph a-fromDistinctList = fromMap-                 . Map.fromListWith (\_ -> duplicateError)-                 . map (\n -> n `seq` (nodeKey n, n))+fromDistinctList =+  fromMap+    . Map.fromListWith (\_ -> duplicateError)+    . map (\n -> n `seq` (nodeKey n, n))   where-    duplicateError n = error $ "Graph.fromDistinctList: duplicate key: "-                            ++ show (nodeKey n)+    duplicateError n =+      error $+        "Graph.fromDistinctList: duplicate key: "+          ++ show (nodeKey n)  -- Map-like operations 
src/Distribution/Compat/Lens.hs view
@@ -1,78 +1,95 @@ {-# LANGUAGE RankNTypes #-}+ -- | This module provides very basic lens functionality, without extra dependencies. -- -- For the documentation of the combinators see <http://hackage.haskell.org/package/lens lens> package. -- This module uses the same vocabulary.-module Distribution.Compat.Lens (-    -- * Types-    Lens,-    Lens',-    Traversal,-    Traversal',+module Distribution.Compat.Lens+  ( -- * Types+    Lens+  , Lens'+  , Traversal+  , Traversal'+     -- ** LensLike-    LensLike,-    LensLike',+  , LensLike+  , LensLike'+     -- ** rank-1 types-    Getting,-    AGetter,-    ASetter,-    ALens,-    ALens',+  , Getting+  , AGetter+  , ASetter+  , ALens+  , ALens'+     -- * Getter-    view,-    use,-    getting,+  , view+  , use+  , getting+     -- * Setter-    set,-    over,+  , set+  , over+     -- * Fold-    toDListOf,-    toListOf,-    toSetOf,+  , toDListOf+  , toListOf+  , toSetOf+     -- * Lens-    cloneLens,-    aview,+  , cloneLens+  , aview+     -- * Common lenses-    _1, _2,+  , _1+  , _2+     -- * Operators-    (&),-    (^.),-    (.~), (?~), (%~),-    (.=), (?=), (%=),-    (^#),-    (#~), (#%~),+  , (&)+  , (^.)+  , (.~)+  , (?~)+  , (%~)+  , (.=)+  , (?=)+  , (%=)+  , (^#)+  , (#~)+  , (#%~)+     -- * Internal Comonads-    Pretext (..),+  , Pretext (..)+     -- * Cabal developer info     -- $development-    ) where+  ) where -import Prelude() import Distribution.Compat.Prelude+import Prelude ()  import Control.Monad.State.Class (MonadState (..), gets, modify) -import qualified Distribution.Compat.DList as DList import qualified Data.Set as Set+import qualified Distribution.Compat.DList as DList  ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- -type LensLike  f s t a b = (a -> f b) -> s -> f t-type LensLike' f s   a   = (a -> f a) -> s -> f s+type LensLike f s t a b = (a -> f b) -> s -> f t+type LensLike' f s a = (a -> f a) -> s -> f s -type Lens      s t a b = forall f. Functor f     => LensLike f s t a b+type Lens s t a b = forall f. Functor f => LensLike f s t a b type Traversal s t a b = forall f. Applicative f => LensLike f s t a b -type Lens'      s a = Lens s s a a+type Lens' s a = Lens s s a a type Traversal' s a = Traversal s s a a  type Getting r s a = LensLike (Const r) s s a a -type AGetter s   a   = LensLike (Const a)     s s a a  -- this doesn't exist in 'lens'-type ASetter s t a b = LensLike Identity      s t a b-type ALens   s t a b = LensLike (Pretext a b) s t a b+type AGetter s a = LensLike (Const a) s s a a -- this doesn't exist in 'lens'+type ASetter s t a b = LensLike Identity s t a b+type ALens s t a b = LensLike (Pretext a b) s t a b  type ALens' s a = ALens s s a a @@ -80,7 +97,7 @@ -- Getter ------------------------------------------------------------------------------- -view :: Getting a s a -> s ->  a+view :: Getting a s a -> s -> a view l s = getConst (l Const s) {-# INLINE view #-} @@ -100,7 +117,7 @@ -- Setter ------------------------------------------------------------------------------- -set :: ASetter s t a  b -> b -> s -> t+set :: ASetter s t a b -> b -> s -> t set l x = over l (const x)  over :: ASetter s t a b -> (a -> b) -> s -> t@@ -116,7 +133,7 @@ toListOf :: Getting (DList.DList a) s a -> s -> [a] toListOf l = DList.runDList . toDListOf l -toSetOf  :: Getting (Set.Set a) s a -> s -> Set.Set a+toSetOf :: Getting (Set.Set a) s a -> s -> Set.Set a toSetOf l s = getConst (l (\x -> Const (Set.singleton x)) s)  -------------------------------------------------------------------------------@@ -124,7 +141,7 @@ -------------------------------------------------------------------------------  aview :: ALens s t a b -> s -> a-aview l = pretextPos  . l pretextSell+aview l = pretextPos . l pretextSell {-# INLINE aview #-}  {-@@ -136,10 +153,10 @@ -- Common ------------------------------------------------------------------------------- -_1 ::  Lens (a, c) (b, c) a b+_1 :: Lens (a, c) (b, c) a b _1 f (a, c) = flip (,) c <$> f a -_2 ::  Lens (c, a) (c, b) a b+_2 :: Lens (c, a) (c, b) a b _2 f (c, a) = (,) c <$> f a  -------------------------------------------------------------------------------@@ -150,6 +167,7 @@ (&) :: a -> (a -> b) -> b (&) = flip ($) {-# INLINE (&) #-}+ infixl 1 &  infixl 8 ^., ^#@@ -221,10 +239,10 @@ -------------------------------------------------------------------------------  -- | @lens@ variant is also parametrised by profunctor.-data Pretext a b t = Pretext { runPretext :: forall f. Functor f => (a -> f b) -> f t }+data Pretext a b t = Pretext {runPretext :: forall f. Functor f => (a -> f b) -> f t}  instance Functor (Pretext a b) where-    fmap f (Pretext pretext) = Pretext (\afb -> fmap f (pretext afb))+  fmap f (Pretext pretext) = Pretext (\afb -> fmap f (pretext afb))  ------------------------------------------------------------------------------- -- Documentation
src/Distribution/Compat/MonadFail.hs view
@@ -1,5 +1,4 @@-{-# LANGUAGE CPP #-}- -- | Compatibility layer for "Control.Monad.Fail"-module Distribution.Compat.MonadFail ( Control.Monad.Fail.MonadFail(fail) ) where+module Distribution.Compat.MonadFail (Control.Monad.Fail.MonadFail (fail)) where+ import Control.Monad.Fail
src/Distribution/Compat/Newtype.hs view
@@ -1,26 +1,21 @@-{-# LANGUAGE CPP                    #-}-{-# LANGUAGE DefaultSignatures      #-}-{-# LANGUAGE FlexibleInstances      #-}+{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-}+ -- | Per Conor McBride, the 'Newtype' typeclass represents the packing and -- unpacking of a newtype, and allows you to operate under that newtype with -- functions such as 'ala'.-module Distribution.Compat.Newtype (-    Newtype (..),-    ala,-    alaf,-    pack',-    unpack',-    ) where+module Distribution.Compat.Newtype+  ( Newtype (..)+  , ala+  , alaf+  , pack'+  , unpack'+  ) where +import Data.Coerce (Coercible, coerce) import Data.Functor.Identity (Identity (..))-import Data.Monoid (Sum (..), Product (..), Endo (..))--#if MIN_VERSION_base(4,7,0)-import Data.Coerce (coerce, Coercible)-#else-import Unsafe.Coerce (unsafeCoerce)-#endif+import Data.Monoid (Endo (..), Product (..), Sum (..))  -- | The @FunctionalDependencies@ version of 'Newtype' type-class. --@@ -36,25 +31,16 @@ -- Another approach would be to use @TypeFamilies@ (and possibly -- compute inner type using "GHC.Generics"), but we think @FunctionalDependencies@ -- version gives cleaner type signatures.---+{- FOURMOLU_DISABLE -} class Newtype o n | n -> o where-    pack   :: o -> n-#if MIN_VERSION_base(4,7,0)-    default pack :: Coercible o n => o -> n-    pack = coerce-#else-    default pack :: o -> n-    pack = unsafeCoerce-#endif+  pack :: o -> n+  default pack :: Coercible o n => o -> n+  pack = coerce -    unpack :: n -> o-#if MIN_VERSION_base(4,7,0)-    default unpack :: Coercible n o => n -> o-    unpack = coerce-#else-    default unpack :: n -> o-    unpack = unsafeCoerce-#endif+  unpack :: n -> o+  default unpack :: Coercible n o => n -> o+  unpack = coerce+{- FOURMOLU_ENABLE -}  instance Newtype a (Identity a) instance Newtype a (Sum a)
src/Distribution/Compat/NonEmptySet.hs view
@@ -1,36 +1,43 @@-{-# LANGUAGE CPP                #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}-module Distribution.Compat.NonEmptySet (-    NonEmptySet,++module Distribution.Compat.NonEmptySet+  ( NonEmptySet+     -- * Construction-    singleton,+  , singleton+     -- * Insertion-    insert,+  , insert+     -- * Deletion-    delete,+  , delete+  , filter+     -- * Conversions-    toNonEmpty,-    fromNonEmpty,-    toList,-    toSet,+  , toNonEmpty+  , fromNonEmpty+  , toList+  , toSet+     -- * Query-    member,+  , member+     -- * Map-    map,-) where+  , map+  ) where  import Prelude (Bool (..), Eq, Maybe (..), Ord (..), Read, Show (..), String, error, otherwise, return, showParen, showString, ($), (++), (.)) -import Control.DeepSeq    (NFData (..))-import Data.Data          (Data)+import Control.DeepSeq (NFData (..))+import Data.Data (Data) import Data.List.NonEmpty (NonEmpty (..))-import Data.Semigroup     (Semigroup (..))-import Data.Typeable      (Typeable)+import Data.Semigroup (Semigroup (..))  import qualified Data.Foldable as F-import qualified Data.Set      as Set+import qualified Data.Set as Set -import Distribution.Compat.Binary    (Binary (..))+import Distribution.Compat.Binary (Binary (..)) import Distribution.Utils.Structured  #if MIN_VERSION_binary(0,6,0)@@ -41,48 +48,48 @@  -- | @since 3.4.0.0 newtype NonEmptySet a = NES (Set.Set a)-  deriving (Eq, Ord, Typeable, Data, Read)+  deriving (Eq, Ord, Data, Read)  ------------------------------------------------------------------------------- -- Instances -------------------------------------------------------------------------------  instance Show a => Show (NonEmptySet a) where-    showsPrec d s = showParen (d > 10)-        $ showString "fromNonEmpty "+  showsPrec d s =+    showParen (d > 10) $+      showString "fromNonEmpty "         . showsPrec 11 (toNonEmpty s) +{- FOURMOLU_DISABLE -} instance Binary a => Binary (NonEmptySet a) where-    put (NES s) = put s-    get = do-        xs <- get-        if Set.null xs+  put (NES s) = put s+  get = do+      xs <- get+      if Set.null xs #if MIN_VERSION_binary(0,6,0)-        then empty+      then empty #else-        then fail "NonEmptySet: empty"+      then fail "NonEmptySet: empty" #endif-        else return (NES xs)+      else return (NES xs)+{- FOURMOLU_ENABLE -}  instance Structured a => Structured (NonEmptySet a) where-    structure = containerStructure+  structure = containerStructure  instance NFData a => NFData (NonEmptySet a) where-    rnf (NES x) = rnf x+  rnf (NES x) = rnf x  -- | Note: there aren't @Monoid@ instance. instance Ord a => Semigroup (NonEmptySet a) where-    NES x <> NES y = NES (Set.union x y)+  NES x <> NES y = NES (Set.union x y)  instance F.Foldable NonEmptySet where-    foldMap f (NES s) = F.foldMap f s-    foldr f z (NES s) = F.foldr f z s--#if MIN_VERSION_base(4,8,0)-    toList         = toList-    null _         = False-    length (NES s) = F.length s-#endif+  foldMap f (NES s) = F.foldMap f s+  foldr f z (NES s) = F.foldr f z s+  toList = toList+  null _ = False+  length (NES s) = F.length s  ------------------------------------------------------------------------------- -- Constructors@@ -104,11 +111,14 @@  delete :: Ord a => a -> NonEmptySet a -> Maybe (NonEmptySet a) delete x (NES xs)-    | Set.null res = Nothing-    | otherwise    = Just (NES xs)+  | Set.null res = Nothing+  | otherwise = Just (NES xs)   where     res = Set.delete x xs +filter :: (a -> Bool) -> NonEmptySet a -> Set.Set a+filter predicate (NES set) = Set.filter predicate set+ ------------------------------------------------------------------------------- -- Conversions -------------------------------------------------------------------------------@@ -118,8 +128,8 @@  toNonEmpty :: NonEmptySet a -> NonEmpty a toNonEmpty (NES s) = case Set.toList s of-    []   -> panic "toNonEmpty"-    x:xs -> x :| xs+  [] -> panic "toNonEmpty"+  x : xs -> x :| xs  toList :: NonEmptySet a -> [a] toList (NES s) = Set.toList s@@ -138,6 +148,7 @@ -- Map ------------------------------------------------------------------------------- +{- FOURMOLU_DISABLE -} map     :: ( Ord b #if !MIN_VERSION_containers(0,5,2)@@ -146,6 +157,7 @@        )     => (a -> b) -> NonEmptySet a -> NonEmptySet b map f (NES x) = NES (Set.map f x)+{- FOURMOLU_ENABLE -}  ------------------------------------------------------------------------------- -- Internal
src/Distribution/Compat/Parsing.hs view
@@ -1,5 +1,10 @@-{-# LANGUAGE GADTs, UndecidableInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE UndecidableInstances #-}+ -----------------------------------------------------------------------------++-----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Compat.Parsing -- Copyright   :  (c) Edward Kmett 2011-2012@@ -12,18 +17,15 @@ -- Alternative parser combinators. -- -- Originally in @parsers@ package.--------------------------------------------------------------------------------- module Distribution.Compat.Parsing-  (-  -- * Parsing Combinators+  ( -- * Parsing Combinators     choice   , option   , optional -- from Control.Applicative, parsec optionMaybe   , skipOptional -- parsec optional   , between-  , some     -- from Control.Applicative, parsec many1-  , many     -- from Control.Applicative+  , some -- from Control.Applicative, parsec many1+  , many -- from Control.Applicative   , sepBy   , sepByNonEmpty   , sepEndByNonEmpty@@ -36,23 +38,24 @@   , chainl1   , chainr1   , manyTill-  -- * Parsing Class-  , Parsing(..)++    -- * Parsing Class+  , Parsing (..)   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Control.Applicative ((<**>), optional)+import Control.Applicative (optional, (<**>)) import Control.Monad.Trans.Class (lift)+import Control.Monad.Trans.Identity (IdentityT (..))+import Control.Monad.Trans.RWS.Lazy as Lazy+import Control.Monad.Trans.RWS.Strict as Strict+import Control.Monad.Trans.Reader (ReaderT (..)) import Control.Monad.Trans.State.Lazy as Lazy import Control.Monad.Trans.State.Strict as Strict import Control.Monad.Trans.Writer.Lazy as Lazy import Control.Monad.Trans.Writer.Strict as Strict-import Control.Monad.Trans.RWS.Lazy as Lazy-import Control.Monad.Trans.RWS.Strict as Strict-import Control.Monad.Trans.Reader (ReaderT (..))-import Control.Monad.Trans.Identity (IdentityT (..)) import Data.Foldable (asum)  import qualified Data.List.NonEmpty as NE@@ -136,8 +139,9 @@ -- equal to zero, the parser equals to @return []@. Returns a list of -- @n@ values returned by @p@. count :: Applicative m => Int -> m a -> m [a]-count n p | n <= 0    = pure []-          | otherwise = sequenceA (replicate n p)+count n p+  | n <= 0 = pure []+  | otherwise = sequenceA (replicate n p) {-# INLINE count #-}  -- | @chainr p op x@ parses /zero/ or more occurrences of @p@,@@ -174,9 +178,10 @@ -- >  addop  = (+) <$ symbol "+" -- >       <|> (-) <$ symbol "-" chainl1 :: Alternative m => m a -> m (a -> a -> a) -> m a-chainl1 p op = scan where-  scan = p <**> rst-  rst = (\f y g x -> g (f x y)) <$> op <*> p <*> rst <|> pure id+chainl1 p op = scan+  where+    scan = p <**> rst+    rst = (\f y g x -> g (f x y)) <$> op <*> p <*> rst <|> pure id {-# INLINE chainl1 #-}  -- | @chainr1 p op x@ parses /one/ or more occurrences of @p@,@@ -184,9 +189,10 @@ -- application of all functions returned by @op@ to the values returned -- by @p@. chainr1 :: Alternative m => m a -> m (a -> a -> a) -> m a-chainr1 p op = scan where-  scan = p <**> rst-  rst = (flip <$> op <*> scan) <|> pure id+chainr1 p op = scan+  where+    scan = p <**> rst+    rst = (flip <$> op <*> scan) <|> pure id {-# INLINE chainr1 #-}  -- | @manyTill p end@ applies parser @p@ /zero/ or more times until@@ -255,8 +261,8 @@   {-# INLINE unexpected #-}   eof = lift eof   {-# INLINE eof #-}-  notFollowedBy (Lazy.StateT m) = Lazy.StateT-    $ \s -> notFollowedBy (fst <$> m s) >> return ((),s)+  notFollowedBy (Lazy.StateT m) = Lazy.StateT $+    \s -> notFollowedBy (fst <$> m s) >> return ((), s)   {-# INLINE notFollowedBy #-}  instance (Parsing m, MonadPlus m) => Parsing (Strict.StateT s m) where@@ -268,8 +274,8 @@   {-# INLINE unexpected #-}   eof = lift eof   {-# INLINE eof #-}-  notFollowedBy (Strict.StateT m) = Strict.StateT-    $ \s -> notFollowedBy (fst <$> m s) >> return ((),s)+  notFollowedBy (Strict.StateT m) = Strict.StateT $+    \s -> notFollowedBy (fst <$> m s) >> return ((), s)   {-# INLINE notFollowedBy #-}  instance (Parsing m, MonadPlus m) => Parsing (ReaderT e m) where@@ -295,8 +301,9 @@   {-# INLINE unexpected #-}   eof = lift eof   {-# INLINE eof #-}-  notFollowedBy (Strict.WriterT m) = Strict.WriterT-    $ notFollowedBy (fst <$> m) >>= \x -> return (x, mempty)+  notFollowedBy (Strict.WriterT m) =+    Strict.WriterT $+      notFollowedBy (fst <$> m) >>= \x -> return (x, mempty)   {-# INLINE notFollowedBy #-}  instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Lazy.WriterT w m) where@@ -308,8 +315,9 @@   {-# INLINE unexpected #-}   eof = lift eof   {-# INLINE eof #-}-  notFollowedBy (Lazy.WriterT m) = Lazy.WriterT-    $ notFollowedBy (fst <$> m) >>= \x -> return (x, mempty)+  notFollowedBy (Lazy.WriterT m) =+    Lazy.WriterT $+      notFollowedBy (fst <$> m) >>= \x -> return (x, mempty)   {-# INLINE notFollowedBy #-}  instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Lazy.RWST r w s m) where@@ -321,8 +329,8 @@   {-# INLINE unexpected #-}   eof = lift eof   {-# INLINE eof #-}-  notFollowedBy (Lazy.RWST m) = Lazy.RWST-    $ \r s -> notFollowedBy ((\(a,_,_) -> a) <$> m r s) >>= \x -> return (x, s, mempty)+  notFollowedBy (Lazy.RWST m) = Lazy.RWST $+    \r s -> notFollowedBy ((\(a, _, _) -> a) <$> m r s) >>= \x -> return (x, s, mempty)   {-# INLINE notFollowedBy #-}  instance (Parsing m, MonadPlus m, Monoid w) => Parsing (Strict.RWST r w s m) where@@ -334,8 +342,8 @@   {-# INLINE unexpected #-}   eof = lift eof   {-# INLINE eof #-}-  notFollowedBy (Strict.RWST m) = Strict.RWST-    $ \r s -> notFollowedBy ((\(a,_,_) -> a) <$> m r s) >>= \x -> return (x, s, mempty)+  notFollowedBy (Strict.RWST m) = Strict.RWST $+    \r s -> notFollowedBy ((\(a, _, _) -> a) <$> m r s) >>= \x -> return (x, s, mempty)   {-# INLINE notFollowedBy #-}  instance (Parsing m, Monad m) => Parsing (IdentityT m) where@@ -353,10 +361,10 @@   {-# INLINE notFollowedBy #-}  instance (Parsec.Stream s m t, Show t) => Parsing (Parsec.ParsecT s u m) where-  try           = Parsec.try-  (<?>)         = (Parsec.<?>)-  skipMany      = Parsec.skipMany-  skipSome      = Parsec.skipMany1-  unexpected    = Parsec.unexpected-  eof           = Parsec.eof+  try = Parsec.try+  (<?>) = (Parsec.<?>)+  skipMany = Parsec.skipMany+  skipSome = Parsec.skipMany1+  unexpected = Parsec.unexpected+  eof = Parsec.eof   notFollowedBy = Parsec.notFollowedBy
src/Distribution/Compat/Prelude.hs view
@@ -1,200 +1,252 @@-{-# LANGUAGE CPP              #-} {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE RankNTypes       #-}-{-# LANGUAGE Trustworthy      #-}-{-# LANGUAGE TypeOperators    #-}--#ifdef MIN_VERSION_base-#define MINVER_base_411 MIN_VERSION_base(4,11,0)-#else-#define MINVER_base_411 (__GLASGOW_HASKELL__ >= 804)-#endif+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE TypeOperators #-}  -- | This module does two things: -- -- * Acts as a compatibility layer, like @base-compat@. -- -- * Provides commonly used imports.-module Distribution.Compat.Prelude (-    -- * Prelude-    ---    -- Prelude is re-exported, following is hidden:-    module BasePrelude,+module Distribution.Compat.Prelude+  ( -- * Prelude +  --+  -- Prelude is re-exported, following is hidden:+      module BasePrelude+     -- * Common type-classes-    Semigroup (..),-    gmappend, gmempty,-    Typeable, TypeRep, typeRep,-    Data,-    Generic,-    NFData (..), genericRnf,-    Binary (..),-    Structured,-    Alternative (..),-    MonadPlus (..),-    IsString (..),+  , Semigroup (..)+  , gmappend+  , gmempty+  , Typeable+  , TypeRep+  , typeRep+  , Data+  , Generic+  , NFData (..)+  , genericRnf+  , Binary (..)+  , Structured+  , Alternative (..)+  , MonadPlus (..)+  , IsString (..)      -- * Some types-    Map,-    Set,-    NonEmptySet,-    Identity (..),-    Proxy (..),-    Const (..),-    Void,+  , Map+  , Set+  , NonEmptySet+  , Identity (..)+  , Proxy (..)+  , Const (..)+  , Void      -- * Data.Either-    partitionEithers,+  , partitionEithers      -- * Data.Maybe-    catMaybes, mapMaybe,-    fromMaybe,-    maybeToList, listToMaybe,-    isNothing, isJust,+  , catMaybes+  , mapMaybe+  , fromMaybe+  , maybeToList+  , listToMaybe+  , isNothing+  , isJust      -- * Data.List-    unfoldr,-    isPrefixOf, isSuffixOf,-    intercalate, intersperse,-    sort, sortBy,-    nub, nubBy,-    partition,-    dropWhileEnd,+  , unfoldr+  , isPrefixOf+  , isSuffixOf+  , intercalate+  , intersperse+  , sort+  , sortBy+  , nub+  , nubBy+  , partition+  , dropWhileEnd      -- * Data.List.NonEmpty-    NonEmpty((:|)), nonEmpty, foldl1, foldr1,-    head, tail, last, init,+  , NonEmpty ((:|))+  , nonEmpty+  , foldl1+  , foldr1+  , head+  , tail+  , last+  , init      -- * Data.Foldable-    Foldable, foldMap, foldr,-    null, length,-    find, foldl',-    traverse_, for_,-    any, all,-    toList,+  , Foldable+  , foldMap+  , foldr+  , null+  , length+  , find+  , foldl'+  , traverse_+  , for_+  , any+  , all+  , toList      -- * Data.Traversable-    Traversable, traverse, sequenceA,-    for,+  , Traversable+  , traverse+  , sequenceA+  , for      -- * Data.Function-    on,+  , on      -- * Data.Ord-    comparing,+  , comparing      -- * Control.Arrow-    first,+  , first      -- * Control.Monad-    liftM, liftM2,-    unless, when,-    ap, void,-    foldM, filterM,-    join, guard,+  , liftM+  , liftM2+  , unless+  , when+  , ap+  , void+  , foldM+  , filterM+  , join+  , guard      -- * Control.Exception-    catch, throwIO, evaluate,-    Exception (..), IOException, SomeException (..),-    tryIO, catchIO, catchExit,+  , catch+  , throwIO+  , evaluate+  , Exception (..)+  , IOException+  , SomeException (..)+  , tryIO+  , catchIO+  , catchExit      -- * Control.DeepSeq-    deepseq, force,+  , deepseq+  , force      -- * Data.Char-    isSpace, isDigit, isUpper, isAlpha, isAlphaNum,-    chr, ord,-    toLower, toUpper,+  , isSpace+  , isDigit+  , isUpper+  , isAlpha+  , isAlphaNum+  , chr+  , ord+  , toLower+  , toUpper      -- * Data.Void-    absurd, vacuous,+  , absurd+  , vacuous      -- * Data.Word & Data.Int-    Word,-    Word8, Word16, Word32, Word64,-    Int8, Int16, Int32, Int64,+  , Word+  , Word8+  , Word16+  , Word32+  , Word64+  , Int8+  , Int16+  , Int32+  , Int64      -- * Text.PrettyPrint-    (<<>>), (Disp.<+>),+  , (<<>>)+  , (Disp.<+>)      -- * System.Exit-    ExitCode (..),-    exitWith, exitSuccess, exitFailure,+  , ExitCode (..)+  , exitWith+  , exitSuccess+  , exitFailure      -- * Text.Read-    readMaybe,+  , readMaybe      -- * Debug.Trace (as deprecated functions)-    trace, traceShow, traceShowId,-    ) where+  , trace+  , traceShow+  , traceShowId+  , traceM+  , traceShowM+  ) where  -- We also could hide few partial function+{- FOURMOLU_DISABLE -} import Prelude                       as BasePrelude hiding     ( mapM, mapM_, sequence, any, all, head, tail, last, init     -- partial functions     , read-#if MINVER_base_411+    , foldr1, foldl1     -- As of base 4.11.0.0 Prelude exports part of Semigroup(..).     -- Hide this so we instead rely on Distribution.Compat.Semigroup.     , Semigroup(..)-#endif     , Word     -- We hide them, as we import only some members     , Traversable, traverse, sequenceA     , Foldable(..)     )-import Data.Foldable as BasePrelude (foldl, elem, sum, product, maximum, minimum)+{- FOURMOLU_ENABLE -}+import Data.Foldable as BasePrelude (elem, foldl, maximum, minimum, product, sum)  -- AMP import Data.Foldable-    ( Foldable(toList),-      length,-      null,-      Foldable(foldMap, foldr),-      all,-      any,-      find,-      foldl',-      for_,-      traverse_ )+  ( Foldable (foldMap, foldr, toList)+  , all+  , any+  , find+  , foldl'+  , for_+  , length+  , null+  , traverse_+  ) import Data.Traversable (Traversable (sequenceA, traverse), for)  import qualified Data.Foldable  -- Extra exports-import Control.Applicative           (Alternative (..), Const(..))-import Control.Arrow                 (first)-import Control.DeepSeq               (NFData (..), deepseq, force)-import Control.Exception             (Exception (..), IOException, SomeException (..), catch, evaluate, throwIO)-import Control.Monad                 (MonadPlus (..), ap, filterM, foldM, guard, join, liftM, liftM2, unless, void, when)-import Data.Char                     (chr, isAlpha, isAlphaNum, isDigit, isSpace, isUpper, ord, toLower, toUpper)-import Data.Data                     (Data)-import Data.Either                   (partitionEithers)-import Data.Function                 (on)-import Data.Functor.Identity         (Identity (..))-import Data.Int                      (Int16, Int32, Int64, Int8)-import Data.List                     (dropWhileEnd, intercalate, intersperse, isPrefixOf, isSuffixOf, nub, nubBy, partition, sort, sortBy, unfoldr)-import Data.List.NonEmpty            (NonEmpty ((:|)), nonEmpty, head, init, last, tail)-import Data.Map                      (Map)-import Data.Maybe                    (catMaybes, fromMaybe, isJust, isNothing, listToMaybe, mapMaybe, maybeToList)-import Data.Ord                      (comparing)-import Data.Proxy                    (Proxy (..))-import Data.Set                      (Set)-import Data.String                   (IsString (..))-import Data.Void                     (Void, absurd, vacuous)-import Data.Word                     (Word, Word16, Word32, Word64, Word8)-import Distribution.Compat.Binary    (Binary (..))+import Control.Applicative (Alternative (..), Const (..))+import Control.Arrow (first)+import Control.DeepSeq (NFData (..), deepseq, force)+import Control.Exception (Exception (..), IOException, SomeException (..), catch, evaluate, throwIO)+import Control.Monad (MonadPlus (..), ap, filterM, foldM, guard, join, liftM, liftM2, unless, void, when)+import Data.Char (chr, isAlpha, isAlphaNum, isDigit, isSpace, isUpper, ord, toLower, toUpper)+import Data.Data (Data)+import Data.Either (partitionEithers)+import Data.Function (on)+import Data.Functor.Identity (Identity (..))+import Data.Int (Int16, Int32, Int64, Int8)+import Data.List (dropWhileEnd, intercalate, intersperse, isPrefixOf, isSuffixOf, nub, nubBy, partition, sort, sortBy, unfoldr)+import Data.List.NonEmpty (NonEmpty ((:|)), head, init, last, nonEmpty, tail)+import Data.Map (Map)+import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing, listToMaybe, mapMaybe, maybeToList)+import Data.Ord (comparing)+import Data.Proxy (Proxy (..))+import Data.Set (Set)+import Data.String (IsString (..))+import Data.Typeable (TypeRep, Typeable, typeRep)+import Data.Void (Void, absurd, vacuous)+import Data.Word (Word, Word16, Word32, Word64, Word8)+import Distribution.Compat.Binary (Binary (..)) import Distribution.Compat.Semigroup (Semigroup (..), gmappend, gmempty)-import Distribution.Compat.Typeable  (TypeRep, Typeable, typeRep)-import GHC.Generics                  (Generic (..), K1 (unK1), M1 (unM1), U1 (U1), V1, (:*:) ((:*:)), (:+:) (L1, R1))-import System.Exit                   (ExitCode (..), exitFailure, exitSuccess, exitWith)-import Text.Read                     (readMaybe)+import GHC.Generics (Generic (..), K1 (unK1), M1 (unM1), U1 (U1), V1, (:*:) ((:*:)), (:+:) (L1, R1))+import System.Exit (ExitCode (..), exitFailure, exitSuccess, exitWith)+import Text.Read (readMaybe)  import qualified Text.PrettyPrint as Disp  import Distribution.Compat.Exception import Distribution.Compat.NonEmptySet (NonEmptySet)-import Distribution.Utils.Structured   (Structured)+import Distribution.Utils.Structured (Structured)  import qualified Debug.Trace @@ -243,7 +295,6 @@   grnf (R1 x) = grnf x   {-# INLINEABLE grnf #-} - -- TODO: if we want foldr1/foldl1 to work on more than NonEmpty, we -- can define a local typeclass 'Foldable1', e.g. --@@ -286,3 +337,11 @@ traceShow :: Show a => a -> b -> b traceShow = Debug.Trace.traceShow {-# DEPRECATED traceShow "Don't leave me in the code" #-}++traceM :: Applicative f => String -> f ()+traceM = Debug.Trace.traceM+{-# DEPRECATED traceM "Don't leave me in the code" #-}++traceShowM :: (Show a, Applicative f) => a -> f ()+traceShowM = Debug.Trace.traceShowM+{-# DEPRECATED traceShowM "Don't leave me in the code" #-}
src/Distribution/Compat/Semigroup.hs view
@@ -1,47 +1,42 @@-{-# LANGUAGE CPP                         #-}-{-# LANGUAGE DeriveDataTypeable          #-}-{-# LANGUAGE DeriveGeneric               #-}-{-# LANGUAGE FlexibleContexts            #-}-{-# LANGUAGE GeneralizedNewtypeDeriving  #-}-{-# LANGUAGE TypeOperators               #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TypeOperators #-}  -- | Compatibility layer for "Data.Semigroup" module Distribution.Compat.Semigroup-    ( Semigroup((<>))-    , Mon.Monoid(..)-    , All(..)-    , Any(..)--    , First'(..)-    , Last'(..)--    , Option'(..)--    , gmappend-    , gmempty-    ) where+  ( Semigroup ((<>))+  , Mon.Monoid (..)+  , All (..)+  , Any (..)+  , First' (..)+  , Last' (..)+  , Option' (..)+  , gmappend+  , gmempty+  ) where  import Distribution.Compat.Binary (Binary) import Distribution.Utils.Structured (Structured)-import Data.Typeable (Typeable)  import GHC.Generics+ -- Data.Semigroup is available since GHC 8.0/base-4.9 in `base` -- for older GHC/base, it's provided by `semigroups`-import Data.Semigroup-import qualified Data.Monoid as Mon +import qualified Data.Monoid as Mon+import Data.Semigroup  -- | A copy of 'Data.Semigroup.First'.-newtype First' a = First' { getFirst' :: a }+newtype First' a = First' {getFirst' :: a}   deriving (Eq, Ord, Show)  instance Semigroup (First' a) where   a <> _ = a  -- | A copy of 'Data.Semigroup.Last'.-newtype Last' a = Last' { getLast' :: a }-  deriving (Eq, Ord, Read, Show, Generic, Binary, Typeable)+newtype Last' a = Last' {getLast' :: a}+  deriving (Eq, Ord, Read, Show, Generic, Binary)  instance Structured a => Structured (Last' a) @@ -53,15 +48,15 @@  -- | A wrapper around 'Maybe', providing the 'Semigroup' and 'Monoid' instances -- implemented for 'Maybe' since @base-4.11@.-newtype Option' a = Option' { getOption' :: Maybe a }-  deriving (Eq, Ord, Read, Show, Binary, Generic, Functor, Typeable)+newtype Option' a = Option' {getOption' :: Maybe a}+  deriving (Eq, Ord, Read, Show, Binary, Generic, Functor)  instance Structured a => Structured (Option' a)  instance Semigroup a => Semigroup (Option' a) where   Option' (Just a) <> Option' (Just b) = Option' (Just (a <> b))-  Option' Nothing  <> b                = b-  a                <> Option' Nothing  = a+  Option' Nothing <> b = b+  a <> Option' Nothing = a  instance Semigroup a => Monoid (Option' a) where   mempty = Option' Nothing@@ -83,16 +78,16 @@ gmappend x y = to (gmappend' (from x) (from y))  class GSemigroup f where-    gmappend' :: f p -> f p -> f p+  gmappend' :: f p -> f p -> f p  instance Semigroup a => GSemigroup (K1 i a) where-    gmappend' (K1 x) (K1 y) = K1 (x <> y)+  gmappend' (K1 x) (K1 y) = K1 (x <> y)  instance GSemigroup f => GSemigroup (M1 i c f) where-    gmappend' (M1 x) (M1 y) = M1 (gmappend' x y)+  gmappend' (M1 x) (M1 y) = M1 (gmappend' x y)  instance (GSemigroup f, GSemigroup g) => GSemigroup (f :*: g) where-    gmappend' (x1 :*: x2) (y1 :*: y2) = gmappend' x1 y1 :*: gmappend' x2 y2+  gmappend' (x1 :*: x2) (y1 :*: y2) = gmappend' x1 y1 :*: gmappend' x2 y2  -- | Generically generate a 'Monoid' 'mempty' for any product-like type -- implementing 'Generic'.@@ -102,18 +97,17 @@ -- @ -- 'gmappend' 'gmempty' a = a = 'gmappend' a 'gmempty' -- @- gmempty :: (Generic a, GMonoid (Rep a)) => a gmempty = to gmempty'  class GSemigroup f => GMonoid f where-    gmempty' :: f p+  gmempty' :: f p  instance (Semigroup a, Monoid a) => GMonoid (K1 i a) where-    gmempty' = K1 mempty+  gmempty' = K1 mempty  instance GMonoid f => GMonoid (M1 i c f) where-    gmempty' = M1 gmempty'+  gmempty' = M1 gmempty'  instance (GMonoid f, GMonoid g) => GMonoid (f :*: g) where-    gmempty' = gmempty' :*: gmempty'+  gmempty' = gmempty' :*: gmempty'
− src/Distribution/Compat/Typeable.hs
@@ -1,18 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Distribution.Compat.Typeable (-    Typeable,-    TypeRep,-    typeRep,-    ) where--#if MIN_VERSION_base(4,7,0)-import Data.Typeable (Typeable, TypeRep, typeRep)-#else-import Data.Typeable (Typeable, TypeRep, typeOf)-#endif--#if !MIN_VERSION_base(4,7,0)-typeRep :: forall a proxy. Typeable a => proxy a -> TypeRep-typeRep _ = typeOf (undefined :: a)-#endif
src/Distribution/Compiler.hs view
@@ -1,10 +1,9 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveTraversable #-}  -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Compiler -- Copyright   :  Isaac Jones 2003-2004@@ -26,47 +25,59 @@ -- 'UserHooks' api, which would break all custom @Setup.hs@ files, so for the -- moment we just have to live with this deficiency. If you're interested, see -- ticket #57.--module Distribution.Compiler (-  -- * Compiler flavor-  CompilerFlavor(..),-  buildCompilerId,-  buildCompilerFlavor,-  defaultCompilerFlavor,-  classifyCompilerFlavor,-  knownCompilerFlavors,+module Distribution.Compiler+  ( -- * Compiler flavor+    CompilerFlavor (..)+  , buildCompilerId+  , buildCompilerFlavor+  , defaultCompilerFlavor+  , classifyCompilerFlavor+  , knownCompilerFlavors -  -- * Per compiler flavor-  PerCompilerFlavor (..),-  perCompilerFlavorToList,+    -- * Per compiler flavor+  , PerCompilerFlavor (..)+  , perCompilerFlavorToList -  -- * Compiler id-  CompilerId(..),+    -- * Compiler id+  , CompilerId (..) -  -- * Compiler info-  CompilerInfo(..),-  unknownCompilerInfo,-  AbiTag(..), abiTagString+    -- * Compiler info+  , CompilerInfo (..)+  , unknownCompilerInfo+  , AbiTag (..)+  , abiTagString   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Language.Haskell.Extension  import Distribution.Version (Version, mkVersion', nullVersion) -import qualified System.Info (compilerName, compilerVersion)+import qualified Distribution.Compat.CharParsing as P import Distribution.Parsec (Parsec (..)) import Distribution.Pretty (Pretty (..), prettyShow)-import qualified Distribution.Compat.CharParsing as P+import qualified System.Info (compilerName, compilerVersion) import qualified Text.PrettyPrint as Disp -data CompilerFlavor =-  GHC | GHCJS | NHC | YHC | Hugs | HBC | Helium | JHC | LHC | UHC | Eta-  | HaskellSuite String -- string is the id of the actual compiler+data CompilerFlavor+  = GHC+  | GHCJS+  | NHC+  | YHC+  | Hugs+  | HBC+  | Helium+  | JHC+  | LHC+  | UHC+  | Eta+  | -- | @since 3.12.1.0+    -- MicroHS, see https://github.com/augustss/MicroHs+    MHS   | OtherCompiler String-  deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary CompilerFlavor instance Structured CompilerFlavor@@ -74,27 +85,28 @@  knownCompilerFlavors :: [CompilerFlavor] knownCompilerFlavors =-  [GHC, GHCJS, NHC, YHC, Hugs, HBC, Helium, JHC, LHC, UHC, Eta]+  [GHC, GHCJS, NHC, YHC, Hugs, HBC, Helium, JHC, LHC, UHC, Eta, MHS]  instance Pretty CompilerFlavor where   pretty (OtherCompiler name) = Disp.text name-  pretty (HaskellSuite name)  = Disp.text name-  pretty NHC                  = Disp.text "nhc98"-  pretty other                = Disp.text (lowercase (show other))+  pretty NHC = Disp.text "nhc98"+  pretty other = Disp.text (lowercase (show other))  instance Parsec CompilerFlavor where-    parsec = classifyCompilerFlavor <$> component-      where-        component = do-          cs <- P.munch1 isAlphaNum-          if all isDigit cs then fail "all digits compiler name" else return cs+  parsec = classifyCompilerFlavor <$> component+    where+      component = do+        cs <- P.munch1 isAlphaNum+        if all isDigit cs then fail "all digits compiler name" else return cs  classifyCompilerFlavor :: String -> CompilerFlavor classifyCompilerFlavor s =   fromMaybe (OtherCompiler s) $ lookup (lowercase s) compilerMap   where-    compilerMap = [ (lowercase (prettyShow compiler), compiler)-                  | compiler <- knownCompilerFlavors ]+    compilerMap =+      [ (lowercase (prettyShow compiler), compiler)+      | compiler <- knownCompilerFlavors+      ]  buildCompilerFlavor :: CompilerFlavor buildCompilerFlavor = classifyCompilerFlavor System.Info.compilerName@@ -110,11 +122,10 @@ -- -- However if it's not a recognised compiler then it's 'Nothing' and the user -- will have to specify which compiler they want.--- defaultCompilerFlavor :: Maybe CompilerFlavor defaultCompilerFlavor = case buildCompilerFlavor of   OtherCompiler _ -> Nothing-  _               -> Just buildCompilerFlavor+  _ -> Just buildCompilerFlavor  ------------------------------------------------------------------------------- -- Per compiler data@@ -123,10 +134,18 @@ -- | 'PerCompilerFlavor' carries only info per GHC and GHCJS -- -- Cabal parses only @ghc-options@ and @ghcjs-options@, others are omitted.--- data PerCompilerFlavor v = PerCompilerFlavor v v-  deriving (Generic, Show, Read, Eq, Ord, Typeable, Data, Functor, Foldable-           , Traversable)+  deriving+    ( Generic+    , Show+    , Read+    , Eq+    , Ord+    , Data+    , Functor+    , Foldable+    , Traversable+    )  instance Binary a => Binary (PerCompilerFlavor a) instance Structured a => Structured (PerCompilerFlavor a)@@ -136,19 +155,23 @@ perCompilerFlavorToList (PerCompilerFlavor a b) = [(GHC, a), (GHCJS, b)]  instance Semigroup a => Semigroup (PerCompilerFlavor a) where-    PerCompilerFlavor a b <> PerCompilerFlavor a' b' = PerCompilerFlavor-        (a <> a') (b <> b')+  PerCompilerFlavor a b <> PerCompilerFlavor a' b' =+    PerCompilerFlavor+      (a <> a')+      (b <> b')  instance (Semigroup a, Monoid a) => Monoid (PerCompilerFlavor a) where-    mempty = PerCompilerFlavor mempty mempty-    mappend = (<>)+  mempty = PerCompilerFlavor mempty mempty+  mappend = (<>)  -- ------------------------------------------------------------+ -- * Compiler Id+ -- ------------------------------------------------------------  data CompilerId = CompilerId CompilerFlavor Version-  deriving (Eq, Generic, Ord, Read, Show, Typeable)+  deriving (Eq, Generic, Ord, Read, Show)  instance Binary CompilerId instance Structured CompilerId@@ -157,7 +180,7 @@ instance Pretty CompilerId where   pretty (CompilerId f v)     | v == nullVersion = pretty f-    | otherwise        = pretty f <<>> Disp.char '-' <<>> pretty v+    | otherwise = pretty f <<>> Disp.char '-' <<>> pretty v  instance Parsec CompilerId where   parsec = do@@ -169,41 +192,42 @@ lowercase = map toLower  -- ------------------------------------------------------------+ -- * Compiler Info+ -- ------------------------------------------------------------  -- | Compiler information used for resolving configurations. Some --   fields can be set to Nothing to indicate that the information is --   unknown.--data CompilerInfo = CompilerInfo {-         compilerInfoId         :: CompilerId,-         -- ^ Compiler flavour and version.-         compilerInfoAbiTag     :: AbiTag,-         -- ^ Tag for distinguishing incompatible ABI's on the same-         -- architecture/os.-         compilerInfoCompat     :: Maybe [CompilerId],-         -- ^ Other implementations that this compiler claims to be-         -- compatible with, if known.-         compilerInfoLanguages  :: Maybe [Language],-         -- ^ Supported language standards, if known.-         compilerInfoExtensions :: Maybe [Extension]-         -- ^ Supported extensions, if known.-     }-     deriving (Generic, Show, Read)+data CompilerInfo = CompilerInfo+  { compilerInfoId :: CompilerId+  -- ^ Compiler flavour and version.+  , compilerInfoAbiTag :: AbiTag+  -- ^ Tag for distinguishing incompatible ABI's on the same+  -- architecture/os.+  , compilerInfoCompat :: Maybe [CompilerId]+  -- ^ Other implementations that this compiler claims to be+  -- compatible with, if known.+  , compilerInfoLanguages :: Maybe [Language]+  -- ^ Supported language standards, if known.+  , compilerInfoExtensions :: Maybe [Extension]+  -- ^ Supported extensions, if known.+  }+  deriving (Generic, Show, Read)  instance Binary CompilerInfo  data AbiTag   = NoAbiTag   | AbiTag String-  deriving (Eq, Generic, Show, Read, Typeable)+  deriving (Eq, Generic, Show, Read)  instance Binary AbiTag instance Structured AbiTag  instance Pretty AbiTag where-  pretty NoAbiTag     = Disp.empty+  pretty NoAbiTag = Disp.empty   pretty (AbiTag tag) = Disp.text tag  instance Parsec AbiTag where@@ -212,7 +236,7 @@     if null tag then return NoAbiTag else return (AbiTag tag)  abiTagString :: AbiTag -> String-abiTagString NoAbiTag     = ""+abiTagString NoAbiTag = "" abiTagString (AbiTag tag) = tag  -- | Make a CompilerInfo of which only the known information is its CompilerId,
src/Distribution/FieldGrammar.hs view
@@ -1,34 +1,38 @@-{-# LANGUAGE FlexibleContexts    #-}-{-# LANGUAGE FlexibleInstances   #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-}+ -- | This module provides a way to specify a grammar of @.cabal@ -like files.-module Distribution.FieldGrammar  (-    -- * Field grammar type-    FieldGrammar (..),-    uniqueField,-    optionalField,-    optionalFieldDef,-    monoidalField,+module Distribution.FieldGrammar+  ( -- * Field grammar type+    FieldGrammar (..)+  , uniqueField+  , optionalField+  , optionalFieldDef+  , monoidalField+     -- * Concrete grammar implementations-    ParsecFieldGrammar,-    ParsecFieldGrammar',-    parseFieldGrammar,-    fieldGrammarKnownFieldList,-    PrettyFieldGrammar,-    PrettyFieldGrammar',-    prettyFieldGrammar,+  , ParsecFieldGrammar+  , ParsecFieldGrammar'+  , parseFieldGrammar+  , fieldGrammarKnownFieldList+  , PrettyFieldGrammar+  , PrettyFieldGrammar'+  , prettyFieldGrammar+     -- * Auxiliary-    (^^^),-    Section(..),-    Fields,-    partitionFields,-    takeFields,-    runFieldParser,-    runFieldParser',-    defaultFreeTextFieldDefST,+  , (^^^)+  , Section (..)+  , Fields+  , partitionFields+  , takeFields+  , runFieldParser+  , runFieldParser'+  , defaultFreeTextFieldDefST+     -- * Newtypes-    module Distribution.FieldGrammar.Newtypes,-    )  where+  , module Distribution.FieldGrammar.Newtypes+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -40,7 +44,7 @@ import Distribution.FieldGrammar.Parsec import Distribution.FieldGrammar.Pretty import Distribution.Fields.Field-import Distribution.Utils.Generic         (spanMaybe)+import Distribution.Utils.Generic (spanMaybe)  type ParsecFieldGrammar' a = ParsecFieldGrammar a a type PrettyFieldGrammar' a = PrettyFieldGrammar a a@@ -66,17 +70,18 @@   where     finalize :: PS ann -> (Fields ann, [[Section ann]])     finalize (PS fs s ss)-        | null s    = (fs, reverse ss)-        | otherwise = (fs, reverse (reverse s : ss))+      | null s = (fs, reverse ss)+      | otherwise = (fs, reverse (reverse s : ss))      f :: PS ann -> Field ann -> PS ann     f (PS fs s ss) (Field (Name ann name) fss) =-        PS (Map.insertWith (flip (++)) name [MkNamelessField ann fss] fs) [] ss'+      PS (Map.insertWith (flip (++)) name [MkNamelessField ann fss] fs) [] ss'       where-        ss' | null s    = ss-            | otherwise = reverse s : ss+        ss'+          | null s = ss+          | otherwise = reverse s : ss     f (PS fs s ss) (Section name sargs sfields) =-        PS fs (MkSection name sargs sfields : s) ss+      PS fs (MkSection name sargs sfields : s) ss  -- | Take all fields from the front. takeFields :: [Field ann] -> (Fields ann, [Field ann])
src/Distribution/FieldGrammar/Class.hs view
@@ -1,24 +1,24 @@-{-# LANGUAGE CPP                     #-}-{-# LANGUAGE ConstraintKinds         #-}-{-# LANGUAGE FunctionalDependencies  #-}-{-# LANGUAGE RankNTypes              #-}-{-# LANGUAGE ScopedTypeVariables     #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableSuperClasses #-}-module Distribution.FieldGrammar.Class (-    FieldGrammar (..),-    uniqueField,-    optionalField,-    optionalFieldDef,-    monoidalField,-    defaultFreeTextFieldDefST,-) where +module Distribution.FieldGrammar.Class+  ( FieldGrammar (..)+  , uniqueField+  , optionalField+  , optionalFieldDef+  , monoidalField+  , defaultFreeTextFieldDefST+  ) where+ import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.CabalSpecVersion      (CabalSpecVersion)-import Distribution.Compat.Newtype        (Newtype)+import Distribution.CabalSpecVersion (CabalSpecVersion)+import Distribution.Compat.Newtype (Newtype) import Distribution.FieldGrammar.Newtypes import Distribution.Fields.Field import Distribution.Utils.ShortText@@ -31,171 +31,213 @@ -- * @a@ type of the field. -- -- /Note:/ We'd like to have @forall s. Applicative (f s)@ context.--- class-    ( c SpecVersion, c TestedWith, c SpecLicense, c Token, c Token', c FilePathNT-    )-    => FieldGrammar c g | g -> c+  ( c SpecVersion+  , c TestedWith+  , c SpecLicense+  , c Token+  , c Token'+  , c FilePathNT+  ) =>+  FieldGrammar c g+    | g -> c   where-    -- | Unfocus, zoom out, /blur/ 'FieldGrammar'.-    blurFieldGrammar :: ALens' a b -> g b d -> g a d+  -- | Unfocus, zoom out, /blur/ 'FieldGrammar'.+  blurFieldGrammar :: ALens' a b -> g b d -> g a d -    -- | Field which should be defined, exactly once.-    uniqueFieldAla-        :: (c b, Newtype a b)-        => FieldName   -- ^ field name-        -> (a -> b)    -- ^ 'Newtype' pack-        -> ALens' s a  -- ^ lens into the field-        -> g s a+  -- | Field which should be defined, exactly once.+  uniqueFieldAla+    :: (c b, Newtype a b)+    => FieldName+    -- ^ field name+    -> (a -> b)+    -- ^ 'Newtype' pack+    -> ALens' s a+    -- ^ lens into the field+    -> g s a -    -- | Boolean field with a default value.-    booleanFieldDef-        :: FieldName     -- ^ field name-        -> ALens' s Bool -- ^ lens into the field-        -> Bool          -- ^ default-        -> g s Bool+  -- | Boolean field with a default value.+  booleanFieldDef+    :: FieldName+    -- ^ field name+    -> ALens' s Bool+    -- ^ lens into the field+    -> Bool+    -- ^ default+    -> g s Bool -    -- | Optional field.-    optionalFieldAla-        :: (c b, Newtype a b)-        => FieldName          -- ^ field name-        -> (a -> b)           -- ^ 'pack'-        -> ALens' s (Maybe a) -- ^ lens into the field-        -> g s (Maybe a)+  -- | Optional field.+  optionalFieldAla+    :: (c b, Newtype a b)+    => FieldName+    -- ^ field name+    -> (a -> b)+    -- ^ 'pack'+    -> ALens' s (Maybe a)+    -- ^ lens into the field+    -> g s (Maybe a) -    -- | Optional field with default value.-    optionalFieldDefAla-        :: (c b, Newtype a b, Eq a)-        => FieldName   -- ^ field name-        -> (a -> b)    -- ^ 'Newtype' pack-        -> ALens' s a  -- ^ @'Lens'' s a@: lens into the field-        -> a           -- ^ default value-        -> g s a+  -- | Optional field with default value.+  optionalFieldDefAla+    :: (c b, Newtype a b, Eq a)+    => FieldName+    -- ^ field name+    -> (a -> b)+    -- ^ 'Newtype' pack+    -> ALens' s a+    -- ^ @'Lens'' s a@: lens into the field+    -> a+    -- ^ default value+    -> g s a -    --  | Free text field is essentially 'optionalFieldDefAla` with @""@-    --  as the default and "accept everything" parser.-    ---    -- @since 3.0.0.0-    freeTextField-        :: FieldName-        -> ALens' s (Maybe String) -- ^ lens into the field-        -> g s (Maybe String)+  --  | Free text field is essentially 'optionalFieldDefAla` with @""@+  --  as the default and "accept everything" parser.+  --+  -- @since 3.0.0.0+  freeTextField+    :: FieldName+    -> ALens' s (Maybe String)+    -- ^ lens into the field+    -> g s (Maybe String) -    --  | Free text field is essentially 'optionalFieldDefAla` with @""@-    --  as the default and "accept everything" parser.-    ---    -- @since 3.0.0.0-    freeTextFieldDef-        :: FieldName-        -> ALens' s String -- ^ lens into the field-        -> g s String+  --  | Free text field is essentially 'optionalFieldDefAla` with @""@+  --  as the default and "accept everything" parser.+  --+  -- @since 3.0.0.0+  freeTextFieldDef+    :: FieldName+    -> ALens' s String+    -- ^ lens into the field+    -> g s String -    -- | @since 3.2.0.0-    freeTextFieldDefST-        :: FieldName-        -> ALens' s ShortText -- ^ lens into the field-        -> g s ShortText+  -- | @since 3.2.0.0+  freeTextFieldDefST+    :: FieldName+    -> ALens' s ShortText+    -- ^ lens into the field+    -> g s ShortText -    -- | Monoidal field.-    ---    -- Values are combined with 'mappend'.-    ---    -- /Note:/ 'optionalFieldAla' is a @monoidalField@ with 'Last' monoid.-    ---    monoidalFieldAla-        :: (c b, Monoid a, Newtype a b)-        => FieldName   -- ^ field name-        -> (a -> b)    -- ^ 'pack'-        -> ALens' s a  -- ^ lens into the field-        -> g s a+  -- | Monoidal field.+  --+  -- Values are combined with 'mappend'.+  --+  -- /Note:/ 'optionalFieldAla' is a @monoidalField@ with 'Last' monoid.+  monoidalFieldAla+    :: (c b, Monoid a, Newtype a b)+    => FieldName+    -- ^ field name+    -> (a -> b)+    -- ^ 'pack'+    -> ALens' s a+    -- ^ lens into the field+    -> g s a -    -- | Parser matching all fields with a name starting with a prefix.-    prefixedFields-        :: FieldName                    -- ^ field name prefix-        -> ALens' s [(String, String)]  -- ^ lens into the field-        -> g s [(String, String)]+  -- | Parser matching all fields with a name starting with a prefix.+  prefixedFields+    :: FieldName+    -- ^ field name prefix+    -> ALens' s [(String, String)]+    -- ^ lens into the field+    -> g s [(String, String)] -    -- | Known field, which we don't parse, nor pretty print.-    knownField :: FieldName -> g s ()+  -- | Known field, which we don't parse, nor pretty print.+  knownField :: FieldName -> g s () -    -- | Field which is parsed but not pretty printed.-    hiddenField :: g s a -> g s a+  -- | Field which is parsed but not pretty printed.+  hiddenField :: g s a -> g s a -    -- | Deprecated since-    deprecatedSince-        :: CabalSpecVersion   -- ^ version-        -> String             -- ^ deprecation message-        -> g s a-        -> g s a+  -- | Deprecated since+  deprecatedSince+    :: CabalSpecVersion+    -- ^ version+    -> String+    -- ^ deprecation message+    -> g s a+    -> g s a -    -- | Removed in. If we encounter removed field, parsing fails.-    removedIn-        :: CabalSpecVersion   -- ^ version-        -> String             -- ^ removal message-        -> g s a-        -> g s a+  -- | Removed in. If we encounter removed field, parsing fails.+  removedIn+    :: CabalSpecVersion+    -- ^ version+    -> String+    -- ^ removal message+    -> g s a+    -> g s a -    -- | Annotate field with since spec-version.-    availableSince-        :: CabalSpecVersion  -- ^ spec version-        -> a                 -- ^ default value-        -> g s a-        -> g s a+  -- | Annotate field with since spec-version.+  availableSince+    :: CabalSpecVersion+    -- ^ spec version+    -> a+    -- ^ default value+    -> g s a+    -> g s a -    -- | Annotate field with since spec-version.-    -- This is used to recognise, but warn about the field.-    -- It is used to process @other-extensions@ field.-    ---    -- Default implementation is to not warn.-    ---    -- @since 3.4.0.0-    availableSinceWarn-        :: CabalSpecVersion  -- ^ spec version-        -> g s a-        -> g s a-    availableSinceWarn _ = id+  -- | Annotate field with since spec-version.+  -- This is used to recognise, but warn about the field.+  -- It is used to process @other-extensions@ field.+  --+  -- Default implementation is to not warn.+  --+  -- @since 3.4.0.0+  availableSinceWarn+    :: CabalSpecVersion+    -- ^ spec version+    -> g s a+    -> g s a+  availableSinceWarn _ = id  -- | Field which can be defined at most once. uniqueField-    :: (FieldGrammar c g, c (Identity a))-    => FieldName   -- ^ field name-    -> ALens' s a  -- ^ lens into the field-    -> g s a+  :: (FieldGrammar c g, c (Identity a))+  => FieldName+  -- ^ field name+  -> ALens' s a+  -- ^ lens into the field+  -> g s a uniqueField fn l = uniqueFieldAla fn Identity l  -- | Field which can be defined at most once. optionalField-    :: (FieldGrammar c g, c (Identity a))-    => FieldName          -- ^ field name-    -> ALens' s (Maybe a) -- ^ lens into the field-    -> g s (Maybe a)+  :: (FieldGrammar c g, c (Identity a))+  => FieldName+  -- ^ field name+  -> ALens' s (Maybe a)+  -- ^ lens into the field+  -> g s (Maybe a) optionalField fn l = optionalFieldAla fn Identity l  -- | Optional field with default value. optionalFieldDef-    :: (FieldGrammar c g, Functor (g s), c (Identity a), Eq a)-    => FieldName   -- ^ field name-    -> ALens' s a  -- ^ @'Lens'' s a@: lens into the field-    -> a           -- ^ default value-    -> g s a+  :: (FieldGrammar c g, Functor (g s), c (Identity a), Eq a)+  => FieldName+  -- ^ field name+  -> ALens' s a+  -- ^ @'Lens'' s a@: lens into the field+  -> a+  -- ^ default value+  -> g s a optionalFieldDef fn l x = optionalFieldDefAla fn Identity l x  -- | Field which can be define multiple times, and the results are @mappend@ed. monoidalField-    :: (FieldGrammar c g, c (Identity a), Monoid a)-    => FieldName   -- ^ field name-    -> ALens' s a  -- ^ lens into the field-    -> g s a+  :: (FieldGrammar c g, c (Identity a), Monoid a)+  => FieldName+  -- ^ field name+  -> ALens' s a+  -- ^ lens into the field+  -> g s a monoidalField fn l = monoidalFieldAla fn Identity l  -- | Default implementation for 'freeTextFieldDefST'. defaultFreeTextFieldDefST-    :: (Functor (g s), FieldGrammar c g)-    => FieldName-    -> ALens' s ShortText -- ^ lens into the field-    -> g s ShortText+  :: (Functor (g s), FieldGrammar c g)+  => FieldName+  -> ALens' s ShortText+  -- ^ lens into the field+  -> g s ShortText defaultFreeTextFieldDefST fn l =-    toShortText <$> freeTextFieldDef fn (cloneLens l . st)+  toShortText <$> freeTextFieldDef fn (cloneLens l . st)   where     st :: Lens' ShortText String     st f s = toShortText <$> f (fromShortText s)
src/Distribution/FieldGrammar/FieldDescrs.hs view
@@ -1,43 +1,44 @@-{-# LANGUAGE DeriveFunctor         #-}-{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE RankNTypes            #-}-{-# LANGUAGE UndecidableInstances  #-}-module Distribution.FieldGrammar.FieldDescrs (-    FieldDescrs,-    fieldDescrPretty,-    fieldDescrParse,-    fieldDescrsToList,-    ) where+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE UndecidableInstances #-} +module Distribution.FieldGrammar.FieldDescrs+  ( FieldDescrs+  , fieldDescrPretty+  , fieldDescrParse+  , fieldDescrsToList+  ) where+ import Distribution.Compat.Prelude import Prelude () -import Distribution.Compat.Lens    (aview, cloneLens)-import Distribution.Utils.String (trim)+import Distribution.Compat.Lens (aview, cloneLens) import Distribution.Compat.Newtype import Distribution.FieldGrammar-import Distribution.Pretty         (Pretty (..), showFreeText)+import Distribution.Pretty (Pretty (..), showFreeText)+import Distribution.Utils.String (trim) -import qualified Data.Map                        as Map+import qualified Data.Map as Map import qualified Distribution.Compat.CharParsing as C-import qualified Distribution.Fields             as P-import qualified Distribution.Parsec             as P-import qualified Text.PrettyPrint                as Disp+import qualified Distribution.Fields as P+import qualified Distribution.Parsec as P+import qualified Text.PrettyPrint as Disp  -- strict pair data SP s = SP-    { pPretty :: !(s -> Disp.Doc)-    , pParse  :: !(forall m. P.CabalParsing m => s -> m s)-    }+  { pPretty :: !(s -> Disp.Doc)+  , pParse :: !(forall m. P.CabalParsing m => s -> m s)+  }  -- | A collection of field parsers and pretty-printers.-newtype FieldDescrs s a = F { runF :: Map P.FieldName (SP s) }+newtype FieldDescrs s a = F {runF :: Map P.FieldName (SP s)}   deriving (Functor)  instance Applicative (FieldDescrs s) where-    pure _  = F mempty-    f <*> x = F (mappend (runF f) (runF x))+  pure _ = F mempty+  f <*> x = F (mappend (runF f) (runF x))  singletonF :: P.FieldName -> (s -> Disp.Doc) -> (forall m. P.CabalParsing m => s -> m s) -> FieldDescrs s a singletonF fn f g = F $ Map.singleton fn (SP f g)@@ -51,55 +52,65 @@ fieldDescrParse (F m) fn = (\f -> pParse f) <$> Map.lookup fn m  fieldDescrsToList-    :: P.CabalParsing m-    => FieldDescrs s a-    -> [(P.FieldName, s -> Disp.Doc, s -> m s)]-fieldDescrsToList = map mk . Map.toList . runF where+  :: P.CabalParsing m+  => FieldDescrs s a+  -> [(P.FieldName, s -> Disp.Doc, s -> m s)]+fieldDescrsToList = map mk . Map.toList . runF+  where     mk (name, SP ppr parse) = (name, ppr, parse)  -- | /Note:/ default values are printed. instance FieldGrammar ParsecPretty FieldDescrs where-    blurFieldGrammar l (F m) = F (fmap blur m) where-        blur (SP f g) = SP (f . aview l) (cloneLens l g)+  blurFieldGrammar l (F m) = F (fmap blur m)+    where+      blur (SP f g) = SP (f . aview l) (cloneLens l g) -    booleanFieldDef fn l _def = singletonF fn f g where-        f s = Disp.text (show (aview l s))-        g s = cloneLens l (const P.parsec) s-      -- Note: eta expansion is needed for RankNTypes type-checking to work.+  booleanFieldDef fn l _def = singletonF fn f g+    where+      f s = Disp.text (show (aview l s))+      g s = cloneLens l (const P.parsec) s -    uniqueFieldAla fn _pack l = singletonF fn f g where-        f s = pretty (pack' _pack (aview l s))-        g s = cloneLens l (const (unpack' _pack <$> P.parsec)) s+  -- Note: eta expansion is needed for RankNTypes type-checking to work. -    optionalFieldAla fn _pack l = singletonF fn f g where-        f s = maybe mempty (pretty . pack' _pack) (aview l s)-        g s = cloneLens l (const (Just . unpack' _pack <$> P.parsec)) s+  uniqueFieldAla fn _pack l = singletonF fn f g+    where+      f s = pretty (pack' _pack (aview l s))+      g s = cloneLens l (const (unpack' _pack <$> P.parsec)) s -    optionalFieldDefAla fn _pack l _def = singletonF fn f g where-        f s = pretty (pack' _pack (aview l s))-        g s = cloneLens l (const (unpack' _pack <$> P.parsec)) s+  optionalFieldAla fn _pack l = singletonF fn f g+    where+      f s = maybe mempty (pretty . pack' _pack) (aview l s)+      g s = cloneLens l (const (Just . unpack' _pack <$> P.parsec)) s -    freeTextField fn l = singletonF fn f g where-        f s = maybe mempty showFreeText (aview l s)-        g s = cloneLens l (const (Just <$> parsecFreeText)) s+  optionalFieldDefAla fn _pack l _def = singletonF fn f g+    where+      f s = pretty (pack' _pack (aview l s))+      g s = cloneLens l (const (unpack' _pack <$> P.parsec)) s -    freeTextFieldDef fn l = singletonF fn f g where-        f s = showFreeText (aview l s)-        g s = cloneLens l (const parsecFreeText) s+  freeTextField fn l = singletonF fn f g+    where+      f s = maybe mempty showFreeText (aview l s)+      g s = cloneLens l (const (Just <$> parsecFreeText)) s -    freeTextFieldDefST = defaultFreeTextFieldDefST+  freeTextFieldDef fn l = singletonF fn f g+    where+      f s = showFreeText (aview l s)+      g s = cloneLens l (const parsecFreeText) s -    monoidalFieldAla fn _pack l = singletonF fn f g where-        f s = pretty (pack' _pack (aview l s))-        g s = cloneLens l (\x -> mappend x . unpack' _pack <$> P.parsec) s+  freeTextFieldDefST = defaultFreeTextFieldDefST -    prefixedFields _fnPfx _l = F mempty-    knownField _           = pure ()-    deprecatedSince _  _ x = x-    removedIn _ _ x        = x-    availableSince _ _     = id-    hiddenField _          = F mempty+  monoidalFieldAla fn _pack l = singletonF fn f g+    where+      f s = pretty (pack' _pack (aview l s))+      g s = cloneLens l (\x -> mappend x . unpack' _pack <$> P.parsec) s +  prefixedFields _fnPfx _l = F mempty+  knownField _ = pure ()+  deprecatedSince _ _ x = x+  removedIn _ _ x = x+  availableSince _ _ = id+  hiddenField _ = F mempty+ parsecFreeText :: P.CabalParsing m => m String parsecFreeText = dropDotLines <$ C.spaces <*> many C.anyChar   where@@ -109,11 +120,10 @@     dropDotLines x = intercalate "\n" . map dotToEmpty . lines $ x      dotToEmpty x | trim' x == "." = ""-    dotToEmpty x                  = trim x+    dotToEmpty x = trim x      trim' :: String -> String     trim' = dropWhileEnd (`elem` (" \t" :: String)) --class    (P.Parsec a, Pretty a) => ParsecPretty a+class (P.Parsec a, Pretty a) => ParsecPretty a instance (P.Parsec a, Pretty a) => ParsecPretty a
src/Distribution/FieldGrammar/Newtypes.hs view
@@ -1,60 +1,82 @@-{-# LANGUAGE FlexibleContexts       #-}-{-# LANGUAGE FlexibleInstances      #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE OverloadedStrings      #-}-{-# LANGUAGE RankNTypes             #-}-{-# LANGUAGE ScopedTypeVariables    #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE InstanceSigs #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+ -- | This module provides @newtype@ wrappers to be used with "Distribution.FieldGrammar".-module Distribution.FieldGrammar.Newtypes (-    -- * List-    alaList,-    alaList',+module Distribution.FieldGrammar.Newtypes+  ( -- * List+    alaList+  , alaList'+     -- ** Modifiers-    CommaVCat (..),-    CommaFSep (..),-    VCat (..),-    FSep (..),-    NoCommaFSep (..),-    Sep (..),+  , CommaVCat (..)+  , CommaFSep (..)+  , VCat (..)+  , FSep (..)+  , NoCommaFSep (..)+  , Sep (..)+     -- ** Type-    List,+  , List+     -- ** Set-    alaSet,-    alaSet',-    Set',+  , alaSet+  , alaSet'+  , Set'+     -- ** NonEmpty-    alaNonEmpty,-    alaNonEmpty',-    NonEmpty',+  , alaNonEmpty+  , alaNonEmpty'+  , NonEmpty'+     -- * Version & License-    SpecVersion (..),-    TestedWith (..),-    SpecLicense (..),+  , SpecVersion (..)+  , TestedWith (..)+  , SpecLicense (..)+     -- * Identifiers-    Token (..),-    Token' (..),-    MQuoted (..),-    FilePathNT (..),-    ) where+  , Token (..)+  , Token' (..)+  , MQuoted (..)+  , FilePathNT (..)+  , SymbolicPathNT (..)+  , RelativePathNT (..)+  ) where  import Distribution.Compat.Newtype import Distribution.Compat.Prelude import Prelude ()  import Distribution.CabalSpecVersion-import Distribution.Compiler         (CompilerFlavor)-import Distribution.License          (License)+import Distribution.Compiler (CompilerFlavor)+import Distribution.License (License) import Distribution.Parsec import Distribution.Pretty+import Distribution.Utils.Path import Distribution.Version-       (LowerBound (..), Version, VersionInterval (..), VersionRange, VersionRangeF (..), anyVersion, asVersionIntervals, cataVersionRange, mkVersion,-       version0, versionNumbers)-import Text.PrettyPrint              (Doc, comma, fsep, punctuate, text, vcat)+  ( LowerBound (..)+  , Version+  , VersionInterval (..)+  , VersionRange+  , VersionRangeF (..)+  , anyVersion+  , asVersionIntervals+  , cataVersionRange+  , mkVersion+  , version0+  , versionNumbers+  )+import Text.PrettyPrint (Doc, comma, fsep, punctuate, text, vcat) -import qualified Data.List.NonEmpty              as NE-import qualified Data.Set                        as Set+import qualified Data.List.NonEmpty as NE+import qualified Data.Set as Set import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.SPDX               as SPDX+import qualified Distribution.SPDX as SPDX  -- | Vertical list with commas. Displayed with 'vcat' data CommaVCat = CommaVCat@@ -71,48 +93,48 @@ -- | Paragraph fill list without commas. Displayed with 'fsep'. data NoCommaFSep = NoCommaFSep -class    Sep sep  where-    prettySep :: Proxy sep -> [Doc] -> Doc+class Sep sep where+  prettySep :: Proxy sep -> [Doc] -> Doc -    parseSep   :: CabalParsing m => Proxy sep -> m a -> m [a]-    parseSepNE :: CabalParsing m => Proxy sep -> m a -> m (NonEmpty a)+  parseSep :: CabalParsing m => Proxy sep -> m a -> m [a]+  parseSepNE :: CabalParsing m => Proxy sep -> m a -> m (NonEmpty a)  instance Sep CommaVCat where-    prettySep  _ = vcat . punctuate comma-    parseSep   _ p = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV2_2 then parsecLeadingCommaList p else parsecCommaList p-    parseSepNE _ p = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV2_2 then parsecLeadingCommaNonEmpty p else parsecCommaNonEmpty p+  prettySep _ = vcat . punctuate comma+  parseSep _ p = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV2_2 then parsecLeadingCommaList p else parsecCommaList p+  parseSepNE _ p = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV2_2 then parsecLeadingCommaNonEmpty p else parsecCommaNonEmpty p instance Sep CommaFSep where-    prettySep _ = fsep . punctuate comma-    parseSep   _ p = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV2_2 then parsecLeadingCommaList p else parsecCommaList p-    parseSepNE _ p = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV2_2 then parsecLeadingCommaNonEmpty p else parsecCommaNonEmpty p+  prettySep _ = fsep . punctuate comma+  parseSep _ p = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV2_2 then parsecLeadingCommaList p else parsecCommaList p+  parseSepNE _ p = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV2_2 then parsecLeadingCommaNonEmpty p else parsecCommaNonEmpty p instance Sep VCat where-    prettySep _  = vcat-    parseSep   _ p = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV3_0 then parsecLeadingOptCommaList p else parsecOptCommaList p-    parseSepNE _ p = NE.some1 (p <* P.spaces)+  prettySep _ = vcat+  parseSep _ p = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV3_0 then parsecLeadingOptCommaList p else parsecOptCommaList p+  parseSepNE _ p = NE.some1 (p <* P.spaces) instance Sep FSep where-    prettySep _  = fsep-    parseSep   _ p = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV3_0 then parsecLeadingOptCommaList p else parsecOptCommaList p-    parseSepNE _ p = NE.some1 (p <* P.spaces)+  prettySep _ = fsep+  parseSep _ p = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV3_0 then parsecLeadingOptCommaList p else parsecOptCommaList p+  parseSepNE _ p = NE.some1 (p <* P.spaces) instance Sep NoCommaFSep where-    prettySep _    = fsep-    parseSep  _ p  = many (p <* P.spaces)-    parseSepNE _ p = NE.some1 (p <* P.spaces)+  prettySep _ = fsep+  parseSep _ p = many (p <* P.spaces)+  parseSepNE _ p = NE.some1 (p <* P.spaces)  -- | List separated with optional commas. Displayed with @sep@, arguments of -- type @a@ are parsed and pretty-printed as @b@.-newtype List sep b a = List { _getList :: [a] }+newtype List sep b a = List {_getList :: [a]}  -- | 'alaList' and 'alaList'' are simply 'List', with additional phantom -- arguments to constrain the resulting type@@ -122,7 +144,6 @@ -- -- >>> :t alaList' FSep Token -- alaList' FSep Token :: [String] -> List FSep Token String--- alaList :: sep -> [a] -> List sep (Identity a) a alaList _ = List @@ -133,16 +154,17 @@ instance Newtype [a] (List sep wrapper a)  instance (Newtype a b, Sep sep, Parsec b) => Parsec (List sep b a) where-    parsec   = pack . map (unpack :: b -> a) <$> parseSep (Proxy :: Proxy sep) parsec+  parsec = pack . map (unpack :: b -> a) <$> parseSep (Proxy :: Proxy sep) parsec  instance (Newtype a b, Sep sep, Pretty b) => Pretty (List sep b a) where-    pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . unpack+  pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . unpack  --+ -- | Like 'List', but for 'Set'. -- -- @since 3.2.0.0-newtype Set' sep b a = Set' { _getSet :: Set a }+newtype Set' sep b a = Set' {_getSet :: Set a}  -- | 'alaSet' and 'alaSet'' are simply 'Set'' constructor, with additional phantom -- arguments to constrain the resulting type@@ -169,16 +191,17 @@ instance Newtype (Set a) (Set' sep wrapper a)  instance (Newtype a b, Ord a, Sep sep, Parsec b) => Parsec (Set' sep b a) where-    parsec   = pack . Set.fromList . map (unpack :: b -> a) <$> parseSep (Proxy :: Proxy sep) parsec+  parsec = pack . Set.fromList . map (unpack :: b -> a) <$> parseSep (Proxy :: Proxy sep) parsec  instance (Newtype a b, Sep sep, Pretty b) => Pretty (Set' sep b a) where-    pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . Set.toList . unpack+  pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . Set.toList . unpack  --+ -- | Like 'List', but for 'NonEmpty'. -- -- @since 3.2.0.0-newtype NonEmpty' sep b a = NonEmpty' { _getNonEmpty :: NonEmpty a }+newtype NonEmpty' sep b a = NonEmpty' {_getNonEmpty :: NonEmpty a}  -- | 'alaNonEmpty' and 'alaNonEmpty'' are simply 'NonEmpty'' constructor, with additional phantom -- arguments to constrain the resulting type@@ -202,63 +225,98 @@ instance Newtype (NonEmpty a) (NonEmpty' sep wrapper a)  instance (Newtype a b, Sep sep, Parsec b) => Parsec (NonEmpty' sep b a) where-    parsec   = pack . fmap (unpack :: b -> a) <$> parseSepNE (Proxy :: Proxy sep) parsec+  parsec = pack . fmap (unpack :: b -> a) <$> parseSepNE (Proxy :: Proxy sep) parsec  instance (Newtype a b, Sep sep, Pretty b) => Pretty (NonEmpty' sep b a) where-    pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . NE.toList . unpack+  pretty = prettySep (Proxy :: Proxy sep) . map (pretty . (pack :: a -> b)) . NE.toList . unpack  ------------------------------------------------------------------------------- -- Identifiers -------------------------------------------------------------------------------  -- | Haskell string or @[^ ,]+@-newtype Token = Token { getToken :: String }+newtype Token = Token {getToken :: String}  instance Newtype String Token  instance Parsec Token where-    parsec = pack <$> parsecToken+  parsec = pack <$> parsecToken  instance Pretty Token where-    pretty = showToken . unpack+  pretty = showToken . unpack  -- | Haskell string or @[^ ]+@-newtype Token' = Token' { getToken' :: String }+newtype Token' = Token' {getToken' :: String}  instance Newtype String Token'  instance Parsec Token' where-    parsec = pack <$> parsecToken'+  parsec = pack <$> parsecToken'  instance Pretty Token' where-    pretty = showToken . unpack+  pretty = showToken . unpack  -- | Either @"quoted"@ or @un-quoted@.-newtype MQuoted a = MQuoted { getMQuoted :: a }+newtype MQuoted a = MQuoted {getMQuoted :: a}  instance Newtype a (MQuoted a)  instance Parsec a => Parsec (MQuoted a) where-    parsec = pack <$> parsecMaybeQuoted parsec+  parsec = pack <$> parsecMaybeQuoted parsec -instance Pretty a => Pretty (MQuoted a)  where-    pretty = pretty . unpack+instance Pretty a => Pretty (MQuoted a) where+  pretty = pretty . unpack  -- | Filepath are parsed as 'Token'.-newtype FilePathNT = FilePathNT { getFilePathNT :: String }+newtype FilePathNT = FilePathNT {getFilePathNT :: String}  instance Newtype String FilePathNT  instance Parsec FilePathNT where-    parsec = do-        token <- parsecToken-        if null token-        then P.unexpected "empty FilePath"-        else return (FilePathNT token)+  parsec = do+    token <- parsecToken+    if null token+      then P.unexpected "empty FilePath"+      else return (FilePathNT token)  instance Pretty FilePathNT where-    pretty = showFilePath . unpack+  pretty = showFilePath . unpack +-- | Newtype for 'SymbolicPath', with a different 'Parsec' instance+-- to disallow empty paths.+newtype SymbolicPathNT from to = SymbolicPathNT {getSymbolicPathNT :: SymbolicPath from to}++instance Newtype (SymbolicPath from to) (SymbolicPathNT from to)++instance Parsec (SymbolicPathNT from to) where+  parsec = do+    token <- parsecToken+    if null token+      then P.unexpected "empty FilePath"+      else return (SymbolicPathNT $ makeSymbolicPath token)++instance Pretty (SymbolicPathNT from to) where+  pretty = showFilePath . getSymbolicPath . getSymbolicPathNT++-- | Newtype for 'RelativePath', with a different 'Parsec' instance+-- to disallow empty paths but allow non-relative paths (which get rejected+-- later with a different error message, see 'Distribution.PackageDescription.Check.Paths.checkPath')+newtype RelativePathNT from to = RelativePathNT {getRelativePathNT :: RelativePath from to}++instance Newtype (RelativePath from to) (RelativePathNT from to)++-- NB: we don't reject non-relative paths here; we allow them here and reject+-- later (see 'Distribution.PackageDescription.Check.Paths.checkPath').+instance Parsec (RelativePathNT from to) where+  parsec = do+    token <- parsecToken+    if null token+      then P.unexpected "empty FilePath"+      else return (RelativePathNT $ unsafeMakeSymbolicPath token)++instance Pretty (RelativePathNT from to) where+  pretty = showFilePath . getSymbolicPath . getRelativePathNT+ ------------------------------------------------------------------------------- -- SpecVersion -------------------------------------------------------------------------------@@ -275,119 +333,124 @@ -- We have this newtype, as writing Parsec and Pretty instances -- for CabalSpecVersion would cause cycle in modules: --     Version -> CabalSpecVersion -> Parsec -> ...----newtype SpecVersion = SpecVersion { getSpecVersion :: CabalSpecVersion }+newtype SpecVersion = SpecVersion {getSpecVersion :: CabalSpecVersion}   deriving (Eq, Show) -- instances needed for tests  instance Newtype CabalSpecVersion SpecVersion  instance Parsec SpecVersion where-    parsec = do-        e <- parsecSpecVersion-        let ver    :: Version-            ver    = either id specVersionFromRange e--            digits :: [Int]-            digits = versionNumbers ver--        case cabalSpecFromVersionDigits digits of-            Nothing  -> fail $ "Unknown cabal spec version specified: " ++ prettyShow ver-            Just csv -> do-                -- Check some warnings:-                case e of-                    -- example:   cabal-version: 1.10-                    -- should be  cabal-version: >=1.10-                    Left _v | csv < CabalSpecV1_12 -> parsecWarning PWTSpecVersion $ concat-                        [ "With 1.10 or earlier, the 'cabal-version' field must use "-                        , "range syntax rather than a simple version number. Use "-                        , "'cabal-version: >= " ++ prettyShow ver ++ "'."-                        ]--                    -- example:   cabal-version: >=1.12-                    -- should be  cabal-version: 1.12-                    Right _vr | csv >= CabalSpecV1_12 -> parsecWarning PWTSpecVersion $ concat-                        [ "Packages with 'cabal-version: 1.12' or later should specify a "-                        , "specific version of the Cabal spec of the form "-                        , "'cabal-version: x.y'. "-                        , "Use 'cabal-version: " ++ prettyShow ver ++ "'."-                        ]--                    -- example:   cabal-version: >=1.10 && <1.12-                    -- should be  cabal-version: >=1.10-                    Right vr | csv < CabalSpecV1_12-                            , not (simpleSpecVersionRangeSyntax vr) -> parsecWarning PWTSpecVersion $ concat-                        [ "It is recommended that the 'cabal-version' field only specify a "-                        , "version range of the form '>= x.y' for older cabal versions. Use "-                        , "'cabal-version: >= " ++ prettyShow ver ++ "'. "-                        , "Tools based on Cabal 1.10 and later will ignore upper bounds."-                        ]+  parsec = do+    e <- parsecSpecVersion+    let ver :: Version+        ver = either id specVersionFromRange e -                    -- otherwise no warnings-                    _ -> pure ()+        digits :: [Int]+        digits = versionNumbers ver -                return (pack csv)-      where-        parsecSpecVersion = Left <$> parsec <|> Right <$> range+    case cabalSpecFromVersionDigits digits of+      Nothing -> fail $ "Unknown cabal spec version specified: " ++ prettyShow ver+      Just csv -> do+        -- Check some warnings:+        case e of+          -- example:   cabal-version: 1.10+          -- should be  cabal-version: >=1.10+          Left _v+            | csv < CabalSpecV1_12 ->+                parsecWarning PWTSpecVersion $+                  concat+                    [ "With 1.10 or earlier, the 'cabal-version' field must use "+                    , "range syntax rather than a simple version number. Use "+                    , "'cabal-version: >= " ++ prettyShow ver ++ "'."+                    ]+          -- example:   cabal-version: >=1.12+          -- should be  cabal-version: 1.12+          Right _vr+            | csv >= CabalSpecV1_12 ->+                parsecWarning PWTSpecVersion $+                  concat+                    [ "Packages with 'cabal-version: 1.12' or later should specify a "+                    , "specific version of the Cabal spec of the form "+                    , "'cabal-version: x.y'. "+                    , "Use 'cabal-version: " ++ prettyShow ver ++ "'."+                    ]+          -- example:   cabal-version: >=1.10 && <1.12+          -- should be  cabal-version: >=1.10+          Right vr+            | csv < CabalSpecV1_12+            , not (simpleSpecVersionRangeSyntax vr) ->+                parsecWarning PWTSpecVersion $+                  concat+                    [ "It is recommended that the 'cabal-version' field only specify a "+                    , "version range of the form '>= x.y' for older cabal versions. Use "+                    , "'cabal-version: >= " ++ prettyShow ver ++ "'. "+                    , "Tools based on Cabal 1.10 and later will ignore upper bounds."+                    ]+          -- otherwise no warnings+          _ -> pure () -        range = do-            vr <- parsec-            if specVersionFromRange vr >= mkVersion [2,1]-            then fail "cabal-version higher than 2.2 cannot be specified as a range. See https://github.com/haskell/cabal/issues/4899"-            else return vr+        return (pack csv)+    where+      parsecSpecVersion = Left <$> parsec <|> Right <$> range -        specVersionFromRange :: VersionRange -> Version-        specVersionFromRange versionRange = case asVersionIntervals versionRange of-            []                                           -> version0-            VersionInterval (LowerBound version _) _ : _ -> version+      range = do+        vr <- parsec+        if specVersionFromRange vr >= mkVersion [2, 1]+          then fail "cabal-version higher than 2.2 cannot be specified as a range. See https://github.com/haskell/cabal/issues/4899"+          else return vr -        simpleSpecVersionRangeSyntax = cataVersionRange alg where-            alg (OrLaterVersionF _) = True-            alg _                   = False+      specVersionFromRange :: VersionRange -> Version+      specVersionFromRange versionRange = case asVersionIntervals versionRange of+        [] -> version0+        VersionInterval (LowerBound version _) _ : _ -> version +      simpleSpecVersionRangeSyntax = cataVersionRange alg+        where+          alg (OrLaterVersionF _) = True+          alg _ = False  instance Pretty SpecVersion where-    pretty (SpecVersion csv)-        | csv >= CabalSpecV1_12 = text (showCabalSpecVersion csv)-        | otherwise             = text ">=" <<>> text (showCabalSpecVersion csv)+  pretty (SpecVersion csv)+    | csv >= CabalSpecV1_12 = text (showCabalSpecVersion csv)+    | otherwise = text ">=" <<>> text (showCabalSpecVersion csv)  ------------------------------------------------------------------------------- -- SpecLicense -------------------------------------------------------------------------------  -- | SPDX License expression or legacy license-newtype SpecLicense = SpecLicense { getSpecLicense :: Either SPDX.License License }-    deriving (Show, Eq)+newtype SpecLicense = SpecLicense {getSpecLicense :: Either SPDX.License License}+  deriving (Show, Eq)  instance Newtype (Either SPDX.License License) SpecLicense  instance Parsec SpecLicense where-    parsec = do-        v <- askCabalSpecVersion-        if v >= CabalSpecV2_2-        then SpecLicense . Left <$> parsec-        else SpecLicense . Right <$> parsec+  parsec = do+    v <- askCabalSpecVersion+    if v >= CabalSpecV2_2+      then SpecLicense . Left <$> parsec+      else SpecLicense . Right <$> parsec  instance Pretty SpecLicense where-    pretty = either pretty pretty . unpack+  pretty = either pretty pretty . unpack  ------------------------------------------------------------------------------- -- TestedWith -------------------------------------------------------------------------------  -- | Version range or just version-newtype TestedWith = TestedWith { getTestedWith :: (CompilerFlavor, VersionRange) }+newtype TestedWith = TestedWith {getTestedWith :: (CompilerFlavor, VersionRange)}  instance Newtype (CompilerFlavor, VersionRange) TestedWith  instance Parsec TestedWith where-    parsec = pack <$> parsecTestedWith+  parsec = pack <$> parsecTestedWith  instance Pretty TestedWith where-    pretty x = case unpack x of-        (compiler, vr) -> pretty compiler <+> pretty vr+  pretty x = case unpack x of+    (compiler, vr) -> pretty compiler <+> pretty vr  parsecTestedWith :: CabalParsing m => m (CompilerFlavor, VersionRange) parsecTestedWith = do-    name <- lexemeParsec-    ver  <- parsec <|> pure anyVersion-    return (name, ver)+  name <- lexemeParsec+  ver <- parsec <|> pure anyVersion+  return (name, ver)
src/Distribution/FieldGrammar/Parsec.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE DeriveFunctor         #-}+{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings     #-}-{-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+ -- | This module provides a 'FieldGrammarParser', one way to parse -- @.cabal@ -like files. --@@ -50,34 +51,34 @@ -- We can parse 'Fields' like we parse @aeson@ objects, yet we use -- slightly higher-level API, so we can process unspecified fields, -- to report unknown fields and save custom @x-fields@.----module Distribution.FieldGrammar.Parsec (-    ParsecFieldGrammar,-    parseFieldGrammar,-    fieldGrammarKnownFieldList,+module Distribution.FieldGrammar.Parsec+  ( ParsecFieldGrammar+  , parseFieldGrammar+  , fieldGrammarKnownFieldList+     -- * Auxiliary-    Fields,-    NamelessField (..),-    namelessFieldAnn,-    Section (..),-    runFieldParser,-    runFieldParser',-    fieldLinesToStream,-    )  where+  , Fields+  , NamelessField (..)+  , namelessFieldAnn+  , Section (..)+  , runFieldParser+  , runFieldParser'+  , fieldLinesToStream+  ) where  import Distribution.Compat.Newtype import Distribution.Compat.Prelude-import Distribution.Utils.Generic  (fromUTF8BS)+import Distribution.Utils.Generic (fromUTF8BS) import Distribution.Utils.String (trim) import Prelude () -import qualified Data.ByteString              as BS-import qualified Data.List.NonEmpty           as NE-import qualified Data.Map.Strict              as Map-import qualified Data.Set                     as Set+import qualified Data.ByteString as BS+import qualified Data.List.NonEmpty as NE+import qualified Data.Map.Strict as Map+import qualified Data.Set as Set import qualified Distribution.Utils.ShortText as ShortText-import qualified Text.Parsec                  as P-import qualified Text.Parsec.Error            as P+import qualified Text.Parsec as P+import qualified Text.Parsec.Error as P  import Distribution.CabalSpecVersion import Distribution.FieldGrammar.Class@@ -85,7 +86,7 @@ import Distribution.Fields.ParseResult import Distribution.Parsec import Distribution.Parsec.FieldLineStream-import Distribution.Parsec.Position        (positionCol, positionRow)+import Distribution.Parsec.Position (positionCol, positionRow)  ------------------------------------------------------------------------------- -- Auxiliary types@@ -109,238 +110,240 @@ -------------------------------------------------------------------------------  data ParsecFieldGrammar s a = ParsecFG-    { fieldGrammarKnownFields   :: !(Set FieldName)-    , fieldGrammarKnownPrefixes :: !(Set FieldName)-    , fieldGrammarParser        :: !(CabalSpecVersion -> Fields Position -> ParseResult a)-    }+  { fieldGrammarKnownFields :: !(Set FieldName)+  , fieldGrammarKnownPrefixes :: !(Set FieldName)+  , fieldGrammarParser :: !(CabalSpecVersion -> Fields Position -> ParseResult a)+  }   deriving (Functor)  parseFieldGrammar :: CabalSpecVersion -> Fields Position -> ParsecFieldGrammar s a -> ParseResult a parseFieldGrammar v fields grammar = do-    for_ (Map.toList (Map.filterWithKey isUnknownField fields)) $ \(name, nfields) ->-        for_ nfields $ \(MkNamelessField pos _) ->-            parseWarning pos PWTUnknownField $ "Unknown field: " ++ show name-            -- TODO: fields allowed in this section--    -- parse-    fieldGrammarParser grammar v fields+  for_ (Map.toList (Map.filterWithKey isUnknownField fields)) $ \(name, nfields) ->+    for_ nfields $ \(MkNamelessField pos _) ->+      parseWarning pos PWTUnknownField $ "Unknown field: " ++ show name+  -- TODO: fields allowed in this section +  -- parse+  fieldGrammarParser grammar v fields   where-    isUnknownField k _ = not $+    isUnknownField k _ =+      not $         k `Set.member` fieldGrammarKnownFields grammar-        || any (`BS.isPrefixOf` k) (fieldGrammarKnownPrefixes grammar)+          || any (`BS.isPrefixOf` k) (fieldGrammarKnownPrefixes grammar)  fieldGrammarKnownFieldList :: ParsecFieldGrammar s a -> [FieldName] fieldGrammarKnownFieldList = Set.toList . fieldGrammarKnownFields  instance Applicative (ParsecFieldGrammar s) where-    pure x = ParsecFG mempty mempty (\_ _  -> pure x)-    {-# INLINE pure  #-}+  pure x = ParsecFG mempty mempty (\_ _ -> pure x)+  {-# INLINE pure #-} -    ParsecFG f f' f'' <*> ParsecFG x x' x'' = ParsecFG-        (mappend f x)-        (mappend f' x')-        (\v fields -> f'' v fields <*> x'' v fields)-    {-# INLINE (<*>) #-}+  ParsecFG f f' f'' <*> ParsecFG x x' x'' =+    ParsecFG+      (mappend f x)+      (mappend f' x')+      (\v fields -> f'' v fields <*> x'' v fields)+  {-# INLINE (<*>) #-}  warnMultipleSingularFields :: FieldName -> [NamelessField Position] -> ParseResult () warnMultipleSingularFields _ [] = pure () warnMultipleSingularFields fn (x : xs) = do-    let pos  = namelessFieldAnn x-        poss = map namelessFieldAnn xs-    parseWarning pos PWTMultipleSingularField $-        "The field " <> show fn <> " is specified more than once at positions " ++ intercalate ", " (map showPos (pos : poss))+  let pos = namelessFieldAnn x+      poss = map namelessFieldAnn xs+  parseWarning pos PWTMultipleSingularField $+    "The field " <> show fn <> " is specified more than once at positions " ++ intercalate ", " (map showPos (pos : poss))  instance FieldGrammar Parsec ParsecFieldGrammar where-    blurFieldGrammar _ (ParsecFG s s' parser) = ParsecFG s s' parser--    uniqueFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser-      where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> parseFatalFailure zeroPos $ show fn ++ " field missing"-            Just []          -> parseFatalFailure zeroPos $ show fn ++ " field missing"-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)--        parseOne v (MkNamelessField pos fls) =-            unpack' _pack <$> runFieldParser pos parsec v fls--    booleanFieldDef fn _extract def = ParsecFG (Set.singleton fn) Set.empty parser-      where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> pure def-            Just []          -> pure def-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)--        parseOne v (MkNamelessField pos fls) = runFieldParser pos parsec v fls+  blurFieldGrammar _ (ParsecFG s s' parser) = ParsecFG s s' parser -    optionalFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser-      where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> pure Nothing-            Just []          -> pure Nothing-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)+  uniqueFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> parseFatalFailure zeroPos $ show fn ++ " field missing"+        Just [] -> parseFatalFailure zeroPos $ show fn ++ " field missing"+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        parseOne v (MkNamelessField pos fls)-            | null fls  = pure Nothing-            | otherwise = Just . unpack' _pack <$> runFieldParser pos parsec v fls+      parseOne v (MkNamelessField pos fls) =+        unpack' _pack <$> runFieldParser pos parsec v fls -    optionalFieldDefAla fn _pack _extract def = ParsecFG (Set.singleton fn) Set.empty parser-      where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> pure def-            Just []          -> pure def-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)+  booleanFieldDef fn _extract def = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure def+        Just [] -> pure def+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        parseOne v (MkNamelessField pos fls)-            | null fls  = pure def-            | otherwise = unpack' _pack <$> runFieldParser pos parsec v fls+      parseOne v (MkNamelessField pos fls) = runFieldParser pos parsec v fls -    freeTextField fn _ = ParsecFG (Set.singleton fn) Set.empty parser where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> pure Nothing-            Just []          -> pure Nothing-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)+  optionalFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure Nothing+        Just [] -> pure Nothing+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        parseOne v (MkNamelessField pos fls)-            | null fls           = pure Nothing-            | v >= CabalSpecV3_0 = pure (Just (fieldlinesToFreeText3 pos fls))-            | otherwise          = pure (Just (fieldlinesToFreeText fls))+      parseOne v (MkNamelessField pos fls)+        | null fls = pure Nothing+        | otherwise = Just . unpack' _pack <$> runFieldParser pos parsec v fls -    freeTextFieldDef fn _ = ParsecFG (Set.singleton fn) Set.empty parser where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> pure ""-            Just []          -> pure ""-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)+  optionalFieldDefAla fn _pack _extract def = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure def+        Just [] -> pure def+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        parseOne v (MkNamelessField pos fls)-            | null fls           = pure ""-            | v >= CabalSpecV3_0 = pure (fieldlinesToFreeText3 pos fls)-            | otherwise          = pure (fieldlinesToFreeText fls)+      parseOne v (MkNamelessField pos fls)+        | null fls = pure def+        | otherwise = unpack' _pack <$> runFieldParser pos parsec v fls -    -- freeTextFieldDefST = defaultFreeTextFieldDefST-    freeTextFieldDefST fn _ = ParsecFG (Set.singleton fn) Set.empty parser where-        parser v fields = case Map.lookup fn fields of-            Nothing          -> pure mempty-            Just []          -> pure mempty-            Just [x]         -> parseOne v x-            Just xs@(_:y:ys) -> do-                warnMultipleSingularFields fn xs-                NE.last <$> traverse (parseOne v) (y:|ys)+  freeTextField fn _ = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure Nothing+        Just [] -> pure Nothing+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        parseOne v (MkNamelessField pos fls) = case fls of-            []                     -> pure mempty-            [FieldLine _  bs]      -> pure (ShortText.unsafeFromUTF8BS bs)-            _ | v >= CabalSpecV3_0 -> pure (ShortText.toShortText $ fieldlinesToFreeText3 pos fls)-              | otherwise          -> pure (ShortText.toShortText $ fieldlinesToFreeText fls)+      parseOne v (MkNamelessField pos fls)+        | null fls = pure Nothing+        | v >= CabalSpecV3_0 = pure (Just (fieldlinesToFreeText3 pos fls))+        | otherwise = pure (Just (fieldlinesToFreeText fls)) -    monoidalFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser-      where-        parser v fields = case Map.lookup fn fields of-            Nothing -> pure mempty-            Just xs -> foldMap (unpack' _pack) <$> traverse (parseOne v) xs+  freeTextFieldDef fn _ = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure ""+        Just [] -> pure ""+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        parseOne v (MkNamelessField pos fls) = runFieldParser pos parsec v fls+      parseOne v (MkNamelessField pos fls)+        | null fls = pure ""+        | v >= CabalSpecV3_0 = pure (fieldlinesToFreeText3 pos fls)+        | otherwise = pure (fieldlinesToFreeText fls) -    prefixedFields fnPfx _extract = ParsecFG mempty (Set.singleton fnPfx) (\_ fs -> pure (parser fs))-      where-        parser :: Fields Position -> [(String, String)]-        parser values = reorder $ concatMap convert $ filter match $ Map.toList values+  -- freeTextFieldDefST = defaultFreeTextFieldDefST+  freeTextFieldDefST fn _ = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure mempty+        Just [] -> pure mempty+        Just [x] -> parseOne v x+        Just xs@(_ : y : ys) -> do+          warnMultipleSingularFields fn xs+          NE.last <$> traverse (parseOne v) (y :| ys) -        match (fn, _) = fnPfx `BS.isPrefixOf` fn-        convert (fn, fields) =-            [ (pos, (fromUTF8BS fn, trim $ fromUTF8BS $ fieldlinesToBS fls))-            | MkNamelessField pos fls <- fields-            ]-        -- hack: recover the order of prefixed fields-        reorder = map snd . sortBy (comparing fst)+      parseOne v (MkNamelessField pos fls) = case fls of+        [] -> pure mempty+        [FieldLine _ bs] -> pure (ShortText.unsafeFromUTF8BS bs)+        _+          | v >= CabalSpecV3_0 -> pure (ShortText.toShortText $ fieldlinesToFreeText3 pos fls)+          | otherwise -> pure (ShortText.toShortText $ fieldlinesToFreeText fls) -    availableSince vs def (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'-      where-        parser' v values-            | v >= vs = parser v values-            | otherwise = do-                let unknownFields = Map.intersection values $ Map.fromSet (const ()) names-                for_ (Map.toList unknownFields) $ \(name, fields) ->-                    for_ fields $ \(MkNamelessField pos _) ->-                        parseWarning pos PWTUnknownField $-                            "The field " <> show name <> " is available only since the Cabal specification version " ++ showCabalSpecVersion vs ++ ". This field will be ignored."+  monoidalFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser+    where+      parser v fields = case Map.lookup fn fields of+        Nothing -> pure mempty+        Just xs -> foldMap (unpack' _pack) <$> traverse (parseOne v) xs -                pure def+      parseOne v (MkNamelessField pos fls) = runFieldParser pos parsec v fls -    availableSinceWarn vs (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'-      where-        parser' v values-            | v >= vs = parser v values-            | otherwise = do-                let unknownFields = Map.intersection values $ Map.fromSet (const ()) names-                for_ (Map.toList unknownFields) $ \(name, fields) ->-                    for_ fields $ \(MkNamelessField pos _) ->-                        parseWarning pos PWTUnknownField $-                            "The field " <> show name <> " is available only since the Cabal specification version " ++ showCabalSpecVersion vs ++ "."+  prefixedFields fnPfx _extract = ParsecFG mempty (Set.singleton fnPfx) (\_ fs -> pure (parser fs))+    where+      parser :: Fields Position -> [(String, String)]+      parser values = reorder $ concatMap convert $ filter match $ Map.toList values -                parser v values+      match (fn, _) = fnPfx `BS.isPrefixOf` fn+      convert (fn, fields) =+        [ (pos, (fromUTF8BS fn, trim $ fromUTF8BS $ fieldlinesToBS fls))+        | MkNamelessField pos fls <- fields+        ]+      -- hack: recover the order of prefixed fields+      reorder = map snd . sortBy (comparing fst) +  availableSince vs def (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'+    where+      parser' v values+        | v >= vs = parser v values+        | otherwise = do+            let unknownFields = Map.intersection values $ Map.fromSet (const ()) names+            for_ (Map.toList unknownFields) $ \(name, fields) ->+              for_ fields $ \(MkNamelessField pos _) ->+                parseWarning pos PWTUnknownField $+                  "The field " <> show name <> " is available only since the Cabal specification version " ++ showCabalSpecVersion vs ++ ". This field will be ignored." -    -- todo we know about this field-    deprecatedSince vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'-      where-        parser' v values-            | v >= vs = do-                let deprecatedFields = Map.intersection values $ Map.fromSet (const ()) names-                for_ (Map.toList deprecatedFields) $ \(name, fields) ->-                    for_ fields $ \(MkNamelessField pos _) ->-                        parseWarning pos PWTDeprecatedField $-                            "The field " <> show name <> " is deprecated in the Cabal specification version " ++ showCabalSpecVersion vs ++ ". " ++ msg+            pure def -                parser v values+  availableSinceWarn vs (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'+    where+      parser' v values+        | v >= vs = parser v values+        | otherwise = do+            let unknownFields = Map.intersection values $ Map.fromSet (const ()) names+            for_ (Map.toList unknownFields) $ \(name, fields) ->+              for_ fields $ \(MkNamelessField pos _) ->+                parseWarning pos PWTUnknownField $+                  "The field " <> show name <> " is available only since the Cabal specification version " ++ showCabalSpecVersion vs ++ "." -            | otherwise = parser v values+            parser v values -    removedIn vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser' where-        parser' v values-            | v >= vs = do-                let msg' = if null msg then "" else ' ' : msg-                let unknownFields = Map.intersection values $ Map.fromSet (const ()) names-                let namePos =-                      [ (name, pos)-                      | (name, fields) <- Map.toList unknownFields-                      , MkNamelessField pos _ <- fields-                      ]+  -- todo we know about this field+  deprecatedSince vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'+    where+      parser' v values+        | v >= vs = do+            let deprecatedFields = Map.intersection values $ Map.fromSet (const ()) names+            for_ (Map.toList deprecatedFields) $ \(name, fields) ->+              for_ fields $ \(MkNamelessField pos _) ->+                parseWarning pos PWTDeprecatedField $+                  "The field " <> show name <> " is deprecated in the Cabal specification version " ++ showCabalSpecVersion vs ++ ". " ++ msg -                let makeMsg name = "The field " <> show name <> " is removed in the Cabal specification version " ++ showCabalSpecVersion vs ++ "." ++ msg'+            parser v values+        | otherwise = parser v values -                case namePos of-                    -- no fields => proceed (with empty values, to be sure)-                    [] -> parser v mempty+  removedIn vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'+    where+      parser' v values+        | v >= vs = do+            let msg' = if null msg then "" else ' ' : msg+            let unknownFields = Map.intersection values $ Map.fromSet (const ()) names+            let namePos =+                  [ (name, pos)+                  | (name, fields) <- Map.toList unknownFields+                  , MkNamelessField pos _ <- fields+                  ] -                    -- if there's single field: fail fatally with it-                    ((name, pos) : rest) -> do-                        for_ rest $ \(name', pos') -> parseFailure pos' $ makeMsg name'-                        parseFatalFailure pos $ makeMsg name+            let makeMsg name = "The field " <> show name <> " is removed in the Cabal specification version " ++ showCabalSpecVersion vs ++ "." ++ msg' -              | otherwise = parser v values+            case namePos of+              -- no fields => proceed (with empty values, to be sure)+              [] -> parser v mempty+              -- if there's single field: fail fatally with it+              ((name, pos) : rest) -> do+                for_ rest $ \(name', pos') -> parseFailure pos' $ makeMsg name'+                parseFatalFailure pos $ makeMsg name+        | otherwise = parser v values -    knownField fn = ParsecFG (Set.singleton fn) Set.empty (\_ _ -> pure ())+  knownField fn = ParsecFG (Set.singleton fn) Set.empty (\_ _ -> pure ()) -    hiddenField = id+  hiddenField = id  ------------------------------------------------------------------------------- -- Parsec@@ -348,26 +351,32 @@  runFieldParser' :: [Position] -> ParsecParser a -> CabalSpecVersion -> FieldLineStream -> ParseResult a runFieldParser' inputPoss p v str = case P.runParser p' [] "<field>" str of-    Right (pok, ws) -> do-        traverse_ (\(PWarning t pos w) -> parseWarning (mapPosition pos) t w) ws-        pure pok-    Left err        -> do-        let ppos = P.errorPos err-        let epos = mapPosition $ Position (P.sourceLine ppos) (P.sourceColumn ppos)+  Right (pok, ws) -> do+    traverse_ (\(PWarning t pos w) -> parseWarning (mapPosition pos) t w) ws+    pure pok+  Left err -> do+    let ppos = P.errorPos err+    let epos = mapPosition $ Position (P.sourceLine ppos) (P.sourceColumn ppos) -        let msg = P.showErrorMessages-                "or" "unknown parse error" "expecting" "unexpected" "end of input"-                (P.errorMessages err)-        parseFatalFailure epos $ msg ++ "\n"+    let msg =+          P.showErrorMessages+            "or"+            "unknown parse error"+            "expecting"+            "unexpected"+            "end of input"+            (P.errorMessages err)+    parseFatalFailure epos $ msg ++ "\n"   where     p' = (,) <$ P.spaces <*> unPP p v <* P.spaces <* P.eof <*> P.getState      -- Positions start from 1:1, not 0:0-    mapPosition (Position prow pcol) = go (prow - 1) inputPoss where-        go _ []                            = zeroPos-        go _ [Position row col]            = Position row (col + pcol - 1)-        go n (Position row col:_) | n <= 0 = Position row (col + pcol - 1)-        go n (_:ps)                        = go (n - 1) ps+    mapPosition (Position prow pcol) = go (prow - 1) inputPoss+      where+        go _ [] = zeroPos+        go _ [Position row col] = Position row (col + pcol - 1)+        go n (Position row col : _) | n <= 0 = Position row (col + pcol - 1)+        go n (_ : ps) = go (n - 1) ps  runFieldParser :: Position -> ParsecParser a -> CabalSpecVersion -> [FieldLine Position] -> ParseResult a runFieldParser pp p v ls = runFieldParser' poss p v (fieldLinesToStream ls)@@ -381,54 +390,55 @@ -- http://hackage.haskell.org/package/copilot-cbmc-0.1/copilot-cbmc.cabal fieldlinesToFreeText :: [FieldLine ann] -> String fieldlinesToFreeText [FieldLine _ "."] = "."-fieldlinesToFreeText fls               = intercalate "\n" (map go fls)+fieldlinesToFreeText fls = intercalate "\n" (map go fls)   where     go (FieldLine _ bs)-        | s == "." = ""-        | otherwise = s+      | s == "." = ""+      | otherwise = s       where         s = trim (fromUTF8BS bs)  fieldlinesToFreeText3 :: Position -> [FieldLine Position] -> String-fieldlinesToFreeText3 _   []               = ""-fieldlinesToFreeText3 _   [FieldLine _ bs] = fromUTF8BS bs+fieldlinesToFreeText3 _ [] = ""+fieldlinesToFreeText3 _ [FieldLine _ bs] = fromUTF8BS bs fieldlinesToFreeText3 pos (FieldLine pos1 bs1 : fls2@(FieldLine pos2 _ : _))-    -- if first line is on the same line with field name:-    -- the indentation level is either-    -- 1. the indentation of left most line in rest fields-    -- 2. the indentation of the first line-    -- whichever is leftmost-    | positionRow pos == positionRow pos1 = concat-        $ fromUTF8BS bs1-        : mealy (mk mcol1) pos1 fls2--    -- otherwise, also indent the first line-    | otherwise = concat-        $ replicate (positionCol pos1 - mcol2) ' '-        : fromUTF8BS bs1-        : mealy (mk mcol2) pos1 fls2-+  -- if first line is on the same line with field name:+  -- the indentation level is either+  -- 1. the indentation of left most line in rest fields+  -- 2. the indentation of the first line+  -- whichever is leftmost+  | positionRow pos == positionRow pos1 =+      concat $+        fromUTF8BS bs1+          : mealy (mk mcol1) pos1 fls2+  -- otherwise, also indent the first line+  | otherwise =+      concat $+        replicate (positionCol pos1 - mcol2) ' '+          : fromUTF8BS bs1+          : mealy (mk mcol2) pos1 fls2   where     mcol1 = foldl' (\a b -> min a $ positionCol $ fieldLineAnn b) (min (positionCol pos1) (positionCol pos2)) fls2     mcol2 = foldl' (\a b -> min a $ positionCol $ fieldLineAnn b) (positionCol pos1) fls2      mk :: Int -> Position -> FieldLine Position -> (Position, String)     mk col p (FieldLine q bs) =-        ( q-        , replicate newlines '\n'+      ( q+      , replicate newlines '\n'           ++ replicate indent ' '           ++ fromUTF8BS bs-        )+      )       where         newlines = positionRow q - positionRow p-        indent   = positionCol q - col+        indent = positionCol q - col  mealy :: (s -> a -> (s, b)) -> s -> [a] -> [b]-mealy f = go where+mealy f = go+  where     go _ [] = []     go s (x : xs) = let ~(s', y) = f s x in y : go s' xs  fieldLinesToStream :: [FieldLine ann] -> FieldLineStream-fieldLinesToStream []                    = fieldLineStreamEnd-fieldLinesToStream [FieldLine _ bs]      = FLSLast bs+fieldLinesToStream [] = fieldLineStreamEnd+fieldLinesToStream [FieldLine _ bs] = FLSLast bs fieldLinesToStream (FieldLine _ bs : fs) = FLSCons bs (fieldLinesToStream fs)
src/Distribution/FieldGrammar/Pretty.hs view
@@ -1,32 +1,33 @@-{-# LANGUAGE DeriveFunctor         #-}+{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-}-module Distribution.FieldGrammar.Pretty (-    PrettyFieldGrammar,-    prettyFieldGrammar,-    ) where -import           Distribution.CabalSpecVersion-import           Distribution.Compat.Lens-import           Distribution.Compat.Newtype-import           Distribution.Compat.Prelude-import           Distribution.Fields.Field     (FieldName)-import           Distribution.Fields.Pretty    (PrettyField (..))-import           Distribution.Pretty           (Pretty (..), showFreeText, showFreeTextV3)-import           Distribution.Utils.Generic    (toUTF8BS)-import           Prelude ()-import           Text.PrettyPrint              (Doc)-import qualified Text.PrettyPrint              as PP+module Distribution.FieldGrammar.Pretty+  ( PrettyFieldGrammar+  , prettyFieldGrammar+  ) where +import Distribution.CabalSpecVersion+import Distribution.Compat.Lens+import Distribution.Compat.Newtype+import Distribution.Compat.Prelude+import Distribution.Fields.Field (FieldName)+import Distribution.Fields.Pretty (PrettyField (..))+import Distribution.Pretty (Pretty (..), showFreeText, showFreeTextV3)+import Distribution.Utils.Generic (toUTF8BS)+import Text.PrettyPrint (Doc)+import qualified Text.PrettyPrint as PP+import Prelude ()+ import Distribution.FieldGrammar.Class  newtype PrettyFieldGrammar s a = PrettyFG-    { fieldGrammarPretty :: CabalSpecVersion -> s -> [PrettyField ()]-    }+  { fieldGrammarPretty :: CabalSpecVersion -> s -> [PrettyField ()]+  }   deriving (Functor)  instance Applicative (PrettyFieldGrammar s) where-    pure _ = PrettyFG (\_ _ -> mempty)-    PrettyFG f <*> PrettyFG x = PrettyFG (\v s -> f v s <> x v s)+  pure _ = PrettyFG (\_ _ -> mempty)+  PrettyFG f <*> PrettyFG x = PrettyFG (\v s -> f v s <> x v s)  -- | We can use 'PrettyFieldGrammar' to pp print the @s@. --@@ -35,70 +36,77 @@ prettyFieldGrammar = flip fieldGrammarPretty  instance FieldGrammar Pretty PrettyFieldGrammar where-    blurFieldGrammar f (PrettyFG pp) = PrettyFG (\v -> pp v . aview f)+  blurFieldGrammar f (PrettyFG pp) = PrettyFG (\v -> pp v . aview f) -    uniqueFieldAla fn _pack l = PrettyFG $ \_v s ->-        ppField fn (pretty (pack' _pack (aview l s)))+  uniqueFieldAla fn _pack l = PrettyFG $ \_v s ->+    ppField fn (pretty (pack' _pack (aview l s))) -    booleanFieldDef fn l def = PrettyFG pp-      where-        pp _v s-            | b == def  = mempty-            | otherwise = ppField fn (PP.text (show b))-          where-            b = aview l s+  booleanFieldDef fn l def = PrettyFG pp+    where+      pp _v s+        | b == def = mempty+        | otherwise = ppField fn (PP.text (show b))+        where+          b = aview l s -    optionalFieldAla fn _pack l = PrettyFG pp-      where-        pp v s = case aview l s of-            Nothing -> mempty-            Just a  -> ppField fn (prettyVersioned v (pack' _pack a))+  optionalFieldAla fn _pack l = PrettyFG pp+    where+      pp v s = case aview l s of+        Nothing -> mempty+        Just a -> ppField fn (prettyVersioned v (pack' _pack a)) -    optionalFieldDefAla fn _pack l def = PrettyFG pp-      where-        pp v s-            | x == def  = mempty-            | otherwise = ppField fn (prettyVersioned v (pack' _pack x))-          where-            x = aview l s+  optionalFieldDefAla fn _pack l def = PrettyFG pp+    where+      pp v s+        | x == def = mempty+        | otherwise = ppField fn (prettyVersioned v (pack' _pack x))+        where+          x = aview l s -    freeTextField fn l = PrettyFG pp where-        pp v s = maybe mempty (ppField fn . showFT) (aview l s) where-            showFT | v >= CabalSpecV3_0 = showFreeTextV3-                   | otherwise          = showFreeText+  freeTextField fn l = PrettyFG pp+    where+      pp v s = maybe mempty (ppField fn . showFT) (aview l s)+        where+          showFT+            | v >= CabalSpecV3_0 = showFreeTextV3+            | otherwise = showFreeText -    -- it's ok to just show, as showFreeText of empty string is empty.-    freeTextFieldDef fn l = PrettyFG pp where-        pp v s = ppField fn (showFT (aview l s)) where-            showFT | v >= CabalSpecV3_0 = showFreeTextV3-                   | otherwise          = showFreeText+  -- it's ok to just show, as showFreeText of empty string is empty.+  freeTextFieldDef fn l = PrettyFG pp+    where+      pp v s = ppField fn (showFT (aview l s))+        where+          showFT+            | v >= CabalSpecV3_0 = showFreeTextV3+            | otherwise = showFreeText -    freeTextFieldDefST = defaultFreeTextFieldDefST+  freeTextFieldDefST = defaultFreeTextFieldDefST -    monoidalFieldAla fn _pack l = PrettyFG pp-      where-        pp v s = ppField fn (prettyVersioned v (pack' _pack (aview l s)))+  monoidalFieldAla fn _pack l = PrettyFG pp+    where+      pp v s = ppField fn (prettyVersioned v (pack' _pack (aview l s))) -    prefixedFields _fnPfx l = PrettyFG (\_ -> pp . aview l)-      where-        pp xs =-            -- always print the field, even its Doc is empty.-            -- i.e. don't use ppField-            [ PrettyField () (toUTF8BS n) $ PP.vcat $ map PP.text $ lines s-            | (n, s) <- xs-            -- fnPfx `isPrefixOf` n-            ]+  prefixedFields _fnPfx l = PrettyFG (\_ -> pp . aview l)+    where+      pp xs =+        -- always print the field, even its Doc is empty.+        -- i.e. don't use ppField+        [ PrettyField () (toUTF8BS n) $ PP.vcat $ map PP.text $ lines s+        | (n, s) <- xs+        -- fnPfx `isPrefixOf` n+        ] -    knownField _           = pure ()-    deprecatedSince _ _ x  = x-    -- TODO: as PrettyFieldGrammar isn't aware of cabal-version: we output the field-    -- this doesn't affect roundtrip as `removedIn` fields cannot be parsed-    -- so invalid documents can be only manually constructed.-    removedIn _ _ x        = x-    availableSince _ _     = id-    hiddenField _          = PrettyFG (\_ -> mempty)+  knownField _ = pure ()+  deprecatedSince _ _ x = x +  -- TODO: as PrettyFieldGrammar isn't aware of cabal-version: we output the field+  -- this doesn't affect roundtrip as `removedIn` fields cannot be parsed+  -- so invalid documents can be only manually constructed.+  removedIn _ _ x = x+  availableSince _ _ = id+  hiddenField _ = PrettyFG (\_ -> mempty)+ ppField :: FieldName -> Doc -> [PrettyField ()] ppField name fielddoc-    | PP.isEmpty fielddoc = []-    | otherwise        = [ PrettyField () name fielddoc ]+  | PP.isEmpty fielddoc = []+  | otherwise = [PrettyField () name fielddoc]
src/Distribution/Fields.hs view
@@ -1,42 +1,49 @@ -- | Utilities to work with @.cabal@ like file structure.-module Distribution.Fields (-    -- * Types-    Field(..),-    Name(..),-    FieldLine(..),-    SectionArg(..),-    FieldName,+module Distribution.Fields+  ( -- * Types+    Field (..)+  , Name (..)+  , FieldLine (..)+  , SectionArg (..)+  , FieldName+     -- * Grammar and parsing-    ---    -- See "Distribution.Fields.Parser" for grammar.-    readFields,-    readFields',++  --+  -- See "Distribution.Fields.Parser" for grammar.+  , readFields+  , readFields'+     -- ** ParseResult-    ParseResult,-    runParseResult,-    parseWarning,-    parseWarnings,-    parseFailure,-    parseFatalFailure,+  , ParseResult+  , runParseResult+  , parseWarning+  , parseWarnings+  , parseFailure+  , parseFatalFailure+     -- ** Warnings-    PWarnType (..),-    PWarning (..),-    showPWarning,+  , PWarnType (..)+  , PWarning (..)+  , showPWarning+     -- ** Errors-    PError (..),-    showPError,+  , PError (..)+  , showPError+     -- * Pretty printing-    CommentPosition (..),-    PrettyField (..),-    showFields,+  , CommentPosition (..)+  , PrettyField (..)+  , showFields+     -- ** Transformation from Field-    genericFromParsecFields,-    fromParsecFields,-    ) where+  , genericFromParsecFields+  , fromParsecFields+  ) where  import Distribution.Fields.Field-import Distribution.Fields.Parser import Distribution.Fields.ParseResult+import Distribution.Fields.Parser import Distribution.Fields.Pretty import Distribution.Parsec.Error import Distribution.Parsec.Warning
src/Distribution/Fields/ConfVar.hs view
@@ -1,47 +1,64 @@ {-# LANGUAGE OverloadedStrings #-}+ module Distribution.Fields.ConfVar (parseConditionConfVar, parseConditionConfVarFromClause) where -import Distribution.Compat.CharParsing     (char, integral)+import Distribution.Compat.CharParsing (char, integral) import Distribution.Compat.Prelude-import Distribution.Fields.Field           (SectionArg (..), Field(..))+import Distribution.Fields.Field (Field (..), SectionArg (..)) import Distribution.Fields.ParseResult-import Distribution.Parsec                 (Parsec (..), Position (..), runParsecParser)+import Distribution.Fields.Parser (readFields)+import Distribution.Parsec (Parsec (..), Position (..), runParsecParser) import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS) import Distribution.Types.Condition-import Distribution.Types.ConfVar          (ConfVar (..))-import Distribution.Fields.Parser          (readFields)+import Distribution.Types.ConfVar (ConfVar (..)) import Distribution.Version-       (anyVersion, earlierVersion, intersectVersionRanges, laterVersion, majorBoundVersion,-       mkVersion, noVersion, orEarlierVersion, orLaterVersion, thisVersion, unionVersionRanges,-       withinVersion)+  ( anyVersion+  , earlierVersion+  , intersectVersionRanges+  , laterVersion+  , majorBoundVersion+  , mkVersion+  , noVersion+  , orEarlierVersion+  , orLaterVersion+  , thisVersion+  , unionVersionRanges+  , withinVersion+  ) import Prelude () -import qualified Text.Parsec       as P-import qualified Text.Parsec.Pos   as P+import qualified Data.ByteString.Char8 as B8+import qualified Text.Parsec as P import qualified Text.Parsec.Error as P-import qualified Data.ByteString.Char8          as B8+import qualified Text.Parsec.Pos as P  parseConditionConfVarFromClause :: B8.ByteString -> Either P.ParseError (Condition ConfVar)-parseConditionConfVarFromClause x = readFields x >>= \r -> case r of-                                       (Section _ xs _ : _ ) -> P.runParser (parser <* P.eof) () "<condition>" xs-                                       _ -> Left $ P.newErrorMessage (P.Message "No fields in clause") (P.initialPos "<condition>")+parseConditionConfVarFromClause x =+  readFields x >>= \r -> case r of+    (Section _ xs _ : _) -> P.runParser (parser <* P.eof) () "<condition>" xs+    _ -> Left $ P.newErrorMessage (P.Message "No fields in clause") (P.initialPos "<condition>")  -- | Parse @'Condition' 'ConfVar'@ from section arguments provided by parsec -- based outline parser. parseConditionConfVar :: [SectionArg Position] -> ParseResult (Condition ConfVar) parseConditionConfVar args =-    -- The name of the input file is irrelevant, as we reformat the error message.-    case P.runParser (parser <* P.eof) () "<condition>" args of-        Right x  -> pure x-        Left err -> do-            -- Mangle the position to the actual one-            let ppos = P.errorPos err-            let epos = Position (P.sourceLine ppos) (P.sourceColumn ppos)-            let msg = P.showErrorMessages-                    "or" "unknown parse error" "expecting" "unexpected" "end of input"-                    (P.errorMessages err)-            parseFailure epos msg-            pure $ Lit True+  -- The name of the input file is irrelevant, as we reformat the error message.+  case P.runParser (parser <* P.eof) () "<condition>" args of+    Right x -> pure x+    Left err -> do+      -- Mangle the position to the actual one+      let ppos = P.errorPos err+      let epos = Position (P.sourceLine ppos) (P.sourceColumn ppos)+      let msg =+            P.showErrorMessages+              "or"+              "unknown parse error"+              "expecting"+              "unexpected"+              "end of input"+              (P.errorMessages err)+      parseFailure epos msg+      pure $ Lit True  type Parser = P.Parsec [SectionArg Position] () @@ -51,72 +68,77 @@ parser :: Parser (Condition ConfVar) parser = condOr   where-    condOr       = sepByNonEmpty condAnd (oper "||") >>= return . foldl1 COr-    condAnd      = sepByNonEmpty cond    (oper "&&") >>= return . foldl1 CAnd-    cond         = P.choice-         [ boolLiteral, parens condOr,  notCond, osCond, archCond, flagCond, implCond ]+    condOr = sepByNonEmpty condAnd (oper "||") >>= return . foldl1 COr+    condAnd = sepByNonEmpty cond (oper "&&") >>= return . foldl1 CAnd+    cond =+      P.choice+        [boolLiteral, parens condOr, notCond, osCond, archCond, flagCond, implCond] -    notCond      = CNot <$ oper "!" <*> cond+    notCond = CNot <$ oper "!" <*> cond -    boolLiteral  = Lit <$> boolLiteral'-    osCond       = Var . OS   <$ string "os"   <*> parens fromParsec-    flagCond     = Var . PackageFlag <$ string "flag" <*> parens fromParsec-    archCond     = Var . Arch <$ string "arch" <*> parens fromParsec-    implCond     = Var        <$ string "impl" <*> parens implCond'+    boolLiteral = Lit <$> boolLiteral'+    osCond = Var . OS <$ string "os" <*> parens fromParsec+    flagCond = Var . PackageFlag <$ string "flag" <*> parens fromParsec+    archCond = Var . Arch <$ string "arch" <*> parens fromParsec+    implCond = Var <$ string "impl" <*> parens implCond' -    implCond'    = Impl+    implCond' =+      Impl         <$> fromParsec         <*> P.option anyVersion versionRange      version = fromParsec-    versionStar  = mkVersion <$> fromParsec' versionStar' <* oper "*"+    versionStar = mkVersion <$> fromParsec' versionStar' <* oper "*"     versionStar' = some (integral <* char '.')      versionRange = expr       where-        expr = foldl1 unionVersionRanges     <$> sepByNonEmpty term   (oper "||")+        expr = foldl1 unionVersionRanges <$> sepByNonEmpty term (oper "||")         term = foldl1 intersectVersionRanges <$> sepByNonEmpty factor (oper "&&") -        factor = P.choice-            $ parens expr-            : parseAnyVersion-            : parseNoVersion-            : parseWildcardRange-            : map parseRangeOp rangeOps+        factor =+          P.choice $+            parens expr+              : parseAnyVersion+              : parseNoVersion+              : parseWildcardRange+              : map parseRangeOp rangeOps -        parseAnyVersion    = anyVersion <$ string "-any"-        parseNoVersion     = noVersion  <$ string "-none"+        parseAnyVersion = anyVersion <$ string "-any"+        parseNoVersion = noVersion <$ string "-none"          parseWildcardRange = P.try $ withinVersion <$ oper "==" <*> versionStar -        parseRangeOp (s,f) = P.try (f <$ oper s <*> version)-        rangeOps = [ ("<",  earlierVersion),-                     ("<=", orEarlierVersion),-                     (">",  laterVersion),-                     (">=", orLaterVersion),-                     ("^>=", majorBoundVersion),-                     ("==", thisVersion) ]+        parseRangeOp (s, f) = P.try (f <$ oper s <*> version)+        rangeOps =+          [ ("<", earlierVersion)+          , ("<=", orEarlierVersion)+          , (">", laterVersion)+          , (">=", orLaterVersion)+          , ("^>=", majorBoundVersion)+          , ("==", thisVersion)+          ]      -- Number token can have many dots in it: SecArgNum (Position 65 15) "7.6.1"     identBS = tokenPrim $ \t -> case t of-        SecArgName _ s -> Just s-        _              -> Nothing+      SecArgName _ s -> Just s+      _ -> Nothing      boolLiteral' = tokenPrim $ \t -> case t of-        SecArgName _ s-            | s == "True"  -> Just True-            | s == "true"  -> Just True-            | s == "False" -> Just False-            | s == "false" -> Just False-        _                  -> Nothing+      SecArgName _ s+        | s == "True" -> Just True+        | s == "true" -> Just True+        | s == "False" -> Just False+        | s == "false" -> Just False+      _ -> Nothing      string s = tokenPrim $ \t -> case t of-        SecArgName _ s' | s == s' -> Just ()-        _                         -> Nothing+      SecArgName _ s' | s == s' -> Just ()+      _ -> Nothing      oper o = tokenPrim $ \t -> case t of-        SecArgOther _ o' | o == o' -> Just ()-        _                          -> Nothing+      SecArgOther _ o' | o == o' -> Just ()+      _ -> Nothing      parens = P.between (oper "(") (oper ")") @@ -129,6 +151,6 @@     fromParsec = fromParsec' parsec      fromParsec' p = do-        bs <- identBS-        let fls = fieldLineStreamFromBS bs-        either (fail . show) pure (runParsecParser p "<fromParsec'>" fls)+      bs <- identBS+      let fls = fieldLineStreamFromBS bs+      either (fail . show) pure (runParsecParser p "<fromParsec'>" fls)
src/Distribution/Fields/Field.hs view
@@ -1,39 +1,44 @@-{-# LANGUAGE DeriveFoldable    #-}-{-# LANGUAGE DeriveFunctor     #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE StandaloneDeriving #-}+ -- | Cabal-like file AST types: 'Field', 'Section' etc ----- These types are parametrized by an annotation.-module Distribution.Fields.Field (-    -- * Cabal file-    Field (..),-    fieldName,-    fieldAnn,-    fieldUniverse,-    FieldLine (..),-    fieldLineAnn,-    fieldLineBS,-    SectionArg (..),-    sectionArgAnn,+-- These types are parameterized by an annotation.+module Distribution.Fields.Field+  ( -- * Cabal file+    Field (..)+  , fieldName+  , fieldAnn+  , fieldUniverse+  , FieldLine (..)+  , fieldLineAnn+  , fieldLineBS+  , SectionArg (..)+  , sectionArgAnn+     -- * Name-    FieldName,-    Name (..),-    mkName,-    getName,-    nameAnn,-    -- * Conversions to String-    sectionArgsToString,-    fieldLinesToString,-    ) where+  , FieldName+  , Name (..)+  , mkName+  , getName+  , nameAnn -import           Data.ByteString             (ByteString)-import qualified Data.ByteString.Char8       as B-import qualified Data.Char                   as Char-import           Distribution.Compat.Prelude-import           Distribution.Pretty         (showTokenStr)-import           Distribution.Utils.Generic  (fromUTF8BS)-import           Prelude ()+    -- * Conversions to String+  , sectionArgsToString+  , fieldLinesToString+  ) where +import Data.ByteString (ByteString)+import qualified Data.ByteString.Char8 as B+import qualified Data.Char as Char+import Distribution.Compat.Prelude+import Distribution.Pretty (showTokenStr)+import Distribution.Utils.Generic (fromUTF8BS)+import Prelude ()+#if MIN_VERSION_base(4,18,0)+import qualified Data.Foldable1 as F1+#endif  ------------------------------------------------------------------------------- -- Cabal file@@ -41,13 +46,16 @@  -- | A Cabal-like file consists of a series of fields (@foo: bar@) and sections (@library ...@). data Field ann-    = Field   !(Name ann) [FieldLine ann]-    | Section !(Name ann) [SectionArg ann] [Field ann]+  = Field !(Name ann) [FieldLine ann]+  | Section !(Name ann) [SectionArg ann] [Field ann]   deriving (Eq, Show, Functor, Foldable, Traversable) +-- | @since 3.12.0.0+deriving instance Ord ann => Ord (Field ann)+ -- | Section of field name fieldName :: Field ann -> Name ann-fieldName (Field n _ )    = n+fieldName (Field n _) = n fieldName (Section n _ _) = n  fieldAnn :: Field ann -> ann@@ -56,18 +64,20 @@ -- | All transitive descendants of 'Field', including itself. -- -- /Note:/ the resulting list is never empty.--- fieldUniverse :: Field ann -> [Field ann] fieldUniverse f@(Section _ _ fs) = f : concatMap fieldUniverse fs-fieldUniverse f@(Field _ _)      = [f]+fieldUniverse f@(Field _ _) = [f]  -- | A line of text representing the value of a field from a Cabal file. -- A field may contain multiple lines. -- -- /Invariant:/ 'ByteString' has no newlines.-data FieldLine ann  = FieldLine  !ann !ByteString+data FieldLine ann = FieldLine !ann !ByteString   deriving (Eq, Show, Functor, Foldable, Traversable) +-- | @since 3.12.0.0+deriving instance Ord ann => Ord (FieldLine ann)+ -- | @since 3.0.0.0 fieldLineAnn :: FieldLine ann -> ann fieldLineAnn (FieldLine ann _) = ann@@ -78,18 +88,21 @@  -- | Section arguments, e.g. name of the library data SectionArg ann-    = SecArgName  !ann !ByteString-      -- ^ identifier, or something which looks like number. Also many dot numbers, i.e. "7.6.3"-    | SecArgStr   !ann !ByteString-      -- ^ quoted string-    | SecArgOther !ann !ByteString-      -- ^ everything else, mm. operators (e.g. in if-section conditionals)+  = -- | identifier, or something which looks like number. Also many dot numbers, i.e. "7.6.3"+    SecArgName !ann !ByteString+  | -- | quoted string+    SecArgStr !ann !ByteString+  | -- | everything else, mm. operators (e.g. in if-section conditionals)+    SecArgOther !ann !ByteString   deriving (Eq, Show, Functor, Foldable, Traversable) +-- | @since 3.12.0.0+deriving instance Ord ann => Ord (SectionArg ann)+ -- | Extract annotation from 'SectionArg'. sectionArgAnn :: SectionArg ann -> ann-sectionArgAnn (SecArgName ann _)  = ann-sectionArgAnn (SecArgStr ann _)   = ann+sectionArgAnn (SecArgName ann _) = ann+sectionArgAnn (SecArgStr ann _) = ann sectionArgAnn (SecArgOther ann _) = ann  -------------------------------------------------------------------------------@@ -101,9 +114,12 @@ -- | A field name. -- -- /Invariant/: 'ByteString' is lower-case ASCII.-data Name ann  = Name       !ann !FieldName+data Name ann = Name !ann !FieldName   deriving (Eq, Show, Functor, Foldable, Traversable) +-- | @since 3.12.0.0+deriving instance Ord ann => Ord (Name ann)+ mkName :: ann -> FieldName -> Name ann mkName ann bs = Name ann (B.map Char.toLower bs) @@ -121,10 +137,11 @@ -- -- @since 3.6.0.0 sectionArgsToString :: [SectionArg ann] -> String-sectionArgsToString = unwords . map toStr where+sectionArgsToString = unwords . map toStr+  where     toStr :: SectionArg ann -> String-    toStr (SecArgName _ bs)  = showTokenStr (fromUTF8BS bs)-    toStr (SecArgStr _ bs)   = showTokenStr (fromUTF8BS bs)+    toStr (SecArgName _ bs) = showTokenStr (fromUTF8BS bs)+    toStr (SecArgStr _ bs) = showTokenStr (fromUTF8BS bs)     toStr (SecArgOther _ bs) = fromUTF8BS bs  -- | Convert @['FieldLine']@ into String.@@ -135,7 +152,34 @@ -- @since 3.6.0.0 fieldLinesToString :: [FieldLine ann] -> String fieldLinesToString =-    -- intercalate to avoid trailing newline.-    intercalate "\n" . map toStr+  -- intercalate to avoid trailing newline.+  intercalate "\n" . map toStr   where     toStr (FieldLine _ bs) = fromUTF8BS bs++-------------------------------------------------------------------------------+-- Foldable1+-------------------------------------------------------------------------------++#if MIN_VERSION_base(4,18,0)++-- | @since 3.12.0.0+instance F1.Foldable1 Field where+  foldMap1 f (Field x ys) =+    F1.fold1 (F1.foldMap1 f x :| map (F1.foldMap1 f) ys)+  foldMap1 f (Section x ys zs) =+    F1.fold1 (F1.foldMap1 f x :| map (F1.foldMap1 f) ys ++ map (F1.foldMap1 f) zs)++-- | @since 3.12.0.0+instance F1.Foldable1 FieldLine where+  foldMap1 = (. fieldLineAnn)++-- | @since 3.12.0.0+instance F1.Foldable1 SectionArg where+  foldMap1 = (. sectionArgAnn)++-- | @since 3.12.0.0+instance F1.Foldable1 Name where+  foldMap1 = (. nameAnn)++#endif
− src/Distribution/Fields/Lexer.hs
@@ -1,589 +0,0 @@-{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-missing-signatures #-}-{-# LANGUAGE CPP #-}-{-# LANGUAGE MagicHash #-}-{-# LINE 1 "templates/Lexer.x" #-}--------------------------------------------------------------------------------- |--- Module      :  Distribution.Fields.Lexer--- License     :  BSD3------ Maintainer  :  cabal-devel@haskell.org--- Portability :  portable------ Lexer for the cabal files.-{-# LANGUAGE CPP #-}-{-# LANGUAGE BangPatterns #-}-#ifdef CABAL_PARSEC_DEBUG-{-# LANGUAGE PatternGuards #-}-#endif-{-# OPTIONS_GHC -fno-warn-unused-imports #-}-module Distribution.Fields.Lexer-  (ltest, lexToken, Token(..), LToken(..)-  ,bol_section, in_section, in_field_layout, in_field_braces-  ,mkLexState) where---- [Note: bootstrapping parsec parser]------ We manually produce the `Lexer.hs` file from `boot/Lexer.x` (make lexer)--- because bootstrapping cabal-install would be otherwise tricky.--- Alex is (atm) tricky package to build, cabal-install has some magic--- to move bundled generated files in place, so rather we don't depend--- on it before we can build it ourselves.--- Therefore there is one thing less to worry in bootstrap.sh, which is a win.------ See also https://github.com/haskell/cabal/issues/4633-----import Prelude ()-import qualified Prelude as Prelude-import Distribution.Compat.Prelude--import Distribution.Fields.LexerMonad-import Distribution.Parsec.Position (Position (..), incPos, retPos)-import Data.ByteString (ByteString)-import qualified Data.ByteString as B-import qualified Data.ByteString.Char8 as B.Char8-import qualified Data.Word as Word--#ifdef CABAL_PARSEC_DEBUG-import Debug.Trace-import qualified Data.Vector as V-import qualified Data.Text   as T-import qualified Data.Text.Encoding as T-import qualified Data.Text.Encoding.Error as T-#endif-#if __GLASGOW_HASKELL__ >= 603-#include "ghcconfig.h"-#elif defined(__GLASGOW_HASKELL__)-#include "config.h"-#endif-#if __GLASGOW_HASKELL__ >= 503-import Data.Array-#else-import Array-#endif-#if __GLASGOW_HASKELL__ >= 503-import Data.Array.Base (unsafeAt)-import GHC.Exts-#else-import GlaExts-#endif-alex_tab_size :: Int-alex_tab_size = 8-alex_base :: AlexAddr-alex_base = AlexA#-  "\x12\xff\xff\xff\xf9\xff\xff\xff\xfb\xff\xff\xff\x01\x00\x00\x00\x2f\x00\x00\x00\x50\x00\x00\x00\xd0\x00\x00\x00\x50\x01\x00\x00\xd0\x01\x00\x00\x50\x02\x00\x00\x81\x00\x00\x00\xfe\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x69\xff\xff\xff\x03\x00\x00\x00\x09\x00\x00\x00\xf8\x00\x00\x00\xe2\xff\xff\xff\xd0\x02\x00\x00\x71\xff\xff\xff\x0b\x00\x00\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x5f\xff\xff\xff\x5d\xff\xff\xff\x00\x00\x00\x00\xf0\x02\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x03\x00\x00\x6a\x00\x00\x00\x00\x00\x00\x00\x15\x00\x00\x00\x66\x03\x00\x00\x98\x00\x00\x00\x80\xff\xff\xff\x00\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x70\x03\x00\x00\x00\x00\x00\x00\xef\x03\x00\x00\x13\x04\x00\x00"#--alex_table :: AlexAddr-alex_table = AlexA#-  "\x00\x00\x18\x00\x11\x00\x17\x00\x02\x00\x17\x00\x16\x00\x0b\x00\x16\x00\x0f\x00\x03\x00\x17\x00\x0f\x00\x17\x00\x16\x00\x13\x00\x16\x00\x15\x00\x10\x00\x17\x00\x15\x00\x17\x00\x16\x00\x17\x00\x16\x00\x11\x00\x19\x00\x02\x00\x1a\x00\x1c\x00\x0b\x00\x22\x00\x10\x00\x03\x00\x27\x00\x0f\x00\x00\x00\x00\x00\x12\x00\x00\x00\x12\x00\x10\x00\x00\x00\x15\x00\x00\x00\x00\x00\x12\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x21\x00\x1c\x00\xff\xff\xff\xff\x1d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x21\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x22\x00\xff\xff\xff\xff\x23\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x00\x00\x00\x00\x21\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00\x0c\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x21\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x25\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x1e\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x25\x00\x00\x00\x00\x00\x14\x00\x00\x00\x26\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x26\x00\x00\x00\x14\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x00\x27\x00\xff\xff\xff\xff\x28\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x00\x2d\x00\x1b\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x2c\x00\x2c\x00\x2d\x00\x2d\x00\x2d\x00\x08\x00\x09\x00\x2d\x00\xff\xff\x11\x00\x17\x00\x00\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2b\x00\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2c\x00\x2d\x00\x2c\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2a\x00\x2d\x00\x29\x00\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\xff\xff\xff\xff\x2d\x00\x2d\x00\x2d\x00\x0a\x00\x09\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\xff\xff\xff\xff\x2d\x00\x2d\x00\x2d\x00\x09\x00\x09\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x2e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x30\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\xff\x2d\x00\xff\xff\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x00\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x2d\x00\x00\x00\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x2e\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"#--alex_check :: AlexAddr-alex_check = AlexA#-  "\xff\xff\xef\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x09\x00\x0d\x00\xa0\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x2d\x00\x0d\x00\xa0\x00\x09\x00\x0a\x00\x09\x00\x0a\x00\x0d\x00\x0a\x00\x0d\x00\x20\x00\xbb\x00\x20\x00\xbf\x00\x0a\x00\x20\x00\x0a\x00\xa0\x00\x20\x00\x0a\x00\x20\x00\xff\xff\xff\xff\x2d\x00\xff\xff\x2d\x00\x20\x00\xff\xff\x20\x00\xff\xff\xff\xff\x2d\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\xff\xff\xff\xff\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x20\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x09\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xc2\x00\xff\xff\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\x7f\x00\x09\x00\x0a\x00\xff\xff\xff\xff\x0d\x00\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x2d\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\xff\xff\xff\xff\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xc2\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x20\x00\x21\x00\x22\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\x28\x00\x29\x00\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3a\x00\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5b\x00\x5c\x00\x5d\x00\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\x7c\x00\x7d\x00\x7e\x00\x7f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\xff\xff\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x7f\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7b\x00\xff\xff\x7d\x00\x21\x00\x7f\x00\x23\x00\x24\x00\x25\x00\x26\x00\xff\xff\xff\xff\xff\xff\x2a\x00\x2b\x00\x2c\x00\x2d\x00\x2e\x00\x2f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x3c\x00\x3d\x00\x3e\x00\x3f\x00\x40\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\x5e\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7c\x00\xff\xff\x7e\x00\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\x00\x00\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x00\x0a\x00\x0b\x00\x0c\x00\x0d\x00\x0e\x00\x0f\x00\x10\x00\x11\x00\x12\x00\x13\x00\x14\x00\x15\x00\x16\x00\x17\x00\x18\x00\x19\x00\x1a\x00\x1b\x00\x1c\x00\x1d\x00\x1e\x00\x1f\x00\xff\xff\xff\xff\x22\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x5c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\x5c\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"#--alex_deflt :: AlexAddr-alex_deflt = AlexA#-  "\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\x24\x00\x07\x00\x07\x00\x07\x00\x07\x00\x0a\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x13\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1b\x00\xff\xff\xff\xff\xff\xff\xff\xff\x20\x00\xff\xff\xff\xff\xff\xff\x24\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1b\x00\x1b\x00"#--alex_accept = listArray (0 :: Int, 48)-  [ AlexAcc 30-  , AlexAcc 29-  , AlexAcc 28-  , AlexAcc 27-  , AlexAccNone-  , AlexAccNone-  , AlexAccNone-  , AlexAcc 26-  , AlexAcc 25-  , AlexAcc 24-  , AlexAccSkip-  , AlexAccSkip-  , AlexAcc 23-  , AlexAcc 22-  , AlexAccNone-  , AlexAcc 21-  , AlexAcc 20-  , AlexAccNone-  , AlexAccNone-  , AlexAccSkip-  , AlexAccNone-  , AlexAccNone-  , AlexAcc 19-  , AlexAcc 18-  , AlexAccNone-  , AlexAccNone-  , AlexAcc 17-  , AlexAccNone-  , AlexAcc 16-  , AlexAcc 15-  , AlexAcc 14-  , AlexAcc 13-  , AlexAcc 12-  , AlexAccSkip-  , AlexAcc 11-  , AlexAcc 10-  , AlexAcc 9-  , AlexAccSkip-  , AlexAccNone-  , AlexAcc 8-  , AlexAcc 7-  , AlexAcc 6-  , AlexAcc 5-  , AlexAcc 4-  , AlexAcc 3-  , AlexAcc 2-  , AlexAcc 1-  , AlexAcc 0-  , AlexAccNone-  ]--alex_actions = array (0 :: Int, 31)-  [ (30,alex_action_0)-  , (29,alex_action_20)-  , (28,alex_action_16)-  , (27,alex_action_3)-  , (26,alex_action_8)-  , (25,alex_action_8)-  , (24,alex_action_8)-  , (23,alex_action_5)-  , (22,alex_action_4)-  , (21,alex_action_3)-  , (20,alex_action_16)-  , (19,alex_action_1)-  , (18,alex_action_1)-  , (17,alex_action_0)-  , (16,alex_action_25)-  , (15,alex_action_25)-  , (14,alex_action_24)-  , (13,alex_action_23)-  , (12,alex_action_22)-  , (11,alex_action_19)-  , (10,alex_action_19)-  , (9,alex_action_18)-  , (8,alex_action_15)-  , (7,alex_action_15)-  , (6,alex_action_14)-  , (5,alex_action_13)-  , (4,alex_action_12)-  , (3,alex_action_11)-  , (2,alex_action_10)-  , (1,alex_action_9)-  , (0,alex_action_9)-  ]--{-# LINE 151 "templates/Lexer.x" #-}--- | Tokens of outer cabal file structure. Field values are treated opaquely.-data Token = TokSym   !ByteString       -- ^ Haskell-like identifier, number or operator-           | TokStr   !ByteString       -- ^ String in quotes-           | TokOther !ByteString       -- ^ Operators and parens-           | Indent   !Int              -- ^ Indentation token-           | TokFieldLine !ByteString   -- ^ Lines after @:@-           | Colon-           | OpenBrace-           | CloseBrace-           | EOF-           | LexicalError InputStream --TODO: add separate string lexical error-  deriving Show--data LToken = L !Position !Token-  deriving Show--toki :: (ByteString -> Token) -> Position -> Int -> ByteString -> Lex LToken-toki t pos  len  input = return $! L pos (t (B.take len input))--tok :: Token -> Position -> Int -> ByteString -> Lex LToken-tok  t pos _len _input = return $! L pos t--checkLeadingWhitespace :: Position -> Int -> ByteString -> Lex Int-checkLeadingWhitespace pos len bs-    | B.any (== 9) (B.take len bs) = do-        addWarningAt pos LexWarningTab-        checkWhitespace pos len bs-    | otherwise = checkWhitespace pos len bs--checkWhitespace :: Position -> Int -> ByteString -> Lex Int-checkWhitespace pos len bs-    | B.any (== 194) (B.take len bs) = do-        addWarningAt pos LexWarningNBSP-        return $ len - B.count 194 (B.take len bs)-    | otherwise = return len---- -------------------------------------------------------------------------------- The input type--type AlexInput = InputStream--alexInputPrevChar :: AlexInput -> Char-alexInputPrevChar _ = error "alexInputPrevChar not used"--alexGetByte :: AlexInput -> Maybe (Word.Word8,AlexInput)-alexGetByte = B.uncons--lexicalError :: Position -> InputStream -> Lex LToken-lexicalError pos inp = do-  setInput B.empty-  return $! L pos (LexicalError inp)--lexToken :: Lex LToken-lexToken = do-  pos <- getPos-  inp <- getInput-  st  <- getStartCode-  case alexScan inp st of-    AlexEOF -> return (L pos EOF)-    AlexError inp' ->-        let !len_bytes = B.length inp - B.length inp' in-            --FIXME: we want len_chars here really-            -- need to decode utf8 up to this point-        lexicalError (incPos len_bytes pos) inp'-    AlexSkip  inp' len_chars -> do-        checkPosition pos inp inp' len_chars-        adjustPos (incPos len_chars)-        setInput inp'-        lexToken-    AlexToken inp' len_chars action -> do-        checkPosition pos inp inp' len_chars-        adjustPos (incPos len_chars)-        setInput inp'-        let !len_bytes = B.length inp - B.length inp'-        t <- action pos len_bytes inp-        --traceShow t $ return tok-        return t--checkPosition :: Position -> ByteString -> ByteString -> Int -> Lex ()-#ifdef CABAL_PARSEC_DEBUG-checkPosition pos@(Position lineno colno) inp inp' len_chars = do-    text_lines <- getDbgText-    let len_bytes = B.length inp - B.length inp'-        pos_txt   | lineno-1 < V.length text_lines = T.take len_chars (T.drop (colno-1) (text_lines V.! (lineno-1)))-                  | otherwise = T.empty-        real_txt  = B.take len_bytes inp-    when (pos_txt /= T.decodeUtf8 real_txt) $-      traceShow (pos, pos_txt, T.decodeUtf8 real_txt) $-      traceShow (take 3 (V.toList text_lines)) $ return ()-  where-    getDbgText = Lex $ \s@LexState{ dbgText = txt } -> LexResult s txt-#else-checkPosition _ _ _ _ = return ()-#endif--lexAll :: Lex [LToken]-lexAll = do-  t <- lexToken-  case t of-    L _ EOF -> return [t]-    _       -> do ts <- lexAll-                  return (t : ts)--ltest :: Int -> String -> Prelude.IO ()-ltest code s =-  let (ws, xs) = execLexer (setStartCode code >> lexAll) (B.Char8.pack s)-   in traverse_ print ws >> traverse_ print xs--mkLexState :: ByteString -> LexState-mkLexState input = LexState-  { curPos   = Position 1 1-  , curInput = input-  , curCode  = 0-  , warnings = []-#ifdef CABAL_PARSEC_DEBUG-  , dbgText  = V.fromList . lines' . T.decodeUtf8With T.lenientDecode $ input-#endif-  }--#ifdef CABAL_PARSEC_DEBUG-lines' :: T.Text -> [T.Text]-lines' s1-  | T.null s1 = []-  | otherwise = case T.break (\c -> c == '\r' || c == '\n') s1 of-                  (l, s2) | Just (c,s3) <- T.uncons s2-                         -> case T.uncons s3 of-                              Just ('\n', s4) | c == '\r' -> l `T.snoc` '\r' `T.snoc` '\n' : lines' s4-                              _                           -> l `T.snoc` c : lines' s3--                          | otherwise-                         -> [l]-#endif--bol_field_braces,bol_field_layout,bol_section,in_field_braces,in_field_layout,in_section :: Int-bol_field_braces = 1-bol_field_layout = 2-bol_section = 3-in_field_braces = 4-in_field_layout = 5-in_section = 6-alex_action_0 = \pos len _ -> do-              when (len /= 0) $ addWarningAt pos LexWarningBOM-              setStartCode bol_section-              lexToken-alex_action_1 = \pos len inp -> checkWhitespace pos len inp >> adjustPos retPos >> lexToken-alex_action_3 = \pos len inp -> checkLeadingWhitespace pos len inp >>-                                     if B.length inp == len-                                       then return (L pos EOF)-                                       else setStartCode in_section-                                         >> return (L pos (Indent len))-alex_action_4 = tok  OpenBrace-alex_action_5 = tok  CloseBrace-alex_action_8 = toki TokSym-alex_action_9 = \pos len inp -> return $! L pos (TokStr (B.take (len - 2) (B.tail inp)))-alex_action_10 = toki TokOther-alex_action_11 = toki TokOther-alex_action_12 = tok  Colon-alex_action_13 = tok  OpenBrace-alex_action_14 = tok  CloseBrace-alex_action_15 = \_ _ _ -> adjustPos retPos >> setStartCode bol_section >> lexToken-alex_action_16 = \pos len inp -> checkLeadingWhitespace pos len inp >>= \len' ->-                                  if B.length inp == len-                                    then return (L pos EOF)-                                    else setStartCode in_field_layout-                                      >> return (L pos (Indent len'))-alex_action_18 = toki TokFieldLine-alex_action_19 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_layout >> lexToken-alex_action_20 = \_ _ _ -> setStartCode in_field_braces >> lexToken-alex_action_22 = toki TokFieldLine-alex_action_23 = tok  OpenBrace-alex_action_24 = tok  CloseBrace-alex_action_25 = \_ _ _ -> adjustPos retPos >> setStartCode bol_field_braces >> lexToken--#define ALEX_GHC 1-#define ALEX_LATIN1 1-#define ALEX_NOPRED 1--- -------------------------------------------------------------------------------- ALEX TEMPLATE------ This code is in the PUBLIC DOMAIN; you may copy it freely and use--- it for any purpose whatsoever.---- -------------------------------------------------------------------------------- INTERNALS and main scanner engine--#ifdef ALEX_GHC-#  define ILIT(n) n#-#  define IBOX(n) (I# (n))-#  define FAST_INT Int#--- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#  if __GLASGOW_HASKELL__ > 706-#    define GTE(n,m) (tagToEnum# (n >=# m))-#    define EQ(n,m) (tagToEnum# (n ==# m))-#  else-#    define GTE(n,m) (n >=# m)-#    define EQ(n,m) (n ==# m)-#  endif-#  define PLUS(n,m) (n +# m)-#  define MINUS(n,m) (n -# m)-#  define TIMES(n,m) (n *# m)-#  define NEGATE(n) (negateInt# (n))-#  define IF_GHC(x) (x)-#else-#  define ILIT(n) (n)-#  define IBOX(n) (n)-#  define FAST_INT Int-#  define GTE(n,m) (n >= m)-#  define EQ(n,m) (n == m)-#  define PLUS(n,m) (n + m)-#  define MINUS(n,m) (n - m)-#  define TIMES(n,m) (n * m)-#  define NEGATE(n) (negate (n))-#  define IF_GHC(x)-#endif--#ifdef ALEX_GHC-data AlexAddr = AlexA# Addr#--- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.-#if __GLASGOW_HASKELL__ < 503-uncheckedShiftL# = shiftL#-#endif--{-# INLINE alexIndexInt16OffAddr #-}-alexIndexInt16OffAddr :: AlexAddr -> Int# -> Int#-alexIndexInt16OffAddr (AlexA# arr) off =-#ifdef WORDS_BIGENDIAN-  narrow16Int# i-  where-        i    = word2Int# ((high `uncheckedShiftL#` 8#) `or#` low)-        high = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))-        low  = int2Word# (ord# (indexCharOffAddr# arr off'))-        off' = off *# 2#-#else-#if __GLASGOW_HASKELL__ >= 901-  int16ToInt#-#endif-    (indexInt16OffAddr# arr off)-#endif-#else-alexIndexInt16OffAddr arr off = arr ! off-#endif--#ifdef ALEX_GHC-{-# INLINE alexIndexInt32OffAddr #-}-alexIndexInt32OffAddr :: AlexAddr -> Int# -> Int#-alexIndexInt32OffAddr (AlexA# arr) off =-#ifdef WORDS_BIGENDIAN-  narrow32Int# i-  where-   i    = word2Int# ((b3 `uncheckedShiftL#` 24#) `or#`-                     (b2 `uncheckedShiftL#` 16#) `or#`-                     (b1 `uncheckedShiftL#` 8#) `or#` b0)-   b3   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 3#)))-   b2   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 2#)))-   b1   = int2Word# (ord# (indexCharOffAddr# arr (off' +# 1#)))-   b0   = int2Word# (ord# (indexCharOffAddr# arr off'))-   off' = off *# 4#-#else-#if __GLASGOW_HASKELL__ >= 901-  int32ToInt#-#endif-    (indexInt32OffAddr# arr off)-#endif-#else-alexIndexInt32OffAddr arr off = arr ! off-#endif--#ifdef ALEX_GHC--#if __GLASGOW_HASKELL__ < 503-quickIndex arr i = arr ! i-#else--- GHC >= 503, unsafeAt is available from Data.Array.Base.-quickIndex = unsafeAt-#endif-#else-quickIndex arr i = arr ! i-#endif---- -------------------------------------------------------------------------------- Main lexing routines--data AlexReturn a-  = AlexEOF-  | AlexError  !AlexInput-  | AlexSkip   !AlexInput !Int-  | AlexToken  !AlexInput !Int a---- alexScan :: AlexInput -> StartCode -> AlexReturn a-alexScan input__ IBOX(sc)-  = alexScanUser undefined input__ IBOX(sc)--alexScanUser user__ input__ IBOX(sc)-  = case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of-  (AlexNone, input__') ->-    case alexGetByte input__ of-      Nothing ->-#ifdef ALEX_DEBUG-                                   trace ("End of input.") $-#endif-                                   AlexEOF-      Just _ ->-#ifdef ALEX_DEBUG-                                   trace ("Error.") $-#endif-                                   AlexError input__'--  (AlexLastSkip input__'' len, _) ->-#ifdef ALEX_DEBUG-    trace ("Skipping.") $-#endif-    AlexSkip input__'' len--  (AlexLastAcc k input__''' len, _) ->-#ifdef ALEX_DEBUG-    trace ("Accept.") $-#endif-    AlexToken input__''' len (alex_actions ! k)---- Push the input through the DFA, remembering the most recent accepting--- state it encountered.--alex_scan_tkn user__ orig_input len input__ s last_acc =-  input__ `seq` -- strict in the input-  let-  new_acc = (check_accs (alex_accept `quickIndex` IBOX(s)))-  in-  new_acc `seq`-  case alexGetByte input__ of-     Nothing -> (new_acc, input__)-     Just (c, new_input) ->-#ifdef ALEX_DEBUG-      trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c) $-#endif-      case fromIntegral c of { IBOX(ord_c) ->-        let-                base   = alexIndexInt32OffAddr alex_base s-                offset = PLUS(base,ord_c)--                new_s = if GTE(offset,ILIT(0))-                          && let check  = alexIndexInt16OffAddr alex_check offset-                             in  EQ(check,ord_c)-                          then alexIndexInt16OffAddr alex_table offset-                          else alexIndexInt16OffAddr alex_deflt s-        in-        case new_s of-            ILIT(-1) -> (new_acc, input__)-                -- on an error, we want to keep the input *before* the-                -- character that failed, not after.-            _ -> alex_scan_tkn user__ orig_input-#ifdef ALEX_LATIN1-                   PLUS(len,ILIT(1))-                   -- issue 119: in the latin1 encoding, *each* byte is one character-#else-                   (if c < 0x80 || c >= 0xC0 then PLUS(len,ILIT(1)) else len)-                   -- note that the length is increased ONLY if this is the 1st byte in a char encoding)-#endif-                   new_input new_s new_acc-      }-  where-        check_accs (AlexAccNone) = last_acc-        check_accs (AlexAcc a  ) = AlexLastAcc a input__ IBOX(len)-        check_accs (AlexAccSkip) = AlexLastSkip  input__ IBOX(len)-#ifndef ALEX_NOPRED-        check_accs (AlexAccPred a predx rest)-           | predx user__ orig_input IBOX(len) input__-           = AlexLastAcc a input__ IBOX(len)-           | otherwise-           = check_accs rest-        check_accs (AlexAccSkipPred predx rest)-           | predx user__ orig_input IBOX(len) input__-           = AlexLastSkip input__ IBOX(len)-           | otherwise-           = check_accs rest-#endif--data AlexLastAcc-  = AlexNone-  | AlexLastAcc !Int !AlexInput !Int-  | AlexLastSkip     !AlexInput !Int--data AlexAcc user-  = AlexAccNone-  | AlexAcc Int-  | AlexAccSkip-#ifndef ALEX_NOPRED-  | AlexAccPred Int (AlexAccPred user) (AlexAcc user)-  | AlexAccSkipPred (AlexAccPred user) (AlexAcc user)--type AlexAccPred user = user -> AlexInput -> Int -> AlexInput -> Bool---- -------------------------------------------------------------------------------- Predicates on a rule--alexAndPred p1 p2 user__ in1 len in2-  = p1 user__ in1 len in2 && p2 user__ in1 len in2----alexPrevCharIsPred :: Char -> AlexAccPred _-alexPrevCharIs c _ input__ _ _ = c == alexInputPrevChar input__--alexPrevCharMatches f _ input__ _ _ = f (alexInputPrevChar input__)----alexPrevCharIsOneOfPred :: Array Char Bool -> AlexAccPred _-alexPrevCharIsOneOf arr _ input__ _ _ = arr ! alexInputPrevChar input__----alexRightContext :: Int -> AlexAccPred _-alexRightContext IBOX(sc) user__ _ _ input__ =-     case alex_scan_tkn user__ input__ ILIT(0) input__ sc AlexNone of-          (AlexNone, _) -> False-          _ -> True-        -- TODO: there's no need to find the longest-        -- match when checking the right context, just-        -- the first match will do.-#endif
+ src/Distribution/Fields/Lexer.x view
@@ -0,0 +1,292 @@+{+-----------------------------------------------------------------------------+-- |+-- Module      :  Distribution.Fields.Lexer+-- License     :  BSD3+--+-- Maintainer  :  cabal-devel@haskell.org+-- Portability :  portable+--+-- Lexer for the cabal files.+{-# LANGUAGE CPP #-}+{-# LANGUAGE BangPatterns #-}+#ifdef CABAL_PARSEC_DEBUG+{-# LANGUAGE PatternGuards #-}+#endif+{-# OPTIONS_GHC -fno-warn-unused-imports #-}+module Distribution.Fields.Lexer+  (ltest, lexToken, Token(..), LToken(..)+  ,bol_section, in_section, in_field_layout, in_field_braces+  ,mkLexState) where++import Prelude ()+import qualified Prelude+import Distribution.Compat.Prelude++import Distribution.Fields.LexerMonad+import Distribution.Parsec.Position (Position (..), incPos, retPos)+import Data.ByteString (ByteString)+import qualified Data.ByteString as B+import qualified Data.ByteString.Char8 as B.Char8+import qualified Data.Word as Word++#ifdef CABAL_PARSEC_DEBUG+import Debug.Trace+import qualified Data.Vector as V+import qualified Data.Text   as T+import qualified Data.Text.Encoding as T+import qualified Data.Text.Encoding.Error as T+#endif++}+-- Various character classes++%encoding "latin1"++$space           = \          -- single space char+$ctlchar         = [\x0-\x1f \x7f]+$printable       = \x0-\xff # $ctlchar   -- so no \n \r+$symbol'         = [ \, \= \< \> \+ \* \& \| \! \$ \% \^ \@ \# \? \/ \\ \~ ]+$symbol          = [$symbol' \- \.]+$spacetab        = [$space \t]++$paren           = [ \( \) \[ \] ]+$field_layout    = [$printable \t]+$field_layout'   = [$printable] # [$space]+$field_braces    = [$printable \t] # [\{ \}]+$field_braces'   = [$printable] # [\{ \} $space]+$comment         = [$printable \t]+$namecore        = [$printable] # [$space \: \" \{ \} $paren $symbol']+$instr           = [$printable $space] # [\"]+$instresc        = $printable++@bom          = \xef \xbb \xbf+@nbsp         = \xc2 \xa0+@nbspspacetab = ($spacetab | @nbsp)+@nbspspace    = ($space | @nbsp)+@nl           = \n | \r\n | \r+@name         = $namecore++@string       = \" ( $instr | \\ $instresc )* \"+@oplike       = $symbol++++tokens :-++<0> {+  @bom?  { \pos len _ -> do+              when (len /= 0) $ addWarningAt pos LexWarningBOM+              setPos pos -- reset position as if BOM didn't exist+              setStartCode bol_section+              lexToken+         }+}++<bol_section, bol_field_layout, bol_field_braces> {+  @nbspspacetab* @nl         { \pos len inp -> checkWhitespace pos len inp >> adjustPos retPos >> lexToken }+  -- no @nl here to allow for comments on last line of the file with no trailing \n+  $spacetab* "--" $comment*  ;  -- TODO: check the lack of @nl works here+                                -- including counting line numbers+}++<bol_section> {+  @nbspspacetab*   { \pos len inp -> checkLeadingWhitespace pos len inp >>= \len' ->+                                     -- len' is character whitespace length (counting nbsp as one)+                                     if B.length inp == len+                                       then return (L pos EOF)+                                       else do+                                        -- Small hack: if char and byte length mismatch+                                        -- subtract the difference, so lexToken will count position correctly.+                                        -- Proper (and slower) fix is to count utf8 length in lexToken+                                        when (len' /= len) $ adjustPos (incPos (len' - len))+                                        setStartCode in_section+                                        return (L pos (Indent len')) }+  $spacetab* \{    { tok  OpenBrace }+  $spacetab* \}    { tok  CloseBrace }+}++<in_section> {+  $spacetab+   ; --TODO: don't allow tab as leading space++  "--" $comment* ;++  @name        { toki TokSym }+  @string      { \pos len inp -> return $! L pos (TokStr (B.take (len - 2) (B.tail inp))) }+  @oplike      { toki TokOther }+  $paren       { toki TokOther }+  \:           { tok  Colon }+  \{           { tok  OpenBrace }+  \}           { tok  CloseBrace }+  @nl          { \_ _ _ -> adjustPos retPos >> setStartCode bol_section >> lexToken }+}++<bol_field_layout> {+  @nbspspacetab* { \pos len inp -> checkLeadingWhitespace pos len inp >>= \len' ->+                                  if B.length inp == len+                                    then return (L pos EOF)+                                    else do+                                      -- Small hack: if char and byte length mismatch+                                      -- subtract the difference, so lexToken will count position correctly.+                                      -- Proper (and slower) fix is to count utf8 length in lexToken+                                      when (len' /= len) $ adjustPos (incPos (len' - len))+                                      setStartCode in_field_layout+                                      return (L pos (Indent len')) }+}++<in_field_layout> {+  $spacetab+;+  $field_layout' $field_layout*  { toki TokFieldLine }+  @nl             { \_ _ _ -> adjustPos retPos >> setStartCode bol_field_layout >> lexToken }+}++<bol_field_braces> {+   ()                { \_ _ _ -> setStartCode in_field_braces >> lexToken }+}++<in_field_braces> {+  $spacetab+;+  $field_braces' $field_braces*    { toki TokFieldLine }+  \{                { tok  OpenBrace  }+  \}                { tok  CloseBrace }+  @nl               { \_ _ _ -> adjustPos retPos >> setStartCode bol_field_braces >> lexToken }+}++{++-- | Tokens of outer cabal file structure. Field values are treated opaquely.+data Token = TokSym   !ByteString       -- ^ Haskell-like identifier, number or operator+           | TokStr   !ByteString       -- ^ String in quotes+           | TokOther !ByteString       -- ^ Operators and parens+           | Indent   !Int              -- ^ Indentation token+           | TokFieldLine !ByteString   -- ^ Lines after @:@+           | Colon+           | OpenBrace+           | CloseBrace+           | EOF+           | LexicalError InputStream --TODO: add separate string lexical error+  deriving Show++data LToken = L !Position !Token+  deriving Show++toki :: (ByteString -> Token) -> Position -> Int -> ByteString -> Lex LToken+toki t pos  len  input = return $! L pos (t (B.take len input))++tok :: Token -> Position -> Int -> ByteString -> Lex LToken+tok  t pos _len _input = return $! L pos t++checkLeadingWhitespace :: Position -> Int -> ByteString -> Lex Int+checkLeadingWhitespace pos len bs+    | B.any (== 9) (B.take len bs) = do+        addWarningAt pos LexWarningTab+        checkWhitespace pos len bs+    | otherwise = checkWhitespace pos len bs++checkWhitespace :: Position -> Int -> ByteString -> Lex Int+checkWhitespace pos len bs+    -- UTF8 NBSP is 194 160. This function is called on whitespace bytestrings,+    -- therefore counting 194 bytes is enough to count non-breaking spaces.+    -- We subtract the amount of 194 bytes to convert bytes length into char length+    | B.any (== 194) (B.take len bs) = do+        addWarningAt pos LexWarningNBSP+        return $ len - B.count 194 (B.take len bs)+    | otherwise = return len++-- -----------------------------------------------------------------------------+-- The input type++type AlexInput = InputStream++alexInputPrevChar :: AlexInput -> Char+alexInputPrevChar _ = error "alexInputPrevChar not used"++alexGetByte :: AlexInput -> Maybe (Word.Word8,AlexInput)+alexGetByte = B.uncons++lexicalError :: Position -> InputStream -> Lex LToken+lexicalError pos inp = do+  setInput B.empty+  return $! L pos (LexicalError inp)++lexToken :: Lex LToken+lexToken = do+  pos <- getPos+  inp <- getInput+  st  <- getStartCode+  case alexScan inp st of+    AlexEOF -> return (L pos EOF)+    AlexError inp' ->+        let !len_bytes = B.length inp - B.length inp' in+            --FIXME: we want len_chars here really+            -- need to decode utf8 up to this point+        lexicalError (incPos len_bytes pos) inp'+    AlexSkip  inp' len_chars -> do+        checkPosition pos inp inp' len_chars+        adjustPos (incPos len_chars)+        setInput inp'+        lexToken+    AlexToken inp' len_chars action -> do+        checkPosition pos inp inp' len_chars+        adjustPos (incPos len_chars)+        setInput inp'+        let !len_bytes = B.length inp - B.length inp'+        t <- action pos len_bytes inp+        --traceShow t $ return tok+        return t+++checkPosition :: Position -> ByteString -> ByteString -> Int -> Lex ()+#ifdef CABAL_PARSEC_DEBUG+checkPosition pos@(Position lineno colno) inp inp' len_chars = do+    text_lines <- getDbgText+    let len_bytes = B.length inp - B.length inp'+        pos_txt   | lineno-1 < V.length text_lines = T.take len_chars (T.drop (colno-1) (text_lines V.! (lineno-1)))+                  | otherwise = T.empty+        real_txt  = B.take len_bytes inp+    when (pos_txt /= T.decodeUtf8 real_txt) $+      traceShow (pos, pos_txt, T.decodeUtf8 real_txt) $+      traceShow (take 3 (V.toList text_lines)) $ return ()+  where+    getDbgText = Lex $ \s@LexState{ dbgText = txt } -> LexResult s txt+#else+checkPosition _ _ _ _ = return ()+#endif++lexAll :: Lex [LToken]+lexAll = do+  t <- lexToken+  case t of+    L _ EOF -> return [t]+    _       -> do ts <- lexAll+                  return (t : ts)++ltest :: Int -> String -> Prelude.IO ()+ltest code s =+  let (ws, xs) = execLexer (setStartCode code >> lexAll) (B.Char8.pack s)+   in traverse_ print ws >> traverse_ print xs+++mkLexState :: ByteString -> LexState+mkLexState input = LexState+  { curPos   = Position 1 1+  , curInput = input+  , curCode  = 0+  , warnings = []+#ifdef CABAL_PARSEC_DEBUG+  , dbgText  = V.fromList . lines' . T.decodeUtf8With T.lenientDecode $ input+#endif+  }++#ifdef CABAL_PARSEC_DEBUG+lines' :: T.Text -> [T.Text]+lines' s1+  | T.null s1 = []+  | otherwise = case T.break (\c -> c == '\r' || c == '\n') s1 of+                  (l, s2) | Just (c,s3) <- T.uncons s2+                         -> case T.uncons s3 of+                              Just ('\n', s4) | c == '\r' -> l `T.snoc` '\r' `T.snoc` '\n' : lines' s4+                              _                           -> l `T.snoc` c : lines' s3++                          | otherwise+                         -> [l]+#endif+}
src/Distribution/Fields/LexerMonad.hs view
@@ -1,43 +1,39 @@ {-# LANGUAGE CPP #-}+ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Fields.LexerMonad -- License     :  BSD3 -- -- Maintainer  :  cabal-devel@haskell.org -- Portability :  portable-module Distribution.Fields.LexerMonad (-    InputStream,-    LexState(..),-    LexResult(..),--    Lex(..),-    execLexer,--    getPos,-    setPos,-    adjustPos,--    getInput,-    setInput,--    getStartCode,-    setStartCode,--    LexWarning(..),-    LexWarningType(..),-    addWarning,-    addWarningAt,-    toPWarnings,-+module Distribution.Fields.LexerMonad+  ( InputStream+  , LexState (..)+  , LexResult (..)+  , Lex (..)+  , execLexer+  , getPos+  , setPos+  , adjustPos+  , getInput+  , setInput+  , getStartCode+  , setStartCode+  , LexWarning (..)+  , LexWarningType (..)+  , addWarning+  , addWarningAt+  , toPWarnings   ) where -import qualified Data.ByteString              as B-import qualified Data.List.NonEmpty           as NE-import           Distribution.Compat.Prelude-import           Distribution.Parsec.Position (Position (..), showPos)-import           Distribution.Parsec.Warning  (PWarnType (..), PWarning (..))-import           Prelude ()+import qualified Data.ByteString as B+import qualified Data.List.NonEmpty as NE+import Distribution.Compat.Prelude+import Distribution.Parsec.Position (Position (..), positionRow, showPos)+import Distribution.Parsec.Warning (PWarnType (..), PWarning (..))+import Prelude ()  import qualified Data.Map.Strict as Map @@ -49,7 +45,7 @@ #endif  -- simple state monad-newtype Lex a = Lex { unLex :: LexState -> LexResult a }+newtype Lex a = Lex {unLex :: LexState -> LexResult a}  instance Functor Lex where   fmap = liftM@@ -60,66 +56,92 @@  instance Monad Lex where   return = pure-  (>>=)  = thenLex+  (>>=) = thenLex  data LexResult a = LexResult {-# UNPACK #-} !LexState a  data LexWarningType-    = LexWarningNBSP  -- ^ Encountered non breaking space-    | LexWarningBOM   -- ^ BOM at the start of the cabal file-    | LexWarningTab   -- ^ Leading tags+  = -- | Encountered non breaking space+    LexWarningNBSP+  | -- | BOM at the start of the cabal file+    LexWarningBOM+  | -- | Leading tags+    LexWarningTab+  | -- | indentation decreases+    LexInconsistentIndentation+  | -- | Brace syntax used+    LexBraces   deriving (Eq, Ord, Show) -data LexWarning = LexWarning                !LexWarningType-                             {-# UNPACK #-} !Position+data LexWarning+  = LexWarning+      !LexWarningType+      {-# UNPACK #-} !Position   deriving (Show)  toPWarnings :: [LexWarning] -> [PWarning]-toPWarnings-    = map (uncurry toWarning)+toPWarnings =+  mapMaybe (uncurry toWarning)     . Map.toList-    . Map.fromListWith (<>)+    . Map.fromListWith (flip (<>)) -- fromListWith gives existing element first.     . map (\(LexWarning t p) -> (t, pure p))   where     toWarning LexWarningBOM poss =-        PWarning PWTLexBOM (NE.head poss) "Byte-order mark found at the beginning of the file"+      Just $ PWarning PWTLexBOM (NE.head poss) "Byte-order mark found at the beginning of the file"     toWarning LexWarningNBSP poss =-        PWarning PWTLexNBSP (NE.head poss) $ "Non breaking spaces at " ++ intercalate ", " (NE.toList $ fmap showPos poss)+      Just $ PWarning PWTLexNBSP (NE.head poss) $ "Non breaking spaces at " ++ intercalate ", " (NE.toList $ fmap showPos poss)     toWarning LexWarningTab poss =-        PWarning PWTLexTab (NE.head poss) $ "Tabs used as indentation at " ++ intercalate ", " (NE.toList $ fmap showPos poss)+      Just $ PWarning PWTLexTab (NE.head poss) $ "Tabs used as indentation at " ++ intercalate ", " (NE.toList $ fmap showPos poss)+    toWarning LexInconsistentIndentation poss =+      Just $ PWarning PWTInconsistentIndentation (NE.head poss) $ "Inconsistent indentation. Indentation jumps at lines " ++ intercalate ", " (NE.toList $ fmap (show . positionRow) poss)+    -- LexBraces warning about using { } delimiters is not reported as parser warning.+    toWarning LexBraces _ =+      Nothing -data LexState = LexState {-        curPos   :: {-# UNPACK #-} !Position,        -- ^ position at current input location-        curInput :: {-# UNPACK #-} !InputStream,     -- ^ the current input-        curCode  :: {-# UNPACK #-} !StartCode,       -- ^ lexer code-        warnings :: [LexWarning]+{- FOURMOLU_DISABLE -}+data LexState = LexState+  { curPos :: {-# UNPACK #-} !Position+  -- ^ position at current input location+  , curInput :: {-# UNPACK #-} !InputStream+  -- ^ the current input+  , curCode :: {-# UNPACK #-} !StartCode+  -- ^ lexer code+  , warnings :: [LexWarning] #ifdef CABAL_PARSEC_DEBUG-        , dbgText  :: V.Vector T.Text                -- ^ input lines, to print pretty debug info+  ,  dbgText :: V.Vector T.Text+  -- ^ input lines, to print pretty debug info #endif-     } --TODO: check if we should cache the first token-       -- since it looks like parsec's uncons can be called many times on the same input+  }+{- FOURMOLU_ENABLE -} -type StartCode   = Int    -- ^ An @alex@ lexer start code-type InputStream = B.ByteString+-- TODO: check if we should cache the first token+-- since it looks like parsec's uncons can be called many times on the same input +type StartCode =+  Int+  -- ^ An @alex@ lexer start code +type InputStream = B.ByteString  -- | Execute the given lexer on the supplied input stream.+{- FOURMOLU_DISABLE -} execLexer :: Lex a -> InputStream -> ([LexWarning], a) execLexer (Lex lexer) input =-    case lexer initialState of-      LexResult LexState{ warnings = ws } result -> (ws, result)+  case lexer initialState of+    LexResult LexState{warnings = ws} result -> (ws, result)   where-    initialState = LexState-      -- TODO: add 'startPosition'-      { curPos   = Position 1 1-      , curInput = input-      , curCode  = 0-      , warnings = []+    initialState =+      LexState+        { -- TODO: add 'startPosition'+          curPos = Position 1 1+        , curInput = input+        , curCode = 0+        , warnings = [] #ifdef CABAL_PARSEC_DEBUG-      , dbgText  = V.fromList . T.lines . T.decodeUtf8 $ input+        ,  dbgText = V.fromList . T.lines . T.decodeUtf8 $ input #endif-      }+        }+{- FOURMOLU_ENABLE -}  {-# INLINE returnLex #-} returnLex :: a -> Lex a@@ -130,32 +152,32 @@ (Lex m) `thenLex` k = Lex $ \s -> case m s of LexResult s' a -> (unLex (k a)) s'  setPos :: Position -> Lex ()-setPos pos = Lex $ \s -> LexResult s{ curPos = pos } ()+setPos pos = Lex $ \s -> LexResult s{curPos = pos} ()  getPos :: Lex Position-getPos = Lex $ \s@LexState{ curPos = pos } -> LexResult s pos+getPos = Lex $ \s@LexState{curPos = pos} -> LexResult s pos  adjustPos :: (Position -> Position) -> Lex ()-adjustPos f = Lex $ \s@LexState{ curPos = pos } -> LexResult s{ curPos = f pos } ()+adjustPos f = Lex $ \s@LexState{curPos = pos} -> LexResult s{curPos = f pos} ()  getInput :: Lex InputStream-getInput = Lex $ \s@LexState{ curInput = i } -> LexResult s i+getInput = Lex $ \s@LexState{curInput = i} -> LexResult s i  setInput :: InputStream -> Lex ()-setInput i = Lex $ \s -> LexResult s{ curInput = i } ()+setInput i = Lex $ \s -> LexResult s{curInput = i} ()  getStartCode :: Lex Int-getStartCode = Lex $ \s@LexState{ curCode = c } -> LexResult s c+getStartCode = Lex $ \s@LexState{curCode = c} -> LexResult s c  setStartCode :: Int -> Lex ()-setStartCode c = Lex $ \s -> LexResult s{ curCode = c } ()+setStartCode c = Lex $ \s -> LexResult s{curCode = c} ()  -- | Add warning at the current position addWarning :: LexWarningType -> Lex ()-addWarning wt = Lex $ \s@LexState{ curPos = pos, warnings = ws  } ->-    LexResult s{ warnings = LexWarning wt pos : ws } ()+addWarning wt = Lex $ \s@LexState{curPos = pos, warnings = ws} ->+  LexResult s{warnings = LexWarning wt pos : ws} ()  -- | Add warning at specific position addWarningAt :: Position -> LexWarningType -> Lex ()-addWarningAt pos wt = Lex $ \s@LexState{ warnings = ws  } ->-    LexResult s{ warnings = LexWarning wt pos : ws } ()+addWarningAt pos wt = Lex $ \s@LexState{warnings = ws} ->+  LexResult s{warnings = LexWarning wt pos : ws} ()
src/Distribution/Fields/ParseResult.hs view
@@ -1,47 +1,37 @@-{-# LANGUAGE BangPatterns     #-}-{-# LANGUAGE CPP              #-}+{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE RankNTypes       #-}--- | A parse result type for parsers from AST to Haskell types.-module Distribution.Fields.ParseResult (-    ParseResult,-    runParseResult,-    recoverWith,-    parseWarning,-    parseWarnings,-    parseFailure,-    parseFatalFailure,-    parseFatalFailure',-    getCabalSpecVersion,-    setCabalSpecVersion,-    withoutWarnings,-    ) where+{-# LANGUAGE RankNTypes #-} -import           Distribution.Parsec.Error    (PError (..))-import           Distribution.Parsec.Position (Position (..), zeroPos)-import           Distribution.Parsec.Warning  (PWarnType (..), PWarning (..))-import           Distribution.Version         (Version)-import           Prelude ()+-- | A parse result type for parsers from AST to Haskell types.+module Distribution.Fields.ParseResult+  ( ParseResult+  , runParseResult+  , recoverWith+  , parseWarning+  , parseWarnings+  , parseFailure+  , parseFatalFailure+  , parseFatalFailure'+  , getCabalSpecVersion+  , setCabalSpecVersion+  , withoutWarnings+  ) where --- liftA2 is not in base <4.10, hence we need to only import it explicitly when we're on >=4.10------ Additionally, since liftA2 will be exported from Prelude starting with ~4.18, we should hide--- it from Prelude and get it from Control.Applicative to be backwards compatible and avoid warnings-#if MIN_VERSION_base(4,10,0)-import           Distribution.Compat.Prelude hiding (Applicative(..))-import           Control.Applicative (Applicative (..))-#else-import           Distribution.Compat.Prelude-#endif+import Distribution.Compat.Prelude+import Distribution.Parsec.Error (PError (..))+import Distribution.Parsec.Position (Position (..), zeroPos)+import Distribution.Parsec.Warning (PWarnType (..), PWarning (..))+import Distribution.Version (Version)  -- | A monad with failure and accumulating errors and warnings. newtype ParseResult a = PR-    { unPR-        :: forall r. PRState-        -> (PRState -> r) -- failure, but we were able to recover a new-style spec-version declaration-        -> (PRState -> a -> r)             -- success-        -> r-    }+  { unPR+      :: forall r+       . PRState+      -> (PRState -> r) -- failure, but we were able to recover a new-style spec-version declaration+      -> (PRState -> a -> r) -- success+      -> r+  }  -- Note: we have version here, as we could get any version. data PRState = PRState ![PWarning] ![PError] !(Maybe Version)@@ -54,7 +44,7 @@ -- @since 3.4.0.0 withoutWarnings :: ParseResult a -> ParseResult a withoutWarnings m = PR $ \s failure success ->-    unPR m s failure $ \ !s1 -> success (s1 `withWarningsOf` s)+  unPR m s failure $ \ !s1 -> success (s1 `withWarningsOf` s)   where     withWarningsOf (PRState _ e v) (PRState w _ _) = PRState w e v @@ -64,99 +54,92 @@ runParseResult :: ParseResult a -> ([PWarning], Either (Maybe Version, NonEmpty PError) a) runParseResult pr = unPR pr emptyPRState failure success   where-    failure (PRState warns []         v)   = (warns, Left (v, PError zeroPos "panic" :| []))-    failure (PRState warns (err:errs) v)   = (warns, Left (v, err :| errs)) where-    success (PRState warns []         _)   x = (warns, Right x)+    failure (PRState warns [] v) = (warns, Left (v, PError zeroPos "panic" :| []))+    failure (PRState warns (err : errs) v) = (warns, Left (v, err :| errs))++    success (PRState warns [] _) x = (warns, Right x)     -- If there are any errors, don't return the result-    success (PRState warns (err:errs) v) _ = (warns, Left (v, err :| errs))+    success (PRState warns (err : errs) v) _ = (warns, Left (v, err :| errs))  instance Functor ParseResult where-    fmap f (PR pr) = PR $ \ !s failure success ->-        pr s failure $ \ !s' a ->-        success s' (f a)-    {-# INLINE fmap #-}+  fmap f (PR pr) = PR $ \ !s failure success ->+    pr s failure $ \ !s' a ->+      success s' (f a)+  {-# INLINE fmap #-}  instance Applicative ParseResult where-    pure x = PR $ \ !s _ success -> success s x-    {-# INLINE pure #-}+  pure x = PR $ \ !s _ success -> success s x+  {-# INLINE pure #-} -    f <*> x = PR $ \ !s0 failure success ->-        unPR f s0 failure $ \ !s1 f' ->-        unPR x s1 failure $ \ !s2 x' ->+  f <*> x = PR $ \ !s0 failure success ->+    unPR f s0 failure $ \ !s1 f' ->+      unPR x s1 failure $ \ !s2 x' ->         success s2 (f' x')-    {-# INLINE (<*>) #-}+  {-# INLINE (<*>) #-} -    x  *> y = PR $ \ !s0 failure success ->-        unPR x s0 failure $ \ !s1 _ ->-        unPR y s1 failure success-    {-# INLINE (*>) #-}+  x *> y = PR $ \ !s0 failure success ->+    unPR x s0 failure $ \ !s1 _ ->+      unPR y s1 failure success+  {-# INLINE (*>) #-} -    x  <* y = PR $ \ !s0 failure success ->-        unPR x s0 failure $ \ !s1 x' ->-        unPR y s1 failure $ \ !s2 _  ->+  x <* y = PR $ \ !s0 failure success ->+    unPR x s0 failure $ \ !s1 x' ->+      unPR y s1 failure $ \ !s2 _ ->         success s2 x'-    {-# INLINE (<*) #-}--#if MIN_VERSION_base(4,10,0)-    liftA2 f x y = PR $ \ !s0 failure success ->-        unPR x s0 failure $ \ !s1 x' ->-        unPR y s1 failure $ \ !s2 y' ->-        success s2 (f x' y')-    {-# INLINE liftA2 #-}-#endif+  {-# INLINE (<*) #-}  instance Monad ParseResult where-    return = pure-    (>>) = (*>)+  return = pure+  (>>) = (*>) -    m >>= k = PR $ \ !s failure success ->-        unPR m s failure $ \ !s' a ->-        unPR (k a) s' failure success-    {-# INLINE (>>=) #-}+  m >>= k = PR $ \ !s failure success ->+    unPR m s failure $ \ !s' a ->+      unPR (k a) s' failure success+  {-# INLINE (>>=) #-}  -- | "Recover" the parse result, so we can proceed parsing. -- 'runParseResult' will still result in 'Nothing', if there are recorded errors. recoverWith :: ParseResult a -> a -> ParseResult a recoverWith (PR pr) x = PR $ \ !s _failure success ->-    pr s (\ !s' -> success s' x) success+  pr s (\ !s' -> success s' x) success  -- | Set cabal spec version. setCabalSpecVersion :: Maybe Version -> ParseResult () setCabalSpecVersion v = PR $ \(PRState warns errs _) _failure success ->-    success (PRState warns errs v) ()+  success (PRState warns errs v) ()  -- | Get cabal spec version. getCabalSpecVersion :: ParseResult (Maybe Version) getCabalSpecVersion = PR $ \s@(PRState _ _ v) _failure success ->-    success s v+  success s v  -- | Add a warning. This doesn't fail the parsing process. parseWarning :: Position -> PWarnType -> String -> ParseResult () parseWarning pos t msg = PR $ \(PRState warns errs v) _failure success ->-    success (PRState (PWarning t pos msg : warns) errs v) ()+  success (PRState (PWarning t pos msg : warns) errs v) ()  -- | Add multiple warnings at once. parseWarnings :: [PWarning] -> ParseResult () parseWarnings newWarns = PR $ \(PRState warns errs v) _failure success ->-    success (PRState (newWarns ++ warns) errs v) ()+  success (PRState (newWarns ++ warns) errs v) ()  -- | Add an error, but not fail the parser yet. -- -- For fatal failure use 'parseFatalFailure' parseFailure :: Position -> String -> ParseResult () parseFailure pos msg = PR $ \(PRState warns errs v) _failure success ->-    success (PRState warns (PError pos msg : errs) v) ()+  success (PRState warns (PError pos msg : errs) v) ()  -- | Add an fatal error. parseFatalFailure :: Position -> String -> ParseResult a parseFatalFailure pos msg = PR $ \(PRState warns errs v) failure _success ->-    failure (PRState warns (PError pos msg : errs) v)+  failure (PRState warns (PError pos msg : errs) v)  -- | A 'mzero'. parseFatalFailure' :: ParseResult a parseFatalFailure' = PR pr   where     pr (PRState warns [] v) failure _success = failure (PRState warns [err] v)-    pr s                    failure _success = failure s+    pr s failure _success = failure s      err = PError zeroPos "Unknown fatal error"
src/Distribution/Fields/Parser.hs view
@@ -1,45 +1,55 @@-{-# LANGUAGE CPP                   #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings     #-}-{-# LANGUAGE PatternGuards         #-}+{-# LANGUAGE OverloadedStrings #-}+ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Fields.Parser -- License     :  BSD3 -- -- Maintainer  :  cabal-devel@haskell.org -- Portability :  portable-module Distribution.Fields.Parser (-    -- * Types-    Field(..),-    Name(..),-    FieldLine(..),-    SectionArg(..),+{- FOURMOLU_DISABLE -}+module Distribution.Fields.Parser+  ( -- * Types+    Field (..)+  , Name (..)+  , FieldLine (..)+  , SectionArg (..)+     -- * Grammar and parsing     -- $grammar-    readFields,-    readFields',+  , readFields+  , readFields' #ifdef CABAL_PARSEC_DEBUG+     -- * Internal-    parseFile,-    parseStr,-    parseBS,+  , parseFile+  , parseStr+  , parseBS #endif-    ) where+  ) where+{- FOURMOLU_ENABLE -} -import qualified Data.ByteString.Char8          as B8-import           Data.Functor.Identity-import           Distribution.Compat.Prelude-import           Distribution.Fields.Field-import           Distribution.Fields.Lexer-import           Distribution.Fields.LexerMonad-                 (LexResult (..), LexState (..), LexWarning (..), unLex)-import           Distribution.Parsec.Position   (Position (..))-import           Prelude ()-import           Text.Parsec.Combinator         hiding (eof, notFollowedBy)-import           Text.Parsec.Error-import           Text.Parsec.Pos-import           Text.Parsec.Prim               hiding (many, (<|>))+import qualified Data.ByteString.Char8 as B8+import Data.Functor.Identity+import Distribution.Compat.Prelude+import Distribution.Fields.Field+import Distribution.Fields.Lexer+import Distribution.Fields.LexerMonad+  ( LexResult (..)+  , LexState (..)+  , LexWarning (..)+  , LexWarningType (..)+  , unLex+  )+import Distribution.Parsec.Position (Position (..), positionCol)+import Text.Parsec.Combinator hiding (eof, notFollowedBy)+import Text.Parsec.Error+import Text.Parsec.Pos+import Text.Parsec.Prim hiding (many, (<|>))+import Prelude ()  #ifdef CABAL_PARSEC_DEBUG import qualified Data.Text                as T@@ -55,8 +65,10 @@ data LexState' = LexState' !LexState (LToken, LexState')  mkLexState' :: LexState -> LexState'-mkLexState' st = LexState' st-                   (case unLex lexToken st of LexResult st' tok -> (tok, mkLexState' st'))+mkLexState' st =+  LexState'+    st+    (case unLex lexToken st of LexResult st' tok -> (tok, mkLexState' st'))  type Parser a = ParsecT LexState' () Identity a @@ -64,19 +76,24 @@   uncons (LexState' _ (tok, st')) =     case tok of       L _ EOF -> return Nothing-      _       -> return (Just (tok, st'))+      _ -> return (Just (tok, st'))  -- | Get lexer warnings accumulated so far getLexerWarnings :: Parser [LexWarning] getLexerWarnings = do-  LexState' (LexState { warnings = ws }) _ <- getInput+  LexState' (LexState{warnings = ws}) _ <- getInput   return ws +addLexerWarning :: LexWarning -> Parser ()+addLexerWarning w = do+  LexState' ls@LexState{warnings = ws} _ <- getInput+  setInput $! mkLexState' ls{warnings = w : ws}+ -- | Set Alex code i.e. the mode "state" lexer is in. setLexerMode :: Int -> Parser () setLexerMode code = do   LexState' ls _ <- getInput-  setInput $! mkLexState' ls { curCode = code }+  setInput $! mkLexState' ls{curCode = code}  getToken :: (Token -> Maybe a) -> Parser a getToken getTok = getTokenWithPos (\(L _ t) -> getTok t)@@ -89,45 +106,46 @@  describeToken :: Token -> String describeToken t = case t of-  TokSym   s      -> "symbol "   ++ show s-  TokStr   s      -> "string "   ++ show s-  TokOther s      -> "operator " ++ show s-  Indent _        -> "new line"-  TokFieldLine _  -> "field content"-  Colon           -> "\":\""-  OpenBrace       -> "\"{\""-  CloseBrace      -> "\"}\""---  SemiColon       -> "\";\""-  EOF             -> "end of file"+  TokSym s -> "symbol " ++ show s+  TokStr s -> "string " ++ show s+  TokOther s -> "operator " ++ show s+  Indent _ -> "new line"+  TokFieldLine _ -> "field content"+  Colon -> "\":\""+  OpenBrace -> "\"{\""+  CloseBrace -> "\"}\""+  --  SemiColon       -> "\";\""+  EOF -> "end of file"   LexicalError is -> "character in input " ++ show (B8.head is)  tokSym :: Parser (Name Position) tokSym', tokStr, tokOther :: Parser (SectionArg Position) tokIndent :: Parser Int-tokColon, tokOpenBrace, tokCloseBrace :: Parser ()+tokColon, tokCloseBrace :: Parser ()+tokOpenBrace :: Parser Position tokFieldLine :: Parser (FieldLine Position)--tokSym        = getTokenWithPos $ \t -> case t of L pos (TokSym   x) -> Just (mkName pos x);  _ -> Nothing-tokSym'       = getTokenWithPos $ \t -> case t of L pos (TokSym   x) -> Just (SecArgName pos x);  _ -> Nothing-tokStr        = getTokenWithPos $ \t -> case t of L pos (TokStr   x) -> Just (SecArgStr pos x);  _ -> Nothing-tokOther      = getTokenWithPos $ \t -> case t of L pos (TokOther x) -> Just (SecArgOther pos x);  _ -> Nothing-tokIndent     = getToken $ \t -> case t of Indent   x -> Just x;  _ -> Nothing-tokColon      = getToken $ \t -> case t of Colon      -> Just (); _ -> Nothing-tokOpenBrace  = getToken $ \t -> case t of OpenBrace  -> Just (); _ -> Nothing+tokSym = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (mkName pos x); _ -> Nothing+tokSym' = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (SecArgName pos x); _ -> Nothing+tokStr = getTokenWithPos $ \t -> case t of L pos (TokStr x) -> Just (SecArgStr pos x); _ -> Nothing+tokOther = getTokenWithPos $ \t -> case t of L pos (TokOther x) -> Just (SecArgOther pos x); _ -> Nothing+tokIndent = getToken $ \t -> case t of Indent x -> Just x; _ -> Nothing+tokColon = getToken $ \t -> case t of Colon -> Just (); _ -> Nothing+tokOpenBrace = getTokenWithPos $ \t -> case t of L pos OpenBrace -> Just pos; _ -> Nothing tokCloseBrace = getToken $ \t -> case t of CloseBrace -> Just (); _ -> Nothing-tokFieldLine  = getTokenWithPos $ \t -> case t of L pos (TokFieldLine s) -> Just (FieldLine pos s); _ -> Nothing+tokFieldLine = getTokenWithPos $ \t -> case t of L pos (TokFieldLine s) -> Just (FieldLine pos s); _ -> Nothing  colon, openBrace, closeBrace :: Parser ()- sectionArg :: Parser (SectionArg Position)-sectionArg   = tokSym' <|> tokStr <|> tokOther <?> "section parameter"+sectionArg = tokSym' <|> tokStr <|> tokOther <?> "section parameter"  fieldSecName :: Parser (Name Position)-fieldSecName = tokSym              <?> "field or section name"+fieldSecName = tokSym <?> "field or section name" -colon        = tokColon      <?> "\":\""-openBrace    = tokOpenBrace  <?> "\"{\""-closeBrace   = tokCloseBrace <?> "\"}\""+colon = tokColon <?> "\":\""+openBrace = do+  pos <- tokOpenBrace <?> "\"{\""+  addLexerWarning (LexWarning LexBraces pos)+closeBrace = tokCloseBrace <?> "\"}\""  fieldContent :: Parser (FieldLine Position) fieldContent = tokFieldLine <?> "field contents"@@ -146,14 +164,12 @@   guard (j >= i) <?> "indentation of at least " ++ show i   return (IndentLevel j) - newtype LexerMode = LexerMode Int  inLexerMode :: LexerMode -> Parser p -> Parser p inLexerMode (LexerMode mode) p =   do setLexerMode mode; x <- p; setLexerMode in_section; return x - ----------------------- -- Cabal file grammar --@@ -210,9 +226,10 @@ -- Top level of a file using cabal syntax -- cabalStyleFile :: Parser [Field Position]-cabalStyleFile = do es <- elements zeroIndentLevel-                    eof-                    return es+cabalStyleFile = do+  es <- elements zeroIndentLevel+  eof+  return es  -- Elements that live at the top level or inside a section, i.e. fields -- and sections content@@ -229,11 +246,15 @@ --           |      name elementInNonLayoutContext element :: IndentLevel -> Parser (Field Position) element ilevel =-      (do ilevel' <- indentOfAtLeast ilevel-          name    <- fieldSecName-          elementInLayoutContext (incIndentLevel ilevel') name)-  <|> (do name    <- fieldSecName-          elementInNonLayoutContext name)+  ( do+      ilevel' <- indentOfAtLeast ilevel+      name <- fieldSecName+      elementInLayoutContext (incIndentLevel ilevel') name+  )+    <|> ( do+            name <- fieldSecName+            elementInNonLayoutContext name+        )  -- An element (field or section) that is valid in a layout context. -- In a layout context we can have fields and sections that themselves@@ -243,10 +264,12 @@ --                          | arg* sectionLayoutOrBraces elementInLayoutContext :: IndentLevel -> Name Position -> Parser (Field Position) elementInLayoutContext ilevel name =-      (do colon; fieldLayoutOrBraces ilevel name)-  <|> (do args  <- many sectionArg-          elems <- sectionLayoutOrBraces ilevel-          return (Section name args elems))+  (do colon; fieldLayoutOrBraces ilevel name)+    <|> ( do+            args <- many sectionArg+            elems <- sectionLayoutOrBraces ilevel+            return (Section name args elems)+        )  -- An element (field or section) that is valid in a non-layout context. -- In a non-layout context we can have only have fields and sections that@@ -256,13 +279,15 @@ --                             | arg* '\\n'? '{' elements '\\n'? '}' elementInNonLayoutContext :: Name Position -> Parser (Field Position) elementInNonLayoutContext name =-      (do colon; fieldInlineOrBraces name)-  <|> (do args <- many sectionArg-          openBrace-          elems <- elements zeroIndentLevel-          optional tokIndent-          closeBrace-          return (Section name args elems))+  (do colon; fieldInlineOrBraces name)+    <|> ( do+            args <- many sectionArg+            openBrace+            elems <- elements zeroIndentLevel+            optional tokIndent+            closeBrace+            return (Section name args elems)+        )  -- The body of a field, using either layout style or braces style. --@@ -272,16 +297,16 @@ fieldLayoutOrBraces ilevel name = braces <|> fieldLayout   where     braces = do-          openBrace-          ls <- inLexerMode (LexerMode in_field_braces) (many fieldContent)-          closeBrace-          return (Field name ls)+      openBrace+      ls <- inLexerMode (LexerMode in_field_braces) (many fieldContent)+      closeBrace+      return (Field name ls)     fieldLayout = inLexerMode (LexerMode in_field_layout) $ do-          l  <- optionMaybe fieldContent-          ls <- many (do _ <- indentOfAtLeast ilevel; fieldContent)-          return $ case l of-              Nothing -> Field name ls-              Just l' -> Field name (l' : ls)+      l <- optionMaybe fieldContent+      ls <- many (do _ <- indentOfAtLeast ilevel; fieldContent)+      return $ case l of+        Nothing -> Field name ls+        Just l' -> Field name (l' : ls)  -- The body of a section, using either layout style or braces style. --@@ -289,12 +314,14 @@ --                         | elements sectionLayoutOrBraces :: IndentLevel -> Parser [Field Position] sectionLayoutOrBraces ilevel =-      (do openBrace-          elems <- elements zeroIndentLevel-          optional tokIndent-          closeBrace-          return elems)-  <|> (elements ilevel)+  ( do+      openBrace+      elems <- elements zeroIndentLevel+      optional tokIndent+      closeBrace+      return elems+  )+    <|> (elements ilevel)  -- The body of a field, using either inline style or braces. --@@ -302,30 +329,83 @@ --                         | content fieldInlineOrBraces :: Name Position -> Parser (Field Position) fieldInlineOrBraces name =-      (do openBrace-          ls <- inLexerMode (LexerMode in_field_braces) (many fieldContent)-          closeBrace-          return (Field name ls))-  <|> (do ls <- inLexerMode (LexerMode in_field_braces) (option [] (fmap (\l -> [l]) fieldContent))-          return (Field name ls))-+  ( do+      openBrace+      ls <- inLexerMode (LexerMode in_field_braces) (many fieldContent)+      closeBrace+      return (Field name ls)+  )+    <|> ( do+            ls <- inLexerMode (LexerMode in_field_braces) (option [] (fmap (\l -> [l]) fieldContent))+            return (Field name ls)+        )  -- | Parse cabal style 'B8.ByteString' into list of 'Field's, i.e. the cabal AST.+--+-- 'readFields' assumes that input 'B8.ByteString' is valid UTF8, specifically it doesn't validate that file is valid UTF8.+-- Therefore bytestrings inside returned 'Field' will be invalid as UTF8 if the input were.+--+-- >>> readFields "foo: \223"+-- Right [Field (Name (Position 1 1) "foo") [FieldLine (Position 1 6) "\223"]]+--+-- 'readFields' won't (necessarily) fail on invalid UTF8 data, but the reported positions may be off.+--+-- __You may get weird errors on non-UTF8 input__, for example 'readFields' will fail on latin1 encoded non-breaking space:+--+-- >>> isLeft (readFields "\xa0 foo: bar")+-- True+--+-- That is rejected because parser thinks @\\xa0@ is a section name,+-- and section arguments may not contain colon.+-- If there are just latin1 non-breaking spaces, they become part of the name:+--+-- >>> readFields "\xa0\&foo: bar"+-- Right [Field (Name (Position 1 1) "\160foo") [FieldLine (Position 1 7) "bar"]]+--+-- The UTF8 non-breaking space is accepted as an indentation character (but warned about by 'readFields'').+--+-- >>> readFields' "\xc2\xa0 foo: bar"+-- Right ([Field (Name (Position 1 3) "foo") [FieldLine (Position 1 8) "bar"]],[LexWarning LexWarningNBSP (Position 1 1)]) readFields :: B8.ByteString -> Either ParseError [Field Position] readFields s = fmap fst (readFields' s) --- | Like 'readFields' but also return lexer warnings+-- | Like 'readFields' but also return lexer warnings. readFields' :: B8.ByteString -> Either ParseError ([Field Position], [LexWarning]) readFields' s = do-    parse parser "the input" lexSt+  parse parser "the input" lexSt   where     parser = do-        fields <- cabalStyleFile-        ws     <- getLexerWarnings-        pure (fields, ws)+      fields <- cabalStyleFile+      ws <- getLexerWarnings -- lexer accumulates warnings in reverse (consing them to the list)+      pure (fields, reverse ws ++ checkIndentation fields [])      lexSt = mkLexState' (mkLexState s) +-- | Check (recursively) that all fields inside a block are indented the same.+--+-- We have to do this as a post-processing check.+-- As the parser uses indentOfAtLeast approach, we don't know what is the "correct"+-- indentation for following fields.+--+-- To catch during parsing we would need to parse first field/section of a section+-- and then parse the following ones (softly) requiring the exactly the same indentation.+checkIndentation :: [Field Position] -> [LexWarning] -> [LexWarning]+checkIndentation [] = id+checkIndentation (Field name _ : fs') = checkIndentation' (nameAnn name) fs'+checkIndentation (Section name _ fs : fs') = checkIndentation fs . checkIndentation' (nameAnn name) fs'++-- | We compare adjacent fields to reduce the amount of reported indentation warnings.+checkIndentation' :: Position -> [Field Position] -> [LexWarning] -> [LexWarning]+checkIndentation' _ [] = id+checkIndentation' pos (Field name _ : fs') = checkIndentation'' pos (nameAnn name) . checkIndentation' (nameAnn name) fs'+checkIndentation' pos (Section name _ fs : fs') = checkIndentation'' pos (nameAnn name) . checkIndentation fs . checkIndentation' (nameAnn name) fs'++-- | Check that positions' columns are the same.+checkIndentation'' :: Position -> Position -> [LexWarning] -> [LexWarning]+checkIndentation'' a b+  | positionCol a == positionCol b = id+  | otherwise = (LexWarning LexInconsistentIndentation b :)+ #ifdef CABAL_PARSEC_DEBUG parseTest' :: Show a => Parsec LexState' () a -> SourceName -> B8.ByteString -> IO () parseTest' p fname s =@@ -376,5 +456,8 @@ eof = notFollowedBy anyToken <?> "end of file"   where     notFollowedBy :: Parser LToken -> Parser ()-    notFollowedBy p = try (    (do L _ t <- try p; unexpected (describeToken t))-                           <|> return ())+    notFollowedBy p =+      try+        ( (do L _ t <- try p; unexpected (describeToken t))+            <|> return ()+        )
src/Distribution/Fields/Pretty.hs view
@@ -1,37 +1,36 @@ {-# LANGUAGE BangPatterns #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE LambdaCase #-}+ -- | Cabal-like file AST types: 'Field', 'Section' etc, -- -- This (intermediate) data type is used for pretty-printing. -- -- @since 3.0.0.0----module Distribution.Fields.Pretty (-    -- * Fields-    CommentPosition (..),-    PrettyField (..),-    showFields,-    showFields',+module Distribution.Fields.Pretty+  ( -- * Fields+    CommentPosition (..)+  , PrettyField (..)+  , showFields+  , showFields'+     -- * Transformation from 'P.Field'-    fromParsecFields,-    genericFromParsecFields,-    prettyFieldLines,-    prettySectionArgs,-    ) where+  , fromParsecFields+  , genericFromParsecFields+  , prettyFieldLines+  , prettySectionArgs+  ) where  import Distribution.Compat.Prelude-import Distribution.Pretty         (showToken)+import Distribution.Pretty (showToken) import Prelude () -import Distribution.Fields.Field   (FieldName)-import Distribution.Utils.Generic  (fromUTF8BS)+import Distribution.Fields.Field (FieldName)+import Distribution.Utils.Generic (fromUTF8BS)  import qualified Distribution.Fields.Parser as P -import qualified Data.ByteString  as BS+import qualified Data.ByteString as BS import qualified Text.PrettyPrint as PP  -- | This type is used to discern when a comment block should go@@ -41,9 +40,9 @@ data CommentPosition = CommentBefore [String] | CommentAfter [String] | NoComment  data PrettyField ann-    = PrettyField ann FieldName PP.Doc-    | PrettySection ann FieldName [PP.Doc] [PrettyField ann]-    | PrettyEmpty+  = PrettyField ann FieldName PP.Doc+  | PrettySection ann FieldName [PP.Doc] [PrettyField ann]+  | PrettyEmpty   deriving (Functor, Foldable, Traversable)  -- | Prettyprint a list of fields.@@ -52,27 +51,27 @@ -- and properly prefixes (with @--@) to count as comments. -- This unsafety is left in place so one could generate empty lines -- between comment lines.--- showFields :: (ann -> CommentPosition) -> [PrettyField ann] -> String showFields rann = showFields' rann (const id) 4  -- | 'showFields' with user specified indentation. showFields'   :: (ann -> CommentPosition)-     -- ^ Convert an annotation to lined to preceed the field or section.+  -- ^ Convert an annotation to lined to precede the field or section.   -> (ann -> [String] -> [String])-     -- ^ Post-process non-annotation produced lines.+  -- ^ Post-process non-annotation produced lines.   -> Int-     -- ^ Indentation level.+  -- ^ Indentation level.   -> [PrettyField ann]-     -- ^ Fields/sections to show.+  -- ^ Fields/sections to show.   -> String showFields' rann post n = unlines . renderFields (Opts rann indent post)   where     -- few hardcoded, "unrolled"  variants.-    indent | n == 4    = indent4-           | n == 2    = indent2-           | otherwise = (replicate (max n 1) ' ' ++)+    indent+      | n == 4 = indent4+      | n == 2 = indent2+      | otherwise = (replicate (max n 1) ' ' ++)      indent4 :: String -> String     indent4 [] = []@@ -92,78 +91,80 @@ renderFields opts fields = flattenBlocks blocks   where     len = maxNameLength 0 fields-    blocks = filter (not . null . _contentsBlock) -- empty blocks cause extra newlines #8236-           $ map (renderField opts len) fields+    blocks =+      filter (not . null . _contentsBlock) $ -- empty blocks cause extra newlines #8236+        map (renderField opts len) fields -    maxNameLength !acc []                            = acc+    maxNameLength !acc [] = acc     maxNameLength !acc (PrettyField _ name _ : rest) = maxNameLength (max acc (BS.length name)) rest-    maxNameLength !acc (PrettySection {}   : rest)   = maxNameLength acc rest+    maxNameLength !acc (PrettySection{} : rest) = maxNameLength acc rest     maxNameLength !acc (PrettyEmpty : rest) = maxNameLength acc rest  -- | Block of lines with flags for optional blank lines before and after data Block = Block-  { _beforeBlock   :: Margin-  , _afterBlock    :: Margin+  { _beforeBlock :: Margin+  , _afterBlock :: Margin   , _contentsBlock :: [String]   }  data Margin = Margin | NoMargin-  deriving Eq+  deriving (Eq)  -- | Collapse margins, any margin = margin instance Semigroup Margin where-    NoMargin <> NoMargin = NoMargin-    _        <> _        = Margin+  NoMargin <> NoMargin = NoMargin+  _ <> _ = Margin  flattenBlocks :: [Block] -> [String]-flattenBlocks = go0 where+flattenBlocks = go0+  where     go0 [] = []     go0 (Block _before after strs : blocks) = strs ++ go after blocks      go _surr' [] = []-    go  surr' (Block before after strs : blocks) = ins $ strs ++ go after blocks where-        ins | surr' <> before == Margin = ("" :)-            | otherwise                 = id+    go surr' (Block before after strs : blocks) = ins $ strs ++ go after blocks+      where+        ins+          | surr' <> before == Margin = ("" :)+          | otherwise = id  renderField :: Opts ann -> Int -> PrettyField ann -> Block renderField (Opts rann indent post) fw (PrettyField ann name doc) =-    Block before after content+  Block before after content   where     content = case comments of       CommentBefore cs -> cs ++ post ann lines'-      CommentAfter  cs -> post ann lines' ++ cs-      NoComment        -> post ann lines'+      CommentAfter cs -> post ann lines' ++ cs+      NoComment -> post ann lines'     comments = rann ann     before = case comments of       CommentBefore [] -> NoMargin-      CommentAfter  [] -> NoMargin-      NoComment        -> NoMargin-      _                -> Margin+      CommentAfter [] -> NoMargin+      NoComment -> NoMargin+      _ -> Margin      (lines', after) = case lines narrow of-        []           -> ([ name' ++ ":" ], NoMargin)-        [singleLine] | length singleLine < 60-                     -> ([ name' ++ ": " ++ replicate (fw - length name') ' ' ++ narrow ], NoMargin)-        _            -> ((name' ++ ":") : map indent (lines (PP.render doc)), Margin)+      [] -> ([name' ++ ":"], NoMargin)+      [singleLine]+        | length singleLine < 60 ->+            ([name' ++ ": " ++ replicate (fw - length name') ' ' ++ narrow], NoMargin)+      _ -> ((name' ++ ":") : map indent (lines (PP.render doc)), Margin)      name' = fromUTF8BS name     narrow = PP.renderStyle narrowStyle doc      narrowStyle :: PP.Style-    narrowStyle = PP.style { PP.lineLength = PP.lineLength PP.style - fw }--renderField opts@(Opts rann indent post) _ (PrettySection ann name args fields) = Block Margin Margin $-+    narrowStyle = PP.style{PP.lineLength = PP.lineLength PP.style - fw}+renderField opts@(Opts rann indent post) _ (PrettySection ann name args fields) =+  Block Margin Margin $     attachComments-      (post ann [ PP.render $ PP.hsep $ PP.text (fromUTF8BS name) : args ])-    ++-    map indent (renderFields opts fields)+      (post ann [PP.render $ PP.hsep $ PP.text (fromUTF8BS name) : args])+      ++ map indent (renderFields opts fields)   where     attachComments content = case rann ann of       CommentBefore cs -> cs ++ content-      CommentAfter  cs -> content ++ cs-      NoComment        -> content-+      CommentAfter cs -> content ++ cs+      NoComment -> content renderField _ _ PrettyEmpty = Block NoMargin NoMargin mempty  -------------------------------------------------------------------------------@@ -171,20 +172,24 @@ -------------------------------------------------------------------------------  genericFromParsecFields-    :: Applicative f-    => (FieldName -> [P.FieldLine ann] -> f PP.Doc)     -- ^ transform field contents-    -> (FieldName -> [P.SectionArg ann] -> f [PP.Doc])  -- ^ transform section arguments-    -> [P.Field ann]-    -> f [PrettyField ann]-genericFromParsecFields f g = goMany where+  :: Applicative f+  => (FieldName -> [P.FieldLine ann] -> f PP.Doc)+  -- ^ transform field contents+  -> (FieldName -> [P.SectionArg ann] -> f [PP.Doc])+  -- ^ transform section arguments+  -> [P.Field ann]+  -> f [PrettyField ann]+genericFromParsecFields f g = goMany+  where     goMany = traverse go -    go (P.Field (P.Name ann name) fls)          = PrettyField ann name <$> f name fls+    go (P.Field (P.Name ann name) fls) = PrettyField ann name <$> f name fls     go (P.Section (P.Name ann name) secargs fs) = PrettySection ann name <$> g name secargs <*> goMany fs  -- | Used in 'fromParsecFields'. prettyFieldLines :: FieldName -> [P.FieldLine ann] -> PP.Doc-prettyFieldLines _ fls = PP.vcat+prettyFieldLines _ fls =+  PP.vcat     [ PP.text $ fromUTF8BS bs     | P.FieldLine _ bs <- fls     ]@@ -192,15 +197,17 @@ -- | Used in 'fromParsecFields'. prettySectionArgs :: FieldName -> [P.SectionArg ann] -> [PP.Doc] prettySectionArgs _ = map $ \case-    P.SecArgName _ bs  -> showToken $ fromUTF8BS bs-    P.SecArgStr _ bs   -> showToken $ fromUTF8BS bs-    P.SecArgOther _ bs -> PP.text $ fromUTF8BS bs+  P.SecArgName _ bs -> showToken $ fromUTF8BS bs+  P.SecArgStr _ bs -> showToken $ fromUTF8BS bs+  P.SecArgOther _ bs -> PP.text $ fromUTF8BS bs  -- | Simple variant of 'genericFromParsecField' fromParsecFields :: [P.Field ann] -> [PrettyField ann]-fromParsecFields = runIdentity . genericFromParsecFields-    (Identity .: prettyFieldLines)-    (Identity .: prettySectionArgs)+fromParsecFields =+  runIdentity+    . genericFromParsecFields+      (Identity .: prettyFieldLines)+      (Identity .: prettySectionArgs)   where     (.:) :: (a -> b) -> (c -> d -> a) -> (c -> d -> b)     (f .: g) x y = f (g x y)
src/Distribution/InstalledPackageInfo.hs view
@@ -1,4 +1,7 @@ -----------------------------------------------------------------------------++-- This module is meant to be local-only to Distribution...+ -- | -- Module      :  Distribution.InstalledPackageInfo -- Copyright   :  (c) The University of Glasgow 2004@@ -21,52 +24,49 @@ -- about an installed package. There is a parser and pretty printer. The -- textual format is rather simpler than the @.cabal@ format: there are no -- sections, for example.---- This module is meant to be local-only to Distribution...--module Distribution.InstalledPackageInfo (-        InstalledPackageInfo(..),-        installedComponentId,-        installedOpenUnitId,-        sourceComponentName,-        requiredSignatures,-        ExposedModule(..),-        AbiDependency(..),-        emptyInstalledPackageInfo,-        parseInstalledPackageInfo,-        showInstalledPackageInfo,-        showFullInstalledPackageInfo,-        showInstalledPackageInfoField,-        showSimpleInstalledPackageInfoField,+module Distribution.InstalledPackageInfo+  ( InstalledPackageInfo (..)+  , installedComponentId+  , installedOpenUnitId+  , sourceComponentName+  , requiredSignatures+  , ExposedModule (..)+  , AbiDependency (..)+  , emptyInstalledPackageInfo+  , parseInstalledPackageInfo+  , showInstalledPackageInfo+  , showFullInstalledPackageInfo+  , showInstalledPackageInfoField+  , showSimpleInstalledPackageInfoField   ) where  import Distribution.Compat.Prelude import Prelude ()  import Distribution.Backpack-import Distribution.CabalSpecVersion         (cabalSpecLatest)+import Distribution.CabalSpecVersion (cabalSpecLatest) import Distribution.FieldGrammar import Distribution.FieldGrammar.FieldDescrs import Distribution.Fields.Pretty import Distribution.ModuleName-import Distribution.Package                  hiding (installedUnitId)+import Distribution.Package hiding (installedUnitId) import Distribution.Types.ComponentName-import Distribution.Utils.Generic            (toUTF8BS)+import Distribution.Utils.Generic (toUTF8BS)  import Data.ByteString (ByteString) -import qualified Data.Map            as Map+import qualified Data.Map as Map import qualified Distribution.Fields as P-import qualified Text.PrettyPrint    as Disp+import qualified Text.PrettyPrint as Disp  import Distribution.Types.InstalledPackageInfo import Distribution.Types.InstalledPackageInfo.FieldGrammar  installedComponentId :: InstalledPackageInfo -> ComponentId installedComponentId ipi =-    case unComponentId (installedComponentId_ ipi) of-        "" -> mkComponentId (unUnitId (installedUnitId ipi))-        _  -> installedComponentId_ ipi+  case unComponentId (installedComponentId_ ipi) of+    "" -> mkComponentId (unUnitId (installedUnitId ipi))+    _ -> installedComponentId_ ipi  -- | Get the indefinite unit identity representing this package. -- This IS NOT guaranteed to give you a substitution; for@@ -74,8 +74,8 @@ -- For indefinite libraries, however, you will correctly get -- an @OpenUnitId@ with the appropriate 'OpenModuleSubst'. installedOpenUnitId :: InstalledPackageInfo -> OpenUnitId-installedOpenUnitId ipi-    = mkOpenUnitId (installedUnitId ipi) (installedComponentId ipi) (Map.fromList (instantiatedWith ipi))+installedOpenUnitId ipi =+  mkOpenUnitId (installedUnitId ipi) (installedComponentId ipi) (Map.fromList (instantiatedWith ipi))  -- | Returns the set of module names which need to be filled for -- an indefinite package, or the empty set if the package is definite.@@ -93,20 +93,23 @@  -- | Return either errors, or IPI with list of warnings parseInstalledPackageInfo-    :: ByteString-    -> Either (NonEmpty String) ([String], InstalledPackageInfo)+  :: ByteString+  -> Either (NonEmpty String) ([String], InstalledPackageInfo) parseInstalledPackageInfo s = case P.readFields s of-    Left err -> Left (show err :| [])-    Right fs -> case partitionFields fs of-        (fs', _) -> case P.runParseResult $ parseFieldGrammar cabalSpecLatest fs' ipiFieldGrammar of-            (ws, Right x) -> x `deepseq` Right (ws', x) where-                ws' = [ P.showPWarning "" w-                      | w@(P.PWarning wt _ _) <- ws-                      -- filter out warnings about experimental features-                      , wt /= P.PWTExperimental-                      ]-            (_,  Left (_, errs)) -> Left errs' where-                errs' = fmap (P.showPError "") errs+  Left err -> Left (show err :| [])+  Right fs -> case partitionFields fs of+    (fs', _) -> case P.runParseResult $ parseFieldGrammar cabalSpecLatest fs' ipiFieldGrammar of+      (ws, Right x) -> x `deepseq` Right (ws', x)+        where+          ws' =+            [ P.showPWarning "" w+            | w@(P.PWarning wt _ _) <- ws+            , -- filter out warnings about experimental features+            wt /= P.PWTExperimental+            ]+      (_, Left (_, errs)) -> Left errs'+        where+          errs' = fmap (P.showPError "") errs  -- ----------------------------------------------------------------------------- -- Pretty-printing@@ -116,7 +119,7 @@ -- @pkgRoot@ isn't printed, as ghc-pkg prints it manually (as GHC-8.4). showInstalledPackageInfo :: InstalledPackageInfo -> String showInstalledPackageInfo ipi =-    showFullInstalledPackageInfo ipi { pkgRoot = Nothing }+  showFullInstalledPackageInfo ipi{pkgRoot = Nothing}  -- | The variant of 'showInstalledPackageInfo' which outputs @pkgroot@ field too. showFullInstalledPackageInfo :: InstalledPackageInfo -> String@@ -129,15 +132,15 @@ -- Just "maintainer: Tester" showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String) showInstalledPackageInfoField fn =-    fmap (\g -> Disp.render . ppField fn . g) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)+  fmap (\g -> Disp.render . ppField fn . g) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)  showSimpleInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String) showSimpleInstalledPackageInfoField fn =-    fmap (Disp.renderStyle myStyle .) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)+  fmap (Disp.renderStyle myStyle .) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)   where-    myStyle = Disp.style { Disp.mode = Disp.LeftMode }+    myStyle = Disp.style{Disp.mode = Disp.LeftMode}  ppField :: String -> Disp.Doc -> Disp.Doc ppField name fielddoc-     | Disp.isEmpty fielddoc = mempty-     | otherwise             = Disp.text name <<>> Disp.colon Disp.<+> fielddoc+  | Disp.isEmpty fielddoc = mempty+  | otherwise = Disp.text name <<>> Disp.colon Disp.<+> fielddoc
src/Distribution/License.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}  -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.License -- Description :  The License data type.@@ -41,12 +42,11 @@ -- intended for informational purposes only and in no way constitute legal -- advice. Please read the text of the licenses and consult a lawyer for any -- advice regarding software licensing.--module Distribution.License (-    License(..),-    knownLicenses,-    licenseToSPDX,-    licenseFromSPDX,+module Distribution.License+  ( License (..)+  , knownLicenses+  , licenseToSPDX+  , licenseFromSPDX   ) where  import Distribution.Compat.Prelude@@ -56,76 +56,62 @@ import Distribution.Pretty import Distribution.Version +import qualified Data.Map.Strict as Map import qualified Distribution.Compat.CharParsing as P-import qualified Data.Map.Strict                 as Map-import qualified Distribution.SPDX               as SPDX-import qualified Text.PrettyPrint                as Disp+import qualified Distribution.SPDX as SPDX+import qualified Text.PrettyPrint as Disp  -- | Indicates the license under which a package's source code is released. -- Versions of the licenses not listed here will be rejected by Hackage and -- cause @cabal check@ to issue a warning.-data License =-    -- TODO: * remove BSD4+data License+  = -- TODO: * remove BSD4      -- | GNU General Public License,     -- <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html version 2> or     -- <https://www.gnu.org/licenses/gpl.html version 3>.     GPL (Maybe Version)--    -- | <https://www.gnu.org/licenses/agpl.html GNU Affero General Public License, version 3>.-  | AGPL (Maybe Version)--    -- | GNU Lesser General Public License,+  | -- | <https://www.gnu.org/licenses/agpl.html GNU Affero General Public License, version 3>.+    AGPL (Maybe Version)+  | -- | GNU Lesser General Public License,     -- <https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html version 2.1> or     -- <https://www.gnu.org/licenses/lgpl.html version 3>.-  | LGPL (Maybe Version)--    -- | <http://www.opensource.org/licenses/bsd-license 2-clause BSD license>.-  | BSD2--    -- | <http://www.opensource.org/licenses/bsd-3-clause 3-clause BSD license>.-  | BSD3--    -- | <http://directory.fsf.org/wiki/License:BSD_4Clause 4-clause BSD license>.+    LGPL (Maybe Version)+  | -- | <http://www.opensource.org/licenses/bsd-license 2-clause BSD license>.+    BSD2+  | -- | <http://www.opensource.org/licenses/bsd-3-clause 3-clause BSD license>.+    BSD3+  | -- | <http://directory.fsf.org/wiki/License:BSD_4Clause 4-clause BSD license>.     -- This license has not been approved by the OSI and is incompatible with     -- the GNU GPL. It is provided for historical reasons and should be avoided.-  | BSD4--    -- | <http://www.opensource.org/licenses/MIT MIT license>.-  | MIT--    -- | <http://www.isc.org/downloads/software-support-policy/isc-license/ ISC license>-  | ISC--    -- | <https://www.mozilla.org/MPL/ Mozilla Public License, version 2.0>.-  | MPL Version--    -- | <https://www.apache.org/licenses/ Apache License, version 2.0>.-  | Apache (Maybe Version)--    -- | The author of a package disclaims any copyright to its source code and+    BSD4+  | -- | <http://www.opensource.org/licenses/MIT MIT license>.+    MIT+  | -- | <http://www.isc.org/downloads/software-support-policy/isc-license/ ISC license>+    ISC+  | -- | <https://www.mozilla.org/MPL/ Mozilla Public License, version 2.0>.+    MPL Version+  | -- | <https://www.apache.org/licenses/ Apache License, version 2.0>.+    Apache (Maybe Version)+  | -- | The author of a package disclaims any copyright to its source code and     -- dedicates it to the public domain. This is not a software license. Please     -- note that it is not possible to dedicate works to the public domain in     -- every jurisdiction, nor is a work that is in the public domain in one     -- jurisdiction necessarily in the public domain elsewhere.-  | PublicDomain--    -- | Explicitly 'All Rights Reserved', eg for proprietary software. The+    PublicDomain+  | -- | Explicitly 'All Rights Reserved', eg for proprietary software. The     -- package may not be legally modified or redistributed by anyone but the     -- rightsholder.-  | AllRightsReserved--    -- | No license specified which legally defaults to 'All Rights Reserved'.+    AllRightsReserved+  | -- | No license specified which legally defaults to 'All Rights Reserved'.     -- The package may not be legally modified or redistributed by anyone but     -- the rightsholder.-  | UnspecifiedLicense--    -- | Any other software license.-  | OtherLicense--    -- | Indicates an erroneous license name.-  | UnknownLicense String-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+    UnspecifiedLicense+  | -- | Any other software license.+    OtherLicense+  | -- | Indicates an erroneous license name.+    UnknownLicense String+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary License instance Structured License@@ -133,16 +119,29 @@  -- | The list of all currently recognised licenses. knownLicenses :: [License]-knownLicenses = [ GPL  unversioned, GPL  (version [2]),    GPL  (version [3])-                , LGPL unversioned, LGPL (version [2, 1]), LGPL (version [3])-                , AGPL unversioned,                        AGPL (version [3])-                , BSD2, BSD3, MIT, ISC-                , MPL (mkVersion [2, 0])-                , Apache unversioned, Apache (version [2, 0])-                , PublicDomain, AllRightsReserved, OtherLicense]+knownLicenses =+  [ GPL unversioned+  , GPL (version [2])+  , GPL (version [3])+  , LGPL unversioned+  , LGPL (version [2, 1])+  , LGPL (version [3])+  , AGPL unversioned+  , AGPL (version [3])+  , BSD2+  , BSD3+  , MIT+  , ISC+  , MPL (mkVersion [2, 0])+  , Apache unversioned+  , Apache (version [2, 0])+  , PublicDomain+  , AllRightsReserved+  , OtherLicense+  ]   where     unversioned = Nothing-    version     = Just . mkVersion+    version = Just . mkVersion  -- | Convert old 'License' to SPDX 'SPDX.License'. -- Non-SPDX licenses are converted to 'SPDX.LicenseRef'.@@ -150,28 +149,28 @@ -- @since 2.2.0.0 licenseToSPDX :: License -> SPDX.License licenseToSPDX l = case l of-    GPL v | v == version [2]      -> spdx SPDX.GPL_2_0_only-    GPL v | v == version [3]      -> spdx SPDX.GPL_3_0_only-    LGPL v | v == version [2,1]   -> spdx SPDX.LGPL_2_1_only-    LGPL v | v == version [3]     -> spdx SPDX.LGPL_3_0_only-    AGPL v | v == version [3]     -> spdx SPDX.AGPL_3_0_only-    BSD2                          -> spdx SPDX.BSD_2_Clause-    BSD3                          -> spdx SPDX.BSD_3_Clause-    BSD4                          -> spdx SPDX.BSD_4_Clause-    MIT                           -> spdx SPDX.MIT-    ISC                           -> spdx SPDX.ISC-    MPL v | v == mkVersion [2,0]  -> spdx SPDX.MPL_2_0-    Apache v | v == version [2,0] -> spdx SPDX.Apache_2_0-    AllRightsReserved             -> SPDX.NONE-    UnspecifiedLicense            -> SPDX.NONE-    OtherLicense                  -> ref (SPDX.mkLicenseRef' Nothing "OtherLicense")-    PublicDomain                  -> ref (SPDX.mkLicenseRef' Nothing "PublicDomain")-    UnknownLicense str            -> ref (SPDX.mkLicenseRef' Nothing str)-    _                             -> ref (SPDX.mkLicenseRef' Nothing $ prettyShow l)+  GPL v | v == version [2] -> spdx SPDX.GPL_2_0_only+  GPL v | v == version [3] -> spdx SPDX.GPL_3_0_only+  LGPL v | v == version [2, 1] -> spdx SPDX.LGPL_2_1_only+  LGPL v | v == version [3] -> spdx SPDX.LGPL_3_0_only+  AGPL v | v == version [3] -> spdx SPDX.AGPL_3_0_only+  BSD2 -> spdx SPDX.BSD_2_Clause+  BSD3 -> spdx SPDX.BSD_3_Clause+  BSD4 -> spdx SPDX.BSD_4_Clause+  MIT -> spdx SPDX.MIT+  ISC -> spdx SPDX.ISC+  MPL v | v == mkVersion [2, 0] -> spdx SPDX.MPL_2_0+  Apache v | v == version [2, 0] -> spdx SPDX.Apache_2_0+  AllRightsReserved -> SPDX.NONE+  UnspecifiedLicense -> SPDX.NONE+  OtherLicense -> ref (SPDX.mkLicenseRef' Nothing "OtherLicense")+  PublicDomain -> ref (SPDX.mkLicenseRef' Nothing "PublicDomain")+  UnknownLicense str -> ref (SPDX.mkLicenseRef' Nothing str)+  _ -> ref (SPDX.mkLicenseRef' Nothing $ prettyShow l)   where     version = Just . mkVersion-    spdx    = SPDX.License . SPDX.simpleLicenseExpression-    ref  r  = SPDX.License $ SPDX.ELicense (SPDX.ELicenseRef r) Nothing+    spdx = SPDX.License . SPDX.simpleLicenseExpression+    ref r = SPDX.License $ SPDX.ELicense (SPDX.ELicenseRef r) Nothing  -- | Convert 'SPDX.License' to 'License', --@@ -199,11 +198,13 @@ licenseFromSPDX :: SPDX.License -> License licenseFromSPDX SPDX.NONE = AllRightsReserved licenseFromSPDX l =-    fromMaybe (mungle $ prettyShow l) $ Map.lookup l m+  fromMaybe (mungle $ prettyShow l) $ Map.lookup l m   where     m :: Map.Map SPDX.License License-    m = Map.fromList $ filter (isSimple . fst ) $-        map (\x -> (licenseToSPDX x, x)) knownLicenses+    m =+      Map.fromList $+        filter (isSimple . fst) $+          map (\x -> (licenseToSPDX x, x)) knownLicenses      isSimple (SPDX.License (SPDX.ELicense (SPDX.ELicenseId _) Nothing)) = True     isSimple _ = False@@ -211,41 +212,43 @@     mungle name = fromMaybe (UnknownLicense (mapMaybe mangle name)) (simpleParsec name)      mangle c-        | isAlphaNum c = Just c-        | otherwise = Nothing+      | isAlphaNum c = Just c+      | otherwise = Nothing  instance Pretty License where-  pretty (GPL  version)         = Disp.text "GPL"    <<>> dispOptVersion version-  pretty (LGPL version)         = Disp.text "LGPL"   <<>> dispOptVersion version-  pretty (AGPL version)         = Disp.text "AGPL"   <<>> dispOptVersion version-  pretty (MPL  version)         = Disp.text "MPL"    <<>> dispVersion    version-  pretty (Apache version)       = Disp.text "Apache" <<>> dispOptVersion version+  pretty (GPL version) = Disp.text "GPL" <<>> dispOptVersion version+  pretty (LGPL version) = Disp.text "LGPL" <<>> dispOptVersion version+  pretty (AGPL version) = Disp.text "AGPL" <<>> dispOptVersion version+  pretty (MPL version) = Disp.text "MPL" <<>> dispVersion version+  pretty (Apache version) = Disp.text "Apache" <<>> dispOptVersion version   pretty (UnknownLicense other) = Disp.text other-  pretty other                  = Disp.text (show other)+  pretty other = Disp.text (show other)  instance Parsec License where   parsec = do-    name    <- P.munch1 isAlphaNum+    name <- P.munch1 isAlphaNum     version <- P.optional (P.char '-' *> parsec)     return $! case (name, version :: Maybe Version) of-      ("GPL",               _      )  -> GPL  version-      ("LGPL",              _      )  -> LGPL version-      ("AGPL",              _      )  -> AGPL version-      ("BSD2",              Nothing)  -> BSD2-      ("BSD3",              Nothing)  -> BSD3-      ("BSD4",              Nothing)  -> BSD4-      ("ISC",               Nothing)  -> ISC-      ("MIT",               Nothing)  -> MIT-      ("MPL",         Just version')  -> MPL version'-      ("Apache",            _      )  -> Apache version-      ("PublicDomain",      Nothing)  -> PublicDomain-      ("AllRightsReserved", Nothing)  -> AllRightsReserved-      ("OtherLicense",      Nothing)  -> OtherLicense-      _                               -> UnknownLicense $ name ++-                                         maybe "" (('-':) . prettyShow) version+      ("GPL", _) -> GPL version+      ("LGPL", _) -> LGPL version+      ("AGPL", _) -> AGPL version+      ("BSD2", Nothing) -> BSD2+      ("BSD3", Nothing) -> BSD3+      ("BSD4", Nothing) -> BSD4+      ("ISC", Nothing) -> ISC+      ("MIT", Nothing) -> MIT+      ("MPL", Just version') -> MPL version'+      ("Apache", _) -> Apache version+      ("PublicDomain", Nothing) -> PublicDomain+      ("AllRightsReserved", Nothing) -> AllRightsReserved+      ("OtherLicense", Nothing) -> OtherLicense+      _ ->+        UnknownLicense $+          name+            ++ maybe "" (('-' :) . prettyShow) version  dispOptVersion :: Maybe Version -> Disp.Doc-dispOptVersion Nothing  = Disp.empty+dispOptVersion Nothing = Disp.empty dispOptVersion (Just v) = dispVersion v  dispVersion :: Version -> Disp.Doc
src/Distribution/ModuleName.hs view
@@ -1,8 +1,10 @@-{-# LANGUAGE BangPatterns        #-}-{-# LANGUAGE DeriveDataTypeable  #-}-{-# LANGUAGE DeriveGeneric       #-}+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE ScopedTypeVariables #-}+ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.ModuleName -- Copyright   :  Duncan Coutts 2008@@ -12,16 +14,16 @@ -- Portability :  portable -- -- Data type for Haskell module names.+module Distribution.ModuleName+  ( ModuleName+  , fromString+  , fromComponents+  , components+  , toFilePath+  , main -module Distribution.ModuleName (-        ModuleName,-        fromString,-        fromComponents,-        components,-        toFilePath,-        main,-        -- * Internal-        validModuleComponent,+    -- * Internal+  , validModuleComponent   ) where  import Distribution.Compat.Prelude@@ -30,16 +32,15 @@ import Distribution.Parsec import Distribution.Pretty import Distribution.Utils.ShortText (ShortText, fromShortText, toShortText)-import System.FilePath              (pathSeparator)+import System.FilePath (pathSeparator)  import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.Compat.DList       as DList-import qualified Text.PrettyPrint                as Disp+import qualified Distribution.Compat.DList as DList+import qualified Text.PrettyPrint as Disp  -- | A valid Haskell module name.--- newtype ModuleName = ModuleName ShortText-  deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)+  deriving (Eq, Generic, Ord, Read, Show, Data)  unModuleName :: ModuleName -> String unModuleName (ModuleName s) = fromShortText s@@ -48,16 +49,17 @@ instance Structured ModuleName  instance NFData ModuleName where-    rnf (ModuleName ms) = rnf ms+  rnf (ModuleName ms) = rnf ms  instance Pretty ModuleName where   pretty = Disp.text . unModuleName  instance Parsec ModuleName where-    parsec = parsecModuleName+  parsec = parsecModuleName  parsecModuleName :: forall m. CabalParsing m => m ModuleName-parsecModuleName = state0 DList.empty where+parsecModuleName = state0 DList.empty+  where     upper :: m Char     !upper = P.satisfy isUpper @@ -69,34 +71,33 @@      state0 :: DList.DList Char -> m ModuleName     state0 acc = do-        c <- upper-        state1 (DList.snoc acc c)+      c <- upper+      state1 (DList.snoc acc c)      state1 :: DList.DList Char -> m ModuleName     state1 acc = state1' acc `alt` return (fromString (DList.toList acc))      state1' :: DList.DList Char -> m ModuleName     state1' acc = do-        c <- ch-        case c of-            '.' -> state0 (DList.snoc acc c)-            _   -> state1 (DList.snoc acc c)+      c <- ch+      case c of+        '.' -> state0 (DList.snoc acc c)+        _ -> state1 (DList.snoc acc c)  validModuleChar :: Char -> Bool validModuleChar c = isAlphaNum c || c == '_' || c == '\''  validModuleComponent :: String -> Bool-validModuleComponent []     = False-validModuleComponent (c:cs) = isUpper c && all validModuleChar cs+validModuleComponent [] = False+validModuleComponent (c : cs) = isUpper c && all validModuleChar cs  -- | Construct a 'ModuleName' from a valid module name 'String'. -- -- This is just a convenience function intended for valid module strings. It is -- an error if it is used with a string that is not a valid module name. If you -- are parsing user input then use 'Distribution.Text.simpleParse' instead.--- instance IsString ModuleName where-    fromString = ModuleName . toShortText+  fromString = ModuleName . toShortText  -- | Construct a 'ModuleName' from valid module components, i.e. parts -- separated by dots.@@ -105,27 +106,25 @@ {-# DEPRECATED fromComponents "Exists for cabal-install only" #-}  -- | The module name @Main@.--- main :: ModuleName main = ModuleName (fromString "Main")  -- | The individual components of a hierarchical module name. For example -- -- > components (fromString "A.B.C") = ["A", "B", "C"]--- components :: ModuleName -> [String] components mn = split (unModuleName mn)   where-    split cs = case break (=='.') cs of-      (chunk,[])     -> chunk : []-      (chunk,_:rest) -> chunk : split rest+    split cs = case break (== '.') cs of+      (chunk, []) -> chunk : []+      (chunk, _ : rest) -> chunk : split rest  -- | Convert a module name to a file path, but without any file extension. -- For example: -- -- > toFilePath (fromString "A.B.C") = "A/B/C"--- toFilePath :: ModuleName -> FilePath-toFilePath = map f . unModuleName where+toFilePath = map f . unModuleName+  where     f '.' = pathSeparator-    f c   = c+    f c = c
src/Distribution/Package.hs view
@@ -1,8 +1,5 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}- -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Package -- Copyright   :  Isaac Jones 2003-2004@@ -15,7 +12,6 @@ -- 'PackageIdentifier's consist of a name and an exact version. It also defines -- a 'Dependency' data type. A dependency is a package name and a version -- range, like @\"foo >= 1.2 && < 2\"@.- module Distribution.Package   ( module Distribution.Types.AbiHash   , module Distribution.Types.ComponentId@@ -25,28 +21,33 @@   , module Distribution.Types.PackageName   , module Distribution.Types.PkgconfigName   , module Distribution.Types.Dependency-  , Package(..), packageName, packageVersion-  , HasMungedPackageId(..), mungedName', mungedVersion'-  , HasUnitId(..)-  , PackageInstalled(..)+  , Package (..)+  , packageName+  , packageVersion+  , HasMungedPackageId (..)+  , mungedName'+  , mungedVersion'+  , HasUnitId (..)+  , PackageInstalled (..)   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Version-         ( Version )+  ( Version+  )  import Distribution.Types.AbiHash import Distribution.Types.ComponentId import Distribution.Types.Dependency-import Distribution.Types.MungedPackageId-import Distribution.Types.PackageId-import Distribution.Types.UnitId import Distribution.Types.Module+import Distribution.Types.MungedPackageId import Distribution.Types.MungedPackageName+import Distribution.Types.PackageId import Distribution.Types.PackageName import Distribution.Types.PkgconfigName+import Distribution.Types.UnitId  -- | Class of things that have a 'PackageIdentifier' --@@ -57,15 +58,14 @@ -- Not all kinds of packages can be uniquely identified by a -- 'PackageIdentifier'. In particular, installed packages cannot, there may be -- many installed instances of the same source package.--- class Package pkg where-  packageId  :: pkg -> PackageIdentifier+  packageId :: pkg -> PackageIdentifier -mungedName'    :: HasMungedPackageId pkg => pkg -> MungedPackageName-mungedName'     = mungedName    . mungedId+mungedName' :: HasMungedPackageId pkg => pkg -> MungedPackageName+mungedName' = mungedName . mungedId  mungedVersion' :: HasMungedPackageId munged => munged -> Version-mungedVersion'  = mungedVersion . mungedId+mungedVersion' = mungedVersion . mungedId  class HasMungedPackageId pkg where   mungedId :: pkg -> MungedPackageId@@ -73,11 +73,11 @@ instance Package PackageIdentifier where   packageId = id -packageName    :: Package pkg => pkg -> PackageName-packageName     = pkgName    . packageId+packageName :: Package pkg => pkg -> PackageName+packageName = pkgName . packageId  packageVersion :: Package pkg => pkg -> Version-packageVersion  = pkgVersion . packageId+packageVersion = pkgVersion . packageId  instance HasMungedPackageId MungedPackageId where   mungedId = id@@ -92,5 +92,5 @@ -- 'InstalledPackageInfo', but when we are doing install plans in Cabal install -- we may have other, installed package-like things which contain more metadata. -- Installed packages have exact dependencies 'installedDepends'.-class (HasUnitId pkg) => PackageInstalled pkg where+class HasUnitId pkg => PackageInstalled pkg where   installedDepends :: pkg -> [UnitId]
src/Distribution/PackageDescription.hs view
@@ -1,4 +1,5 @@ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.PackageDescription -- Copyright   :  Isaac Jones 2003-2005@@ -9,81 +10,95 @@ -- -- Backwards compatibility reexport of most things you need to know -- about @.cabal@ files.+module Distribution.PackageDescription+  ( -- * PD and GPD+      module Distribution.Types.PackageDescription+  , module Distribution.Types.GenericPackageDescription -module Distribution.PackageDescription (-    -- * PD and GPD-    module Distribution.Types.PackageDescription,-    module Distribution.Types.GenericPackageDescription,     -- * Components-    module Distribution.Types.ComponentName,+  , module Distribution.Types.ComponentName+     -- ** Library-    module Distribution.Types.Library,-    module Distribution.Types.LibraryName,-    module Distribution.Types.LibraryVisibility,+  , module Distribution.Types.Library+  , module Distribution.Types.LibraryName+  , module Distribution.Types.LibraryVisibility+     -- ** Executable-    module Distribution.Types.Executable,-    module Distribution.Types.ExecutableScope,+  , module Distribution.Types.Executable+  , module Distribution.Types.ExecutableScope+     -- ** TestSuite-    module Distribution.Types.TestSuite,-    module Distribution.Types.TestType,-    module Distribution.Types.TestSuiteInterface,+  , module Distribution.Types.TestSuite+  , module Distribution.Types.TestType+  , module Distribution.Types.TestSuiteInterface+     -- ** Benchmark-    module Distribution.Types.Benchmark,-    module Distribution.Types.BenchmarkType,-    module Distribution.Types.BenchmarkInterface,+  , module Distribution.Types.Benchmark+  , module Distribution.Types.BenchmarkType+  , module Distribution.Types.BenchmarkInterface+     -- ** Foreign library-    module Distribution.Types.ForeignLib,-    module Distribution.Types.ForeignLibType,-    module Distribution.Types.ForeignLibOption,+  , module Distribution.Types.ForeignLib+  , module Distribution.Types.ForeignLibType+  , module Distribution.Types.ForeignLibOption+     -- * BuildInfo-    module Distribution.Types.BuildType,-    module Distribution.Types.BuildInfo,-    module Distribution.Types.HookedBuildInfo,-    module Distribution.Types.SetupBuildInfo,+  , module Distribution.Types.BuildType+  , module Distribution.Types.BuildInfo+  , module Distribution.Types.HookedBuildInfo+  , module Distribution.Types.SetupBuildInfo+     -- * Flags-    module Distribution.Types.Flag,+  , module Distribution.Types.Flag+     -- * Identifiers-    module Distribution.Types.PackageId,-    module Distribution.Types.PackageName,-    module Distribution.Types.UnqualComponentName,+  , module Distribution.Types.PackageId+  , module Distribution.Types.PackageName+  , module Distribution.Types.UnqualComponentName+     -- * Pkgconfig-    module Distribution.Types.PkgconfigName,-    module Distribution.Types.PkgconfigVersion,-    module Distribution.Types.PkgconfigVersionRange,+  , module Distribution.Types.PkgconfigName+  , module Distribution.Types.PkgconfigVersion+  , module Distribution.Types.PkgconfigVersionRange+     -- * Dependencies-    module Distribution.Types.Dependency,-    module Distribution.Types.ExeDependency,-    module Distribution.Types.LegacyExeDependency,-    module Distribution.Types.PkgconfigDependency,+  , module Distribution.Types.Dependency+  , module Distribution.Types.ExeDependency+  , module Distribution.Types.LegacyExeDependency+  , module Distribution.Types.PkgconfigDependency+     -- * Condition trees-    module Distribution.Types.CondTree,-    module Distribution.Types.Condition,-    module Distribution.Types.ConfVar,+  , module Distribution.Types.CondTree+  , module Distribution.Types.Condition+  , module Distribution.Types.ConfVar+     -- * Mixin-   module Distribution.Types.IncludeRenaming,-   module Distribution.Types.Mixin,-   module Distribution.Types.ModuleReexport,-   module Distribution.Types.ModuleRenaming,+  , module Distribution.Types.IncludeRenaming+  , module Distribution.Types.Mixin+  , module Distribution.Types.ModuleReexport+  , module Distribution.Types.ModuleRenaming+     -- * Source repository-    module Distribution.Types.SourceRepo,+  , module Distribution.Types.SourceRepo   ) where  import Prelude ()---import Distribution.Compat.Prelude +-- import Distribution.Compat.Prelude+ import Distribution.Types.Benchmark import Distribution.Types.BenchmarkInterface import Distribution.Types.BenchmarkType import Distribution.Types.BuildInfo import Distribution.Types.BuildType import Distribution.Types.ComponentName-import Distribution.Types.Condition import Distribution.Types.CondTree+import Distribution.Types.Condition import Distribution.Types.ConfVar import Distribution.Types.Dependency+import Distribution.Types.ExeDependency import Distribution.Types.Executable import Distribution.Types.ExecutableScope-import Distribution.Types.ExeDependency import Distribution.Types.Flag import Distribution.Types.ForeignLib import Distribution.Types.ForeignLibOption
src/Distribution/PackageDescription/Configuration.hs view
@@ -1,6 +1,8 @@--- -fno-warn-deprecations for use of Map.foldWithKey-{-# OPTIONS_GHC -fno-warn-deprecations #-}+-- -Wno-deprecations for use of Map.foldWithKey+{-# OPTIONS_GHC -Wno-deprecations #-}+ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.PackageDescription.Configuration -- Copyright   :  Thomas Schilling, 2007@@ -14,76 +16,79 @@ -- functions for converting 'GenericPackageDescription's down to -- 'PackageDescription's. It has code for working with the tree of conditions -- and resolving or flattening conditions.--module Distribution.PackageDescription.Configuration (-    finalizePD,-    flattenPackageDescription,--    -- Utils-    parseCondition,-    freeVars,-    extractCondition,-    extractConditions,-    addBuildableCondition,-    mapCondTree,-    mapTreeData,-    mapTreeConds,-    mapTreeConstrs,-    transformAllBuildInfos,-    transformAllBuildDepends,-    transformAllBuildDependsN,-    simplifyWithSysParams+module Distribution.PackageDescription.Configuration+  ( finalizePD+  , flattenPackageDescription+  -- Utils+  , parseCondition+  , freeVars+  , extractCondition+  , extractConditions+  , addBuildableCondition+  , mapCondTree+  , mapTreeData+  , mapTreeConds+  , mapTreeConstrs+  , transformAllBuildInfos+  , transformAllBuildDepends+  , transformAllBuildDependsN+  , simplifyWithSysParams   ) where  import Distribution.Compat.Prelude import Prelude ()  -- lens-import qualified Distribution.Types.BuildInfo.Lens                 as L+import qualified Distribution.Types.BuildInfo.Lens as L import qualified Distribution.Types.GenericPackageDescription.Lens as L-import qualified Distribution.Types.PackageDescription.Lens        as L-import qualified Distribution.Types.SetupBuildInfo.Lens            as L+import qualified Distribution.Types.PackageDescription.Lens as L+import qualified Distribution.Types.SetupBuildInfo.Lens as L -import           Distribution.Compat.CharParsing             hiding (char)-import qualified Distribution.Compat.CharParsing             as P-import           Distribution.Compat.Lens-import           Distribution.Compiler-import           Distribution.PackageDescription-import           Distribution.PackageDescription.Utils-import           Distribution.Parsec-import           Distribution.Pretty-import           Distribution.System-import           Distribution.Types.Component-import Distribution.Utils.Path-import           Distribution.Types.ComponentRequestedSpec-import           Distribution.Types.DependencyMap-import           Distribution.Types.PackageVersionConstraint-import           Distribution.Utils.Generic-import           Distribution.Version+import Distribution.Compat.CharParsing hiding (char)+import qualified Distribution.Compat.CharParsing as P+import Distribution.Compat.Lens+import Distribution.Compiler+import Distribution.PackageDescription+import Distribution.PackageDescription.Utils+import Distribution.Parsec+import Distribution.Pretty+import Distribution.System+import Distribution.Types.Component+import Distribution.Types.ComponentRequestedSpec+import Distribution.Types.DependencyMap+import Distribution.Types.DependencySatisfaction (DependencySatisfaction (..))+import Distribution.Types.MissingDependency (MissingDependency (..))+import Distribution.Types.PackageVersionConstraint+import Distribution.Utils.Generic+import Distribution.Utils.Path (sameDirectory)+import Distribution.Version -import qualified Data.Map.Lazy as Map-import           Data.Tree     (Tree (Node))+import Data.Tree (Tree (Node))  ------------------------------------------------------------------------------  -- | Simplify a configuration condition using the OS and arch names.  Returns --   the names of all the flags occurring in the condition.-simplifyWithSysParams :: OS -> Arch -> CompilerInfo -> Condition ConfVar-                      -> (Condition FlagName, [FlagName])+simplifyWithSysParams+  :: OS+  -> Arch+  -> CompilerInfo+  -> Condition ConfVar+  -> (Condition FlagName, [FlagName]) simplifyWithSysParams os arch cinfo cond = (cond', flags)   where     (cond', flags) = simplifyCondition cond interp-    interp (OS os')    = Right $ os' == os+    interp (OS os') = Right $ os' == os     interp (Arch arch') = Right $ arch' == arch     interp (Impl comp vr)       | matchImpl (compilerInfoId cinfo) = Right True       | otherwise = case compilerInfoCompat cinfo of           -- fixme: treat Nothing as unknown, rather than empty list once we           --        support partial resolution of system parameters-          Nothing     -> Right False+          Nothing -> Right False           Just compat -> Right (any matchImpl compat)-          where-            matchImpl (CompilerId c v) = comp == c && v `withinRange` vr+      where+        matchImpl (CompilerId c v) = comp == c && v `withinRange` vr     interp (PackageFlag f) = Left f  -- TODO: Add instances and check@@ -107,43 +112,53 @@ parseCondition :: CabalParsing m => m (Condition ConfVar) parseCondition = condOr   where-    condOr   = sepByNonEmpty condAnd (oper "||") >>= return . foldl1 COr-    condAnd  = sepByNonEmpty cond (oper "&&")>>= return . foldl1 CAnd+    condOr = sepByNonEmpty condAnd (oper "||") >>= return . foldl1 COr+    condAnd = sepByNonEmpty cond (oper "&&") >>= return . foldl1 CAnd     -- TODO: try?-    cond     = sp >> (boolLiteral <|> inparens condOr <|> notCond <|> osCond-                      <|> archCond <|> flagCond <|> implCond )-    inparens   = between (P.char '(' >> sp) (sp >> P.char ')' >> sp)-    notCond  = P.char '!' >> sp >> cond >>= return . CNot-    osCond   = string "os" >> sp >> inparens osIdent >>= return . Var+    cond =+      sp+        >> ( boolLiteral+              <|> inparens condOr+              <|> notCond+              <|> osCond+              <|> archCond+              <|> flagCond+              <|> implCond+           )+    inparens = between (P.char '(' >> sp) (sp >> P.char ')' >> sp)+    notCond = P.char '!' >> sp >> cond >>= return . CNot+    osCond = string "os" >> sp >> inparens osIdent >>= return . Var     archCond = string "arch" >> sp >> inparens archIdent >>= return . Var     flagCond = string "flag" >> sp >> inparens flagIdent >>= return . Var     implCond = string "impl" >> sp >> inparens implIdent >>= return . Var-    boolLiteral   = fmap Lit  parsec-    archIdent     = fmap Arch parsec-    osIdent       = fmap OS   parsec-    flagIdent     = fmap (PackageFlag . mkFlagName . lowercase) (munch1 isIdentChar)+    boolLiteral = fmap Lit parsec+    archIdent = fmap Arch parsec+    osIdent = fmap OS parsec+    flagIdent = fmap (PackageFlag . mkFlagName . lowercase) (munch1 isIdentChar)     isIdentChar c = isAlphaNum c || c == '_' || c == '-'-    oper s        = sp >> string s >> sp-    sp            = spaces-    implIdent     = do i <- parsec-                       vr <- sp >> option anyVersion parsec-                       return $ Impl i vr+    oper s = sp >> string s >> sp+    sp = spaces+    implIdent = do+      i <- parsec+      vr <- sp >> option anyVersion parsec+      return $ Impl i vr  ------------------------------------------------------------------------------ --- | Result of dependency test. Isomorphic to @Maybe d@ but renamed for+-- | Result of dependency test. Isomorphic to @Maybe@ but renamed for --   clarity.-data DepTestRslt d = DepOk | MissingDeps d--instance Semigroup d => Monoid (DepTestRslt d) where-    mempty = DepOk-    mappend = (<>)+data DepTestRslt+  = DepOk+  | MissingDeps [MissingDependency] -instance Semigroup d => Semigroup (DepTestRslt d) where-    DepOk <> x     = x-    x     <> DepOk = x-    (MissingDeps d) <> (MissingDeps d') = MissingDeps (d <> d')+instance Monoid DepTestRslt where+  mempty = DepOk+  mappend = (<>) +instance Semigroup DepTestRslt where+  DepOk <> x = x+  x <> DepOk = x+  (MissingDeps d) <> (MissingDeps d') = MissingDeps (d <> d')  -- | Try to find a flag assignment that satisfies the constraints of all trees. --@@ -165,68 +180,79 @@ -- -- This would require some sort of SAT solving, though, thus it's not -- implemented unless we really need it.----resolveWithFlags ::-     [(FlagName,[Bool])]-        -- ^ Domain for each flag name, will be tested in order.+resolveWithFlags+  :: [(FlagName, [Bool])]+  -- ^ Domain for each flag name, will be tested in order.   -> ComponentRequestedSpec-  -> OS      -- ^ OS where the installed artifacts will run (host OS)-  -> Arch    -- ^ Arch where the installed artifacts will run (host Arch)-  -> CompilerInfo  -- ^ Compiler information-  -> [PackageVersionConstraint]  -- ^ Additional constraints+  -> OS+  -- ^ OS where the installed artifacts will run (host OS)+  -> Arch+  -- ^ Arch where the installed artifacts will run (host Arch)+  -> CompilerInfo+  -- ^ Compiler information+  -> [PackageVersionConstraint]+  -- ^ Additional constraints   -> [CondTree ConfVar [Dependency] PDTagged]-  -> ([Dependency] -> DepTestRslt [Dependency])  -- ^ Dependency test function.-  -> Either [Dependency] (TargetSet PDTagged, FlagAssignment)-       -- ^ Either the missing dependencies (error case), or a pair of-       -- (set of build targets with dependencies, chosen flag assignments)+  -> ([Dependency] -> DepTestRslt)+  -- ^ Dependency test function.+  -> Either [MissingDependency] (TargetSet PDTagged, FlagAssignment)+  -- ^ Either the missing dependencies (error case), or a pair of+  -- (set of build targets with dependencies, chosen flag assignments) resolveWithFlags dom enabled os arch impl constrs trees checkDeps =-    either (Left . fromDepMapUnion) Right $ explore (build mempty dom)+  explore (build mempty dom)   where     -- simplify trees by (partially) evaluating all conditions and converting     -- dependencies to dependency maps.     simplifiedTrees :: [CondTree FlagName DependencyMap PDTagged]-    simplifiedTrees = map ( mapTreeConstrs toDepMap  -- convert to maps-                          . addBuildableConditionPDTagged-                          . mapTreeConds (fst . simplifyWithSysParams os arch impl))-                          trees+    simplifiedTrees =+      map+        ( mapTreeConstrs toDepMap -- convert to maps+            . addBuildableConditionPDTagged+            . mapTreeConds (fst . simplifyWithSysParams os arch impl)+        )+        trees      -- @explore@ searches a tree of assignments, backtracking whenever a flag     -- introduces a dependency that cannot be satisfied.  If there is no     -- solution, @explore@ returns the union of all dependencies that caused     -- it to backtrack.  Since the tree is constructed lazily, we avoid some     -- computation overhead in the successful case.-    explore :: Tree FlagAssignment-            -> Either DepMapUnion (TargetSet PDTagged, FlagAssignment)+    explore+      :: Tree FlagAssignment+      -> Either [MissingDependency] (TargetSet PDTagged, FlagAssignment)     explore (Node flags ts) =-        let targetSet = TargetSet $ flip map simplifiedTrees $+      let targetSet =+            TargetSet $+              flip map simplifiedTrees $                 -- apply additional constraints to all dependencies-                first (`constrainBy` constrs) .-                simplifyCondTree (env flags)-            deps = overallDependencies enabled targetSet-        in case checkDeps (fromDepMap deps) of-             DepOk | null ts   -> Right (targetSet, flags)-                   | otherwise -> tryAll $ map explore ts-             MissingDeps mds   -> Left (toDepMapUnion mds)+                first (`constrainBy` constrs)+                  . simplifyCondTree (env flags)+          deps = overallDependencies enabled targetSet+       in case checkDeps (fromDepMap deps) of+            DepOk+              | null ts -> Right (targetSet, flags)+              | otherwise -> tryAll $ map explore ts+            MissingDeps mds -> Left mds      -- Builds a tree of all possible flag assignments.  Internal nodes     -- have only partial assignments.     build :: FlagAssignment -> [(FlagName, [Bool])] -> Tree FlagAssignment     build assigned [] = Node assigned []     build assigned ((fn, vals) : unassigned) =-        Node assigned $ map (\v -> build (insertFlagAssignment fn v assigned) unassigned) vals+      Node assigned $ map (\v -> build (insertFlagAssignment fn v assigned) unassigned) vals -    tryAll :: [Either DepMapUnion a] -> Either DepMapUnion a+    tryAll :: Monoid a => [Either a b] -> Either a b     tryAll = foldr mp mz      -- special version of `mplus' for our local purposes-    mp :: Either DepMapUnion a -> Either DepMapUnion a -> Either DepMapUnion a-    mp m@(Right _) _           = m-    mp _           m@(Right _) = m-    mp (Left xs)   (Left ys)   = Left (xs <> ys)+    mp :: Monoid a => Either a b -> Either a b -> Either a b+    mp m@(Right _) _ = m+    mp _ m@(Right _) = m+    mp (Left xs) (Left ys) = Left (xs <> ys)      -- `mzero'-    mz :: Either DepMapUnion a-    mz = Left (DepMapUnion Map.empty)+    mz :: Monoid a => Either a b+    mz = Left mempty      env :: FlagAssignment -> FlagName -> Either FlagName Bool     env flags flag = (maybe (Left flag) Right . lookupFlagAssignment flag) flags@@ -235,14 +261,16 @@ -- conditional that is True when Buildable is True. If 'addBuildableCondition' -- can determine that Buildable is always True, it returns the input unchanged. -- If Buildable is always False, it returns the empty 'CondTree'.-addBuildableCondition :: (Eq v, Monoid a, Monoid c) => (a -> BuildInfo)-                      -> CondTree v c a-                      -> CondTree v c a+addBuildableCondition+  :: (Eq v, Monoid a, Monoid c)+  => (a -> BuildInfo)+  -> CondTree v c a+  -> CondTree v c a addBuildableCondition getInfo t =   case extractCondition (buildable . getInfo) t of-    Lit True  -> t+    Lit True -> t     Lit False -> CondNode mempty mempty []-    c         -> CondNode mempty mempty [condIfThen c t]+    c -> CondNode mempty mempty [condIfThen c t]  -- | This is a special version of 'addBuildableCondition' for the 'PDTagged' -- type.@@ -253,15 +281,15 @@ -- completely deleting components that are not buildable. -- -- See <https://github.com/haskell/cabal/pull/4094> for more details.----addBuildableConditionPDTagged :: (Eq v, Monoid c) =>-                                 CondTree v c PDTagged-                              -> CondTree v c PDTagged+addBuildableConditionPDTagged+  :: (Eq v, Monoid c)+  => CondTree v c PDTagged+  -> CondTree v c PDTagged addBuildableConditionPDTagged t =-    case extractCondition (buildable . getInfo) t of-      Lit True  -> t-      Lit False -> deleteConstraints t-      c         -> CondNode mempty mempty [condIfThenElse c t (deleteConstraints t)]+  case extractCondition (buildable . getInfo) t of+    Lit True -> t+    Lit False -> deleteConstraints t+    c -> CondNode mempty mempty [condIfThenElse c t (deleteConstraints t)]   where     deleteConstraints = mapTreeConstrs (const mempty) @@ -270,7 +298,6 @@     getInfo (SubComp _ c) = componentBuildInfo c     getInfo PDNull = mempty - -- Note: extracting buildable conditions. -- -------------------------------------- --@@ -286,52 +313,31 @@  -- | Extract conditions matched by the given predicate from all cond trees in a -- 'GenericPackageDescription'.-extractConditions :: (BuildInfo -> Bool) -> GenericPackageDescription-                     -> [Condition ConfVar]+extractConditions+  :: (BuildInfo -> Bool)+  -> GenericPackageDescription+  -> [Condition ConfVar] extractConditions f gpkg =-  concat [-      extractCondition (f . libBuildInfo)             <$> maybeToList (condLibrary gpkg)-    , extractCondition (f . libBuildInfo)       . snd <$> condSubLibraries   gpkg-    , extractCondition (f . buildInfo)          . snd <$> condExecutables gpkg-    , extractCondition (f . testBuildInfo)      . snd <$> condTestSuites  gpkg-    , extractCondition (f . benchmarkBuildInfo) . snd <$> condBenchmarks  gpkg+  concat+    [ extractCondition (f . libBuildInfo) <$> maybeToList (condLibrary gpkg)+    , extractCondition (f . libBuildInfo) . snd <$> condSubLibraries gpkg+    , extractCondition (f . buildInfo) . snd <$> condExecutables gpkg+    , extractCondition (f . testBuildInfo) . snd <$> condTestSuites gpkg+    , extractCondition (f . benchmarkBuildInfo) . snd <$> condBenchmarks gpkg     ] ---- | A map of package constraints that combines version ranges using 'unionVersionRanges'.-newtype DepMapUnion = DepMapUnion { unDepMapUnion :: Map PackageName (VersionRange, NonEmptySet LibraryName) }--instance Semigroup DepMapUnion where-    DepMapUnion x <> DepMapUnion y = DepMapUnion $-        Map.unionWith unionVersionRanges' x y--unionVersionRanges'-    :: (VersionRange, NonEmptySet LibraryName)-    -> (VersionRange, NonEmptySet LibraryName)-    -> (VersionRange, NonEmptySet LibraryName)-unionVersionRanges' (vr, cs) (vr', cs') = (unionVersionRanges vr vr', cs <> cs')--toDepMapUnion :: [Dependency] -> DepMapUnion-toDepMapUnion ds =-  DepMapUnion $ Map.fromListWith unionVersionRanges' [ (p,(vr,cs)) | Dependency p vr cs <- ds ]---fromDepMapUnion :: DepMapUnion -> [Dependency]-fromDepMapUnion m = [ Dependency p vr cs | (p,(vr,cs)) <- Map.toList (unDepMapUnion m) ]--freeVars :: CondTree ConfVar c a  -> [FlagName]-freeVars t = [ f | PackageFlag f <- freeVars' t ]+freeVars :: CondTree ConfVar c a -> [FlagName]+freeVars t = [f | PackageFlag f <- freeVars' t]   where     freeVars' (CondNode _ _ ifs) = concatMap compfv ifs     compfv (CondBranch c ct mct) = condfv c ++ freeVars' ct ++ maybe [] freeVars' mct     condfv c = case c of-      Var v      -> [v]-      Lit _      -> []-      CNot c'    -> condfv c'-      COr c1 c2  -> condfv c1 ++ condfv c2+      Var v -> [v]+      Lit _ -> []+      CNot c' -> condfv c'+      COr c1 c2 -> condfv c1 ++ condfv c2       CAnd c1 c2 -> condfv c1 ++ condfv c2 - ------------------------------------------------------------------------------  -- | A set of targets with their package dependencies@@ -347,55 +353,58 @@     -- UGH. The embedded componentName in the 'Component's here is     -- BLANK.  I don't know whose fault this is but I'll use the tag     -- instead. -- ezyang-    removeDisabledSections (Lib _)     = componentNameRequested-                                           enabled-                                           (CLibName LMainLibName)-    removeDisabledSections (SubComp t c)-        -- Do NOT use componentName-        = componentNameRequested enabled-        $ case c of-            CLib  _ -> CLibName (LSubLibName t)-            CFLib _ -> CFLibName   t-            CExe  _ -> CExeName    t-            CTest _ -> CTestName   t-            CBench _ -> CBenchName t-    removeDisabledSections PDNull      = True+    removeDisabledSections (Lib _) =+      componentNameRequested+        enabled+        (CLibName LMainLibName)+    removeDisabledSections (SubComp t c) =+      -- Do NOT use componentName+      componentNameRequested enabled $+        case c of+          CLib _ -> CLibName (LSubLibName t)+          CFLib _ -> CFLibName t+          CExe _ -> CExeName t+          CTest _ -> CTestName t+          CBench _ -> CBenchName t+    removeDisabledSections PDNull = True  -- | Collect up the targets in a TargetSet of tagged targets, storing the -- dependencies as we go. flattenTaggedTargets :: TargetSet PDTagged -> (Maybe Library, [(UnqualComponentName, Component)])-flattenTaggedTargets (TargetSet targets) = foldr untag (Nothing, []) targets where-  untag (depMap, pdTagged) accum = case (pdTagged, accum) of-    (Lib _, (Just _, _)) -> userBug "Only one library expected"-    (Lib l, (Nothing, comps)) -> (Just $ redoBD l, comps)-    (SubComp n c, (mb_lib, comps))-      | any ((== n) . fst) comps ->-        userBug $ "There exist several components with the same name: '" ++ prettyShow n ++ "'"-      | otherwise -> (mb_lib, (n, redoBD c) : comps)-    (PDNull, x) -> x  -- actually this should not happen, but let's be liberal-    where-      redoBD :: L.HasBuildInfo a => a -> a-      redoBD = set L.targetBuildDepends $ fromDepMap depMap+flattenTaggedTargets (TargetSet targets) = foldr untag (Nothing, []) targets+  where+    untag (depMap, pdTagged) accum = case (pdTagged, accum) of+      (Lib _, (Just _, _)) -> userBug "Only one library expected"+      (Lib l, (Nothing, comps)) -> (Just $ redoBD l, comps)+      (SubComp n c, (mb_lib, comps))+        | any ((== n) . fst) comps ->+            userBug $ "There exist several components with the same name: '" ++ prettyShow n ++ "'"+        | otherwise -> (mb_lib, (n, redoBD c) : comps)+      (PDNull, x) -> x -- actually this should not happen, but let's be liberal+      where+        redoBD :: L.HasBuildInfo a => a -> a+        redoBD = set L.targetBuildDepends $ fromDepMap depMap  ------------------------------------------------------------------------------ -- Convert GenericPackageDescription to PackageDescription -- -data PDTagged = Lib Library-              | SubComp UnqualComponentName Component-              | PDNull-              deriving Show+data PDTagged+  = Lib Library+  | SubComp UnqualComponentName Component+  | PDNull+  deriving (Show)  instance Monoid PDTagged where-    mempty = PDNull-    mappend = (<>)+  mempty = PDNull+  mappend = (<>)  instance Semigroup PDTagged where-    PDNull    <> x      = x-    x         <> PDNull = x-    Lib l     <> Lib l' = Lib (l <> l')-    SubComp n x <> SubComp n' x' | n == n' = SubComp n (x <> x')-    _         <> _  = cabalBug "Cannot combine incompatible tags"+  PDNull <> x = x+  x <> PDNull = x+  Lib l <> Lib l' = Lib (l <> l')+  SubComp n x <> SubComp n' x' | n == n' = SubComp n (x <> x')+  _ <> _ = cabalBug "Cannot combine incompatible tags"  -- | Create a package description with all configurations resolved. --@@ -422,66 +431,91 @@ -- Note that this drops any stanzas which have @buildable: False@.  While -- this is arguably the right thing to do, it means we give bad error -- messages in some situations, see #3858.----finalizePD ::-     FlagAssignment  -- ^ Explicitly specified flag assignments+finalizePD+  :: FlagAssignment+  -- ^ Explicitly specified flag assignments   -> ComponentRequestedSpec-  -> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of-                          -- available packages?  If this is unknown then use-                          -- True.-  -> Platform      -- ^ The 'Arch' and 'OS'-  -> CompilerInfo  -- ^ Compiler information-  -> [PackageVersionConstraint]  -- ^ Additional constraints+  -> (Dependency -> DependencySatisfaction)+  -- ^ Is a given dependency satisfiable from the set of+  -- available packages?  If this is unknown then use+  -- True.+  -> Platform+  -- ^ The 'Arch' and 'OS'+  -> CompilerInfo+  -- ^ Compiler information+  -> [PackageVersionConstraint]+  -- ^ Additional constraints   -> GenericPackageDescription-  -> Either [Dependency]-            (PackageDescription, FlagAssignment)-             -- ^ Either missing dependencies or the resolved package-             -- description along with the flag assignments chosen.-finalizePD userflags enabled satisfyDep-        (Platform arch os) impl constraints-        (GenericPackageDescription pkg _ver flags mb_lib0 sub_libs0 flibs0 exes0 tests0 bms0) = do-  (targetSet, flagVals) <--    resolveWithFlags flagChoices enabled os arch impl constraints condTrees check-  let-    (mb_lib, comps) = flattenTaggedTargets targetSet-    mb_lib' = fmap libFillInDefaults mb_lib-    comps' = flip map comps $ \(n,c) -> foldComponent-      (\l -> CLib   (libFillInDefaults l)   { libName = LSubLibName n-                                            , libExposed = False })-      (\l -> CFLib  (flibFillInDefaults l)  { foreignLibName = n })-      (\e -> CExe   (exeFillInDefaults e)   { exeName = n })-      (\t -> CTest  (testFillInDefaults t)  { testName = n })-      (\b -> CBench (benchFillInDefaults b) { benchmarkName = n })-      c-    (sub_libs', flibs', exes', tests', bms') = partitionComponents comps'-  return ( pkg { library = mb_lib'-               , subLibraries = sub_libs'-               , foreignLibs = flibs'-               , executables = exes'-               , testSuites = tests'-               , benchmarks = bms'-               }-         , flagVals )-  where-    -- Combine lib, exes, and tests into one list of @CondTree@s with tagged data-    condTrees =    maybeToList (fmap (mapTreeData Lib) mb_lib0)-                ++ map (\(name,tree) -> mapTreeData (SubComp name . CLib) tree) sub_libs0-                ++ map (\(name,tree) -> mapTreeData (SubComp name . CFLib) tree) flibs0-                ++ map (\(name,tree) -> mapTreeData (SubComp name . CExe) tree) exes0-                ++ map (\(name,tree) -> mapTreeData (SubComp name . CTest) tree) tests0-                ++ map (\(name,tree) -> mapTreeData (SubComp name . CBench) tree) bms0+  -> Either+      [MissingDependency]+      (PackageDescription, FlagAssignment)+  -- ^ Either missing dependencies or the resolved package+  -- description along with the flag assignments chosen.+finalizePD+  userflags+  enabled+  satisfyDep+  (Platform arch os)+  impl+  constraints+  (GenericPackageDescription pkg _ver flags mb_lib0 sub_libs0 flibs0 exes0 tests0 bms0) = do+    (targetSet, flagVals) <-+      resolveWithFlags flagChoices enabled os arch impl constraints condTrees check+    let+      (mb_lib, comps) = flattenTaggedTargets targetSet+      mb_lib' = fmap libFillInDefaults mb_lib+      comps' = flip map comps $ \(n, c) ->+        foldComponent+          ( \l ->+              CLib+                (libFillInDefaults l)+                  { libName = LSubLibName n+                  , libExposed = False+                  }+          )+          (\l -> CFLib (flibFillInDefaults l){foreignLibName = n})+          (\e -> CExe (exeFillInDefaults e){exeName = n})+          (\t -> CTest (testFillInDefaults t){testName = n})+          (\b -> CBench (benchFillInDefaults b){benchmarkName = n})+          c+      (sub_libs', flibs', exes', tests', bms') = partitionComponents comps'+    return+      ( pkg+          { library = mb_lib'+          , subLibraries = sub_libs'+          , foreignLibs = flibs'+          , executables = exes'+          , testSuites = tests'+          , benchmarks = bms'+          }+      , flagVals+      )+    where+      -- Combine lib, exes, and tests into one list of @CondTree@s with tagged data+      condTrees =+        maybeToList (fmap (mapTreeData Lib) mb_lib0)+          ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib) tree) sub_libs0+          ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib) tree) flibs0+          ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe) tree) exes0+          ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest) tree) tests0+          ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench) tree) bms0 -    flagChoices    = map (\(MkPackageFlag n _ d manual) -> (n, d2c manual n d)) flags-    d2c manual n b = case lookupFlagAssignment n userflags of-                     Just val -> [val]-                     Nothing-                      | manual -> [b]-                      | otherwise -> [b, not b]-    --flagDefaults = map (\(n,x:_) -> (n,x)) flagChoices-    check ds     = let missingDeps = filter (not . satisfyDep) ds-                   in if null missingDeps-                      then DepOk-                      else MissingDeps missingDeps+      flagChoices = map (\(MkPackageFlag n _ d manual) -> (n, d2c manual n d)) flags+      d2c manual n b = case lookupFlagAssignment n userflags of+        Just val -> [val]+        Nothing+          | manual -> [b]+          | otherwise -> [b, not b]+      -- flagDefaults = map (\(n,x:_) -> (n,x)) flagChoices+      check ds =+        let missingDeps =+              [ MissingDependency dependency reason+              | (dependency, Unsatisfied reason) <-+                  map (\dependency -> (dependency, satisfyDep dependency)) ds+              ]+         in if null missingDeps+              then DepOk+              else MissingDeps missingDeps  {- let tst_p = (CondNode [1::Int] [Distribution.Package.Dependency "a" AnyVersion] [])@@ -509,31 +543,49 @@ flattenPackageDescription :: GenericPackageDescription -> PackageDescription flattenPackageDescription   (GenericPackageDescription pkg _ _ mlib0 sub_libs0 flibs0 exes0 tests0 bms0) =-    pkg { library      = mlib-        , subLibraries = reverse sub_libs-        , foreignLibs  = reverse flibs-        , executables  = reverse exes-        , testSuites   = reverse tests-        , benchmarks   = reverse bms-        }-  where-    mlib = f <$> mlib0-      where f lib = (libFillInDefaults . fst . ignoreConditions $ lib) { libName = LMainLibName }-    sub_libs = flattenLib  <$> sub_libs0-    flibs    = flattenFLib <$> flibs0-    exes     = flattenExe  <$> exes0-    tests    = flattenTst  <$> tests0-    bms      = flattenBm   <$> bms0-    flattenLib (n, t) = libFillInDefaults $ (fst $ ignoreConditions t)-      { libName = LSubLibName n, libExposed = False }-    flattenFLib (n, t) = flibFillInDefaults $ (fst $ ignoreConditions t)-      { foreignLibName = n }-    flattenExe (n, t) = exeFillInDefaults $ (fst $ ignoreConditions t)-      { exeName = n }-    flattenTst (n, t) = testFillInDefaults $ (fst $ ignoreConditions t)-      { testName = n }-    flattenBm (n, t) = benchFillInDefaults $ (fst $ ignoreConditions t)-      { benchmarkName = n }+    pkg+      { library = mlib+      , subLibraries = reverse sub_libs+      , foreignLibs = reverse flibs+      , executables = reverse exes+      , testSuites = reverse tests+      , benchmarks = reverse bms+      }+    where+      mlib = f <$> mlib0+        where+          f lib = (libFillInDefaults . fst . ignoreConditions $ lib){libName = LMainLibName}+      sub_libs = flattenLib <$> sub_libs0+      flibs = flattenFLib <$> flibs0+      exes = flattenExe <$> exes0+      tests = flattenTst <$> tests0+      bms = flattenBm <$> bms0+      flattenLib (n, t) =+        libFillInDefaults $+          (fst $ ignoreConditions t)+            { libName = LSubLibName n+            , libExposed = False+            }+      flattenFLib (n, t) =+        flibFillInDefaults $+          (fst $ ignoreConditions t)+            { foreignLibName = n+            }+      flattenExe (n, t) =+        exeFillInDefaults $+          (fst $ ignoreConditions t)+            { exeName = n+            }+      flattenTst (n, t) =+        testFillInDefaults $+          (fst $ ignoreConditions t)+            { testName = n+            }+      flattenBm (n, t) =+        benchFillInDefaults $+          (fst $ ignoreConditions t)+            { benchmarkName = n+            }  -- This is in fact rather a hack.  The original version just overrode the -- default values, however, when adding conditions we had to switch to a@@ -543,59 +595,62 @@ -- This is the cleanest way i could think of, that doesn't require -- changing all field parsing functions to return modifiers instead. libFillInDefaults :: Library -> Library-libFillInDefaults lib@(Library { libBuildInfo = bi }) =-    lib { libBuildInfo = biFillInDefaults bi }+libFillInDefaults lib@(Library{libBuildInfo = bi}) =+  lib{libBuildInfo = biFillInDefaults bi}  flibFillInDefaults :: ForeignLib -> ForeignLib-flibFillInDefaults flib@(ForeignLib { foreignLibBuildInfo = bi }) =-    flib { foreignLibBuildInfo = biFillInDefaults bi }+flibFillInDefaults flib@(ForeignLib{foreignLibBuildInfo = bi}) =+  flib{foreignLibBuildInfo = biFillInDefaults bi}  exeFillInDefaults :: Executable -> Executable-exeFillInDefaults exe@(Executable { buildInfo = bi }) =-    exe { buildInfo = biFillInDefaults bi }+exeFillInDefaults exe@(Executable{buildInfo = bi}) =+  exe{buildInfo = biFillInDefaults bi}  testFillInDefaults :: TestSuite -> TestSuite-testFillInDefaults tst@(TestSuite { testBuildInfo = bi }) =-    tst { testBuildInfo = biFillInDefaults bi }+testFillInDefaults tst@(TestSuite{testBuildInfo = bi}) =+  tst{testBuildInfo = biFillInDefaults bi}  benchFillInDefaults :: Benchmark -> Benchmark-benchFillInDefaults bm@(Benchmark { benchmarkBuildInfo = bi }) =-    bm { benchmarkBuildInfo = biFillInDefaults bi }+benchFillInDefaults bm@(Benchmark{benchmarkBuildInfo = bi}) =+  bm{benchmarkBuildInfo = biFillInDefaults bi}  biFillInDefaults :: BuildInfo -> BuildInfo biFillInDefaults bi =-    if null (hsSourceDirs bi)-    then bi { hsSourceDirs = [sameDirectory] }+  if null (hsSourceDirs bi)+    then bi{hsSourceDirs = [sameDirectory]}     else bi  -- Walk a 'GenericPackageDescription' and apply @onBuildInfo@/@onSetupBuildInfo@ -- to all nested 'BuildInfo'/'SetupBuildInfo' values.-transformAllBuildInfos :: (BuildInfo -> BuildInfo)-                       -> (SetupBuildInfo -> SetupBuildInfo)-                       -> GenericPackageDescription-                       -> GenericPackageDescription+transformAllBuildInfos+  :: (BuildInfo -> BuildInfo)+  -> (SetupBuildInfo -> SetupBuildInfo)+  -> GenericPackageDescription+  -> GenericPackageDescription transformAllBuildInfos onBuildInfo onSetupBuildInfo =   over L.traverseBuildInfos onBuildInfo-  . over (L.packageDescription . L.setupBuildInfo . traverse) onSetupBuildInfo+    . over (L.packageDescription . L.setupBuildInfo . traverse) onSetupBuildInfo  -- | Walk a 'GenericPackageDescription' and apply @f@ to all nested -- @build-depends@ fields.-transformAllBuildDepends :: (Dependency -> Dependency)-                         -> GenericPackageDescription-                         -> GenericPackageDescription+transformAllBuildDepends+  :: (Dependency -> Dependency)+  -> GenericPackageDescription+  -> GenericPackageDescription transformAllBuildDepends f =   over (L.traverseBuildInfos . L.targetBuildDepends . traverse) f-  . over (L.packageDescription . L.setupBuildInfo . traverse . L.setupDepends . traverse) f-  -- cannot be point-free as normal because of higher rank-  . over (\f' -> L.allCondTrees $ traverseCondTreeC f') (map f)+    . over (L.packageDescription . L.setupBuildInfo . traverse . L.setupDepends . traverse) f+    -- cannot be point-free as normal because of higher rank+    . over (\f' -> L.allCondTrees $ traverseCondTreeC f') (map f)  -- | Walk a 'GenericPackageDescription' and apply @f@ to all nested -- @build-depends@ fields.-transformAllBuildDependsN :: ([Dependency] -> [Dependency])-                          -> GenericPackageDescription-                          -> GenericPackageDescription+transformAllBuildDependsN+  :: ([Dependency] -> [Dependency])+  -> GenericPackageDescription+  -> GenericPackageDescription transformAllBuildDependsN f =   over (L.traverseBuildInfos . L.targetBuildDepends) f-  . over (L.packageDescription . L.setupBuildInfo . traverse . L.setupDepends) f-  -- cannot be point-free as normal because of higher rank-  . over (\f' -> L.allCondTrees $ traverseCondTreeC f') f+    . over (L.packageDescription . L.setupBuildInfo . traverse . L.setupDepends) f+    -- cannot be point-free as normal because of higher rank+    . over (\f' -> L.allCondTrees $ traverseCondTreeC f') f
src/Distribution/PackageDescription/FieldGrammar.hs view
@@ -1,824 +1,927 @@-{-# LANGUAGE ConstraintKinds       #-}-{-# LANGUAGE FlexibleInstances     #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings     #-}--- | 'GenericPackageDescription' Field descriptions-module Distribution.PackageDescription.FieldGrammar (-    -- * Package description-    packageDescriptionFieldGrammar,-    CompatFilePath(..),-    CompatLicenseFile(..),-    -- * Library-    libraryFieldGrammar,-    -- * Foreign library-    foreignLibFieldGrammar,-    -- * Executable-    executableFieldGrammar,-    -- * Test suite-    TestSuiteStanza (..),-    testSuiteFieldGrammar,-    validateTestSuite,-    unvalidateTestSuite,-    -- ** Lenses-    testStanzaTestType,-    testStanzaMainIs,-    testStanzaTestModule,-    testStanzaBuildInfo,-    -- * Benchmark-    BenchmarkStanza (..),-    benchmarkFieldGrammar,-    validateBenchmark,-    unvalidateBenchmark,-    -- * Field grammars-    formatDependencyList,-    formatExposedModules,-    formatExtraSourceFiles,-    formatHsSourceDirs,-    formatMixinList,-    formatOtherExtensions,-    formatOtherModules,-    -- ** Lenses-    benchmarkStanzaBenchmarkType,-    benchmarkStanzaMainIs,-    benchmarkStanzaBenchmarkModule,-    benchmarkStanzaBuildInfo,-    -- * Flag-    flagFieldGrammar,-    -- * Source repository-    sourceRepoFieldGrammar,-    -- * Setup build info-    setupBInfoFieldGrammar,-    -- * Component build info-    buildInfoFieldGrammar,-    ) where---import Distribution.Compat.Lens-import Distribution.Compat.Prelude-import Language.Haskell.Extension-import Prelude ()--import Distribution.CabalSpecVersion-import Distribution.Compat.Newtype     (Newtype, pack', unpack')-import Distribution.Compiler           (CompilerFlavor (..), PerCompilerFlavor (..))-import Distribution.FieldGrammar-import Distribution.Fields-import Distribution.ModuleName         (ModuleName)-import Distribution.Package-import Distribution.PackageDescription-import Distribution.Parsec-import Distribution.Pretty             (Pretty (..), prettyShow, showToken)-import Distribution.Utils.Path-import Distribution.Version            (Version, VersionRange)--import qualified Data.ByteString.Char8           as BS8-import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.SPDX               as SPDX-import qualified Distribution.Types.Lens         as L------------------------------------------------------------------------------------ PackageDescription----------------------------------------------------------------------------------packageDescriptionFieldGrammar-    :: ( FieldGrammar c g, Applicative (g PackageDescription), Applicative (g PackageIdentifier)-       , c (Identity BuildType)-       , c (Identity PackageName)-       , c (Identity Version)-       , c (List FSep FilePathNT String)-       , c (List FSep CompatFilePath String)-       , c (List FSep (Identity (SymbolicPath PackageDir LicenseFile)) (SymbolicPath PackageDir LicenseFile))-       , c (List FSep TestedWith (CompilerFlavor, VersionRange))-       , c (List VCat FilePathNT String)-       , c FilePathNT-       , c CompatLicenseFile-       , c CompatFilePath-       , c SpecLicense-       , c SpecVersion-       )-    => g PackageDescription PackageDescription-packageDescriptionFieldGrammar = PackageDescription-    <$> optionalFieldDefAla "cabal-version" SpecVersion                L.specVersion CabalSpecV1_0-    <*> blurFieldGrammar L.package packageIdentifierGrammar-    <*> optionalFieldDefAla "license"       SpecLicense                L.licenseRaw (Left SPDX.NONE)-    <*> licenseFilesGrammar-    <*> freeTextFieldDefST  "copyright"                                L.copyright-    <*> freeTextFieldDefST  "maintainer"                               L.maintainer-    <*> freeTextFieldDefST  "author"                                   L.author-    <*> freeTextFieldDefST  "stability"                                L.stability-    <*> monoidalFieldAla    "tested-with"   (alaList' FSep TestedWith) L.testedWith-    <*> freeTextFieldDefST  "homepage"                                 L.homepage-    <*> freeTextFieldDefST  "package-url"                              L.pkgUrl-    <*> freeTextFieldDefST   "bug-reports"                              L.bugReports-    <*> pure [] -- source-repos are stanza-    <*> freeTextFieldDefST  "synopsis"                                 L.synopsis-    <*> freeTextFieldDefST  "description"                              L.description-    <*> freeTextFieldDefST  "category"                                 L.category-    <*> prefixedFields      "x-"                                       L.customFieldsPD-    <*> optionalField       "build-type"                               L.buildTypeRaw-    <*> pure Nothing -- custom-setup-    -- components-    <*> pure Nothing  -- lib-    <*> pure []       -- sub libs-    <*> pure []       -- executables-    <*> pure []       -- foreign libs-    <*> pure []       -- test suites-    <*> pure []       -- benchmarks-    --  * Files-    <*> monoidalFieldAla    "data-files"         (alaList' VCat FilePathNT) L.dataFiles-    <*> optionalFieldDefAla "data-dir"           CompatFilePath             L.dataDir "."-        ^^^ fmap (\x -> if null x then "." else x) -- map empty directories to "."-    <*> monoidalFieldAla    "extra-source-files" formatExtraSourceFiles     L.extraSrcFiles-    <*> monoidalFieldAla    "extra-tmp-files"    (alaList' VCat FilePathNT) L.extraTmpFiles-    <*> monoidalFieldAla    "extra-doc-files"    (alaList' VCat FilePathNT) L.extraDocFiles-  where-    packageIdentifierGrammar = PackageIdentifier-        <$> uniqueField "name"    L.pkgName-        <*> uniqueField "version" L.pkgVersion--    licenseFilesGrammar = (++)-        -- TODO: neither field is deprecated-        -- should we pretty print license-file if there's single license file-        -- and license-files when more-        <$> monoidalFieldAla    "license-file"   CompatLicenseFile L.licenseFiles-        <*> monoidalFieldAla    "license-files"  (alaList FSep)    L.licenseFiles-            ^^^ hiddenField------------------------------------------------------------------------------------ Library----------------------------------------------------------------------------------libraryFieldGrammar-    :: ( FieldGrammar c g, Applicative (g Library), Applicative (g BuildInfo)-       , c (Identity LibraryVisibility)-       , c (List CommaFSep (Identity ExeDependency) ExeDependency)-       , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)-       , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)-       , c (List CommaVCat (Identity Dependency) Dependency)-       , c (List CommaVCat (Identity Mixin) Mixin)-       , c (List CommaVCat (Identity ModuleReexport) ModuleReexport)-       , c (List FSep (MQuoted Extension) Extension)-       , c (List FSep (MQuoted Language) Language)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (List NoCommaFSep Token' String)-       , c (List VCat (MQuoted ModuleName) ModuleName)-       , c (List VCat FilePathNT String)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       , c (List VCat Token String)-       , c (MQuoted Language)-       )-    => LibraryName-    -> g Library Library-libraryFieldGrammar n = Library n-    <$> monoidalFieldAla  "exposed-modules"    formatExposedModules    L.exposedModules-    <*> monoidalFieldAla  "reexported-modules" (alaList  CommaVCat)    L.reexportedModules-    <*> monoidalFieldAla  "signatures"         (alaList' VCat MQuoted) L.signatures-        ^^^ availableSince CabalSpecV2_0 []-    <*> booleanFieldDef   "exposed"                                    L.libExposed True-    <*> visibilityField-    <*> blurFieldGrammar L.libBuildInfo buildInfoFieldGrammar-  where-    visibilityField = case n of-        -- nameless/"main" libraries are public-        LMainLibName -> pure LibraryVisibilityPublic-        -- named libraries have the field-        LSubLibName _ ->-            optionalFieldDef "visibility" L.libVisibility LibraryVisibilityPrivate-            ^^^ availableSince CabalSpecV3_0 LibraryVisibilityPrivate--{-# SPECIALIZE libraryFieldGrammar :: LibraryName -> ParsecFieldGrammar' Library #-}-{-# SPECIALIZE libraryFieldGrammar :: LibraryName -> PrettyFieldGrammar' Library #-}------------------------------------------------------------------------------------ Foreign library----------------------------------------------------------------------------------foreignLibFieldGrammar-    :: ( FieldGrammar c g, Applicative (g ForeignLib), Applicative (g BuildInfo)-       , c (Identity ForeignLibType)-       , c (Identity LibVersionInfo)-       , c (Identity Version)-       , c (List CommaFSep (Identity ExeDependency) ExeDependency)-       , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)-       , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)-       , c (List CommaVCat (Identity Dependency) Dependency)-       , c (List CommaVCat (Identity Mixin) Mixin)-       , c (List FSep (Identity ForeignLibOption) ForeignLibOption)-       , c (List FSep (MQuoted Extension) Extension)-       , c (List FSep (MQuoted Language) Language)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       , c (List NoCommaFSep Token' String)-       , c (List VCat (MQuoted ModuleName) ModuleName)-       , c (List VCat FilePathNT String), c (List VCat Token String)-       , c (MQuoted Language)-       )-    => UnqualComponentName -> g ForeignLib ForeignLib-foreignLibFieldGrammar n = ForeignLib n-    <$> optionalFieldDef "type"                                         L.foreignLibType ForeignLibTypeUnknown-    <*> monoidalFieldAla "options"           (alaList FSep)             L.foreignLibOptions-    <*> blurFieldGrammar L.foreignLibBuildInfo buildInfoFieldGrammar-    <*> optionalField    "lib-version-info"                             L.foreignLibVersionInfo-    <*> optionalField    "lib-version-linux"                            L.foreignLibVersionLinux-    <*> monoidalFieldAla "mod-def-file"      (alaList' FSep FilePathNT) L.foreignLibModDefFile-{-# SPECIALIZE foreignLibFieldGrammar :: UnqualComponentName -> ParsecFieldGrammar' ForeignLib #-}-{-# SPECIALIZE foreignLibFieldGrammar :: UnqualComponentName -> PrettyFieldGrammar' ForeignLib #-}------------------------------------------------------------------------------------ Executable----------------------------------------------------------------------------------executableFieldGrammar-    :: ( FieldGrammar c g, Applicative (g Executable), Applicative (g BuildInfo)-       , c (Identity ExecutableScope)-       , c (List CommaFSep (Identity ExeDependency) ExeDependency)-       , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)-       , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)-       , c (List CommaVCat (Identity Dependency) Dependency)-       , c (List CommaVCat (Identity Mixin) Mixin)-       , c (List FSep (MQuoted Extension) Extension)-       , c (List FSep (MQuoted Language) Language)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       , c (List NoCommaFSep Token' String)-       , c (List VCat (MQuoted ModuleName) ModuleName)-       , c (List VCat FilePathNT String)-       , c (List VCat Token String)-       , c (MQuoted Language)-       )-    => UnqualComponentName -> g Executable Executable-executableFieldGrammar n = Executable n-    -- main-is is optional as conditional blocks don't have it-    <$> optionalFieldDefAla "main-is" FilePathNT L.modulePath ""-    <*> optionalFieldDef    "scope"              L.exeScope ExecutablePublic-        ^^^ availableSince CabalSpecV2_0 ExecutablePublic-    <*> blurFieldGrammar L.buildInfo buildInfoFieldGrammar-{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> ParsecFieldGrammar' Executable #-}-{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> PrettyFieldGrammar' Executable #-}------------------------------------------------------------------------------------ TestSuite------------------------------------------------------------------------------------ | An intermediate type just used for parsing the test-suite stanza.--- After validation it is converted into the proper 'TestSuite' type.-data TestSuiteStanza = TestSuiteStanza-    { _testStanzaTestType   :: Maybe TestType-    , _testStanzaMainIs     :: Maybe FilePath-    , _testStanzaTestModule :: Maybe ModuleName-    , _testStanzaBuildInfo  :: BuildInfo-    , _testStanzaCodeGenerators :: [String]-    }--instance L.HasBuildInfo TestSuiteStanza where-    buildInfo = testStanzaBuildInfo--testStanzaTestType :: Lens' TestSuiteStanza (Maybe TestType)-testStanzaTestType f s = fmap (\x -> s { _testStanzaTestType = x }) (f (_testStanzaTestType s))-{-# INLINE testStanzaTestType #-}--testStanzaMainIs :: Lens' TestSuiteStanza (Maybe FilePath)-testStanzaMainIs f s = fmap (\x -> s { _testStanzaMainIs = x }) (f (_testStanzaMainIs s))-{-# INLINE testStanzaMainIs #-}--testStanzaTestModule :: Lens' TestSuiteStanza (Maybe ModuleName)-testStanzaTestModule f s = fmap (\x -> s { _testStanzaTestModule = x }) (f (_testStanzaTestModule s))-{-# INLINE testStanzaTestModule #-}--testStanzaBuildInfo :: Lens' TestSuiteStanza BuildInfo-testStanzaBuildInfo f s = fmap (\x -> s { _testStanzaBuildInfo = x }) (f (_testStanzaBuildInfo s))-{-# INLINE testStanzaBuildInfo #-}--testStanzaCodeGenerators :: Lens' TestSuiteStanza [String]-testStanzaCodeGenerators f s = fmap (\x -> s { _testStanzaCodeGenerators = x }) (f (_testStanzaCodeGenerators s))-{-# INLINE testStanzaCodeGenerators #-}--testSuiteFieldGrammar-    :: ( FieldGrammar c g, Applicative (g TestSuiteStanza), Applicative (g BuildInfo)-       , c (Identity ModuleName)-       , c (Identity TestType)-       , c (List CommaFSep (Identity ExeDependency) ExeDependency)-       , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)-       , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)-       , c (List CommaFSep Token String)-       , c (List CommaVCat (Identity Dependency) Dependency)-       , c (List CommaVCat (Identity Mixin) Mixin)-       , c (List FSep (MQuoted Extension) Extension)-       , c (List FSep (MQuoted Language) Language)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (List NoCommaFSep Token' String)-       , c (List VCat (MQuoted ModuleName) ModuleName)-       , c (List VCat FilePathNT String)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       , c (List VCat Token String)-       , c (MQuoted Language)-       )-    => g TestSuiteStanza TestSuiteStanza-testSuiteFieldGrammar = TestSuiteStanza-    <$> optionalField    "type"                   testStanzaTestType-    <*> optionalFieldAla "main-is"     FilePathNT testStanzaMainIs-    <*> optionalField    "test-module"            testStanzaTestModule-    <*> blurFieldGrammar testStanzaBuildInfo buildInfoFieldGrammar-    <*> monoidalFieldAla "code-generators"        (alaList'  CommaFSep Token)     testStanzaCodeGenerators-          ^^^ availableSince CabalSpecV3_8 []--validateTestSuite :: CabalSpecVersion -> Position -> TestSuiteStanza -> ParseResult TestSuite-validateTestSuite cabalSpecVersion pos stanza = case testSuiteType of-    Nothing -> pure basicTestSuite--    Just tt@(TestTypeUnknown _ _) ->-        pure basicTestSuite-            { testInterface = TestSuiteUnsupported tt }--    Just tt | tt `notElem` knownTestTypes ->-        pure basicTestSuite-            { testInterface = TestSuiteUnsupported tt }--    Just tt@(TestTypeExe ver) -> case _testStanzaMainIs stanza of-        Nothing   -> do-            parseFailure pos (missingField "main-is" tt)-            pure emptyTestSuite-        Just file -> do-            when (isJust (_testStanzaTestModule stanza)) $-                parseWarning pos PWTExtraBenchmarkModule (extraField "test-module" tt)-            pure basicTestSuite-                { testInterface = TestSuiteExeV10 ver file }--    Just tt@(TestTypeLib ver) -> case _testStanzaTestModule stanza of-         Nothing      -> do-            parseFailure pos (missingField "test-module" tt)-            pure emptyTestSuite-         Just module_ -> do-            when (isJust (_testStanzaMainIs stanza)) $-                parseWarning pos PWTExtraMainIs (extraField "main-is" tt)-            pure basicTestSuite-                { testInterface = TestSuiteLibV09 ver module_ }--  where-    testSuiteType = _testStanzaTestType stanza <|> do-        guard (cabalSpecVersion >= CabalSpecV3_8)--        testTypeExe <$ _testStanzaMainIs stanza-        <|> testTypeLib <$ _testStanzaTestModule stanza--    missingField name tt = "The '" ++ name ++ "' field is required for the "-                        ++ prettyShow tt ++ " test suite type."--    extraField   name tt = "The '" ++ name ++ "' field is not used for the '"-                        ++ prettyShow tt ++ "' test suite type."-    basicTestSuite =-             emptyTestSuite {-                  testBuildInfo = _testStanzaBuildInfo stanza-                , testCodeGenerators = _testStanzaCodeGenerators stanza-             }--unvalidateTestSuite :: TestSuite -> TestSuiteStanza-unvalidateTestSuite t = TestSuiteStanza-    { _testStanzaTestType   = ty-    , _testStanzaMainIs     = ma-    , _testStanzaTestModule = mo-    , _testStanzaBuildInfo  = testBuildInfo t-    , _testStanzaCodeGenerators = testCodeGenerators t-    }-  where-    (ty, ma, mo) = case testInterface t of-        TestSuiteExeV10 ver file -> (Just $ TestTypeExe ver, Just file, Nothing)-        TestSuiteLibV09 ver modu -> (Just $ TestTypeLib ver, Nothing, Just modu)-        _                        -> (Nothing, Nothing, Nothing)------------------------------------------------------------------------------------ Benchmark------------------------------------------------------------------------------------ | An intermediate type just used for parsing the benchmark stanza.--- After validation it is converted into the proper 'Benchmark' type.-data BenchmarkStanza = BenchmarkStanza-    { _benchmarkStanzaBenchmarkType   :: Maybe BenchmarkType-    , _benchmarkStanzaMainIs          :: Maybe FilePath-    , _benchmarkStanzaBenchmarkModule :: Maybe ModuleName-    , _benchmarkStanzaBuildInfo       :: BuildInfo-    }--instance L.HasBuildInfo BenchmarkStanza where-    buildInfo = benchmarkStanzaBuildInfo--benchmarkStanzaBenchmarkType :: Lens' BenchmarkStanza (Maybe BenchmarkType)-benchmarkStanzaBenchmarkType f s = fmap (\x -> s { _benchmarkStanzaBenchmarkType = x }) (f (_benchmarkStanzaBenchmarkType s))-{-# INLINE benchmarkStanzaBenchmarkType #-}--benchmarkStanzaMainIs :: Lens' BenchmarkStanza (Maybe FilePath)-benchmarkStanzaMainIs f s = fmap (\x -> s { _benchmarkStanzaMainIs = x }) (f (_benchmarkStanzaMainIs s))-{-# INLINE benchmarkStanzaMainIs #-}--benchmarkStanzaBenchmarkModule :: Lens' BenchmarkStanza (Maybe ModuleName)-benchmarkStanzaBenchmarkModule f s = fmap (\x -> s { _benchmarkStanzaBenchmarkModule = x }) (f (_benchmarkStanzaBenchmarkModule s))-{-# INLINE benchmarkStanzaBenchmarkModule #-}--benchmarkStanzaBuildInfo :: Lens' BenchmarkStanza BuildInfo-benchmarkStanzaBuildInfo f s = fmap (\x -> s { _benchmarkStanzaBuildInfo = x }) (f (_benchmarkStanzaBuildInfo s))-{-# INLINE benchmarkStanzaBuildInfo #-}--benchmarkFieldGrammar-    :: ( FieldGrammar c g, Applicative (g BenchmarkStanza), Applicative (g BuildInfo)-       , c (Identity BenchmarkType)-       , c (Identity ModuleName)-       , c (List CommaFSep (Identity ExeDependency) ExeDependency)-       , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)-       , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)-       , c (List CommaVCat (Identity Dependency) Dependency)-       , c (List CommaVCat (Identity Mixin) Mixin)-       , c (List FSep (MQuoted Extension) Extension)-       , c (List FSep (MQuoted Language) Language)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (List NoCommaFSep Token' String)-       , c (List VCat (MQuoted ModuleName) ModuleName)-       , c (List VCat FilePathNT String)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       , c (List VCat Token String)-       , c (MQuoted Language)-       )-    => g BenchmarkStanza BenchmarkStanza-benchmarkFieldGrammar = BenchmarkStanza-    <$> optionalField    "type"                        benchmarkStanzaBenchmarkType-    <*> optionalFieldAla "main-is"          FilePathNT benchmarkStanzaMainIs-    <*> optionalField    "benchmark-module"            benchmarkStanzaBenchmarkModule-    <*> blurFieldGrammar benchmarkStanzaBuildInfo buildInfoFieldGrammar--validateBenchmark :: CabalSpecVersion -> Position -> BenchmarkStanza -> ParseResult Benchmark-validateBenchmark cabalSpecVersion pos stanza = case benchmarkStanzaType of-    Nothing -> pure emptyBenchmark-        { benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza }--    Just tt@(BenchmarkTypeUnknown _ _) -> pure emptyBenchmark-        { benchmarkInterface = BenchmarkUnsupported tt-        , benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza-        }--    Just tt | tt `notElem` knownBenchmarkTypes -> pure emptyBenchmark-        { benchmarkInterface = BenchmarkUnsupported tt-        , benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza-        }--    Just tt@(BenchmarkTypeExe ver) -> case _benchmarkStanzaMainIs stanza of-        Nothing   -> do-            parseFailure pos (missingField "main-is" tt)-            pure emptyBenchmark-        Just file -> do-            when (isJust (_benchmarkStanzaBenchmarkModule stanza)) $-                parseWarning pos PWTExtraBenchmarkModule (extraField "benchmark-module" tt)-            pure emptyBenchmark-                { benchmarkInterface = BenchmarkExeV10 ver file-                , benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza-                }--  where-    benchmarkStanzaType = _benchmarkStanzaBenchmarkType stanza <|> do-        guard (cabalSpecVersion >= CabalSpecV3_8)--        benchmarkTypeExe <$ _benchmarkStanzaMainIs stanza--    missingField name tt = "The '" ++ name ++ "' field is required for the "-                        ++ prettyShow tt ++ " benchmark type."--    extraField   name tt = "The '" ++ name ++ "' field is not used for the '"-                        ++ prettyShow tt ++ "' benchmark type."--unvalidateBenchmark :: Benchmark -> BenchmarkStanza-unvalidateBenchmark b = BenchmarkStanza-    { _benchmarkStanzaBenchmarkType   = ty-    , _benchmarkStanzaMainIs          = ma-    , _benchmarkStanzaBenchmarkModule = mo-    , _benchmarkStanzaBuildInfo       = benchmarkBuildInfo b-    }-  where-    (ty, ma, mo) = case benchmarkInterface b of-        BenchmarkExeV10 ver ""  -> (Just $ BenchmarkTypeExe ver, Nothing,  Nothing)-        BenchmarkExeV10 ver ma' -> (Just $ BenchmarkTypeExe ver, Just ma', Nothing)-        _                       -> (Nothing, Nothing,  Nothing)------------------------------------------------------------------------------------ Build info----------------------------------------------------------------------------------buildInfoFieldGrammar-    :: ( FieldGrammar c g, Applicative (g BuildInfo)-       , c (List CommaFSep (Identity ExeDependency) ExeDependency)-       , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)-       , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)-       , c (List CommaVCat (Identity Dependency) Dependency)-       , c (List CommaVCat (Identity Mixin) Mixin)-       , c (List FSep (MQuoted Extension) Extension)-       , c (List FSep (MQuoted Language) Language)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (List NoCommaFSep Token' String)-       , c (List VCat (MQuoted ModuleName) ModuleName)-       , c (List VCat FilePathNT String)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       , c (List VCat Token String)-       , c (MQuoted Language)-       )-    => g BuildInfo BuildInfo-buildInfoFieldGrammar = BuildInfo-    <$> booleanFieldDef  "buildable"                                          L.buildable True-    <*> monoidalFieldAla "build-tools"          (alaList  CommaFSep)          L.buildTools-        ^^^ deprecatedSince CabalSpecV2_0-            "Please use 'build-tool-depends' field"-        ^^^ removedIn CabalSpecV3_0-            "Please use 'build-tool-depends' field."-    <*> monoidalFieldAla "build-tool-depends"   (alaList  CommaFSep)          L.buildToolDepends-        -- {- ^^^ availableSince [2,0] [] -}-        -- here, we explicitly want to recognise build-tool-depends for all Cabal files-        -- as otherwise cabal new-build cannot really work.-        ---        -- I.e. we don't want trigger unknown field warning-    <*> monoidalFieldAla "cpp-options"          (alaList' NoCommaFSep Token') L.cppOptions-    <*> monoidalFieldAla "asm-options"          (alaList' NoCommaFSep Token') L.asmOptions-        ^^^ availableSince CabalSpecV3_0 []-    <*> monoidalFieldAla "cmm-options"          (alaList' NoCommaFSep Token') L.cmmOptions-        ^^^ availableSince CabalSpecV3_0 []-    <*> monoidalFieldAla "cc-options"           (alaList' NoCommaFSep Token') L.ccOptions-    <*> monoidalFieldAla "cxx-options"          (alaList' NoCommaFSep Token') L.cxxOptions-        ^^^ availableSince CabalSpecV2_2 []-    <*> monoidalFieldAla "ld-options"           (alaList' NoCommaFSep Token') L.ldOptions-    <*> monoidalFieldAla "hsc2hs-options"       (alaList' NoCommaFSep Token') L.hsc2hsOptions-        ^^^ availableSince CabalSpecV3_6 []-    <*> monoidalFieldAla "pkgconfig-depends"    (alaList  CommaFSep)          L.pkgconfigDepends-    <*> monoidalFieldAla "frameworks"           (alaList' FSep Token)         L.frameworks-    <*> monoidalFieldAla "extra-framework-dirs" (alaList' FSep FilePathNT)    L.extraFrameworkDirs-    <*> monoidalFieldAla "asm-sources"          (alaList' VCat FilePathNT)    L.asmSources-        ^^^ availableSince CabalSpecV3_0 []-    <*> monoidalFieldAla "cmm-sources"          (alaList' VCat FilePathNT)    L.cmmSources-        ^^^ availableSince CabalSpecV3_0 []-    <*> monoidalFieldAla "c-sources"            (alaList' VCat FilePathNT)    L.cSources-    <*> monoidalFieldAla "cxx-sources"          (alaList' VCat FilePathNT)    L.cxxSources-        ^^^ availableSince CabalSpecV2_2 []-    <*> monoidalFieldAla "js-sources"           (alaList' VCat FilePathNT)    L.jsSources-    <*> hsSourceDirsGrammar-    <*> monoidalFieldAla "other-modules"        formatOtherModules            L.otherModules-    <*> monoidalFieldAla "virtual-modules"      (alaList' VCat MQuoted)       L.virtualModules-        ^^^ availableSince CabalSpecV2_2 []-    <*> monoidalFieldAla "autogen-modules"      (alaList' VCat MQuoted)       L.autogenModules-        ^^^ availableSince CabalSpecV2_0 []-    <*> optionalFieldAla "default-language"     MQuoted                       L.defaultLanguage-        ^^^ availableSince CabalSpecV1_10 Nothing-    <*> monoidalFieldAla "other-languages"      (alaList' FSep MQuoted)       L.otherLanguages-        ^^^ availableSince CabalSpecV1_10 []-    <*> monoidalFieldAla "default-extensions"   (alaList' FSep MQuoted)       L.defaultExtensions-        ^^^ availableSince CabalSpecV1_10 []-    <*> monoidalFieldAla "other-extensions"     formatOtherExtensions         L.otherExtensions-        ^^^ availableSinceWarn CabalSpecV1_10-    <*> monoidalFieldAla "extensions"           (alaList' FSep MQuoted)       L.oldExtensions-        ^^^ deprecatedSince CabalSpecV1_12-            "Please use 'default-extensions' or 'other-extensions' fields."-        ^^^ removedIn CabalSpecV3_0-            "Please use 'default-extensions' or 'other-extensions' fields."-    <*> monoidalFieldAla "extra-libraries"      (alaList' VCat Token)         L.extraLibs-    <*> monoidalFieldAla "extra-libraries-static" (alaList' VCat Token)       L.extraLibsStatic-        ^^^ availableSince CabalSpecV3_8 []-    <*> monoidalFieldAla "extra-ghci-libraries" (alaList' VCat Token)         L.extraGHCiLibs-    <*> monoidalFieldAla "extra-bundled-libraries" (alaList' VCat Token)      L.extraBundledLibs-    <*> monoidalFieldAla "extra-library-flavours" (alaList' VCat Token)       L.extraLibFlavours-    <*> monoidalFieldAla "extra-dynamic-library-flavours" (alaList' VCat Token) L.extraDynLibFlavours-        ^^^ availableSince CabalSpecV3_0 []-    <*> monoidalFieldAla "extra-lib-dirs"       (alaList' FSep FilePathNT)    L.extraLibDirs-    <*> monoidalFieldAla "extra-lib-dirs-static" (alaList' FSep FilePathNT)   L.extraLibDirsStatic-        ^^^ availableSince CabalSpecV3_8 []-    <*> monoidalFieldAla "include-dirs"         (alaList' FSep FilePathNT)    L.includeDirs-    <*> monoidalFieldAla "includes"             (alaList' FSep FilePathNT)    L.includes-    <*> monoidalFieldAla "autogen-includes"     (alaList' FSep FilePathNT)    L.autogenIncludes-        ^^^ availableSince CabalSpecV3_0 []-    <*> monoidalFieldAla "install-includes"     (alaList' FSep FilePathNT)    L.installIncludes-    <*> optionsFieldGrammar-    <*> profOptionsFieldGrammar-    <*> sharedOptionsFieldGrammar-    <*> pure mempty -- static-options ???-    <*> prefixedFields   "x-"                                                 L.customFieldsBI-    <*> monoidalFieldAla "build-depends"        formatDependencyList          L.targetBuildDepends-    <*> monoidalFieldAla "mixins"               formatMixinList               L.mixins-        ^^^ availableSince CabalSpecV2_0 []-{-# SPECIALIZE buildInfoFieldGrammar :: ParsecFieldGrammar' BuildInfo #-}-{-# SPECIALIZE buildInfoFieldGrammar :: PrettyFieldGrammar' BuildInfo #-}--hsSourceDirsGrammar-    :: ( FieldGrammar c g, Applicative (g BuildInfo)-       , c (List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir))-       )-    => g BuildInfo [SymbolicPath PackageDir SourceDir]-hsSourceDirsGrammar = (++)-    <$> monoidalFieldAla "hs-source-dirs" formatHsSourceDirs L.hsSourceDirs-    <*> monoidalFieldAla "hs-source-dir"  (alaList FSep) wrongLens-        --- https://github.com/haskell/cabal/commit/49e3cdae3bdf21b017ccd42e66670ca402e22b44-        ^^^ deprecatedSince CabalSpecV1_2 "Please use 'hs-source-dirs'"-        ^^^ removedIn CabalSpecV3_0 "Please use 'hs-source-dirs' field."-  where-    -- TODO: make pretty printer aware of CabalSpecVersion-    wrongLens :: Functor f => LensLike' f BuildInfo [SymbolicPath PackageDir SourceDir]-    wrongLens f bi = (\fps -> set L.hsSourceDirs fps bi) <$> f []--optionsFieldGrammar-    :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))-    => g BuildInfo (PerCompilerFlavor [String])-optionsFieldGrammar = PerCompilerFlavor-    <$> monoidalFieldAla "ghc-options"   (alaList' NoCommaFSep Token') (extract GHC)-    <*> monoidalFieldAla "ghcjs-options" (alaList' NoCommaFSep Token') (extract GHCJS)-    -- NOTE: Hugs, NHC and JHC are not supported anymore, but these-    -- fields are kept around so that we can still parse legacy .cabal-    -- files that have them.-    <*  knownField "jhc-options"-    <*  knownField "hugs-options"-    <*  knownField "nhc98-options"-  where-    extract :: CompilerFlavor -> ALens' BuildInfo [String]-    extract flavor = L.options . lookupLens flavor--profOptionsFieldGrammar-    :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))-    => g BuildInfo (PerCompilerFlavor [String])-profOptionsFieldGrammar = PerCompilerFlavor-    <$> monoidalFieldAla "ghc-prof-options"   (alaList' NoCommaFSep Token') (extract GHC)-    <*> monoidalFieldAla "ghcjs-prof-options" (alaList' NoCommaFSep Token') (extract GHCJS)-  where-    extract :: CompilerFlavor -> ALens' BuildInfo [String]-    extract flavor = L.profOptions . lookupLens flavor--sharedOptionsFieldGrammar-    :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))-    => g BuildInfo (PerCompilerFlavor [String])-sharedOptionsFieldGrammar = PerCompilerFlavor-    <$> monoidalFieldAla "ghc-shared-options"   (alaList' NoCommaFSep Token') (extract GHC)-    <*> monoidalFieldAla "ghcjs-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)-  where-    extract :: CompilerFlavor -> ALens' BuildInfo [String]-    extract flavor = L.sharedOptions . lookupLens flavor--lookupLens :: (Functor f, Monoid v) => CompilerFlavor -> LensLike' f (PerCompilerFlavor v) v-lookupLens k f p@(PerCompilerFlavor ghc ghcjs)-    | k == GHC   = (\n -> PerCompilerFlavor n ghcjs) <$> f ghc-    | k == GHCJS = (\n -> PerCompilerFlavor ghc n) <$> f ghcjs-    | otherwise  = p <$ f mempty------------------------------------------------------------------------------------ Flag----------------------------------------------------------------------------------flagFieldGrammar-    :: (FieldGrammar c g, Applicative (g PackageFlag))-    =>  FlagName -> g PackageFlag PackageFlag-flagFieldGrammar name = MkPackageFlag name-    <$> freeTextFieldDef    "description"          L.flagDescription-    <*> booleanFieldDef     "default"              L.flagDefault     True-    <*> booleanFieldDef     "manual"               L.flagManual      False-{-# SPECIALIZE flagFieldGrammar :: FlagName -> ParsecFieldGrammar' PackageFlag #-}-{-# SPECIALIZE flagFieldGrammar :: FlagName -> PrettyFieldGrammar' PackageFlag #-}------------------------------------------------------------------------------------ SourceRepo----------------------------------------------------------------------------------sourceRepoFieldGrammar-    :: (FieldGrammar c g, Applicative (g SourceRepo), c (Identity RepoType), c Token, c FilePathNT)-    => RepoKind -> g SourceRepo SourceRepo-sourceRepoFieldGrammar kind = SourceRepo kind-    <$> optionalField    "type"                L.repoType-    <*> freeTextField    "location"            L.repoLocation-    <*> optionalFieldAla "module"   Token      L.repoModule-    <*> optionalFieldAla "branch"   Token      L.repoBranch-    <*> optionalFieldAla "tag"      Token      L.repoTag-    <*> optionalFieldAla "subdir"   FilePathNT L.repoSubdir-{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind -> ParsecFieldGrammar' SourceRepo #-}-{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind -> PrettyFieldGrammar' SourceRepo #-}------------------------------------------------------------------------------------ SetupBuildInfo----------------------------------------------------------------------------------setupBInfoFieldGrammar-    :: (FieldGrammar c g, Functor (g SetupBuildInfo), c (List CommaVCat (Identity Dependency) Dependency))-    => Bool -> g SetupBuildInfo SetupBuildInfo-setupBInfoFieldGrammar def = flip SetupBuildInfo def-    <$> monoidalFieldAla "setup-depends" (alaList CommaVCat) L.setupDepends-{-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> ParsecFieldGrammar' SetupBuildInfo #-}-{-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> PrettyFieldGrammar' SetupBuildInfo #-}------------------------------------------------------------------------------------ Define how field values should be formatted for 'pretty'.----------------------------------------------------------------------------------formatDependencyList :: [Dependency] -> List CommaVCat (Identity Dependency) Dependency-formatDependencyList = alaList CommaVCat--formatMixinList :: [Mixin] -> List CommaVCat (Identity Mixin) Mixin-formatMixinList = alaList CommaVCat--formatExtraSourceFiles :: [FilePath] -> List VCat FilePathNT FilePath-formatExtraSourceFiles = alaList' VCat FilePathNT--formatExposedModules :: [ModuleName] -> List VCat (MQuoted ModuleName) ModuleName-formatExposedModules = alaList' VCat MQuoted--formatHsSourceDirs :: [SymbolicPath PackageDir SourceDir] -> List FSep (Identity (SymbolicPath PackageDir SourceDir)) (SymbolicPath PackageDir SourceDir)-formatHsSourceDirs = alaList FSep--formatOtherExtensions :: [Extension] -> List FSep (MQuoted Extension) Extension-formatOtherExtensions = alaList' FSep MQuoted--formatOtherModules :: [ModuleName] -> List VCat (MQuoted ModuleName) ModuleName-formatOtherModules = alaList' VCat MQuoted------------------------------------------------------------------------------------ newtypes------------------------------------------------------------------------------------ | Compat FilePath accepts empty file path,--- but issues a warning.------ There are simply too many (~1200) package definition files------ @--- license-file: ""--- @------ and------ @--- data-dir: ""--- @------ across Hackage to outrule them completely.--- I suspect some of them are generated (e.g. formatted) by machine.----newtype CompatFilePath = CompatFilePath { getCompatFilePath :: FilePath } -- TODO: Change to use SymPath--instance Newtype String CompatFilePath--instance Parsec CompatFilePath where-    parsec = do-        token <- parsecToken-        if null token-        then do-            parsecWarning PWTEmptyFilePath "empty FilePath"-            return (CompatFilePath "")-        else return (CompatFilePath token)--instance Pretty CompatFilePath where-    pretty = showToken . getCompatFilePath--newtype CompatLicenseFile = CompatLicenseFile { getCompatLicenseFile :: [SymbolicPath PackageDir LicenseFile] }--instance Newtype [SymbolicPath PackageDir LicenseFile] CompatLicenseFile---- TODO-instance Parsec CompatLicenseFile where-    parsec = emptyToken <|> CompatLicenseFile . unpack' (alaList FSep) <$> parsec-      where-        emptyToken = P.try $ do-            token <- parsecToken-            if null token-            then return (CompatLicenseFile [])-            else P.unexpected "non-empty-token"--instance Pretty CompatLicenseFile where-    pretty = pretty . pack' (alaList FSep) . getCompatLicenseFile------------------------------------------------------------------------------------ vim syntax definitions------------------------------------------------------------------------------------ | '_syntaxFieldNames' and '_syntaxExtensions'--- are for generating VIM syntax file definitions.----_syntaxFieldNames :: IO ()-_syntaxFieldNames = sequence_-    [ BS8.putStrLn $ " \\ " <> n-    | n <- nub $ sort $ mconcat-        [ fieldGrammarKnownFieldList packageDescriptionFieldGrammar-        , fieldGrammarKnownFieldList $ libraryFieldGrammar LMainLibName-        , fieldGrammarKnownFieldList $ executableFieldGrammar "exe"-        , fieldGrammarKnownFieldList $ foreignLibFieldGrammar "flib"-        , fieldGrammarKnownFieldList testSuiteFieldGrammar-        , fieldGrammarKnownFieldList benchmarkFieldGrammar-        , fieldGrammarKnownFieldList $ flagFieldGrammar (error "flagname")-        , fieldGrammarKnownFieldList $ sourceRepoFieldGrammar (error "repokind")-        , fieldGrammarKnownFieldList $ setupBInfoFieldGrammar True-        ]-    ]--_syntaxExtensions :: IO ()-_syntaxExtensions = sequence_-    [ putStrLn $ "  \\ " <> e-    | e <- ["Safe","Trustworthy","Unsafe"]-        ++ es-        ++ map ("No"++) es-    ]-  where-    es = nub $ sort-          [ prettyShow e-          | e <- [ minBound .. maxBound ]-          , e `notElem` [Safe,Unsafe,Trustworthy]+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuantifiedConstraints #-}++-- | 'GenericPackageDescription' Field descriptions+module Distribution.PackageDescription.FieldGrammar+  ( -- * Package description+    packageDescriptionFieldGrammar+  , CompatDataDir (..)+  , CompatLicenseFile (..)++    -- * Library+  , libraryFieldGrammar++    -- * Foreign library+  , foreignLibFieldGrammar++    -- * Executable+  , executableFieldGrammar++    -- * Test suite+  , TestSuiteStanza (..)+  , testSuiteFieldGrammar+  , validateTestSuite+  , unvalidateTestSuite++    -- ** Lenses+  , testStanzaTestType+  , testStanzaMainIs+  , testStanzaTestModule+  , testStanzaBuildInfo++    -- * Benchmark+  , BenchmarkStanza (..)+  , benchmarkFieldGrammar+  , validateBenchmark+  , unvalidateBenchmark++    -- * Field grammars+  , formatDependencyList+  , formatExposedModules+  , formatExtraSourceFiles+  , formatHsSourceDirs+  , formatMixinList+  , formatOtherExtensions+  , formatOtherModules++    -- ** Lenses+  , benchmarkStanzaBenchmarkType+  , benchmarkStanzaMainIs+  , benchmarkStanzaBenchmarkModule+  , benchmarkStanzaBuildInfo++    -- * Flag+  , flagFieldGrammar++    -- * Source repository+  , sourceRepoFieldGrammar++    -- * Setup build info+  , setupBInfoFieldGrammar++    -- * Component build info+  , buildInfoFieldGrammar+  ) where++import Distribution.Compat.Lens+import Distribution.Compat.Prelude+import Language.Haskell.Extension+import Prelude ()++import Distribution.CabalSpecVersion+import Distribution.Compat.Newtype (Newtype, pack', unpack')+import Distribution.Compiler (CompilerFlavor (..), PerCompilerFlavor (..))+import Distribution.FieldGrammar+import Distribution.Fields+import Distribution.ModuleName (ModuleName)+import Distribution.Package+import Distribution.PackageDescription+import Distribution.Parsec+import Distribution.Pretty (Pretty (..), prettyShow, showToken)+import Distribution.Utils.Path+import Distribution.Version (Version, VersionRange)++import qualified Data.ByteString.Char8 as BS8+import qualified Distribution.Compat.CharParsing as P+import qualified Distribution.SPDX as SPDX+import qualified Distribution.Types.Lens as L++-------------------------------------------------------------------------------+-- PackageDescription+-------------------------------------------------------------------------------++packageDescriptionFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g PackageDescription)+     , Applicative (g PackageIdentifier)+     , c (Identity BuildType)+     , c (Identity PackageName)+     , c (Identity Version)+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (RelativePathNT from to) (RelativePath from to))+     , c (List FSep TestedWith (CompilerFlavor, VersionRange))+     , c CompatLicenseFile+     , c CompatDataDir+     )+  => g PackageDescription PackageDescription+packageDescriptionFieldGrammar =+  PackageDescription+    <$> optionalFieldDefAla "cabal-version" SpecVersion L.specVersion CabalSpecV1_0+    <*> blurFieldGrammar L.package packageIdentifierGrammar+    <*> optionalFieldDefAla "license" SpecLicense L.licenseRaw (Left SPDX.NONE)+    <*> licenseFilesGrammar+    <*> freeTextFieldDefST "copyright" L.copyright+    <*> freeTextFieldDefST "maintainer" L.maintainer+    <*> freeTextFieldDefST "author" L.author+    <*> freeTextFieldDefST "stability" L.stability+    <*> monoidalFieldAla "tested-with" (alaList' FSep TestedWith) L.testedWith+    <*> freeTextFieldDefST "homepage" L.homepage+    <*> freeTextFieldDefST "package-url" L.pkgUrl+    <*> freeTextFieldDefST "bug-reports" L.bugReports+    <*> pure [] -- source-repos are stanza+    <*> freeTextFieldDefST "synopsis" L.synopsis+    <*> freeTextFieldDefST "description" L.description+    <*> freeTextFieldDefST "category" L.category+    <*> prefixedFields "x-" L.customFieldsPD+    <*> optionalField "build-type" L.buildTypeRaw+    <*> pure Nothing -- custom-setup+    -- components+    <*> pure Nothing -- lib+    <*> pure [] -- sub libs+    <*> pure [] -- executables+    <*> pure [] -- foreign libs+    <*> pure [] -- test suites+    <*> pure [] -- benchmarks+    --  * Files+    <*> monoidalFieldAla "data-files" (alaList' VCat RelativePathNT) L.dataFiles+    <*> optionalFieldDefAla "data-dir" CompatDataDir L.dataDir sameDirectory+      ^^^ fmap (\x -> if null (getSymbolicPath x) then sameDirectory else x) -- map empty directories to "."+    <*> monoidalFieldAla "extra-source-files" formatExtraSourceFiles L.extraSrcFiles+    <*> monoidalFieldAla "extra-tmp-files" (alaList' VCat RelativePathNT) L.extraTmpFiles+    <*> monoidalFieldAla "extra-doc-files" formatExtraSourceFiles L.extraDocFiles+    <*> monoidalFieldAla "extra-files" formatExtraSourceFiles L.extraFiles+      ^^^ availableSince CabalSpecV3_14 []+  where+    packageIdentifierGrammar =+      PackageIdentifier+        <$> uniqueField "name" L.pkgName+        <*> uniqueField "version" L.pkgVersion++    licenseFilesGrammar =+      (++)+        -- TODO: neither field is deprecated+        -- should we pretty print license-file if there's single license file+        -- and license-files when more+        <$> monoidalFieldAla "license-file" CompatLicenseFile L.licenseFiles+        <*> monoidalFieldAla "license-files" (alaList' FSep RelativePathNT) L.licenseFiles+          ^^^ hiddenField++-------------------------------------------------------------------------------+-- Library+-------------------------------------------------------------------------------++libraryFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g Library)+     , Applicative (g BuildInfo)+     , c (Identity LibraryVisibility)+     , c (List CommaFSep (Identity ExeDependency) ExeDependency)+     , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)+     , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)+     , c (List CommaVCat (Identity Dependency) Dependency)+     , c (List CommaVCat (Identity Mixin) Mixin)+     , c (List CommaVCat (Identity ModuleReexport) ModuleReexport)+     , c (List FSep (MQuoted Extension) Extension)+     , c (List FSep (MQuoted Language) Language)+     , c (List FSep Token String)+     , c (List NoCommaFSep Token' String)+     , c (List VCat (MQuoted ModuleName) ModuleName)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (SymbolicPathNT from to) (SymbolicPath from to))+     , c (List VCat Token String)+     , c (MQuoted Language)+     )+  => LibraryName+  -> g Library Library+libraryFieldGrammar n =+  Library n+    <$> monoidalFieldAla "exposed-modules" formatExposedModules L.exposedModules+    <*> monoidalFieldAla "reexported-modules" (alaList CommaVCat) L.reexportedModules+    <*> monoidalFieldAla "signatures" (alaList' VCat MQuoted) L.signatures+      ^^^ availableSince CabalSpecV2_0 []+    <*> booleanFieldDef "exposed" L.libExposed True+    <*> visibilityField+    <*> blurFieldGrammar L.libBuildInfo buildInfoFieldGrammar+  where+    visibilityField = case n of+      -- nameless/"main" libraries are public+      LMainLibName -> pure LibraryVisibilityPublic+      -- named libraries have the field+      LSubLibName _ ->+        optionalFieldDef "visibility" L.libVisibility LibraryVisibilityPrivate+          ^^^ availableSince CabalSpecV3_0 LibraryVisibilityPrivate+{-# SPECIALIZE libraryFieldGrammar :: LibraryName -> ParsecFieldGrammar' Library #-}+{-# SPECIALIZE libraryFieldGrammar :: LibraryName -> PrettyFieldGrammar' Library #-}++-------------------------------------------------------------------------------+-- Foreign library+-------------------------------------------------------------------------------++foreignLibFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g ForeignLib)+     , Applicative (g BuildInfo)+     , c (Identity ForeignLibType)+     , c (Identity LibVersionInfo)+     , c (Identity Version)+     , c (List CommaFSep (Identity ExeDependency) ExeDependency)+     , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)+     , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)+     , c (List CommaVCat (Identity Dependency) Dependency)+     , c (List CommaVCat (Identity Mixin) Mixin)+     , c (List FSep (Identity ForeignLibOption) ForeignLibOption)+     , c (List FSep (MQuoted Extension) Extension)+     , c (List FSep (MQuoted Language) Language)+     , c (List FSep Token String)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (SymbolicPathNT from to) (SymbolicPath from to))+     , c (List NoCommaFSep Token' String)+     , c (List VCat (MQuoted ModuleName) ModuleName)+     , c (List VCat Token String)+     , c (MQuoted Language)+     )+  => UnqualComponentName+  -> g ForeignLib ForeignLib+foreignLibFieldGrammar n =+  ForeignLib n+    <$> optionalFieldDef "type" L.foreignLibType ForeignLibTypeUnknown+    <*> monoidalFieldAla "options" (alaList FSep) L.foreignLibOptions+    <*> blurFieldGrammar L.foreignLibBuildInfo buildInfoFieldGrammar+    <*> optionalField "lib-version-info" L.foreignLibVersionInfo+    <*> optionalField "lib-version-linux" L.foreignLibVersionLinux+    <*> monoidalFieldAla "mod-def-file" (alaList' FSep RelativePathNT) L.foreignLibModDefFile+{-# SPECIALIZE foreignLibFieldGrammar :: UnqualComponentName -> ParsecFieldGrammar' ForeignLib #-}+{-# SPECIALIZE foreignLibFieldGrammar :: UnqualComponentName -> PrettyFieldGrammar' ForeignLib #-}++-------------------------------------------------------------------------------+-- Executable+-------------------------------------------------------------------------------++executableFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g Executable)+     , Applicative (g BuildInfo)+     , c (Identity ExecutableScope)+     , c (List CommaFSep (Identity ExeDependency) ExeDependency)+     , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)+     , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)+     , c (List CommaVCat (Identity Dependency) Dependency)+     , c (List CommaVCat (Identity Mixin) Mixin)+     , c (List FSep (MQuoted Extension) Extension)+     , c (List FSep (MQuoted Language) Language)+     , c (List FSep Token String)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (SymbolicPathNT from to)+     , forall from to. c (RelativePathNT from to)+     , c (List NoCommaFSep Token' String)+     , c (List VCat (MQuoted ModuleName) ModuleName)+     , c (List VCat Token String)+     , c (MQuoted Language)+     )+  => UnqualComponentName+  -> g Executable Executable+executableFieldGrammar n =+  Executable n+    -- main-is is optional as conditional blocks don't have it+    <$> optionalFieldDefAla "main-is" RelativePathNT L.modulePath (modulePath mempty)+    <*> optionalFieldDef "scope" L.exeScope ExecutablePublic+      ^^^ availableSince CabalSpecV2_0 ExecutablePublic+    <*> blurFieldGrammar L.buildInfo buildInfoFieldGrammar+{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> ParsecFieldGrammar' Executable #-}+{-# SPECIALIZE executableFieldGrammar :: UnqualComponentName -> PrettyFieldGrammar' Executable #-}++-------------------------------------------------------------------------------+-- TestSuite+-------------------------------------------------------------------------------++-- | An intermediate type just used for parsing the test-suite stanza.+-- After validation it is converted into the proper 'TestSuite' type.+data TestSuiteStanza = TestSuiteStanza+  { _testStanzaTestType :: Maybe TestType+  , _testStanzaMainIs :: Maybe (RelativePath Source File)+  , _testStanzaTestModule :: Maybe ModuleName+  , _testStanzaBuildInfo :: BuildInfo+  , _testStanzaCodeGenerators :: [String]+  }++instance L.HasBuildInfo TestSuiteStanza where+  buildInfo = testStanzaBuildInfo++testStanzaTestType :: Lens' TestSuiteStanza (Maybe TestType)+testStanzaTestType f s = fmap (\x -> s{_testStanzaTestType = x}) (f (_testStanzaTestType s))+{-# INLINE testStanzaTestType #-}++testStanzaMainIs :: Lens' TestSuiteStanza (Maybe (RelativePath Source File))+testStanzaMainIs f s = fmap (\x -> s{_testStanzaMainIs = x}) (f (_testStanzaMainIs s))+{-# INLINE testStanzaMainIs #-}++testStanzaTestModule :: Lens' TestSuiteStanza (Maybe ModuleName)+testStanzaTestModule f s = fmap (\x -> s{_testStanzaTestModule = x}) (f (_testStanzaTestModule s))+{-# INLINE testStanzaTestModule #-}++testStanzaBuildInfo :: Lens' TestSuiteStanza BuildInfo+testStanzaBuildInfo f s = fmap (\x -> s{_testStanzaBuildInfo = x}) (f (_testStanzaBuildInfo s))+{-# INLINE testStanzaBuildInfo #-}++testStanzaCodeGenerators :: Lens' TestSuiteStanza [String]+testStanzaCodeGenerators f s = fmap (\x -> s{_testStanzaCodeGenerators = x}) (f (_testStanzaCodeGenerators s))+{-# INLINE testStanzaCodeGenerators #-}++testSuiteFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g TestSuiteStanza)+     , Applicative (g BuildInfo)+     , c (Identity ModuleName)+     , c (Identity TestType)+     , c (List CommaFSep (Identity ExeDependency) ExeDependency)+     , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)+     , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)+     , c (List CommaFSep Token String)+     , c (List CommaVCat (Identity Dependency) Dependency)+     , c (List CommaVCat (Identity Mixin) Mixin)+     , c (List FSep (MQuoted Extension) Extension)+     , c (List FSep (MQuoted Language) Language)+     , c (List FSep Token String)+     , c (List NoCommaFSep Token' String)+     , c (List VCat (MQuoted ModuleName) ModuleName)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (RelativePathNT from to)+     , c (List VCat Token String)+     , c (MQuoted Language)+     )+  => g TestSuiteStanza TestSuiteStanza+testSuiteFieldGrammar =+  TestSuiteStanza+    <$> optionalField "type" testStanzaTestType+    <*> optionalFieldAla "main-is" RelativePathNT testStanzaMainIs+    <*> optionalField "test-module" testStanzaTestModule+    <*> blurFieldGrammar testStanzaBuildInfo buildInfoFieldGrammar+    <*> monoidalFieldAla "code-generators" (alaList' CommaFSep Token) testStanzaCodeGenerators+      ^^^ availableSince CabalSpecV3_8 []++validateTestSuite :: CabalSpecVersion -> Position -> TestSuiteStanza -> ParseResult TestSuite+validateTestSuite cabalSpecVersion pos stanza = case testSuiteType of+  Nothing -> pure basicTestSuite+  Just tt@(TestTypeUnknown _ _) ->+    pure+      basicTestSuite+        { testInterface = TestSuiteUnsupported tt+        }+  Just tt+    | tt `notElem` knownTestTypes ->+        pure+          basicTestSuite+            { testInterface = TestSuiteUnsupported tt+            }+  Just tt@(TestTypeExe ver) -> case _testStanzaMainIs stanza of+    Nothing -> do+      parseFailure pos (missingField "main-is" tt)+      pure emptyTestSuite+    Just file -> do+      when (isJust (_testStanzaTestModule stanza)) $+        parseWarning pos PWTExtraBenchmarkModule (extraField "test-module" tt)+      pure+        basicTestSuite+          { testInterface = TestSuiteExeV10 ver file+          }+  Just tt@(TestTypeLib ver) -> case _testStanzaTestModule stanza of+    Nothing -> do+      parseFailure pos (missingField "test-module" tt)+      pure emptyTestSuite+    Just module_ -> do+      when (isJust (_testStanzaMainIs stanza)) $+        parseWarning pos PWTExtraMainIs (extraField "main-is" tt)+      pure+        basicTestSuite+          { testInterface = TestSuiteLibV09 ver module_+          }+  where+    testSuiteType =+      _testStanzaTestType stanza+        <|> do+          guard (cabalSpecVersion >= CabalSpecV3_8)++          testTypeExe <$ _testStanzaMainIs stanza+        <|> testTypeLib <$ _testStanzaTestModule stanza++    missingField name tt =+      "The '"+        ++ name+        ++ "' field is required for the "+        ++ prettyShow tt+        ++ " test suite type."++    extraField name tt =+      "The '"+        ++ name+        ++ "' field is not used for the '"+        ++ prettyShow tt+        ++ "' test suite type."+    basicTestSuite =+      emptyTestSuite+        { testBuildInfo = _testStanzaBuildInfo stanza+        , testCodeGenerators = _testStanzaCodeGenerators stanza+        }++unvalidateTestSuite :: TestSuite -> TestSuiteStanza+unvalidateTestSuite t =+  TestSuiteStanza+    { _testStanzaTestType = ty+    , _testStanzaMainIs = ma+    , _testStanzaTestModule = mo+    , _testStanzaBuildInfo = testBuildInfo t+    , _testStanzaCodeGenerators = testCodeGenerators t+    }+  where+    (ty, ma, mo) = case testInterface t of+      TestSuiteExeV10 ver file -> (Just $ TestTypeExe ver, Just file, Nothing)+      TestSuiteLibV09 ver modu -> (Just $ TestTypeLib ver, Nothing, Just modu)+      _ -> (Nothing, Nothing, Nothing)++-------------------------------------------------------------------------------+-- Benchmark+-------------------------------------------------------------------------------++-- | An intermediate type just used for parsing the benchmark stanza.+-- After validation it is converted into the proper 'Benchmark' type.+data BenchmarkStanza = BenchmarkStanza+  { _benchmarkStanzaBenchmarkType :: Maybe BenchmarkType+  , _benchmarkStanzaMainIs :: Maybe (RelativePath Source File)+  , _benchmarkStanzaBenchmarkModule :: Maybe ModuleName+  , _benchmarkStanzaBuildInfo :: BuildInfo+  }++instance L.HasBuildInfo BenchmarkStanza where+  buildInfo = benchmarkStanzaBuildInfo++benchmarkStanzaBenchmarkType :: Lens' BenchmarkStanza (Maybe BenchmarkType)+benchmarkStanzaBenchmarkType f s = fmap (\x -> s{_benchmarkStanzaBenchmarkType = x}) (f (_benchmarkStanzaBenchmarkType s))+{-# INLINE benchmarkStanzaBenchmarkType #-}++benchmarkStanzaMainIs :: Lens' BenchmarkStanza (Maybe (RelativePath Source File))+benchmarkStanzaMainIs f s = fmap (\x -> s{_benchmarkStanzaMainIs = x}) (f (_benchmarkStanzaMainIs s))+{-# INLINE benchmarkStanzaMainIs #-}++benchmarkStanzaBenchmarkModule :: Lens' BenchmarkStanza (Maybe ModuleName)+benchmarkStanzaBenchmarkModule f s = fmap (\x -> s{_benchmarkStanzaBenchmarkModule = x}) (f (_benchmarkStanzaBenchmarkModule s))+{-# INLINE benchmarkStanzaBenchmarkModule #-}++benchmarkStanzaBuildInfo :: Lens' BenchmarkStanza BuildInfo+benchmarkStanzaBuildInfo f s = fmap (\x -> s{_benchmarkStanzaBuildInfo = x}) (f (_benchmarkStanzaBuildInfo s))+{-# INLINE benchmarkStanzaBuildInfo #-}++benchmarkFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g BenchmarkStanza)+     , Applicative (g BuildInfo)+     , c (Identity BenchmarkType)+     , c (Identity ModuleName)+     , c (List CommaFSep (Identity ExeDependency) ExeDependency)+     , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)+     , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)+     , c (List CommaVCat (Identity Dependency) Dependency)+     , c (List CommaVCat (Identity Mixin) Mixin)+     , c (List FSep (MQuoted Extension) Extension)+     , c (List FSep (MQuoted Language) Language)+     , c (List FSep Token String)+     , c (List NoCommaFSep Token' String)+     , c (List VCat (MQuoted ModuleName) ModuleName)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (RelativePathNT from to)+     , c (List VCat Token String)+     , c (MQuoted Language)+     )+  => g BenchmarkStanza BenchmarkStanza+benchmarkFieldGrammar =+  BenchmarkStanza+    <$> optionalField "type" benchmarkStanzaBenchmarkType+    <*> optionalFieldAla "main-is" RelativePathNT benchmarkStanzaMainIs+    <*> optionalField "benchmark-module" benchmarkStanzaBenchmarkModule+    <*> blurFieldGrammar benchmarkStanzaBuildInfo buildInfoFieldGrammar++validateBenchmark :: CabalSpecVersion -> Position -> BenchmarkStanza -> ParseResult Benchmark+validateBenchmark cabalSpecVersion pos stanza = case benchmarkStanzaType of+  Nothing ->+    pure+      emptyBenchmark+        { benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza+        }+  Just tt@(BenchmarkTypeUnknown _ _) ->+    pure+      emptyBenchmark+        { benchmarkInterface = BenchmarkUnsupported tt+        , benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza+        }+  Just tt+    | tt `notElem` knownBenchmarkTypes ->+        pure+          emptyBenchmark+            { benchmarkInterface = BenchmarkUnsupported tt+            , benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza+            }+  Just tt@(BenchmarkTypeExe ver) -> case _benchmarkStanzaMainIs stanza of+    Nothing -> do+      parseFailure pos (missingField "main-is" tt)+      pure emptyBenchmark+    Just file -> do+      when (isJust (_benchmarkStanzaBenchmarkModule stanza)) $+        parseWarning pos PWTExtraBenchmarkModule (extraField "benchmark-module" tt)+      pure+        emptyBenchmark+          { benchmarkInterface = BenchmarkExeV10 ver file+          , benchmarkBuildInfo = _benchmarkStanzaBuildInfo stanza+          }+  where+    benchmarkStanzaType =+      _benchmarkStanzaBenchmarkType stanza <|> do+        guard (cabalSpecVersion >= CabalSpecV3_8)++        benchmarkTypeExe <$ _benchmarkStanzaMainIs stanza++    missingField name tt =+      "The '"+        ++ name+        ++ "' field is required for the "+        ++ prettyShow tt+        ++ " benchmark type."++    extraField name tt =+      "The '"+        ++ name+        ++ "' field is not used for the '"+        ++ prettyShow tt+        ++ "' benchmark type."++unvalidateBenchmark :: Benchmark -> BenchmarkStanza+unvalidateBenchmark b =+  BenchmarkStanza+    { _benchmarkStanzaBenchmarkType = ty+    , _benchmarkStanzaMainIs = ma+    , _benchmarkStanzaBenchmarkModule = mo+    , _benchmarkStanzaBuildInfo = benchmarkBuildInfo b+    }+  where+    (ty, ma, mo) = case benchmarkInterface b of+      BenchmarkExeV10 ver ma'+        | getSymbolicPath ma' == "" ->+            (Just $ BenchmarkTypeExe ver, Nothing, Nothing)+        | otherwise ->+            (Just $ BenchmarkTypeExe ver, Just ma', Nothing)+      _ -> (Nothing, Nothing, Nothing)++-------------------------------------------------------------------------------+-- Build info+-------------------------------------------------------------------------------++buildInfoFieldGrammar+  :: ( FieldGrammar c g+     , Applicative (g BuildInfo)+     , c (List CommaFSep (Identity ExeDependency) ExeDependency)+     , c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)+     , c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)+     , c (List CommaVCat (Identity Dependency) Dependency)+     , c (List CommaVCat (Identity Mixin) Mixin)+     , c (List FSep (MQuoted Extension) Extension)+     , c (List FSep (MQuoted Language) Language)+     , c (List FSep Token String)+     , c (List NoCommaFSep Token' String)+     , c (List VCat (MQuoted ModuleName) ModuleName)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     , forall from to. c (List FSep (RelativePathNT from to) (RelativePath from to))+     , forall from to. c (List VCat (SymbolicPathNT from to) (SymbolicPath from to))+     , c (List VCat Token String)+     , c (MQuoted Language)+     )+  => g BuildInfo BuildInfo+buildInfoFieldGrammar =+  BuildInfo+    <$> booleanFieldDef "buildable" L.buildable True+    <*> monoidalFieldAla "build-tools" (alaList CommaFSep) L.buildTools+      ^^^ deprecatedSince+        CabalSpecV2_0+        "Please use 'build-tool-depends' field"+      ^^^ removedIn+        CabalSpecV3_0+        "Please use 'build-tool-depends' field."+    <*> monoidalFieldAla "build-tool-depends" (alaList CommaFSep) L.buildToolDepends+    -- {- ^^^ availableSince [2,0] [] -}+    -- here, we explicitly want to recognise build-tool-depends for all Cabal files+    -- as otherwise cabal new-build cannot really work.+    --+    -- I.e. we don't want trigger unknown field warning+    <*> monoidalFieldAla "cpp-options" (alaList' NoCommaFSep Token') L.cppOptions+    <*> monoidalFieldAla "asm-options" (alaList' NoCommaFSep Token') L.asmOptions+      ^^^ availableSince CabalSpecV3_0 []+    <*> monoidalFieldAla "cmm-options" (alaList' NoCommaFSep Token') L.cmmOptions+      ^^^ availableSince CabalSpecV3_0 []+    <*> monoidalFieldAla "cc-options" (alaList' NoCommaFSep Token') L.ccOptions+    <*> monoidalFieldAla "cxx-options" (alaList' NoCommaFSep Token') L.cxxOptions+      ^^^ availableSince CabalSpecV2_2 []+    <*> monoidalFieldAla "jspp-options" (alaList' NoCommaFSep Token') L.jsppOptions+      ^^^ availableSince CabalSpecV3_16 []+    <*> monoidalFieldAla "ld-options" (alaList' NoCommaFSep Token') L.ldOptions+    <*> monoidalFieldAla "hsc2hs-options" (alaList' NoCommaFSep Token') L.hsc2hsOptions+      ^^^ availableSince CabalSpecV3_6 []+    <*> monoidalFieldAla "pkgconfig-depends" (alaList CommaFSep) L.pkgconfigDepends+    <*> monoidalFieldAla "frameworks" (alaList' FSep RelativePathNT) L.frameworks+    <*> monoidalFieldAla "extra-framework-dirs" (alaList' FSep SymbolicPathNT) L.extraFrameworkDirs+    <*> monoidalFieldAla "asm-sources" (alaList' VCat SymbolicPathNT) L.asmSources+      ^^^ availableSince CabalSpecV3_0 []+    <*> monoidalFieldAla "cmm-sources" (alaList' VCat SymbolicPathNT) L.cmmSources+      ^^^ availableSince CabalSpecV3_0 []+    <*> monoidalFieldAla "c-sources" (alaList' VCat SymbolicPathNT) L.cSources+    <*> monoidalFieldAla "cxx-sources" (alaList' VCat SymbolicPathNT) L.cxxSources+      ^^^ availableSince CabalSpecV2_2 []+    <*> monoidalFieldAla "js-sources" (alaList' VCat SymbolicPathNT) L.jsSources+    <*> hsSourceDirsGrammar+    <*> monoidalFieldAla "other-modules" formatOtherModules L.otherModules+    <*> monoidalFieldAla "virtual-modules" (alaList' VCat MQuoted) L.virtualModules+      ^^^ availableSince CabalSpecV2_2 []+    <*> monoidalFieldAla "autogen-modules" (alaList' VCat MQuoted) L.autogenModules+      ^^^ availableSince CabalSpecV2_0 []+    <*> optionalFieldAla "default-language" MQuoted L.defaultLanguage+      ^^^ availableSince CabalSpecV1_10 Nothing+    <*> monoidalFieldAla "other-languages" (alaList' FSep MQuoted) L.otherLanguages+      ^^^ availableSince CabalSpecV1_10 []+    <*> monoidalFieldAla "default-extensions" (alaList' FSep MQuoted) L.defaultExtensions+      ^^^ availableSince CabalSpecV1_10 []+    <*> monoidalFieldAla "other-extensions" formatOtherExtensions L.otherExtensions+      ^^^ availableSinceWarn CabalSpecV1_10+    <*> monoidalFieldAla "extensions" (alaList' FSep MQuoted) L.oldExtensions+      ^^^ deprecatedSince+        CabalSpecV1_12+        "Please use 'default-extensions' or 'other-extensions' fields."+      ^^^ removedIn+        CabalSpecV3_0+        "Please use 'default-extensions' or 'other-extensions' fields."+    <*> monoidalFieldAla "extra-libraries" (alaList' VCat Token) L.extraLibs+    <*> monoidalFieldAla "extra-libraries-static" (alaList' VCat Token) L.extraLibsStatic+      ^^^ availableSince CabalSpecV3_8 []+    <*> monoidalFieldAla "extra-ghci-libraries" (alaList' VCat Token) L.extraGHCiLibs+    <*> monoidalFieldAla "extra-bundled-libraries" (alaList' VCat Token) L.extraBundledLibs+    <*> monoidalFieldAla "extra-library-flavours" (alaList' VCat Token) L.extraLibFlavours+    <*> monoidalFieldAla "extra-dynamic-library-flavours" (alaList' VCat Token) L.extraDynLibFlavours+      ^^^ availableSince CabalSpecV3_0 []+    <*> monoidalFieldAla "extra-lib-dirs" (alaList' FSep SymbolicPathNT) L.extraLibDirs+    <*> monoidalFieldAla "extra-lib-dirs-static" (alaList' FSep SymbolicPathNT) L.extraLibDirsStatic+      ^^^ availableSince CabalSpecV3_8 []+    <*> monoidalFieldAla "include-dirs" (alaList' FSep SymbolicPathNT) L.includeDirs+    <*> monoidalFieldAla "includes" (alaList' FSep SymbolicPathNT) L.includes+    <*> monoidalFieldAla "autogen-includes" (alaList' FSep RelativePathNT) L.autogenIncludes+      ^^^ availableSince CabalSpecV3_0 []+    <*> monoidalFieldAla "install-includes" (alaList' FSep RelativePathNT) L.installIncludes+    <*> optionsFieldGrammar+    <*> profOptionsFieldGrammar+    <*> sharedOptionsFieldGrammar+    <*> profSharedOptionsFieldGrammar+    <*> pure mempty -- static-options ???+    <*> prefixedFields "x-" L.customFieldsBI+    <*> monoidalFieldAla "build-depends" formatDependencyList L.targetBuildDepends+    <*> monoidalFieldAla "mixins" formatMixinList L.mixins+      ^^^ availableSince CabalSpecV2_0 []+{-# SPECIALIZE buildInfoFieldGrammar :: ParsecFieldGrammar' BuildInfo #-}+{-# SPECIALIZE buildInfoFieldGrammar :: PrettyFieldGrammar' BuildInfo #-}++hsSourceDirsGrammar+  :: ( FieldGrammar c g+     , Applicative (g BuildInfo)+     , forall from to. c (List FSep (SymbolicPathNT from to) (SymbolicPath from to))+     )+  => g BuildInfo [SymbolicPath Pkg (Dir Source)]+hsSourceDirsGrammar =+  (++)+    <$> monoidalFieldAla "hs-source-dirs" formatHsSourceDirs L.hsSourceDirs+    <*> monoidalFieldAla "hs-source-dir" (alaList' FSep SymbolicPathNT) wrongLens+      --- https://github.com/haskell/cabal/commit/49e3cdae3bdf21b017ccd42e66670ca402e22b44+      ^^^ deprecatedSince CabalSpecV1_2 "Please use 'hs-source-dirs'"+      ^^^ removedIn CabalSpecV3_0 "Please use 'hs-source-dirs' field."+  where+    -- TODO: make pretty printer aware of CabalSpecVersion+    wrongLens :: Functor f => LensLike' f BuildInfo [SymbolicPath Pkg (Dir Source)]+    wrongLens f bi = (\fps -> set L.hsSourceDirs fps bi) <$> f []++optionsFieldGrammar+  :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))+  => g BuildInfo (PerCompilerFlavor [String])+optionsFieldGrammar =+  PerCompilerFlavor+    <$> monoidalFieldAla "ghc-options" (alaList' NoCommaFSep Token') (extract GHC)+    <*> monoidalFieldAla "ghcjs-options" (alaList' NoCommaFSep Token') (extract GHCJS)+    -- NOTE: Hugs, NHC and JHC are not supported anymore, but these+    -- fields are kept around so that we can still parse legacy .cabal+    -- files that have them.+    <* knownField "jhc-options"+    <* knownField "hugs-options"+    <* knownField "nhc98-options"+  where+    extract :: CompilerFlavor -> ALens' BuildInfo [String]+    extract flavor = L.options . lookupLens flavor++profOptionsFieldGrammar+  :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))+  => g BuildInfo (PerCompilerFlavor [String])+profOptionsFieldGrammar =+  PerCompilerFlavor+    <$> monoidalFieldAla "ghc-prof-options" (alaList' NoCommaFSep Token') (extract GHC)+    <*> monoidalFieldAla "ghcjs-prof-options" (alaList' NoCommaFSep Token') (extract GHCJS)+  where+    extract :: CompilerFlavor -> ALens' BuildInfo [String]+    extract flavor = L.profOptions . lookupLens flavor++sharedOptionsFieldGrammar+  :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))+  => g BuildInfo (PerCompilerFlavor [String])+sharedOptionsFieldGrammar =+  PerCompilerFlavor+    <$> monoidalFieldAla "ghc-shared-options" (alaList' NoCommaFSep Token') (extract GHC)+    <*> monoidalFieldAla "ghcjs-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)+  where+    extract :: CompilerFlavor -> ALens' BuildInfo [String]+    extract flavor = L.sharedOptions . lookupLens flavor++profSharedOptionsFieldGrammar+  :: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))+  => g BuildInfo (PerCompilerFlavor [String])+profSharedOptionsFieldGrammar =+  PerCompilerFlavor+    <$> monoidalFieldAla "ghc-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHC)+      ^^^ availableSince CabalSpecV3_14 []+    <*> monoidalFieldAla "ghcjs-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)+      ^^^ availableSince CabalSpecV3_14 []+  where+    extract :: CompilerFlavor -> ALens' BuildInfo [String]+    extract flavor = L.profSharedOptions . lookupLens flavor++lookupLens :: (Functor f, Monoid v) => CompilerFlavor -> LensLike' f (PerCompilerFlavor v) v+lookupLens k f p@(PerCompilerFlavor ghc ghcjs)+  | k == GHC = (\n -> PerCompilerFlavor n ghcjs) <$> f ghc+  | k == GHCJS = (\n -> PerCompilerFlavor ghc n) <$> f ghcjs+  | otherwise = p <$ f mempty++-------------------------------------------------------------------------------+-- Flag+-------------------------------------------------------------------------------++flagFieldGrammar+  :: (FieldGrammar c g, Applicative (g PackageFlag))+  => FlagName+  -> g PackageFlag PackageFlag+flagFieldGrammar name =+  MkPackageFlag name+    <$> freeTextFieldDef "description" L.flagDescription+    <*> booleanFieldDef "default" L.flagDefault True+    <*> booleanFieldDef "manual" L.flagManual False+{-# SPECIALIZE flagFieldGrammar :: FlagName -> ParsecFieldGrammar' PackageFlag #-}+{-# SPECIALIZE flagFieldGrammar :: FlagName -> PrettyFieldGrammar' PackageFlag #-}++-------------------------------------------------------------------------------+-- SourceRepo+-------------------------------------------------------------------------------++sourceRepoFieldGrammar+  :: (FieldGrammar c g, Applicative (g SourceRepo), c (Identity RepoType), c Token, c FilePathNT)+  => RepoKind+  -> g SourceRepo SourceRepo+sourceRepoFieldGrammar kind =+  SourceRepo kind+    <$> optionalField "type" L.repoType+    <*> freeTextField "location" L.repoLocation+    <*> optionalFieldAla "module" Token L.repoModule+    <*> optionalFieldAla "branch" Token L.repoBranch+    <*> optionalFieldAla "tag" Token L.repoTag+    <*> optionalFieldAla "subdir" FilePathNT L.repoSubdir+{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind -> ParsecFieldGrammar' SourceRepo #-}+{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind -> PrettyFieldGrammar' SourceRepo #-}++-------------------------------------------------------------------------------+-- SetupBuildInfo+-------------------------------------------------------------------------------++setupBInfoFieldGrammar+  :: (FieldGrammar c g, Functor (g SetupBuildInfo), c (List CommaVCat (Identity Dependency) Dependency))+  => Bool+  -> g SetupBuildInfo SetupBuildInfo+setupBInfoFieldGrammar def =+  flip SetupBuildInfo def+    <$> monoidalFieldAla "setup-depends" (alaList CommaVCat) L.setupDepends+{-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> ParsecFieldGrammar' SetupBuildInfo #-}+{-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> PrettyFieldGrammar' SetupBuildInfo #-}++-------------------------------------------------------------------------------+-- Define how field values should be formatted for 'pretty'.+-------------------------------------------------------------------------------++formatDependencyList :: [Dependency] -> List CommaVCat (Identity Dependency) Dependency+formatDependencyList = alaList CommaVCat++formatMixinList :: [Mixin] -> List CommaVCat (Identity Mixin) Mixin+formatMixinList = alaList CommaVCat++formatExtraSourceFiles :: [RelativePath Pkg File] -> List VCat (RelativePathNT Pkg File) (RelativePath Pkg File)+formatExtraSourceFiles = alaList' VCat RelativePathNT++formatExposedModules :: [ModuleName] -> List VCat (MQuoted ModuleName) ModuleName+formatExposedModules = alaList' VCat MQuoted++formatHsSourceDirs :: [SymbolicPath Pkg (Dir Source)] -> List FSep (SymbolicPathNT Pkg (Dir Source)) (SymbolicPath Pkg (Dir Source))+formatHsSourceDirs = alaList' FSep SymbolicPathNT++formatOtherExtensions :: [Extension] -> List FSep (MQuoted Extension) Extension+formatOtherExtensions = alaList' FSep MQuoted++formatOtherModules :: [ModuleName] -> List VCat (MQuoted ModuleName) ModuleName+formatOtherModules = alaList' VCat MQuoted++-------------------------------------------------------------------------------+-- newtypes+-------------------------------------------------------------------------------++-- | Newtype for data directory (absolute or relative).+--+-- Accepts empty file path, but issues a warning;+-- there are simply too many (~1200) package definition files+--+-- @+-- data-dir: ""+-- @+--+-- across Hackage to outrule them completely.+-- I suspect some of them are generated (e.g. formatted) by machine.+newtype CompatDataDir = CompatDataDir {getCompatDataDir :: SymbolicPath Pkg (Dir DataDir)}++instance Newtype (SymbolicPath Pkg (Dir DataDir)) CompatDataDir++instance Parsec CompatDataDir where+  parsec = do+    token <- parsecToken+    when (null token) $+      parsecWarning PWTEmptyFilePath "empty FilePath"+    return (CompatDataDir $ makeSymbolicPath token)++instance Pretty CompatDataDir where+  pretty = showToken . getSymbolicPath . getCompatDataDir++newtype CompatLicenseFile = CompatLicenseFile {getCompatLicenseFile :: [RelativePath Pkg File]}++instance Newtype [RelativePath Pkg File] CompatLicenseFile++-- TODO+instance Parsec CompatLicenseFile where+  parsec = emptyToken <|> CompatLicenseFile . unpack' (alaList FSep) <$> parsec+    where+      emptyToken = P.try $ do+        token <- parsecToken+        if null token+          then return (CompatLicenseFile [])+          else P.unexpected "non-empty-token"++instance Pretty CompatLicenseFile where+  pretty = pretty . pack' (alaList FSep) . getCompatLicenseFile++-------------------------------------------------------------------------------+-- vim syntax definitions+-------------------------------------------------------------------------------++-- | '_syntaxFieldNames' and '_syntaxExtensions'+-- are for generating VIM syntax file definitions.+_syntaxFieldNames :: IO ()+_syntaxFieldNames =+  sequence_+    [ BS8.putStrLn $ " \\ " <> n+    | n <-+        nub $+          sort $+            mconcat+              [ fieldGrammarKnownFieldList packageDescriptionFieldGrammar+              , fieldGrammarKnownFieldList $ libraryFieldGrammar LMainLibName+              , fieldGrammarKnownFieldList $ executableFieldGrammar "exe"+              , fieldGrammarKnownFieldList $ foreignLibFieldGrammar "flib"+              , fieldGrammarKnownFieldList testSuiteFieldGrammar+              , fieldGrammarKnownFieldList benchmarkFieldGrammar+              , fieldGrammarKnownFieldList $ flagFieldGrammar (error "flagname")+              , fieldGrammarKnownFieldList $ sourceRepoFieldGrammar (error "repokind")+              , fieldGrammarKnownFieldList $ setupBInfoFieldGrammar True+              ]+    ]++_syntaxExtensions :: IO ()+_syntaxExtensions =+  sequence_+    [ putStrLn $ "  \\ " <> e+    | e <-+        ["Safe", "Trustworthy", "Unsafe"]+          ++ es+          ++ map ("No" ++) es+    ]+  where+    es =+      nub $+        sort+          [ prettyShow e+          | e <- [minBound .. maxBound]+          , e `notElem` [Safe, Unsafe, Trustworthy]           ]
src/Distribution/PackageDescription/Parsec.hs view
@@ -1,9 +1,8 @@-{-# LANGUAGE CPP                 #-}-{-# LANGUAGE FlexibleContexts    #-}-{-# LANGUAGE OverloadedStrings   #-}-{-# LANGUAGE Rank2Types          #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-}------------------------------------------------------------------------------+ -- | -- Module      :  Distribution.PackageDescription.Parsec -- Copyright   :  Isaac Jones 2003-2005@@ -13,92 +12,96 @@ -- Portability :  portable -- -- This defined parsers and partial pretty printers for the @.cabal@ format.--module Distribution.PackageDescription.Parsec (-    -- * Package descriptions-    parseGenericPackageDescription,-    parseGenericPackageDescriptionMaybe,+module Distribution.PackageDescription.Parsec+  ( -- * Package descriptions+    parseGenericPackageDescription+  , parseGenericPackageDescriptionMaybe      -- ** Parsing-    ParseResult,-    runParseResult,+  , ParseResult+  , runParseResult      -- * New-style spec-version-    scanSpecVersion,+  , scanSpecVersion      -- ** Supplementary build information-    parseHookedBuildInfo,-    ) where+  , parseHookedBuildInfo+  ) where  import Distribution.Compat.Prelude import Prelude () -import Control.Monad.State.Strict                    (StateT, execStateT)-import Control.Monad.Trans.Class                     (lift)+import Control.Monad.State.Strict (StateT, execStateT)+import Control.Monad.Trans.Class (lift) import Distribution.CabalSpecVersion import Distribution.Compat.Lens import Distribution.FieldGrammar-import Distribution.FieldGrammar.Parsec              (NamelessField (..))-import Distribution.Fields.ConfVar                   (parseConditionConfVar)-import Distribution.Fields.Field                     (FieldName, getName)-import Distribution.Fields.LexerMonad                (LexWarning, toPWarnings)-import Distribution.Fields.Parser+import Distribution.FieldGrammar.Parsec (NamelessField (..))+import Distribution.Fields.ConfVar (parseConditionConfVar)+import Distribution.Fields.Field (FieldName, getName)+import Distribution.Fields.LexerMonad (LexWarning, toPWarnings) import Distribution.Fields.ParseResult+import Distribution.Fields.Parser import Distribution.PackageDescription import Distribution.PackageDescription.Configuration (freeVars, transformAllBuildInfos) import Distribution.PackageDescription.FieldGrammar-import Distribution.PackageDescription.Quirks        (patchQuirks)-import Distribution.Parsec                           (parsec, simpleParsecBS)-import Distribution.Parsec.FieldLineStream           (fieldLineStreamFromBS)-import Distribution.Parsec.Position                  (Position (..), zeroPos)-import Distribution.Parsec.Warning                   (PWarnType (..))-import Distribution.Pretty                           (prettyShow)-import Distribution.Utils.Generic                    (breakMaybe, fromUTF8BS, toUTF8BS, unfoldrM, validateUTF8)-import Distribution.Version                          (Version, mkVersion, versionNumbers)+import Distribution.PackageDescription.Quirks (patchQuirks)+import Distribution.Parsec (parsec, simpleParsecBS)+import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS)+import Distribution.Parsec.Position (Position (..), zeroPos)+import Distribution.Parsec.Warning (PWarnType (..))+import Distribution.Pretty (prettyShow)+import Distribution.Utils.Generic (breakMaybe, fromUTF8BS, toUTF8BS, unfoldrM, validateUTF8)+import Distribution.Version (Version, mkVersion, versionNumbers) -import qualified Data.ByteString                                   as BS-import qualified Data.ByteString.Char8                             as BS8-import qualified Data.Map.Strict                                   as Map-import qualified Data.Set                                          as Set-import qualified Distribution.Compat.Newtype                       as Newtype-import qualified Distribution.Compat.NonEmptySet                   as NES-import qualified Distribution.Types.BuildInfo.Lens                 as L-import qualified Distribution.Types.Executable.Lens                as L-import qualified Distribution.Types.ForeignLib.Lens                as L+import qualified Data.ByteString as BS+import qualified Data.ByteString.Char8 as BS8+import qualified Data.Map.Strict as Map+import qualified Data.Set as Set+import qualified Distribution.Compat.Newtype as Newtype+import qualified Distribution.Compat.NonEmptySet as NES+import qualified Distribution.Types.BuildInfo.Lens as L+import qualified Distribution.Types.Executable.Lens as L+import qualified Distribution.Types.ForeignLib.Lens as L import qualified Distribution.Types.GenericPackageDescription.Lens as L-import qualified Distribution.Types.PackageDescription.Lens        as L-import qualified Distribution.Types.SetupBuildInfo.Lens            as L-import qualified Text.Parsec                                       as P+import qualified Distribution.Types.PackageDescription.Lens as L+import qualified Distribution.Types.SetupBuildInfo.Lens as L+import qualified Text.Parsec as P  ------------------------------------------------------------------------------+ -- | Parses the given file into a 'GenericPackageDescription'. -- -- In Cabal 1.2 the syntax for package descriptions was changed to a format -- with sections and possibly indented property descriptions.--- parseGenericPackageDescription :: BS.ByteString -> ParseResult GenericPackageDescription parseGenericPackageDescription bs = do-    -- set scanned version-    setCabalSpecVersion ver+  -- set scanned version+  setCabalSpecVersion ver -    csv <- case ver of-        -- if we get too new version, fail right away-        Just v -> case cabalSpecFromVersionDigits (versionNumbers v) of-            Just csv -> return (Just csv)-            Nothing  -> parseFatalFailure zeroPos $-                "Unsupported cabal-version " ++ prettyShow v ++ ". See https://github.com/haskell/cabal/issues/4899."-        _ -> pure Nothing+  csv <- case ver of+    -- if we get too new version, fail right away+    Just v -> case cabalSpecFromVersionDigits (versionNumbers v) of+      Just csv -> return (Just csv)+      Nothing ->+        parseFatalFailure zeroPos $+          "Unsupported cabal format version in cabal-version field: "+            ++ prettyShow v+            ++ ".\n"+            ++ cabalFormatVersionsDesc+    _ -> pure Nothing -    case readFields' bs'' of-        Right (fs, lexWarnings) -> do-            when patched $-                parseWarning zeroPos PWTQuirkyCabalFile "Legacy cabal file"-            -- UTF8 is validated in a prepass step, afterwards parsing is lenient.-            parseGenericPackageDescription' csv lexWarnings invalidUtf8 fs-        -- TODO: better marshalling of errors-        Left perr -> parseFatalFailure pos (show perr) where-            ppos = P.errorPos perr-            pos  = Position (P.sourceLine ppos) (P.sourceColumn ppos)+  case readFields' bs'' of+    Right (fs, lexWarnings) -> do+      when patched $+        parseWarning zeroPos PWTQuirkyCabalFile "Legacy cabal file"+      -- UTF8 is validated in a prepass step, afterwards parsing is lenient.+      parseGenericPackageDescription' csv lexWarnings invalidUtf8 fs+    -- TODO: better marshalling of errors+    Left perr -> parseFatalFailure pos (show perr)+      where+        ppos = P.errorPos perr+        pos = Position (P.sourceLine ppos) (P.sourceColumn ppos)   where     (patched, bs') = patchQuirks bs     ver = scanSpecVersion bs'@@ -107,14 +110,13 @@      -- if there are invalid utf8 characters, we make the bytestring valid.     bs'' = case invalidUtf8 of-        Nothing -> bs'-        Just _  -> toUTF8BS (fromUTF8BS bs')-+      Nothing -> bs'+      Just _ -> toUTF8BS (fromUTF8BS bs')  -- | 'Maybe' variant of 'parseGenericPackageDescription' parseGenericPackageDescriptionMaybe :: BS.ByteString -> Maybe GenericPackageDescription parseGenericPackageDescriptionMaybe =-    either (const Nothing) Just . snd . runParseResult . parseGenericPackageDescription+  either (const Nothing) Just . snd . runParseResult . parseGenericPackageDescription  fieldlinesToBS :: [FieldLine ann] -> BS.ByteString fieldlinesToBS = BS.intercalate "\n" . map (\(FieldLine _ bs) -> bs)@@ -124,9 +126,9 @@  -- | State of section parser data SectionS = SectionS-    { _stateGpd           :: !GenericPackageDescription-    , _stateCommonStanzas :: !(Map String CondTreeBuildInfo)-    }+  { _stateGpd :: !GenericPackageDescription+  , _stateCommonStanzas :: !(Map String CondTreeBuildInfo)+  }  stateGpd :: Lens' SectionS GenericPackageDescription stateGpd f (SectionS gpd cs) = (\x -> SectionS x cs) <$> f gpd@@ -139,69 +141,78 @@ -- Note [Accumulating parser] -- -- This parser has two "states":+ -- * first we parse fields of PackageDescription+ -- * then we parse sections (libraries, executables, etc) parseGenericPackageDescription'-    :: Maybe CabalSpecVersion-    -> [LexWarning]-    -> Maybe Int-    -> [Field Position]-    -> ParseResult GenericPackageDescription+  :: Maybe CabalSpecVersion+  -> [LexWarning]+  -> Maybe Int+  -> [Field Position]+  -> ParseResult GenericPackageDescription parseGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do-    parseWarnings (toPWarnings lexWarnings)-    for_ utf8WarnPos $ \pos ->-        parseWarning zeroPos PWTUTF $ "UTF8 encoding problem at byte offset " ++ show pos-    let (syntax, fs') = sectionizeFields fs-    let (fields, sectionFields) = takeFields fs'+  parseWarnings (toPWarnings lexWarnings)+  for_ utf8WarnPos $ \pos ->+    parseWarning zeroPos PWTUTF $ "UTF8 encoding problem at byte offset " ++ show pos+  let (syntax, fs') = sectionizeFields fs+  let (fields, sectionFields) = takeFields fs' -    -- cabal-version-    specVer <- case scannedVer of-        Just v  -> return v-        Nothing -> case Map.lookup "cabal-version" fields >>= safeLast of-            Nothing                        -> return CabalSpecV1_0-            Just (MkNamelessField pos fls) -> do-                -- version will be parsed twice, therefore we parse without warnings.-                v <- withoutWarnings $-                    Newtype.unpack' SpecVersion <$>-                    -- Use version with || and && but before addition of ^>= and removal of -any-                    runFieldParser pos parsec CabalSpecV1_24 fls+  -- cabal-version+  specVer <- case scannedVer of+    Just v -> return v+    Nothing -> case Map.lookup "cabal-version" fields >>= safeLast of+      Nothing -> return CabalSpecV1_0+      Just (MkNamelessField pos fls) -> do+        -- version will be parsed twice, therefore we parse without warnings.+        v <-+          withoutWarnings $+            Newtype.unpack' SpecVersion+              <$>+              -- Use version with || and && but before addition of ^>= and removal of -any+              runFieldParser pos parsec CabalSpecV1_24 fls -                -- if it were at the beginning, scanner would found it-                when (v >= CabalSpecV2_2) $ parseFailure pos $-                    "cabal-version should be at the beginning of the file starting with spec version 2.2. " ++-                    "See https://github.com/haskell/cabal/issues/4899"+        -- if it were at the beginning, scanner would found it+        when (v >= CabalSpecV2_2) $+          parseFailure pos $+            "cabal-version should be at the beginning of the file starting with spec version 2.2.\n"+              ++ cabalFormatVersionsDesc -                return v+        return v -    -- reset cabal version, it might not be set-    let specVer' = mkVersion (cabalSpecToVersionDigits specVer)-    setCabalSpecVersion (Just specVer')+  -- reset cabal version, it might not be set+  let specVer' = mkVersion (cabalSpecToVersionDigits specVer)+  setCabalSpecVersion (Just specVer') -    -- Package description-    pd <- parseFieldGrammar specVer fields packageDescriptionFieldGrammar+  -- Package description+  pd <- parseFieldGrammar specVer fields packageDescriptionFieldGrammar -    -- Check that scanned and parsed versions match.-    unless (specVer == specVersion pd) $ parseFailure zeroPos $-        "Scanned and parsed cabal-versions don't match " ++-        prettyShow (SpecVersion specVer) ++ " /= " ++ prettyShow (SpecVersion (specVersion pd))+  -- Check that scanned and parsed versions match.+  unless (specVer == specVersion pd) $+    parseFailure zeroPos $+      "Scanned and parsed cabal-versions don't match "+        ++ prettyShow (SpecVersion specVer)+        ++ " /= "+        ++ prettyShow (SpecVersion (specVersion pd)) -    maybeWarnCabalVersion syntax pd+  maybeWarnCabalVersion syntax pd -    -- Sections-    let gpd = emptyGenericPackageDescription-            & L.packageDescription .~ pd-    gpd1 <- view stateGpd <$> execStateT (goSections specVer sectionFields) (SectionS gpd Map.empty)+  -- Sections+  let gpd =+        emptyGenericPackageDescription+          & L.packageDescription .~ pd+  gpd1 <- view stateGpd <$> execStateT (goSections specVer sectionFields) (SectionS gpd Map.empty) -    let gpd2 = postProcessInternalDeps specVer gpd1-    checkForUndefinedFlags gpd2-    checkForUndefinedCustomSetup gpd2-    -- See nothunks test, without this deepseq we get (at least):-    -- Thunk in ThunkInfo {thunkContext = ["PackageIdentifier","PackageDescription","GenericPackageDescription"]}-    ---    -- TODO: re-benchmark, whether `deepseq` is important (both cabal-benchmarks and solver-benchmarks)-    -- TODO: remove the need for deepseq if `deepseq` in fact matters-    -- NOTE: IIRC it does affect (maximal) memory usage, which causes less GC pressure-    gpd2 `deepseq` return gpd2+  let gpd2 = postProcessInternalDeps specVer gpd1+  checkForUndefinedFlags gpd2+  checkForUndefinedCustomSetup gpd2+  -- See nothunks test, without this deepseq we get (at least):+  -- Thunk in ThunkInfo {thunkContext = ["PackageIdentifier","PackageDescription","GenericPackageDescription"]}+  --+  -- TODO: re-benchmark, whether `deepseq` is important (both cabal-benchmarks and solver-benchmarks)+  -- TODO: remove the need for deepseq if `deepseq` in fact matters+  -- NOTE: IIRC it does affect (maximal) memory usage, which causes less GC pressure+  gpd2 `deepseq` return gpd2   where     safeLast :: [a] -> Maybe a     safeLast = listToMaybe . reverse@@ -211,28 +222,31 @@      maybeWarnCabalVersion :: Syntax -> PackageDescription -> ParseResult ()     maybeWarnCabalVersion syntax pkg-      | syntax == NewSyntax && specVersion pkg < newSyntaxVersion-      = parseWarning zeroPos PWTNewSyntax $-             "A package using section syntax must specify at least\n"-          ++ "'cabal-version: >= 1.2'."-+      | syntax == NewSyntax && specVersion pkg < newSyntaxVersion =+          parseWarning zeroPos PWTNewSyntax $+            "A package using section syntax must specify at least\n"+              ++ "'cabal-version: >= 1.2'."     maybeWarnCabalVersion syntax pkg-      | syntax == OldSyntax && specVersion pkg >= newSyntaxVersion-      = parseWarning zeroPos PWTOldSyntax $-             "A package using 'cabal-version: "-          ++ prettyShow (SpecVersion (specVersion pkg))-          ++ "' must use section syntax. See the Cabal user guide for details."-+      | syntax == OldSyntax && specVersion pkg >= newSyntaxVersion =+          parseWarning zeroPos PWTOldSyntax $+            "A package using 'cabal-version: "+              ++ prettyShow (SpecVersion (specVersion pkg))+              ++ "' must use section syntax. See the Cabal user guide for details."     maybeWarnCabalVersion _ _ = return () +-- See #4899+cabalFormatVersionsDesc :: String+cabalFormatVersionsDesc = "Current cabal-version values are listed at https://cabal.readthedocs.io/en/stable/file-format-changelog.html."+ goSections :: CabalSpecVersion -> [Field Position] -> SectionParser () goSections specVer = traverse_ process   where     process (Field (Name pos name) _) =-        lift $ parseWarning pos PWTTrailingFields $-            "Ignoring trailing fields after sections: " ++ show name+      lift $+        parseWarning pos PWTTrailingFields $+          "Ignoring trailing fields after sections: " ++ show name     process (Section name args secFields) =-        parseSection name args secFields+      parseSection name args secFields      snoc x xs = xs ++ [x] @@ -240,154 +254,164 @@      -- we need signature, because this is polymorphic, but not-closed     parseCondTree'-        :: L.HasBuildInfo a-        => ParsecFieldGrammar' a       -- ^ grammar-        -> (BuildInfo -> a)-        -> Map String CondTreeBuildInfo  -- ^ common stanzas-        -> [Field Position]-        -> ParseResult (CondTree ConfVar [Dependency] a)+      :: L.HasBuildInfo a+      => ParsecFieldGrammar' a+      -- \^ grammar+      -> (BuildInfo -> a)+      -> Map String CondTreeBuildInfo+      -- \^ common stanzas+      -> [Field Position]+      -> ParseResult (CondTree ConfVar [Dependency] a)     parseCondTree' = parseCondTreeWithCommonStanzas specVer      parseSection :: Name Position -> [SectionArg Position] -> [Field Position] -> SectionParser ()     parseSection (Name pos name) args fields-        | hasCommonStanzas == NoCommonStanzas, name == "common" = lift $ do+      | hasCommonStanzas == NoCommonStanzas+      , name == "common" = lift $ do           parseWarning pos PWTUnknownSection $ "Ignoring section: common. You should set cabal-version: 2.2 or larger to use common stanzas."--        | name == "common" = do-            commonStanzas <- use stateCommonStanzas-            name' <- lift $ parseCommonName pos args-            biTree <- lift $ parseCondTree' buildInfoFieldGrammar id commonStanzas fields--            case Map.lookup name' commonStanzas of-                Nothing -> stateCommonStanzas .= Map.insert name' biTree commonStanzas-                Just _  -> lift $ parseFailure pos $-                    "Duplicate common stanza: " ++ name'+      | name == "common" = do+          commonStanzas <- use stateCommonStanzas+          name' <- lift $ parseCommonName pos args+          biTree <- lift $ parseCondTree' buildInfoFieldGrammar id commonStanzas fields -        | name == "library" && null args = do-            prev <- use $ stateGpd . L.condLibrary-            when (isJust prev) $ lift $ parseFailure pos $+          case Map.lookup name' commonStanzas of+            Nothing -> stateCommonStanzas .= Map.insert name' biTree commonStanzas+            Just _ ->+              lift $+                parseFailure pos $+                  "Duplicate common stanza: " ++ name'+      | name == "library" && null args = do+          prev <- use $ stateGpd . L.condLibrary+          when (isJust prev) $+            lift $+              parseFailure pos $                 "Multiple main libraries; have you forgotten to specify a name for an internal library?" -            commonStanzas <- use stateCommonStanzas-            let name'' = LMainLibName-            lib <- lift $ parseCondTree' (libraryFieldGrammar name'') (libraryFromBuildInfo name'') commonStanzas fields-            ---            -- TODO check that not set-            stateGpd . L.condLibrary ?= lib--        -- Sublibraries-        -- TODO: check cabal-version-        | name == "library" = do-            commonStanzas <- use stateCommonStanzas-            name' <- parseUnqualComponentName pos args-            let name'' = LSubLibName name'-            lib   <- lift $ parseCondTree' (libraryFieldGrammar name'') (libraryFromBuildInfo name'') commonStanzas fields-            -- TODO check duplicate name here?-            stateGpd . L.condSubLibraries %= snoc (name', lib)--        -- TODO: check cabal-version-        | name == "foreign-library" = do-            commonStanzas <- use stateCommonStanzas-            name' <- parseUnqualComponentName pos args-            flib  <- lift $ parseCondTree' (foreignLibFieldGrammar name') (fromBuildInfo' name') commonStanzas fields--            let hasType ts = foreignLibType ts /= foreignLibType mempty-            unless (onAllBranches hasType flib) $ lift $ parseFailure pos $ concat-                [ "Foreign library " ++ show (prettyShow name')-                , " is missing required field \"type\" or the field "-                , "is not present in all conditional branches. The "-                , "available test types are: "-                , intercalate ", " (map prettyShow knownForeignLibTypes)-                ]+          commonStanzas <- use stateCommonStanzas+          let name'' = LMainLibName+          lib <- lift $ parseCondTree' (libraryFieldGrammar name'') (libraryFromBuildInfo name'') commonStanzas fields+          --+          -- TODO check that not set+          stateGpd . L.condLibrary ?= lib -            -- TODO check duplicate name here?-            stateGpd . L.condForeignLibs %= snoc (name', flib)+      -- Sublibraries+      -- TODO: check cabal-version+      | name == "library" = do+          commonStanzas <- use stateCommonStanzas+          name' <- parseUnqualComponentName pos args+          let name'' = LSubLibName name'+          lib <- lift $ parseCondTree' (libraryFieldGrammar name'') (libraryFromBuildInfo name'') commonStanzas fields+          -- TODO check duplicate name here?+          stateGpd . L.condSubLibraries %= snoc (name', lib) -        | name == "executable" = do-            commonStanzas <- use stateCommonStanzas-            name' <- parseUnqualComponentName pos args-            exe   <- lift $ parseCondTree' (executableFieldGrammar name') (fromBuildInfo' name') commonStanzas fields-            -- TODO check duplicate name here?-            stateGpd . L.condExecutables %= snoc (name', exe)+      -- TODO: check cabal-version+      | name == "foreign-library" = do+          commonStanzas <- use stateCommonStanzas+          name' <- parseUnqualComponentName pos args+          flib <- lift $ parseCondTree' (foreignLibFieldGrammar name') (fromBuildInfo' name') commonStanzas fields -        | name == "test-suite" = do-            commonStanzas <- use stateCommonStanzas-            name'      <- parseUnqualComponentName pos args-            testStanza <- lift $ parseCondTree' testSuiteFieldGrammar (fromBuildInfo' name') commonStanzas fields-            testSuite  <- lift $ traverse (validateTestSuite specVer pos) testStanza+          let hasType ts = foreignLibType ts /= foreignLibType mempty+          unless (onAllBranches hasType flib) $+            lift $+              parseFailure pos $+                concat+                  [ "Foreign library " ++ show (prettyShow name')+                  , " is missing required field \"type\" or the field "+                  , "is not present in all conditional branches. The "+                  , "available test types are: "+                  , intercalate ", " (map prettyShow knownForeignLibTypes)+                  ] -            let hasType ts = testInterface ts /= testInterface mempty-            unless (onAllBranches hasType testSuite) $ lift $ parseFailure pos $ concat-                [ "Test suite " ++ show (prettyShow name')+          -- TODO check duplicate name here?+          stateGpd . L.condForeignLibs %= snoc (name', flib)+      | name == "executable" = do+          commonStanzas <- use stateCommonStanzas+          name' <- parseUnqualComponentName pos args+          exe <- lift $ parseCondTree' (executableFieldGrammar name') (fromBuildInfo' name') commonStanzas fields+          -- TODO check duplicate name here?+          stateGpd . L.condExecutables %= snoc (name', exe)+      | name == "test-suite" = do+          commonStanzas <- use stateCommonStanzas+          name' <- parseUnqualComponentName pos args+          testStanza <- lift $ parseCondTree' testSuiteFieldGrammar (fromBuildInfo' name') commonStanzas fields+          testSuite <- lift $ traverse (validateTestSuite specVer pos) testStanza -                , concat $ case specVer of-                    v | v >= CabalSpecV3_8 ->-                        [ " is missing required field \"main-is\" or the field "-                        , "is not present in all conditional branches."-                        ]-                    _ ->+          let hasType ts = testInterface ts /= testInterface mempty+          unless (onAllBranches hasType testSuite) $+            lift $+              parseFailure pos $+                concat+                  [ "Test suite " ++ show (prettyShow name')+                  , concat $ case specVer of+                      v+                        | v >= CabalSpecV3_8 ->+                            [ " is missing required field \"main-is\" or the field "+                            , "is not present in all conditional branches."+                            ]+                      _ ->                         [ " is missing required field \"type\" or the field "                         , "is not present in all conditional branches. The "                         , "available test types are: "                         , intercalate ", " (map prettyShow knownTestTypes)                         ]-                ]--            -- TODO check duplicate name here?-            stateGpd . L.condTestSuites %= snoc (name', testSuite)+                  ] -        | name == "benchmark" = do-            commonStanzas <- use stateCommonStanzas-            name'       <- parseUnqualComponentName pos args-            benchStanza <- lift $ parseCondTree' benchmarkFieldGrammar (fromBuildInfo' name') commonStanzas fields-            bench       <- lift $ traverse (validateBenchmark specVer pos) benchStanza+          -- TODO check duplicate name here?+          stateGpd . L.condTestSuites %= snoc (name', testSuite)+      | name == "benchmark" = do+          commonStanzas <- use stateCommonStanzas+          name' <- parseUnqualComponentName pos args+          benchStanza <- lift $ parseCondTree' benchmarkFieldGrammar (fromBuildInfo' name') commonStanzas fields+          bench <- lift $ traverse (validateBenchmark specVer pos) benchStanza -            let hasType ts = benchmarkInterface ts /= benchmarkInterface mempty-            unless (onAllBranches hasType bench) $ lift $ parseFailure pos $ concat-                [ "Benchmark " ++ show (prettyShow name')-                , concat $ case specVer of-                    v | v >= CabalSpecV3_8 ->-                        [ " is missing required field \"main-is\" or the field "-                        , "is not present in all conditional branches."-                        ]-                    _ ->+          let hasType ts = benchmarkInterface ts /= benchmarkInterface mempty+          unless (onAllBranches hasType bench) $+            lift $+              parseFailure pos $+                concat+                  [ "Benchmark " ++ show (prettyShow name')+                  , concat $ case specVer of+                      v+                        | v >= CabalSpecV3_8 ->+                            [ " is missing required field \"main-is\" or the field "+                            , "is not present in all conditional branches."+                            ]+                      _ ->                         [ " is missing required field \"type\" or the field "                         , "is not present in all conditional branches. The "                         , "available benchmark types are: "                         , intercalate ", " (map prettyShow knownBenchmarkTypes)                         ]-                ]--            -- TODO check duplicate name here?-            stateGpd . L.condBenchmarks %= snoc (name', bench)--        | name == "flag" = do-            name'  <- parseNameBS pos args-            name'' <- lift $ runFieldParser' [pos] parsec specVer (fieldLineStreamFromBS name') `recoverWith` mkFlagName ""-            flag   <- lift $ parseFields specVer fields (flagFieldGrammar name'')-            -- Check default flag-            stateGpd . L.genPackageFlags %= snoc flag--        | name == "custom-setup" && null args = do-            sbi <- lift $ parseFields specVer fields  (setupBInfoFieldGrammar False)-            stateGpd . L.packageDescription . L.setupBuildInfo ?= sbi--        | name == "source-repository" = do-            kind <- lift $ case args of-                [SecArgName spos secName] ->-                    runFieldParser' [spos] parsec specVer (fieldLineStreamFromBS secName) `recoverWith` RepoHead-                [] -> do-                    parseFailure pos "'source-repository' requires exactly one argument"-                    pure RepoHead-                _ -> do-                    parseFailure pos $ "Invalid source-repository kind " ++ show args-                    pure RepoHead+                  ] -            sr <- lift $ parseFields specVer fields (sourceRepoFieldGrammar kind)-            stateGpd . L.packageDescription . L.sourceRepos %= snoc sr+          -- TODO check duplicate name here?+          stateGpd . L.condBenchmarks %= snoc (name', bench)+      | name == "flag" = do+          name' <- parseNameBS pos args+          name'' <- lift $ runFieldParser' [pos] parsec specVer (fieldLineStreamFromBS name') `recoverWith` mkFlagName ""+          flag <- lift $ parseFields specVer fields (flagFieldGrammar name'')+          -- Check default flag+          stateGpd . L.genPackageFlags %= snoc flag+      | name == "custom-setup" && null args = do+          sbi <- lift $ parseFields specVer fields (setupBInfoFieldGrammar False)+          stateGpd . L.packageDescription . L.setupBuildInfo ?= sbi+      | name == "source-repository" = do+          kind <- lift $ case args of+            [SecArgName spos secName] ->+              runFieldParser' [spos] parsec specVer (fieldLineStreamFromBS secName) `recoverWith` RepoHead+            [] -> do+              parseFailure pos "'source-repository' requires exactly one argument"+              pure RepoHead+            _ -> do+              parseFailure pos $ "Invalid source-repository kind " ++ show args+              pure RepoHead -        | otherwise = lift $-            parseWarning pos PWTUnknownSection $ "Ignoring section: " ++ show name+          sr <- lift $ parseFields specVer fields (sourceRepoFieldGrammar kind)+          stateGpd . L.packageDescription . L.sourceRepos %= snoc sr+      | otherwise =+          lift $+            parseWarning pos PWTUnknownSection $+              "Ignoring section: " ++ show name  parseName :: Position -> [SectionArg Position] -> SectionParser String parseName pos args = fromUTF8BS <$> parseNameBS pos args@@ -395,31 +419,31 @@ parseNameBS :: Position -> [SectionArg Position] -> SectionParser BS.ByteString -- TODO: use strict parser parseNameBS pos args = case args of-    [SecArgName _pos secName] ->-         pure secName-    [SecArgStr _pos secName] ->-         pure secName-    [] -> do-         lift $ parseFailure pos "name required"-         pure ""-    _ -> do-         -- TODO: pretty print args-         lift $ parseFailure pos $ "Invalid name " ++ show args-         pure ""+  [SecArgName _pos secName] ->+    pure secName+  [SecArgStr _pos secName] ->+    pure secName+  [] -> do+    lift $ parseFailure pos "name required"+    pure ""+  _ -> do+    -- TODO: pretty print args+    lift $ parseFailure pos $ "Invalid name " ++ show args+    pure ""  parseCommonName :: Position -> [SectionArg Position] -> ParseResult String parseCommonName pos args = case args of-    [SecArgName _pos secName] ->-         pure $ fromUTF8BS secName-    [SecArgStr _pos secName] ->-         pure $ fromUTF8BS secName-    [] -> do-         parseFailure pos $ "name required"-         pure ""-    _ -> do-         -- TODO: pretty print args-         parseFailure pos $ "Invalid name " ++ show args-         pure ""+  [SecArgName _pos secName] ->+    pure $ fromUTF8BS secName+  [SecArgStr _pos secName] ->+    pure $ fromUTF8BS secName+  [] -> do+    parseFailure pos $ "name required"+    pure ""+  _ -> do+    -- TODO: pretty print args+    parseFailure pos $ "Invalid name " ++ show args+    pure ""  -- TODO: avoid conversion to 'String'. parseUnqualComponentName :: Position -> [SectionArg Position] -> SectionParser UnqualComponentName@@ -427,76 +451,83 @@  -- | Parse a non-recursive list of fields. parseFields-    :: CabalSpecVersion-    -> [Field Position] -- ^ fields to be parsed-    -> ParsecFieldGrammar' a-    -> ParseResult a+  :: CabalSpecVersion+  -> [Field Position]+  -- ^ fields to be parsed+  -> ParsecFieldGrammar' a+  -> ParseResult a parseFields v fields grammar = do-    let (fs0, ss) = partitionFields fields-    traverse_ (traverse_ warnInvalidSubsection) ss-    parseFieldGrammar v fs0 grammar+  let (fs0, ss) = partitionFields fields+  traverse_ (traverse_ warnInvalidSubsection) ss+  parseFieldGrammar v fs0 grammar  warnInvalidSubsection :: Section Position -> ParseResult () warnInvalidSubsection (MkSection (Name pos name) _ _) =-    void $ parseFailure pos $ "invalid subsection " ++ show name+  void $ parseFailure pos $ "invalid subsection " ++ show name  parseCondTree-    :: forall a. L.HasBuildInfo a-    => CabalSpecVersion-    -> HasElif                        -- ^ accept @elif@-    -> ParsecFieldGrammar' a          -- ^ grammar-    -> Map String CondTreeBuildInfo   -- ^ common stanzas-    -> (BuildInfo -> a)               -- ^ constructor from buildInfo-    -> (a -> [Dependency])            -- ^ condition extractor-    -> [Field Position]-    -> ParseResult (CondTree ConfVar [Dependency] a)+  :: forall a+   . L.HasBuildInfo a+  => CabalSpecVersion+  -> HasElif+  -- ^ accept @elif@+  -> ParsecFieldGrammar' a+  -- ^ grammar+  -> Map String CondTreeBuildInfo+  -- ^ common stanzas+  -> (BuildInfo -> a)+  -- ^ constructor from buildInfo+  -> (a -> [Dependency])+  -- ^ condition extractor+  -> [Field Position]+  -> ParseResult (CondTree ConfVar [Dependency] a) parseCondTree v hasElif grammar commonStanzas fromBuildInfo cond = go   where     go fields0 = do-        (fields, endo) <--            if v >= CabalSpecV3_0-            then processImports v fromBuildInfo commonStanzas fields0-            else traverse (warnImport v) fields0 >>= \fields1 -> return (catMaybes fields1, id)+      (fields, endo) <-+        if v >= CabalSpecV3_0+          then processImports v fromBuildInfo commonStanzas fields0+          else traverse (warnImport v) fields0 >>= \fields1 -> return (catMaybes fields1, id) -        let (fs, ss) = partitionFields fields-        x <- parseFieldGrammar v fs grammar-        branches <- concat <$> traverse parseIfs ss-        return $ endo $ CondNode x (cond x) branches+      let (fs, ss) = partitionFields fields+      x <- parseFieldGrammar v fs grammar+      branches <- concat <$> traverse parseIfs ss+      return $ endo $ CondNode x (cond x) branches      parseIfs :: [Section Position] -> ParseResult [CondBranch ConfVar [Dependency] a]     parseIfs [] = return []     parseIfs (MkSection (Name _ name) test fields : sections) | name == "if" = do-        test' <- parseConditionConfVar test-        fields' <- go fields-        (elseFields, sections') <- parseElseIfs sections-        return (CondBranch test' fields' elseFields : sections')+      test' <- parseConditionConfVar test+      fields' <- go fields+      (elseFields, sections') <- parseElseIfs sections+      return (CondBranch test' fields' elseFields : sections')     parseIfs (MkSection (Name pos name) _ _ : sections) = do-        parseWarning pos PWTInvalidSubsection $ "invalid subsection " ++ show name-        parseIfs sections+      parseWarning pos PWTInvalidSubsection $ "invalid subsection " ++ show name+      parseIfs sections      parseElseIfs-        :: [Section Position]-        -> ParseResult (Maybe (CondTree ConfVar [Dependency] a), [CondBranch ConfVar [Dependency] a])+      :: [Section Position]+      -> ParseResult (Maybe (CondTree ConfVar [Dependency] a), [CondBranch ConfVar [Dependency] a])     parseElseIfs [] = return (Nothing, [])     parseElseIfs (MkSection (Name pos name) args fields : sections) | name == "else" = do-        unless (null args) $-            parseFailure pos $ "`else` section has section arguments " ++ show args-        elseFields <- go fields-        sections' <- parseIfs sections-        return (Just elseFields, sections')--    parseElseIfs (MkSection (Name _ name) test fields : sections) | hasElif == HasElif, name == "elif" = do-        test' <- parseConditionConfVar test-        fields' <- go fields-        (elseFields, sections') <- parseElseIfs sections-        -- we parse an empty 'Fields', to get empty value for a node-        a <- parseFieldGrammar v mempty grammar-        return (Just $ CondNode a (cond a) [CondBranch test' fields' elseFields], sections')-+      unless (null args) $+        parseFailure pos $+          "`else` section has section arguments " ++ show args+      elseFields <- go fields+      sections' <- parseIfs sections+      return (Just elseFields, sections')+    parseElseIfs (MkSection (Name _ name) test fields : sections)+      | hasElif == HasElif+      , name == "elif" = do+          test' <- parseConditionConfVar test+          fields' <- go fields+          (elseFields, sections') <- parseElseIfs sections+          -- we parse an empty 'Fields', to get empty value for a node+          a <- parseFieldGrammar v mempty grammar+          return (Just $ CondNode a (cond a) [CondBranch test' fields' elseFields], sections')     parseElseIfs (MkSection (Name pos name) _ _ : sections) | name == "elif" = do-        parseWarning pos PWTInvalidSubsection $ "invalid subsection \"elif\". You should set cabal-version: 2.2 or larger to use elif-conditionals."-        (,) Nothing <$> parseIfs sections-+      parseWarning pos PWTInvalidSubsection $ "invalid subsection \"elif\". You should set cabal-version: 2.2 or larger to use elif-conditionals."+      (,) Nothing <$> parseIfs sections     parseElseIfs sections = (,) Nothing <$> parseIfs sections  {- Note [Accumulating parser]@@ -507,15 +538,15 @@ FieldParser a)@.  The weird value is used because we accumulate structure of @a@ by folding over the fields.  There are various reasons for that: -* Almost all fields are optional+\* Almost all fields are optional -* This is simple approach so declarative bi-directional format (parsing and+\* This is simple approach so declarative bi-directional format (parsing and printing) of structure could be specified (list of @'FieldDescr' a@) -* There are surface syntax fields corresponding to single field in the file:+\* There are surface syntax fields corresponding to single field in the file:   @license-file@ and @license-files@ -* This is quite safe approach.+\* This is quite safe approach.  When/if we re-implement the parser to support formatting preservging roundtrip with new AST, this all need to be rewritten.@@ -555,7 +586,6 @@ -- The approach is simple, and have good properties: -- -- * Common stanzas are parsed exactly once, even if not-used. Thus we report errors in them.--- type CondTreeBuildInfo = CondTree ConfVar [Dependency] BuildInfo  -- | Create @a@ from 'BuildInfo'.@@ -565,49 +595,57 @@ -- -- This takes name, as 'FieldGrammar's take names too. class L.HasBuildInfo a => FromBuildInfo a where-    fromBuildInfo' :: UnqualComponentName -> BuildInfo -> a+  fromBuildInfo' :: UnqualComponentName -> BuildInfo -> a  libraryFromBuildInfo :: LibraryName -> BuildInfo -> Library-libraryFromBuildInfo n bi = emptyLibrary-    { libName       = n+libraryFromBuildInfo n bi =+  emptyLibrary+    { libName = n     , libVisibility = case n of-        LMainLibName  -> LibraryVisibilityPublic+        LMainLibName -> LibraryVisibilityPublic         LSubLibName _ -> LibraryVisibilityPrivate-    , libBuildInfo  = bi+    , libBuildInfo = bi     } -instance FromBuildInfo BuildInfo  where fromBuildInfo' _ = id+instance FromBuildInfo BuildInfo where fromBuildInfo' _ = id instance FromBuildInfo ForeignLib where fromBuildInfo' n bi = set L.foreignLibName n $ set L.buildInfo bi emptyForeignLib-instance FromBuildInfo Executable where fromBuildInfo' n bi = set L.exeName        n $ set L.buildInfo bi emptyExecutable+instance FromBuildInfo Executable where fromBuildInfo' n bi = set L.exeName n $ set L.buildInfo bi emptyExecutable  instance FromBuildInfo TestSuiteStanza where-    fromBuildInfo' _ bi = TestSuiteStanza Nothing Nothing Nothing bi []+  fromBuildInfo' _ bi = TestSuiteStanza Nothing Nothing Nothing bi []  instance FromBuildInfo BenchmarkStanza where-    fromBuildInfo' _ bi = BenchmarkStanza Nothing Nothing Nothing bi+  fromBuildInfo' _ bi = BenchmarkStanza Nothing Nothing Nothing bi  parseCondTreeWithCommonStanzas-    :: forall a. L.HasBuildInfo a-    => CabalSpecVersion-    -> ParsecFieldGrammar' a       -- ^ grammar-    -> (BuildInfo -> a)              -- ^ construct fromBuildInfo-    -> Map String CondTreeBuildInfo  -- ^ common stanzas-    -> [Field Position]-    -> ParseResult (CondTree ConfVar [Dependency] a)+  :: forall a+   . L.HasBuildInfo a+  => CabalSpecVersion+  -> ParsecFieldGrammar' a+  -- ^ grammar+  -> (BuildInfo -> a)+  -- ^ construct fromBuildInfo+  -> Map String CondTreeBuildInfo+  -- ^ common stanzas+  -> [Field Position]+  -> ParseResult (CondTree ConfVar [Dependency] a) parseCondTreeWithCommonStanzas v grammar fromBuildInfo commonStanzas fields = do-    (fields', endo) <- processImports v fromBuildInfo commonStanzas fields-    x <- parseCondTree v hasElif grammar commonStanzas fromBuildInfo (view L.targetBuildDepends) fields'-    return (endo x)+  (fields', endo) <- processImports v fromBuildInfo commonStanzas fields+  x <- parseCondTree v hasElif grammar commonStanzas fromBuildInfo (view L.targetBuildDepends) fields'+  return (endo x)   where     hasElif = specHasElif v  processImports-    :: forall a. L.HasBuildInfo a-    => CabalSpecVersion-    -> (BuildInfo -> a)              -- ^ construct fromBuildInfo-    -> Map String CondTreeBuildInfo  -- ^ common stanzas-    -> [Field Position]-    -> ParseResult ([Field Position], CondTree ConfVar [Dependency] a -> CondTree ConfVar [Dependency] a)+  :: forall a+   . L.HasBuildInfo a+  => CabalSpecVersion+  -> (BuildInfo -> a)+  -- ^ construct fromBuildInfo+  -> Map String CondTreeBuildInfo+  -- ^ common stanzas+  -> [Field Position]+  -> ParseResult ([Field Position], CondTree ConfVar [Dependency] a -> CondTree ConfVar [Dependency] a) processImports v fromBuildInfo commonStanzas = go []   where     hasCommonStanzas = specHasCommonStanzas v@@ -615,44 +653,46 @@     getList' :: List CommaFSep Token String -> [String]     getList' = Newtype.unpack -    go acc (Field (Name pos name) _ : fields) | name == "import", hasCommonStanzas == NoCommonStanzas = do-        parseWarning pos PWTUnknownField "Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas"-        go acc fields+    go acc (Field (Name pos name) _ : fields)+      | name == "import"+      , hasCommonStanzas == NoCommonStanzas = do+          parseWarning pos PWTUnknownField "Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas"+          go acc fields     -- supported:     go acc (Field (Name pos name) fls : fields) | name == "import" = do-        names <- getList' <$> runFieldParser pos parsec v fls-        names' <- for names $ \commonName ->-            case Map.lookup commonName commonStanzas of-                Nothing -> do-                    parseFailure pos $ "Undefined common stanza imported: " ++ commonName-                    pure Nothing-                Just commonTree ->-                    pure (Just commonTree)+      names <- getList' <$> runFieldParser pos parsec v fls+      names' <- for names $ \commonName ->+        case Map.lookup commonName commonStanzas of+          Nothing -> do+            parseFailure pos $ "Undefined common stanza imported: " ++ commonName+            pure Nothing+          Just commonTree ->+            pure (Just commonTree) -        go (acc ++ catMaybes names') fields+      go (acc ++ catMaybes names') fields      -- parse actual CondTree     go acc fields = do-        fields' <- catMaybes <$> traverse (warnImport v) fields-        pure $ (fields', \x -> foldr (mergeCommonStanza fromBuildInfo) x acc)+      fields' <- catMaybes <$> traverse (warnImport v) fields+      pure $ (fields', \x -> foldr (mergeCommonStanza fromBuildInfo) x acc) --- | Warn on "import" fields, also map to Maybe, so errorneous fields can be filtered+-- | Warn on "import" fields, also map to Maybe, so erroneous fields can be filtered warnImport :: CabalSpecVersion -> Field Position -> ParseResult (Maybe (Field Position))-warnImport v (Field (Name pos name) _) | name ==  "import" = do-    if specHasCommonStanzas v == NoCommonStanzas+warnImport v (Field (Name pos name) _) | name == "import" = do+  if specHasCommonStanzas v == NoCommonStanzas     then parseWarning pos PWTUnknownField "Unknown field: import. You should set cabal-version: 2.2 or larger to use common stanzas"     else parseWarning pos PWTUnknownField "Unknown field: import. Common stanza imports should be at the top of the enclosing section"-    return Nothing+  return Nothing warnImport _ f = pure (Just f)  mergeCommonStanza-    :: L.HasBuildInfo a-    => (BuildInfo -> a)-    -> CondTree ConfVar [Dependency] BuildInfo-    -> CondTree ConfVar [Dependency] a-    -> CondTree ConfVar [Dependency] a+  :: L.HasBuildInfo a+  => (BuildInfo -> a)+  -> CondTree ConfVar [Dependency] BuildInfo+  -> CondTree ConfVar [Dependency] a+  -> CondTree ConfVar [Dependency] a mergeCommonStanza fromBuildInfo (CondNode bi _ bis) (CondNode x _ cs) =-    CondNode x' (x' ^. L.targetBuildDepends) cs'+  CondNode x' (x' ^. L.targetBuildDepends) cs'   where     -- new value is old value with buildInfo field _prepended_.     x' = x & L.buildInfo %~ (bi <>)@@ -674,13 +714,14 @@     -- one need one to satisfy the property because the configure step uses     -- 'mappend' to join together the results of flag resolution.     go :: a -> CondTree v c a -> Bool-    go acc ct = let acc' = acc `mappend` condTreeData ct-                in p acc' || any (goBranch acc') (condTreeComponents ct)+    go acc ct =+      let acc' = acc `mappend` condTreeData ct+       in p acc' || any (goBranch acc') (condTreeComponents ct)      -- Both the 'true' and the 'false' block must satisfy the property.     goBranch :: a -> CondBranch v c a -> Bool-    goBranch _   (CondBranch _ _ Nothing) = False-    goBranch acc (CondBranch _ t (Just e))  = go acc t && go acc e+    goBranch _ (CondBranch _ _ Nothing) = False+    goBranch acc (CondBranch _ t (Just e)) = go acc t && go acc e  ------------------------------------------------------------------------------- -- Post parsing checks@@ -690,33 +731,37 @@ -- -- * don't use undefined flags (very bad) -- * define flags which are unused (just bad)--- checkForUndefinedFlags :: GenericPackageDescription -> ParseResult () checkForUndefinedFlags gpd = do-    let definedFlags, usedFlags :: Set.Set FlagName-        definedFlags = toSetOf (L.genPackageFlags . traverse . getting flagName) gpd-        usedFlags    = getConst $ L.allCondTrees f gpd+  let definedFlags, usedFlags :: Set.Set FlagName+      definedFlags = toSetOf (L.genPackageFlags . traverse . getting flagName) gpd+      usedFlags = getConst $ L.allCondTrees f gpd -    -- Note: we can check for defined, but unused flags here too.-    unless (usedFlags `Set.isSubsetOf` definedFlags) $ parseFailure zeroPos $-        "These flags are used without having been defined: " ++-        intercalate ", " [ unFlagName fn | fn <- Set.toList $ usedFlags `Set.difference` definedFlags ]+  -- Note: we can check for defined, but unused flags here too.+  unless (usedFlags `Set.isSubsetOf` definedFlags) $+    parseFailure zeroPos $+      "These flags are used without having been defined: "+        ++ intercalate ", " [unFlagName fn | fn <- Set.toList $ usedFlags `Set.difference` definedFlags]   where     f :: CondTree ConfVar c a -> Const (Set.Set FlagName) (CondTree ConfVar c a)     f ct = Const (Set.fromList (freeVars ct))  -- | Since @cabal-version: 1.24@ one can specify @custom-setup@. -- Let us require it.--- checkForUndefinedCustomSetup :: GenericPackageDescription -> ParseResult () checkForUndefinedCustomSetup gpd = do-    let pd  = packageDescription gpd-    let csv = specVersion pd+  let pd = packageDescription gpd+  let csv = specVersion pd -    when (buildType pd == Custom && isNothing (setupBuildInfo pd)) $-        when (csv >= CabalSpecV1_24) $ parseFailure zeroPos $-            "Since cabal-version: 1.24 specifying custom-setup section is mandatory"+  when (buildType pd == Custom && isNothing (setupBuildInfo pd)) $+    when (csv >= CabalSpecV1_24) $+      parseFailure zeroPos $+        "Since cabal-version: 1.24 specifying custom-setup section is mandatory" +  when (buildType pd == Hooks && isNothing (setupBuildInfo pd)) $+    parseFailure zeroPos $+      "Packages with build-type: Hooks require a custom-setup stanza"+ ------------------------------------------------------------------------------- -- Post processing of internal dependencies -------------------------------------------------------------------------------@@ -761,12 +806,12 @@  postProcessInternalDeps :: CabalSpecVersion -> GenericPackageDescription -> GenericPackageDescription postProcessInternalDeps specVer gpd-    | specVer >= CabalSpecV3_4 = gpd-    | otherwise                = transformAllBuildInfos transformBI transformSBI gpd+  | specVer >= CabalSpecV3_4 = gpd+  | otherwise = transformAllBuildInfos transformBI transformSBI gpd   where     transformBI :: BuildInfo -> BuildInfo-    transformBI-        = over L.targetBuildDepends (concatMap transformD)+    transformBI =+      over L.targetBuildDepends (concatMap transformD)         . over L.mixins (map transformM)      transformSBI :: SetupBuildInfo -> SetupBuildInfo@@ -774,31 +819,30 @@      transformD :: Dependency -> [Dependency]     transformD (Dependency pn vr ln)-        | uqn `Set.member` internalLibs-        , LMainLibName `NES.member` ln-        = case NES.delete LMainLibName ln of-            Nothing  -> [dep]+      | uqn `Set.member` internalLibs+      , LMainLibName `NES.member` ln =+          case NES.delete LMainLibName ln of+            Nothing -> [dep]             Just ln' -> [dep, Dependency pn vr ln']       where         uqn = packageNameToUnqualComponentName pn         dep = Dependency thisPn vr (NES.singleton (LSubLibName uqn))-     transformD d = [d]      transformM :: Mixin -> Mixin     transformM (Mixin pn LMainLibName incl)-        | uqn `Set.member` internalLibs-        = mkMixin thisPn (LSubLibName uqn) incl+      | uqn `Set.member` internalLibs =+          mkMixin thisPn (LSubLibName uqn) incl       where         uqn = packageNameToUnqualComponentName pn-     transformM m = m      thisPn :: PackageName     thisPn = pkgName (package (packageDescription gpd))      internalLibs :: Set UnqualComponentName-    internalLibs = Set.fromList+    internalLibs =+      Set.fromList         [ n         | (n, _) <- condSubLibraries gpd         ]@@ -823,15 +867,15 @@ -- section. sectionizeFields :: [Field ann] -> (Syntax, [Field ann]) sectionizeFields fs = case classifyFields fs of-    Just fields -> (OldSyntax, convert fields)-    Nothing     -> (NewSyntax, fs)+  Just fields -> (OldSyntax, convert fields)+  Nothing -> (NewSyntax, fs)   where     -- return 'Just' if all fields are simple fields     classifyFields :: [Field ann] -> Maybe [(Name ann, [FieldLine ann])]     classifyFields = traverse f       where         f (Field name fieldlines) = Just (name, fieldlines)-        f _                      = Nothing+        f _ = Nothing      trim = BS.dropWhile isSpace' . BS.reverse . BS.dropWhile isSpace' . BS.reverse     isSpace' = (== 32)@@ -844,30 +888,32 @@         -- compatible, we still allow it as a global field in old-style         -- package description files and translate it to a local field by         -- adding it to every non-empty section-        (hdr0, exes0) = break ((=="executable") . getName . fst) fields+        (hdr0, exes0) = break ((== "executable") . getName . fst) fields         (hdr, libfs0) = partition (not . (`elem` libFieldNames) . getName . fst) hdr0 -        (deps, libfs) = partition ((== "build-depends") . getName . fst)-                                   libfs0+        (deps, libfs) =+          partition+            ((== "build-depends") . getName . fst)+            libfs0          exes = unfoldr toExe exes0         toExe [] = Nothing         toExe ((Name pos n, ls) : r)           | n == "executable" =               let (efs, r') = break ((== "executable") . getName . fst) r-              in Just (Section (Name pos "executable") [SecArgName pos $ trim $ fieldlinesToBS ls] (map toField $ deps ++ efs), r')+               in Just (Section (Name pos "executable") [SecArgName pos $ trim $ fieldlinesToBS ls] (map toField $ deps ++ efs), r')         toExe _ = error "unexpected input to 'toExe'"          lib = case libfs of-            []                         -> []-            ((Name pos _,  _) : _) ->-                [Section (Name pos "library") [] (map toField $ deps ++ libfs)]--      in map toField hdr ++ lib ++ exes+          [] -> []+          ((Name pos _, _) : _) ->+            [Section (Name pos "library") [] (map toField $ deps ++ libfs)]+       in+        map toField hdr ++ lib ++ exes  -- | See 'sectionizeFields'. data Syntax = OldSyntax | NewSyntax-    deriving (Eq, Show)+  deriving (Eq, Show)  -- TODO: libFieldNames :: [FieldName]@@ -879,57 +925,57 @@  parseHookedBuildInfo :: BS.ByteString -> ParseResult HookedBuildInfo parseHookedBuildInfo bs = case readFields' bs of-    Right (fs, lexWarnings) -> do-        parseHookedBuildInfo' lexWarnings fs-    -- TODO: better marshalling of errors-    Left perr -> parseFatalFailure zeroPos (show perr)+  Right (fs, lexWarnings) -> do+    parseHookedBuildInfo' lexWarnings fs+  -- TODO: better marshalling of errors+  Left perr -> parseFatalFailure zeroPos (show perr)  parseHookedBuildInfo'-    :: [LexWarning]-    -> [Field Position]-    -> ParseResult HookedBuildInfo+  :: [LexWarning]+  -> [Field Position]+  -> ParseResult HookedBuildInfo parseHookedBuildInfo' lexWarnings fs = do-    parseWarnings (toPWarnings lexWarnings)-    (mLibFields, exes) <- stanzas fs-    mLib <- parseLib mLibFields-    biExes <- traverse parseExe exes-    return (mLib, biExes)+  parseWarnings (toPWarnings lexWarnings)+  (mLibFields, exes) <- stanzas fs+  mLib <- parseLib mLibFields+  biExes <- traverse parseExe exes+  return (mLib, biExes)   where     parseLib :: Fields Position -> ParseResult (Maybe BuildInfo)     parseLib fields-        | Map.null fields = pure Nothing-        | otherwise       = Just <$> parseFieldGrammar cabalSpecLatest fields buildInfoFieldGrammar+      | Map.null fields = pure Nothing+      | otherwise = Just <$> parseFieldGrammar cabalSpecLatest fields buildInfoFieldGrammar      parseExe :: (UnqualComponentName, Fields Position) -> ParseResult (UnqualComponentName, BuildInfo)     parseExe (n, fields) = do-        bi <- parseFieldGrammar cabalSpecLatest fields buildInfoFieldGrammar-        pure (n, bi)+      bi <- parseFieldGrammar cabalSpecLatest fields buildInfoFieldGrammar+      pure (n, bi)      stanzas :: [Field Position] -> ParseResult (Fields Position, [(UnqualComponentName, Fields Position)])     stanzas fields = do-        let (hdr0, exes0) = breakMaybe isExecutableField fields-        hdr <- toFields hdr0-        exes <- unfoldrM (traverse toExe) exes0-        pure (hdr, exes)+      let (hdr0, exes0) = breakMaybe isExecutableField fields+      hdr <- toFields hdr0+      exes <- unfoldrM (traverse toExe) exes0+      pure (hdr, exes)      toFields :: [Field Position] -> ParseResult (Fields Position)     toFields fields = do-        let (fields', ss) = partitionFields fields-        traverse_ (traverse_ warnInvalidSubsection) ss-        pure fields'+      let (fields', ss) = partitionFields fields+      traverse_ (traverse_ warnInvalidSubsection) ss+      pure fields'      toExe-        :: ([FieldLine Position], [Field Position])-        -> ParseResult ((UnqualComponentName, Fields Position), Maybe ([FieldLine Position], [Field Position]))+      :: ([FieldLine Position], [Field Position])+      -> ParseResult ((UnqualComponentName, Fields Position), Maybe ([FieldLine Position], [Field Position]))     toExe (fss, fields) = do-        name <- runFieldParser zeroPos parsec cabalSpecLatest fss-        let (hdr0, rest) = breakMaybe isExecutableField fields-        hdr <- toFields hdr0-        pure ((name, hdr), rest)+      name <- runFieldParser zeroPos parsec cabalSpecLatest fss+      let (hdr0, rest) = breakMaybe isExecutableField fields+      hdr <- toFields hdr0+      pure ((name, hdr), rest)      isExecutableField (Field (Name _ name) fss)-        | name == "executable" = Just fss-        | otherwise            = Nothing+      | name == "executable" = Just fss+      | otherwise = Nothing     isExecutableField _ = Nothing  -------------------------------------------------------------------------------@@ -943,7 +989,7 @@ -- RFC5234 ABNF): -- -- @--- newstyle-spec-version-decl = "cabal-version" *WS ":" *WS newstyle-pec-version *WS+-- newstyle-spec-version-decl = "cabal-version" *WS ":" *WS newstyle-spec-version *WS -- -- spec-version               = NUM "." NUM [ "." NUM ] --@@ -952,29 +998,29 @@ -- DIGITP = %x31-39 -- WS = %20 -- @--- scanSpecVersion :: BS.ByteString -> Maybe Version scanSpecVersion bs = do-    fstline':_ <- pure (BS8.lines bs)+  fstline' : _ <- pure (BS8.lines bs) -    -- parse <newstyle-spec-version-decl>-    -- normalise: remove all whitespace, convert to lower-case-    let fstline = BS.map toLowerW8 $ BS.filter (/= 0x20) fstline'-    ["cabal-version",vers] <- pure (BS8.split ':' fstline)+  -- parse <newstyle-spec-version-decl>+  -- normalise: remove all whitespace, convert to lower-case+  let fstline = BS.map toLowerW8 $ BS.filter (/= 0x20) fstline'+  ["cabal-version", vers] <- pure (BS8.split ':' fstline) -    -- parse <spec-version>-    ---    -- This is currently more tolerant regarding leading 0 digits.-    ---    ver <- simpleParsecBS vers-    guard $ case versionNumbers ver of-              [_,_]   -> True-              [_,_,_] -> True-              _       -> False+  -- parse <spec-version>+  --+  -- This is currently more tolerant regarding leading 0 digits.+  --+  ver <- simpleParsecBS vers+  guard $ case versionNumbers ver of+    [_, _] -> True+    [_, _, _] -> True+    _ -> False -    pure ver+  pure ver   where-    -- | Translate ['A'..'Z'] to ['a'..'z']+    -- \| Translate ['A'..'Z'] to ['a'..'z']     toLowerW8 :: Word8 -> Word8-    toLowerW8 w | 0x40 < w && w < 0x5b = w+0x20-                | otherwise            = w+    toLowerW8 w+      | 0x40 < w && w < 0x5b = w + 0x20+      | otherwise = w
src/Distribution/PackageDescription/PrettyPrint.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE OverloadedStrings #-}+ -----------------------------------------------------------------------------++-----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.PackageDescription.PrettyPrint -- Copyright   :  Jürgen Nicklisch-Franken 2010@@ -10,46 +14,52 @@ -- Portability : portable -- -- Pretty printing for cabal files-----------------------------------------------------------------------------------module Distribution.PackageDescription.PrettyPrint (-    -- * Generic package descriptions-    writeGenericPackageDescription,-    showGenericPackageDescription,-    ppGenericPackageDescription,+module Distribution.PackageDescription.PrettyPrint+  ( -- * Generic package descriptions+    writeGenericPackageDescription+  , showGenericPackageDescription+  , ppGenericPackageDescription      -- * Package descriptions-     writePackageDescription,-     showPackageDescription,+  , writePackageDescription+  , showPackageDescription -     -- ** Supplementary build information-     writeHookedBuildInfo,-     showHookedBuildInfo,-) where+    -- ** Supplementary build information+  , writeHookedBuildInfo+  , showHookedBuildInfo+  ) where  import Distribution.Compat.Prelude import Prelude ()  import Distribution.CabalSpecVersion-import Distribution.Fields.Pretty import Distribution.Compat.Lens+import Distribution.FieldGrammar (PrettyFieldGrammar', prettyFieldGrammar)+import Distribution.Fields.Pretty import Distribution.PackageDescription-import Distribution.Pretty-import Distribution.FieldGrammar                     (PrettyFieldGrammar', prettyFieldGrammar) import Distribution.PackageDescription.Configuration (transformAllBuildInfos) import Distribution.PackageDescription.FieldGrammar-       (benchmarkFieldGrammar, buildInfoFieldGrammar, executableFieldGrammar, flagFieldGrammar, foreignLibFieldGrammar, libraryFieldGrammar,-       packageDescriptionFieldGrammar, setupBInfoFieldGrammar, sourceRepoFieldGrammar, testSuiteFieldGrammar)-import Distribution.Utils.Generic                    (writeFileAtomic, writeUTF8File)+  ( benchmarkFieldGrammar+  , buildInfoFieldGrammar+  , executableFieldGrammar+  , flagFieldGrammar+  , foreignLibFieldGrammar+  , libraryFieldGrammar+  , packageDescriptionFieldGrammar+  , setupBInfoFieldGrammar+  , sourceRepoFieldGrammar+  , testSuiteFieldGrammar+  )+import Distribution.Pretty+import Distribution.Utils.Generic (writeFileAtomic, writeUTF8File)  import qualified Distribution.PackageDescription.FieldGrammar as FG-import qualified Distribution.Types.BuildInfo.Lens                 as L-import qualified Distribution.Types.SetupBuildInfo.Lens            as L+import qualified Distribution.Types.BuildInfo.Lens as L+import qualified Distribution.Types.SetupBuildInfo.Lens as L  import Text.PrettyPrint (Doc, char, hsep, parens, text) -import qualified Data.ByteString.Lazy.Char8      as BS.Char8+import qualified Data.ByteString.Lazy.Char8 as BS.Char8 import qualified Distribution.Compat.NonEmptySet as NES  -- | Writes a .cabal file from a generic package description@@ -64,7 +74,8 @@  -- | Convert a generic package description to 'PrettyField's. ppGenericPackageDescription :: CabalSpecVersion -> GenericPackageDescription -> [PrettyField ()]-ppGenericPackageDescription v gpd0 = concat+ppGenericPackageDescription v gpd0 =+  concat     [ ppPackageDescription v (packageDescription gpd)     , ppSetupBInfo v (setupBuildInfo (packageDescription gpd))     , ppGenPackageFlags v (genPackageFlags gpd)@@ -78,17 +89,17 @@   where     gpd = preProcessInternalDeps (specVersion (packageDescription gpd0)) gpd0 - ppPackageDescription :: CabalSpecVersion -> PackageDescription -> [PrettyField ()] ppPackageDescription v pd =-    prettyFieldGrammar v packageDescriptionFieldGrammar pd+  prettyFieldGrammar v packageDescriptionFieldGrammar pd     ++ ppSourceRepos v (sourceRepos pd)  ppSourceRepos :: CabalSpecVersion -> [SourceRepo] -> [PrettyField ()] ppSourceRepos = map . ppSourceRepo  ppSourceRepo :: CabalSpecVersion -> SourceRepo -> PrettyField ()-ppSourceRepo v repo = PrettySection () "source-repository" [pretty kind] $+ppSourceRepo v repo =+  PrettySection () "source-repository" [pretty kind] $     prettyFieldGrammar v (sourceRepoFieldGrammar kind) repo   where     kind = repoKind repo@@ -96,15 +107,18 @@ ppSetupBInfo :: CabalSpecVersion -> Maybe SetupBuildInfo -> [PrettyField ()] ppSetupBInfo _ Nothing = mempty ppSetupBInfo v (Just sbi)-    | defaultSetupDepends sbi = mempty-    | otherwise = pure $ PrettySection () "custom-setup" [] $-        prettyFieldGrammar v (setupBInfoFieldGrammar False) sbi+  | defaultSetupDepends sbi = mempty+  | otherwise =+      pure $+        PrettySection () "custom-setup" [] $+          prettyFieldGrammar v (setupBInfoFieldGrammar False) sbi  ppGenPackageFlags :: CabalSpecVersion -> [PackageFlag] -> [PrettyField ()] ppGenPackageFlags = map . ppFlag  ppFlag :: CabalSpecVersion -> PackageFlag -> PrettyField ()-ppFlag v flag@(MkPackageFlag name _ _ _)  = PrettySection () "flag" [ppFlagName name] $+ppFlag v flag@(MkPackageFlag name _ _ _) =+  PrettySection () "flag" [ppFlagName name] $     prettyFieldGrammar v (flagFieldGrammar name) flag  ppCondTree2 :: CabalSpecVersion -> PrettyFieldGrammar' s -> CondTree ConfVar [Dependency] s -> [PrettyField ()]@@ -112,15 +126,14 @@   where     -- TODO: recognise elif opportunities     go (CondNode it _ ifs) =-        prettyFieldGrammar v grammar it ++-        concatMap ppIf ifs+      prettyFieldGrammar v grammar it+        ++ concatMap ppIf ifs      ppIf (CondBranch c thenTree Nothing)---        | isEmpty thenDoc = mempty-        | otherwise       = [ppIfCondition c thenDoc]+      --        | isEmpty thenDoc = mempty+      | otherwise = [ppIfCondition c thenDoc]       where         thenDoc = go thenTree-     ppIf (CondBranch c thenTree (Just elseTree)) =       -- See #6193       [ ppIfCondition c (go thenTree)@@ -129,60 +142,74 @@  ppCondLibrary :: CabalSpecVersion -> Maybe (CondTree ConfVar [Dependency] Library) -> [PrettyField ()] ppCondLibrary _ Nothing = mempty-ppCondLibrary v (Just condTree) = pure $ PrettySection () "library" [] $-    ppCondTree2 v (libraryFieldGrammar LMainLibName) condTree+ppCondLibrary v (Just condTree) =+  pure $+    PrettySection () "library" [] $+      ppCondTree2 v (libraryFieldGrammar LMainLibName) condTree  ppCondSubLibraries :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)] -> [PrettyField ()] ppCondSubLibraries v libs =-    [ PrettySection () "library" [pretty n]-    $ ppCondTree2 v (libraryFieldGrammar $ LSubLibName n) condTree-    | (n, condTree) <- libs-    ]+  [ PrettySection () "library" [pretty n] $+    ppCondTree2 v (libraryFieldGrammar $ LSubLibName n) condTree+  | (n, condTree) <- libs+  ]  ppCondForeignLibs :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)] -> [PrettyField ()] ppCondForeignLibs v flibs =-    [ PrettySection () "foreign-library" [pretty n]-    $ ppCondTree2 v (foreignLibFieldGrammar n) condTree-    | (n, condTree) <- flibs-    ]+  [ PrettySection () "foreign-library" [pretty n] $+    ppCondTree2 v (foreignLibFieldGrammar n) condTree+  | (n, condTree) <- flibs+  ]  ppCondExecutables :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)] -> [PrettyField ()] ppCondExecutables v exes =-    [ PrettySection () "executable" [pretty n]-    $ ppCondTree2 v (executableFieldGrammar n) condTree-    | (n, condTree) <- exes-    ]+  [ PrettySection () "executable" [pretty n] $+    ppCondTree2 v (executableFieldGrammar n) condTree+  | (n, condTree) <- exes+  ]  ppCondTestSuites :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)] -> [PrettyField ()] ppCondTestSuites v suites =-    [ PrettySection () "test-suite" [pretty n]-    $ ppCondTree2 v testSuiteFieldGrammar (fmap FG.unvalidateTestSuite condTree)-    | (n, condTree) <- suites-    ]+  [ PrettySection () "test-suite" [pretty n] $+    ppCondTree2 v testSuiteFieldGrammar (fmap FG.unvalidateTestSuite condTree)+  | (n, condTree) <- suites+  ]  ppCondBenchmarks :: CabalSpecVersion -> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)] -> [PrettyField ()] ppCondBenchmarks v suites =-    [ PrettySection () "benchmark" [pretty n]-    $ ppCondTree2 v benchmarkFieldGrammar (fmap FG.unvalidateBenchmark condTree)-    | (n, condTree) <- suites-    ]+  [ PrettySection () "benchmark" [pretty n] $+    ppCondTree2 v benchmarkFieldGrammar (fmap FG.unvalidateBenchmark condTree)+  | (n, condTree) <- suites+  ]  ppCondition :: Condition ConfVar -> Doc-ppCondition (Var x)                      = ppConfVar x-ppCondition (Lit b)                      = text (show b)-ppCondition (CNot c)                     = char '!' <<>> (ppCondition c)-ppCondition (COr c1 c2)                  = parens (hsep [ppCondition c1, text "||"-                                                         <+> ppCondition c2])-ppCondition (CAnd c1 c2)                 = parens (hsep [ppCondition c1, text "&&"-                                                         <+> ppCondition c2])+ppCondition (Var x) = ppConfVar x+ppCondition (Lit b) = text (show b)+ppCondition (CNot c) = char '!' <<>> (ppCondition c)+ppCondition (COr c1 c2) =+  parens+    ( hsep+        [ ppCondition c1+        , text "||"+            <+> ppCondition c2+        ]+    )+ppCondition (CAnd c1 c2) =+  parens+    ( hsep+        [ ppCondition c1+        , text "&&"+            <+> ppCondition c2+        ]+    ) ppConfVar :: ConfVar -> Doc-ppConfVar (OS os)            = text "os"   <<>> parens (pretty os)-ppConfVar (Arch arch)        = text "arch" <<>> parens (pretty arch)+ppConfVar (OS os) = text "os" <<>> parens (pretty os)+ppConfVar (Arch arch) = text "arch" <<>> parens (pretty arch) ppConfVar (PackageFlag name) = text "flag" <<>> parens (ppFlagName name)-ppConfVar (Impl c v)         = text "impl" <<>> parens (pretty c <+> pretty v)+ppConfVar (Impl c v) = text "impl" <<>> parens (pretty c <+> pretty v)  ppFlagName :: FlagName -> Doc-ppFlagName                               = text . unFlagName+ppFlagName = text . unFlagName  ppIfCondition :: Condition ConfVar -> [PrettyField ()] -> PrettyField () ppIfCondition c = PrettySection () "if" [ppCondition c]@@ -191,7 +218,7 @@ writePackageDescription :: FilePath -> PackageDescription -> IO () writePackageDescription fpath pkg = writeUTF8File fpath (showPackageDescription pkg) ---TODO: make this use section syntax+-- TODO: make this use section syntax -- add equivalent for GenericPackageDescription  -- | @since 2.0.0.2@@ -199,26 +226,28 @@ showPackageDescription = showGenericPackageDescription . pdToGpd  pdToGpd :: PackageDescription -> GenericPackageDescription-pdToGpd pd = GenericPackageDescription+pdToGpd pd =+  GenericPackageDescription     { packageDescription = pd-    , gpdScannedVersion  = Nothing-    , genPackageFlags    = []-    , condLibrary        = mkCondTree <$> library pd-    , condSubLibraries   = mkCondTreeL <$> subLibraries pd-    , condForeignLibs    = mkCondTree' foreignLibName <$> foreignLibs pd-    , condExecutables    = mkCondTree' exeName <$> executables pd-    , condTestSuites     = mkCondTree' testName <$> testSuites pd-    , condBenchmarks     = mkCondTree' benchmarkName <$> benchmarks pd+    , gpdScannedVersion = Nothing+    , genPackageFlags = []+    , condLibrary = mkCondTree <$> library pd+    , condSubLibraries = mkCondTreeL <$> subLibraries pd+    , condForeignLibs = mkCondTree' foreignLibName <$> foreignLibs pd+    , condExecutables = mkCondTree' exeName <$> executables pd+    , condTestSuites = mkCondTree' testName <$> testSuites pd+    , condBenchmarks = mkCondTree' benchmarkName <$> benchmarks pd     }   where     -- We set CondTree's [Dependency] to an empty list, as it     -- is not pretty printed anyway.-    mkCondTree  x = CondNode x [] []+    mkCondTree x = CondNode x [] []     mkCondTreeL l = (fromMaybe (mkUnqualComponentName "") (libraryNameString (libName l)), CondNode l [] [])      mkCondTree'-        :: (a -> UnqualComponentName)-        -> a -> (UnqualComponentName, CondTree ConfVar [Dependency] a)+      :: (a -> UnqualComponentName)+      -> a+      -> (UnqualComponentName, CondTree ConfVar [Dependency] a)     mkCondTree' f x = (f x, CondNode x [] [])  -------------------------------------------------------------------------------@@ -229,12 +258,12 @@ -- preProcessInternalDeps :: CabalSpecVersion -> GenericPackageDescription -> GenericPackageDescription preProcessInternalDeps specVer gpd-    | specVer >= CabalSpecV3_4 = gpd-    | otherwise                = transformAllBuildInfos transformBI transformSBI gpd+  | specVer >= CabalSpecV3_4 = gpd+  | otherwise = transformAllBuildInfos transformBI transformSBI gpd   where     transformBI :: BuildInfo -> BuildInfo-    transformBI-        = over L.targetBuildDepends (concatMap transformD)+    transformBI =+      over L.targetBuildDepends (concatMap transformD)         . over L.mixins (map transformM)      transformSBI :: SetupBuildInfo -> SetupBuildInfo@@ -242,22 +271,24 @@      transformD :: Dependency -> [Dependency]     transformD (Dependency pn vr ln)-        | pn == thisPn-        = if LMainLibName `NES.member` ln-          then Dependency thisPn vr mainLibSet : sublibs-          else sublibs+      | pn == thisPn && specVer < CabalSpecV3_0 =+          if LMainLibName `NES.member` ln+            then Dependency thisPn vr mainLibSet : sublibs+            else sublibs       where         sublibs =-            [ Dependency (unqualComponentNameToPackageName uqn) vr mainLibSet-            | LSubLibName uqn <- NES.toList ln-            ]-+          [ Dependency (unqualComponentNameToPackageName uqn) vr mainLibSet+          | LSubLibName uqn <- NES.toList ln+          ]     transformD d = [d] +    -- Always perform transformation for mixins as syntax was only introduced in 3.4+    -- This guard is uncessary as no transformations take place when cabalSpec >= CabalSpecV3_4 but+    -- it more clearly signifies the intent. (See the specVer >= CabalSpecV3_4 line above).     transformM :: Mixin -> Mixin     transformM (Mixin pn (LSubLibName uqn) inc)-        | pn == thisPn-        = mkMixin (unqualComponentNameToPackageName uqn) LMainLibName inc+      | pn == thisPn && specVer < CabalSpecV3_4 =+          mkMixin (unqualComponentNameToPackageName uqn) LMainLibName inc     transformM m = m      thisPn :: PackageName@@ -269,14 +300,17 @@  -- | @since 2.0.0.2 writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> IO ()-writeHookedBuildInfo fpath = writeFileAtomic fpath . BS.Char8.pack-                             . showHookedBuildInfo+writeHookedBuildInfo fpath =+  writeFileAtomic fpath+    . BS.Char8.pack+    . showHookedBuildInfo  -- | @since 2.0.0.2 showHookedBuildInfo :: HookedBuildInfo -> String-showHookedBuildInfo (mb_lib_bi, ex_bis) = showFields (const NoComment) $-    maybe mempty (prettyFieldGrammar cabalSpecLatest buildInfoFieldGrammar) mb_lib_bi ++-    [ PrettySection () "executable:" [pretty name]-    $ prettyFieldGrammar cabalSpecLatest buildInfoFieldGrammar bi-    | (name, bi) <- ex_bis-    ]+showHookedBuildInfo (mb_lib_bi, ex_bis) =+  showFields (const NoComment) $+    maybe mempty (prettyFieldGrammar cabalSpecLatest buildInfoFieldGrammar) mb_lib_bi+      ++ [ PrettySection () "executable:" [pretty name] $+          prettyFieldGrammar cabalSpecLatest buildInfoFieldGrammar bi+         | (name, bi) <- ex_bis+         ]
src/Distribution/PackageDescription/Quirks.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RankNTypes        #-}+{-# LANGUAGE RankNTypes #-}+ -- | -- -- @since 2.2.0.0@@ -7,11 +8,11 @@  import Distribution.Compat.Prelude import Distribution.Utils.MD5-import GHC.Fingerprint             (Fingerprint (..))+import GHC.Fingerprint (Fingerprint (..)) import Prelude ()  import qualified Data.ByteString as BS-import qualified Data.Map        as Map+import qualified Data.Map as Map  -- | Patch legacy @.cabal@ file contents to allow parsec parser to accept -- all of Hackage.@@ -21,274 +22,330 @@ -- @since 2.2.0.0 patchQuirks :: BS.ByteString -> (Bool, BS.ByteString) patchQuirks bs = case Map.lookup (BS.take 256 bs, md5 bs) patches of-    Nothing -> (False, bs)-    Just (post, f)-        | post /= md5 output -> (False, bs)-        | otherwise          -> (True, output)-      where-        output = f bs+  Nothing -> (False, bs)+  Just (post, f)+    | post /= md5 output -> (False, bs)+    | otherwise -> (True, output)+    where+      output = f bs  -- | 'patches' contains first 256 bytes, pre- and post-fingerprints and a patch function. patches :: Map.Map (BS.ByteString, Fingerprint) (Fingerprint, BS.ByteString -> BS.ByteString)-patches = Map.fromList+patches =+  Map.fromList     -- http://hackage.haskell.org/package/unicode-transforms-0.3.3     -- other-modules: .     -- ReadP assumed dot is empty line-    [ mk "-- This file has been generated from package.yaml by hpack version 0.17.0.\n--\n-- see: https://github.com/sol/hpack\n\nname:                unicode-transforms\nversion:             0.3.3\nsynopsis:            Unicode normalization\ndescription:         Fast Unic"-         (Fingerprint 15958160436627155571 10318709190730872881)-         (Fingerprint 11008465475756725834 13815629925116264363)-         (bsRemove "  other-modules:\n      .\n") -- TODO: remove trailing \n to test structural-diff-    -- http://hackage.haskell.org/package/DSTM-0.1.2-    -- http://hackage.haskell.org/package/DSTM-0.1.1-    -- http://hackage.haskell.org/package/DSTM-0.1-    -- Other Modules: no dash-    -- ReadP parsed as section-    , mk "Name: DSTM\nVersion: 0.1.2\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: frk@informatik.uni-kiel.de\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed "-         (Fingerprint 6919263071548559054 9050746360708965827)-         (Fingerprint 17015177514298962556 11943164891661867280)-         (bsReplace "Other modules:" "-- ")-    , mk "Name: DSTM\nVersion: 0.1.1\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: frk@informatik.uni-kiel.de\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed "-         (Fingerprint 17313105789069667153 9610429408495338584)-         (Fingerprint 17250946493484671738 17629939328766863497)-         (bsReplace "Other modules:" "-- ")-    , mk "Name: DSTM\nVersion: 0.1\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: frk@informatik.uni-kiel.de\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed sy"-         (Fingerprint 10502599650530614586 16424112934471063115)-         (Fingerprint 13562014713536696107 17899511905611879358)-         (bsReplace "Other modules:" "-- ")-    -- http://hackage.haskell.org/package/control-monad-exception-mtl-0.10.3-    , mk "name: control-monad-exception-mtl\nversion: 0.10.3\nCabal-Version:  >= 1.10\nbuild-type: Simple\nlicense: PublicDomain\nauthor: Pepe Iborra\nmaintainer: pepeiborra@gmail.com\nhomepage: http://pepeiborra.github.com/control-monad-exception\nsynopsis: MTL instances f"-         (Fingerprint 18274748422558568404 4043538769550834851)-         (Fingerprint 11395257416101232635 4303318131190196308)-         (bsReplace " default- extensions:" "unknown-section")-    -- http://hackage.haskell.org/package/vacuum-opengl-0.0-    -- \DEL character-    , mk "Name:                vacuum-opengl\nVersion:             0.0\nSynopsis:            Visualize live Haskell data structures using vacuum, graphviz and OpenGL.\nDescription:         \DELVisualize live Haskell data structures using vacuum, graphviz and OpenGL.\n     "-         (Fingerprint 5946760521961682577 16933361639326309422)-         (Fingerprint 14034745101467101555 14024175957788447824)-         (bsRemove "\DEL")-    , mk "Name:                vacuum-opengl\nVersion:             0.0.1\nSynopsis:            Visualize live Haskell data structures using vacuum, graphviz and OpenGL.\nDescription:         \DELVisualize live Haskell data structures using vacuum, graphviz and OpenGL.\n   "-         (Fingerprint 10790950110330119503 1309560249972452700)-         (Fingerprint 1565743557025952928 13645502325715033593)-         (bsRemove "\DEL")-    -- http://hackage.haskell.org/package/ixset-1.0.4-    -- {- comments -}-    , mk "Name:                ixset\nVersion:             1.0.4\nSynopsis:            Efficient relational queries on Haskell sets.\nDescription:\n    Create and query sets that are indexed by multiple indices.\nLicense:             BSD3\nLicense-file:        COPYING\nAut"-         (Fingerprint 11886092342440414185 4150518943472101551)-         (Fingerprint 5731367240051983879 17473925006273577821)-         (bsRemoveStarting "{-")-    -- : after section-    -- http://hackage.haskell.org/package/ds-kanren-    , mk "name:                ds-kanren\nversion:             0.2.0.0\nsynopsis:            A subset of the miniKanren language\ndescription:\n  ds-kanren is an implementation of the <http://minikanren.org miniKanren> language.\n  .\n  == What's in ds-kanren?\n  .\n  ['dis"-         (Fingerprint 2804006762382336875 9677726932108735838)-         (Fingerprint 9830506174094917897 12812107316777006473)-         (bsReplace "Test-Suite test-unify:" "Test-Suite \"test-unify:\"" . bsReplace "Test-Suite test-list-ops:" "Test-Suite \"test-list-ops:\"")-    , mk "name:                ds-kanren\nversion:             0.2.0.1\nsynopsis:            A subset of the miniKanren language\ndescription:\n  ds-kanren is an implementation of the <http://minikanren.org miniKanren> language.\n\nlicense:             MIT\nlicense-file:  "-         (Fingerprint 9130259649220396193 2155671144384738932)-         (Fingerprint 1847988234352024240 4597789823227580457)-         (bsReplace "Test-Suite test-unify:" "Test-Suite \"test-unify:\"" . bsReplace "Test-Suite test-list-ops:" "Test-Suite \"test-list-ops:\"")-    , mk "name:                metric\nversion:             0.1.4\nsynopsis:            Metric spaces.\nlicense:             MIT\nlicense-file:        LICENSE\nauthor:              Vikram Verma\nmaintainer:          me@vikramverma.com\ncategory:            Data\nbuild-type:"-         (Fingerprint 6150019278861565482 3066802658031228162)-         (Fingerprint 9124826020564520548 15629704249829132420)-         (bsReplace "test-suite metric-tests:" "test-suite \"metric-tests:\"")-    , mk "name:                metric\nversion:             0.2.0\nsynopsis:            Metric spaces.\nlicense:             MIT\nlicense-file:        LICENSE\nauthor:              Vikram Verma\nmaintainer:          me@vikramverma.com\ncategory:            Data\nbuild-type:"-         (Fingerprint 4639805967994715694 7859317050376284551)-         (Fingerprint 5566222290622325231 873197212916959151)-         (bsReplace "test-suite metric-tests:" "test-suite \"metric-tests:\"")-    , mk "name:          phasechange\ncategory:      Data\nversion:       0.1\nauthor:        G\195\161bor Lehel\nmaintainer:    G\195\161bor Lehel <illissius@gmail.com>\nhomepage:      http://github.com/glehel/phasechange\ncopyright:     Copyright (C) 2012 G\195\161bor Lehel\nlicense:     "-         (Fingerprint 10546509771395401582 245508422312751943)-         (Fingerprint 5169853482576003304 7247091607933993833)-         (bsReplace "impl(ghc >= 7.4):" "erroneous-section" . bsReplace "impl(ghc >= 7.6):" "erroneous-section")-    , mk "Name:                smartword\nSynopsis:            Web based flash card for Word Smart I and II vocabularies\nVersion:             0.0.0.5\nHomepage:            http://kyagrd.dyndns.org/~kyagrd/project/smartword/\nCategory:            Web,Education\nLicense: "-         (Fingerprint 7803544783533485151 10807347873998191750)-         (Fingerprint 1665635316718752601 16212378357991151549)-         (bsReplace "build depends:" "--")-    , mk "name:           shelltestrunner\n-- sync with README.md, ANNOUNCE:\nversion:        1.3\ncategory:       Testing\nsynopsis:       A tool for testing command-line programs.\ndescription:\n shelltestrunner is a cross-platform tool for testing command-line\n program"-         (Fingerprint 4403237110790078829 15392625961066653722)-         (Fingerprint 10218887328390239431 4644205837817510221)-         (bsReplace "other modules:" "--")-    -- &&!-    -- http://hackage.haskell.org/package/hblas-0.3.0.0-    , mk "-- Initial hblas.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP) \n-- "-         (Fingerprint 8570120150072467041 18315524331351505945)-         (Fingerprint 10838007242302656005 16026440017674974175)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP) \n-- "-         (Fingerprint 5262875856214215155 10846626274067555320)-         (Fingerprint 3022954285783401045 13395975869915955260)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP) \n-- "-         (Fingerprint 54222628930951453 5526514916844166577)-         (Fingerprint 1749630806887010665 8607076506606977549)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"-         (Fingerprint 6817250511240350300 15278852712000783849)-         (Fingerprint 15757717081429529536 15542551865099640223)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"-         (Fingerprint 8310050400349211976 201317952074418615)-         (Fingerprint 10283381191257209624 4231947623042413334)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"-         (Fingerprint 7010988292906098371 11591884496857936132)-         (Fingerprint 6158672440010710301 6419743768695725095)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further\r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\n-- The name of the package.\r\nname:                hblas\r\n\r\n-- The package version.  See the Haskell package versioning policy (PVP)"-         (Fingerprint 2076850805659055833 16615160726215879467)-         (Fingerprint 10634706281258477722 5285812379517916984)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further\r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\n-- The name of the package.\r\nname:                hblas\r\n\r\n-- The package version.  See the Haskell package versioning policy (PVP)"-         (Fingerprint 11850020631622781099 11956481969231030830)-         (Fingerprint 13702868780337762025 13383526367149067158)-         (bsReplace "&&!" "&& !")-    , mk "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"-         (Fingerprint 13690322768477779172 19704059263540994)-         (Fingerprint 11189374824645442376 8363528115442591078)-         (bsReplace "&&!" "&& !")-    -- flag used, but not defined-    , mk "name:                brainheck\nversion:             0.1.0.2\nsynopsis:            Brainh*ck interpreter in haskell\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\nhomepage:            https://gi"-         (Fingerprint 6910727116443152200 15401634478524888973)-         (Fingerprint 16551412117098094368 16260377389127603629)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                brainheck\r\nversion:             0.1.0.2\r\nx-revision: 1\r\nsynopsis:            Brainh*ck interpreter in haskell\r\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage:   "-         (Fingerprint 14320987921316832277 10031098243571536929)-         (Fingerprint 7959395602414037224 13279941216182213050)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                brainheck\r\nversion:             0.1.0.2\r\nx-revision: 2\r\nsynopsis:            Brainh*ck interpreter in haskell\r\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage:   "-         (Fingerprint 3809078390223299128 10796026010775813741)-         (Fingerprint 1127231189459220796 12088367524333209349)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                brainheck\r\nversion:             0.1.0.2\r\nx-revision: 3\r\nsynopsis:            Brainh*ck interpreter in haskell\r\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage:   "-         (Fingerprint 13860013038089410950 12479824176801390651)-         (Fingerprint 4687484721703340391 8013395164515771785)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                wordchoice\nversion:             0.1.0.1\nsynopsis:            Get word counts and distributions\ndescription:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"-         (Fingerprint 16215911397419608203 15594928482155652475)-         (Fingerprint 15120681510314491047 2666192399775157359)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                wordchoice\r\nversion:             0.1.0.1\r\nx-revision: 1\r\nsynopsis:            Get word counts and distributions\r\ndescription:         A command line tool to compute the word distribution from various types of document, converting to te"-         (Fingerprint 16593139224723441188 4052919014346212001)-         (Fingerprint 3577381082410411593 11481899387780544641)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                wordchoice\nversion:             0.1.0.2\nsynopsis:            Get word counts and distributions\ndescription:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"-         (Fingerprint 9321301260802539374 1316392715016096607)-         (Fingerprint 3784628652257760949 12662640594755291035)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                wordchoice\r\nversion:             0.1.0.2\r\nx-revision: 1\r\nsynopsis:            Get word counts and distributions\r\ndescription:         A command line tool to compute the word distribution from various types of document, converting to te"-         (Fingerprint 2546901804824433337 2059732715322561176)-         (Fingerprint 8082068680348326500 615008613291421947)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                wordchoice\nversion:             0.1.0.3\nsynopsis:            Get word counts and distributions\ndescription:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"-         (Fingerprint 2282380737467965407 12457554753171662424)-         (Fingerprint 17324757216926991616 17172911843227482125)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                wordchoice\r\nversion:             0.1.0.3\r\nx-revision: 1\r\nsynopsis:            Get word counts and distributions\r\ndescription:         A command line tool to compute the word distribution from various types of document, converting to te"-         (Fingerprint 12907988890480595481 11078473638628359710)-         (Fingerprint 13246185333368731848 4663060731847518614)-         (bsReplace "flag(llvm-fast)" "False")-    , mk "name:                hw-prim-bits\nversion:             0.1.0.0\nsynopsis:            Primitive support for bit manipulation\ndescription:         Please see README.md\nhomepage:            https://github.com/githubuser/hw-prim-bits#readme\nlicense:            "-         (Fingerprint 12386777729082870356 17414156731912743711)-         (Fingerprint 3452290353395041602 14102887112483033720)-         (bsReplace "flag(sse42)" "False")-    , mk "name:                   hw-prim-bits\nversion:                0.1.0.1\nsynopsis:               Primitive support for bit manipulation\ndescription:            Please see README.md\nhomepage:               https://github.com/githubuser/hw-prim-bits#readme\nlicen"-         (Fingerprint 6870520675313101180 14553457351296240636)-         (Fingerprint 12481021059537696455 14711088786769892762)-         (bsReplace "flag(sse42)" "False")-    -- leading zeros in version digits-    -- https://github.com/haskell-infra/hackage-trustees/issues/128-    -- https://github.com/haskell/cabal/issues/5092-    -- https://github.com/haskell/cabal/issues/5138-    , mk "name:            Sit\nversion:         0.2017.02.26\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Anonymous\nmaintainer:      Anonymous\nhomepage:        NONE\ncategory:        Dependent"-         (Fingerprint 8458530898096910998 3228538743646501413)-         (Fingerprint 14470502514907936793 17514354054641875371)-         (bsReplace "0.2017.02.26" "0.2017.2.26")-    , mk "name:            Sit\nversion:         0.2017.05.01\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Andreas Abel <andreas.abel@gu.se>\nmaintainer:      Andreas Abel <andreas.abel@gu.se>\n"-         (Fingerprint 1450130849535097473 11742099607098860444)-         (Fingerprint 16679762943850814021 4253724355613883542)-         (bsReplace "0.2017.05.01" "0.2017.5.1")-    , mk "name:            Sit\nversion:         0.2017.05.02\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Andreas Abel <andreas.abel@gu.se>\nmaintainer:      Andreas Abel <andreas.abel@gu.se>\n"-         (Fingerprint 297248532398492441 17322625167861324800)-         (Fingerprint 634812045126693280 1755581866539318862)-         (bsReplace "0.2017.05.02" "0.2017.5.2")-    , mk "name:            Sit\nversion:         0.2017.5.02\nx-revision: 1\n-- x-revision:1 see https://github.com/haskell-infra/hackage-trustees/issues/128\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor: "-         (Fingerprint 3697869560530373941 3942982281026987312)-         (Fingerprint 14344526114710295386 16386400353475114712)-         (bsReplace "0.2017.5.02" "0.2017.5.2")-    , mk "name:            MiniAgda\nversion:         0.2017.02.18\nbuild-type:      Simple\ncabal-version:   >= 1.22\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Andreas Abel and Karl Mehltretter\nmaintainer:      Andreas Abel <andreas.abel@i"-         (Fingerprint 17167128953451088679 4300350537748753465)-         (Fingerprint 12402236925293025673 7715084875284020606)-         (bsReplace "0.2017.02.18" "0.2017.2.18")-    , mk "cabal-version:\n  2.0\nname:\n  fast-downward\nversion:\n  0.1.0.0\nbuild-type:\n  Simple\nsynopsis:\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n  @fast-downward@ is a library for modelling classical planning probl"-         (Fingerprint 11256076039027887363 6867903407496243216)-         (Fingerprint 12159816716813155434 5278015399212299853)-         (bsReplace "1.2.03.0" "1.2.3.0")-    , mk "cabal-version:\r\n  2.0\r\nname:\r\n  fast-downward\r\nversion:\r\n  0.1.0.0\r\nx-revision: \r\n  1\r\nbuild-type:\r\n  Simple\r\nsynopsis:\r\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\r\ndescription:\r\n  @fast-downward@ is a library for mode"-         (Fingerprint 9216193973149680231 893446343655828508)-         (Fingerprint 10020169545407746427 1828336750379510675)-         (bsReplace "1.2.03.0" "1.2.3.0")-    , mk "cabal-version:\n  2.0\nname:\n  fast-downward\nversion:\n  0.1.0.1\nbuild-type:\n  Simple\nsynopsis:\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n  @fast-downward@ is a library for modelling classical planning probl"-         (Fingerprint 9899886602574848632 5980433644983783334)-         (Fingerprint 12007469255857289958 8321466548645225439)-         (bsReplace "1.2.03.0" "1.2.3.0")-    , mk "cabal-version:\n  2.0\nname:\n  fast-downward\nversion:\n  0.1.1.0\nbuild-type:\n  Simple\nsynopsis:\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n  @fast-downward@ is a library for modelling classical planning probl"-         (Fingerprint 12694656661460787751 1902242956706735615)-         (Fingerprint 15433152131513403849 2284712791516353264)-         (bsReplace "1.2.03.0" "1.2.3.0")-    -- 9 digits limit-    , mk "Name:                SGplus\nVersion:             1.1\nSynopsis:            (updated) Small geometry library for dealing with vectors and collision detection\nLicense:             BSD3\nLicense-file:        LICENSE\nAuthor:              Neil Brown\nMaintainer:  "-         (Fingerprint 17735649550442248029 11493772714725351354)-         (Fingerprint 9565458801063261772 15955773698774721052)-         (bsReplace "1000000000" "100000000")-    , mk "-- Initial control-dotdotdot.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\nname:                control-dotdotdot\nversion:             0.1.0.1\nsynopsis:            Haskell operator\n               "-         (Fingerprint 1514257173776509942 7756050823377346485)-         (Fingerprint 14082092642045505999 18415918653404121035)-         (bsReplace "9223372036854775807" "5")-    , mk "name:                data-foldapp\r\nversion:             0.1.1.0\r\nsynopsis:            Fold function applications. Framework for variadic functions.\r\ndescription:         Fold function applications. Framework for variadic functions.\r\nhomepage:            ht"-         (Fingerprint 4511234156311243251 11701153011544112556)-         (Fingerprint 11820542702491924189 4902231447612406724)-         (bsReplace "9223372036854775807" "999" . bsReplace "9223372036854775807" "999")-    , mk "-- Initial data-list-zigzag.cabal generated by cabal init.  For further \r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\nname:                data-list-zigzag\r\nversion:             0.1.1.1\r\nsynopsis:            A list but with a balanced en"-         (Fingerprint 12475837388692175691 18053834261188158945)-         (Fingerprint 16279938253437334942 15753349540193002309)-         (bsReplace "9223372036854775807" "999")-    -- Not UTF8-    , mk "Name:                     nat\nVersion:                  0.1\nDescription:            Implementation of natural numbers and integers by a binary\n                                representation. The implementation is supposed to be lazy and\n                   "-         (Fingerprint 9222512268705577108 13085311382746579495)-         (Fingerprint 17468921266614378430 13221316288008291892)-         (bsReplace "\xf6" "\xc3\xb6")-    -- cabal-version: 2-    , mk "name:                streaming-bracketed\nversion:             0.1.0.0\nsynopsis:            A resource management decorator for \"streaming\".        \ndescription:         This package provides a decorator for the Stream type from\n                     the \"st"-         (Fingerprint 14670044663153191927 1427497586294143829)-         (Fingerprint 9233007756654759985 6571998449003682006)-         (bsReplace "cabal-version:       2" "cabal-version: 2.0")-    , mk "name:                streaming-bracketed\nversion:             0.1.0.1\nsynopsis:            A resource management decorator for \"streaming\".        \ndescription:         This package provides a decorator for the Stream type from\n                     \"stream"-         (Fingerprint 7298738862909203815 10141693276062967842)-         (Fingerprint 1349949738792220441 3593683359695349293)-         (bsReplace "cabal-version:       2" "cabal-version: 2.0")-    , mk "name:           zsyntax\nversion:        0.2.0.0\ndescription:    An automated theorem prover for Zsyntax, a\n                logical calculus for molecular biology inspired by linear logic,\n                that can be used to automatically verify biological\n"-         (Fingerprint 17812331267506881875 3005293725141563863)-         (Fingerprint 3445957263137759540 12472369104312474458)-         (bsReplace "cabal-version:  2" "cabal-version: 2.0")--    -- Empty filepath in not license-file or data-dir-    -- These have hs-source-dirs: ""-    , mk "\nname:                wai-middleware-hmac-client\nversion:             0.1.0.1\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Christopher Reichert\nmaintainer:          creichert07@gmail.com\ncopyright:           (c) 2015, Christo"-         (Fingerprint 3112606538775065787 11984607507024462091)-         (Fingerprint 6916432989977230500 6621389616675138128)-         (bsReplace "\"\"" ".")-    , mk "\nname:                wai-middleware-hmac-client\nversion:             0.1.0.2\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Christopher Reichert\nmaintainer:          creichert07@gmail.com\ncopyright:           (c) 2015, Christo"-         (Fingerprint 12566783342663020458 17562089389615949789)-         (Fingerprint 15745683452603944938 10556498036622072844)-         (bsReplace "\"\"" ".")--    -- absolute license-file-    , mk "name: reheat\nversion: 0.1.4\ncabal-version: >=1.8\nbuild-type: Simple\nlicense: GPL\nlicense-file: /home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt\ncopyright: GPL\nmaintainer: Ingolf Wagner <palipalo9@gmail.com>\nstability: experimental\nhomepage: h"-         (Fingerprint 9155400339287317061 14812953666990892802)-         (Fingerprint 7687053346032173923 15384472501136606592)-         (bsReplace "/home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt" "")-    , mk "name: reheat\nversion: 0.1.5\ncabal-version: >=1.8\nbuild-type: Simple\nlicense: GPL\nlicense-file: /home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt\ncopyright: GPL\nmaintainer: Ingolf Wagner <palipalo9@gmail.com>\nstability: experimental\nhomepage: h"-         (Fingerprint 2984391146441073709 11728234882049907993)-         (Fingerprint 12058479081855347701 14017937756688869826)-         (bsReplace "/home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt" "")+    [ mk+        "-- This file has been generated from package.yaml by hpack version 0.17.0.\n--\n-- see: https://github.com/sol/hpack\n\nname:                unicode-transforms\nversion:             0.3.3\nsynopsis:            Unicode normalization\ndescription:         Fast Unic"+        (Fingerprint 15958160436627155571 10318709190730872881)+        (Fingerprint 11008465475756725834 13815629925116264363)+        (bsRemove "  other-modules:\n      .\n") -- TODO: remove trailing \n to test structural-diff+        -- http://hackage.haskell.org/package/DSTM-0.1.2+        -- http://hackage.haskell.org/package/DSTM-0.1.1+        -- http://hackage.haskell.org/package/DSTM-0.1+        -- Other Modules: no dash+        -- ReadP parsed as section+    , mk+        "Name: DSTM\nVersion: 0.1.2\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: frk@informatik.uni-kiel.de\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed "+        (Fingerprint 6919263071548559054 9050746360708965827)+        (Fingerprint 17015177514298962556 11943164891661867280)+        (bsReplace "Other modules:" "-- ")+    , mk+        "Name: DSTM\nVersion: 0.1.1\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: frk@informatik.uni-kiel.de\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed "+        (Fingerprint 17313105789069667153 9610429408495338584)+        (Fingerprint 17250946493484671738 17629939328766863497)+        (bsReplace "Other modules:" "-- ")+    , mk+        "Name: DSTM\nVersion: 0.1\nCopyright: (c) 2010, Frank Kupke\nLicense: LGPL\nLicense-File: LICENSE\nAuthor: Frank Kupke\nMaintainer: frk@informatik.uni-kiel.de\nCabal-Version: >= 1.2.3\nStability: provisional\nSynopsis: A framework for using STM within distributed sy"+        (Fingerprint 10502599650530614586 16424112934471063115)+        (Fingerprint 13562014713536696107 17899511905611879358)+        (bsReplace "Other modules:" "-- ")+    , -- http://hackage.haskell.org/package/control-monad-exception-mtl-0.10.3+      mk+        "name: control-monad-exception-mtl\nversion: 0.10.3\nCabal-Version:  >= 1.10\nbuild-type: Simple\nlicense: PublicDomain\nauthor: Pepe Iborra\nmaintainer: pepeiborra@gmail.com\nhomepage: http://pepeiborra.github.com/control-monad-exception\nsynopsis: MTL instances f"+        (Fingerprint 18274748422558568404 4043538769550834851)+        (Fingerprint 11395257416101232635 4303318131190196308)+        (bsReplace " default- extensions:" "unknown-section")+    , -- http://hackage.haskell.org/package/vacuum-opengl-0.0+      -- \DEL character+      mk+        "Name:                vacuum-opengl\nVersion:             0.0\nSynopsis:            Visualize live Haskell data structures using vacuum, graphviz and OpenGL.\nDescription:         \DELVisualize live Haskell data structures using vacuum, graphviz and OpenGL.\n     "+        (Fingerprint 5946760521961682577 16933361639326309422)+        (Fingerprint 14034745101467101555 14024175957788447824)+        (bsRemove "\DEL")+    , mk+        "Name:                vacuum-opengl\nVersion:             0.0.1\nSynopsis:            Visualize live Haskell data structures using vacuum, graphviz and OpenGL.\nDescription:         \DELVisualize live Haskell data structures using vacuum, graphviz and OpenGL.\n   "+        (Fingerprint 10790950110330119503 1309560249972452700)+        (Fingerprint 1565743557025952928 13645502325715033593)+        (bsRemove "\DEL")+    , -- http://hackage.haskell.org/package/ixset-1.0.4+      -- {- comments -}+      mk+        "Name:                ixset\nVersion:             1.0.4\nSynopsis:            Efficient relational queries on Haskell sets.\nDescription:\n    Create and query sets that are indexed by multiple indices.\nLicense:             BSD3\nLicense-file:        COPYING\nAut"+        (Fingerprint 11886092342440414185 4150518943472101551)+        (Fingerprint 5731367240051983879 17473925006273577821)+        (bsRemoveStarting "{-")+    , -- : after section+      -- http://hackage.haskell.org/package/ds-kanren+      mk+        "name:                ds-kanren\nversion:             0.2.0.0\nsynopsis:            A subset of the miniKanren language\ndescription:\n  ds-kanren is an implementation of the <http://minikanren.org miniKanren> language.\n  .\n  == What's in ds-kanren?\n  .\n  ['dis"+        (Fingerprint 2804006762382336875 9677726932108735838)+        (Fingerprint 9830506174094917897 12812107316777006473)+        (bsReplace "Test-Suite test-unify:" "Test-Suite \"test-unify:\"" . bsReplace "Test-Suite test-list-ops:" "Test-Suite \"test-list-ops:\"")+    , mk+        "name:                ds-kanren\nversion:             0.2.0.1\nsynopsis:            A subset of the miniKanren language\ndescription:\n  ds-kanren is an implementation of the <http://minikanren.org miniKanren> language.\n\nlicense:             MIT\nlicense-file:  "+        (Fingerprint 9130259649220396193 2155671144384738932)+        (Fingerprint 1847988234352024240 4597789823227580457)+        (bsReplace "Test-Suite test-unify:" "Test-Suite \"test-unify:\"" . bsReplace "Test-Suite test-list-ops:" "Test-Suite \"test-list-ops:\"")+    , mk+        "name:                metric\nversion:             0.1.4\nsynopsis:            Metric spaces.\nlicense:             MIT\nlicense-file:        LICENSE\nauthor:              Vikram Verma\nmaintainer:          me@vikramverma.com\ncategory:            Data\nbuild-type:"+        (Fingerprint 6150019278861565482 3066802658031228162)+        (Fingerprint 9124826020564520548 15629704249829132420)+        (bsReplace "test-suite metric-tests:" "test-suite \"metric-tests:\"")+    , mk+        "name:                metric\nversion:             0.2.0\nsynopsis:            Metric spaces.\nlicense:             MIT\nlicense-file:        LICENSE\nauthor:              Vikram Verma\nmaintainer:          me@vikramverma.com\ncategory:            Data\nbuild-type:"+        (Fingerprint 4639805967994715694 7859317050376284551)+        (Fingerprint 5566222290622325231 873197212916959151)+        (bsReplace "test-suite metric-tests:" "test-suite \"metric-tests:\"")+    , mk+        "name:          phasechange\ncategory:      Data\nversion:       0.1\nauthor:        G\195\161bor Lehel\nmaintainer:    G\195\161bor Lehel <illissius@gmail.com>\nhomepage:      http://github.com/glehel/phasechange\ncopyright:     Copyright (C) 2012 G\195\161bor Lehel\nlicense:     "+        (Fingerprint 10546509771395401582 245508422312751943)+        (Fingerprint 5169853482576003304 7247091607933993833)+        (bsReplace "impl(ghc >= 7.4):" "erroneous-section" . bsReplace "impl(ghc >= 7.6):" "erroneous-section")+    , mk+        "Name:                smartword\nSynopsis:            Web based flash card for Word Smart I and II vocabularies\nVersion:             0.0.0.5\nHomepage:            http://kyagrd.dyndns.org/~kyagrd/project/smartword/\nCategory:            Web,Education\nLicense: "+        (Fingerprint 7803544783533485151 10807347873998191750)+        (Fingerprint 1665635316718752601 16212378357991151549)+        (bsReplace "build depends:" "--")+    , mk+        "name:           shelltestrunner\n-- sync with README.md, ANNOUNCE:\nversion:        1.3\ncategory:       Testing\nsynopsis:       A tool for testing command-line programs.\ndescription:\n shelltestrunner is a cross-platform tool for testing command-line\n program"+        (Fingerprint 4403237110790078829 15392625961066653722)+        (Fingerprint 10218887328390239431 4644205837817510221)+        (bsReplace "other modules:" "--")+    , -- &&!+      -- http://hackage.haskell.org/package/hblas-0.3.0.0+      mk+        "-- Initial hblas.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP) \n-- "+        (Fingerprint 8570120150072467041 18315524331351505945)+        (Fingerprint 10838007242302656005 16026440017674974175)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP) \n-- "+        (Fingerprint 5262875856214215155 10846626274067555320)+        (Fingerprint 3022954285783401045 13395975869915955260)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP) \n-- "+        (Fingerprint 54222628930951453 5526514916844166577)+        (Fingerprint 1749630806887010665 8607076506606977549)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"+        (Fingerprint 6817250511240350300 15278852712000783849)+        (Fingerprint 15757717081429529536 15542551865099640223)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"+        (Fingerprint 8310050400349211976 201317952074418615)+        (Fingerprint 10283381191257209624 4231947623042413334)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"+        (Fingerprint 7010988292906098371 11591884496857936132)+        (Fingerprint 6158672440010710301 6419743768695725095)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further\r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\n-- The name of the package.\r\nname:                hblas\r\n\r\n-- The package version.  See the Haskell package versioning policy (PVP)"+        (Fingerprint 2076850805659055833 16615160726215879467)+        (Fingerprint 10634706281258477722 5285812379517916984)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further\r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\n-- The name of the package.\r\nname:                hblas\r\n\r\n-- The package version.  See the Haskell package versioning policy (PVP)"+        (Fingerprint 11850020631622781099 11956481969231030830)+        (Fingerprint 13702868780337762025 13383526367149067158)+        (bsReplace "&&!" "&& !")+    , mk+        "-- Initial hblas.cabal generated by cabal init.  For further\n-- documentation, see http://haskell.org/cabal/users-guide/\n\n-- The name of the package.\nname:                hblas\n\n-- The package version.  See the Haskell package versioning policy (PVP)\n-- fo"+        (Fingerprint 13690322768477779172 19704059263540994)+        (Fingerprint 11189374824645442376 8363528115442591078)+        (bsReplace "&&!" "&& !")+    , -- flag used, but not defined+      mk+        "name:                brainheck\nversion:             0.1.0.2\nsynopsis:            Brainh*ck interpreter in haskell\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\nhomepage:            https://gi"+        (Fingerprint 6910727116443152200 15401634478524888973)+        (Fingerprint 16551412117098094368 16260377389127603629)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                brainheck\r\nversion:             0.1.0.2\r\nx-revision: 1\r\nsynopsis:            Brainh*ck interpreter in haskell\r\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage:   "+        (Fingerprint 14320987921316832277 10031098243571536929)+        (Fingerprint 7959395602414037224 13279941216182213050)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                brainheck\r\nversion:             0.1.0.2\r\nx-revision: 2\r\nsynopsis:            Brainh*ck interpreter in haskell\r\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage:   "+        (Fingerprint 3809078390223299128 10796026010775813741)+        (Fingerprint 1127231189459220796 12088367524333209349)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                brainheck\r\nversion:             0.1.0.2\r\nx-revision: 3\r\nsynopsis:            Brainh*ck interpreter in haskell\r\ndescription:         Brainh*ck interpreter written in haskell and taking advantage of many prominent libraries\r\nhomepage:   "+        (Fingerprint 13860013038089410950 12479824176801390651)+        (Fingerprint 4687484721703340391 8013395164515771785)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                wordchoice\nversion:             0.1.0.1\nsynopsis:            Get word counts and distributions\ndescription:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"+        (Fingerprint 16215911397419608203 15594928482155652475)+        (Fingerprint 15120681510314491047 2666192399775157359)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                wordchoice\r\nversion:             0.1.0.1\r\nx-revision: 1\r\nsynopsis:            Get word counts and distributions\r\ndescription:         A command line tool to compute the word distribution from various types of document, converting to te"+        (Fingerprint 16593139224723441188 4052919014346212001)+        (Fingerprint 3577381082410411593 11481899387780544641)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                wordchoice\nversion:             0.1.0.2\nsynopsis:            Get word counts and distributions\ndescription:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"+        (Fingerprint 9321301260802539374 1316392715016096607)+        (Fingerprint 3784628652257760949 12662640594755291035)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                wordchoice\r\nversion:             0.1.0.2\r\nx-revision: 1\r\nsynopsis:            Get word counts and distributions\r\ndescription:         A command line tool to compute the word distribution from various types of document, converting to te"+        (Fingerprint 2546901804824433337 2059732715322561176)+        (Fingerprint 8082068680348326500 615008613291421947)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                wordchoice\nversion:             0.1.0.3\nsynopsis:            Get word counts and distributions\ndescription:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.\nho"+        (Fingerprint 2282380737467965407 12457554753171662424)+        (Fingerprint 17324757216926991616 17172911843227482125)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                wordchoice\r\nversion:             0.1.0.3\r\nx-revision: 1\r\nsynopsis:            Get word counts and distributions\r\ndescription:         A command line tool to compute the word distribution from various types of document, converting to te"+        (Fingerprint 12907988890480595481 11078473638628359710)+        (Fingerprint 13246185333368731848 4663060731847518614)+        (bsReplace "flag(llvm-fast)" "False")+    , mk+        "name:                hw-prim-bits\nversion:             0.1.0.0\nsynopsis:            Primitive support for bit manipulation\ndescription:         Please see README.md\nhomepage:            https://github.com/githubuser/hw-prim-bits#readme\nlicense:            "+        (Fingerprint 12386777729082870356 17414156731912743711)+        (Fingerprint 3452290353395041602 14102887112483033720)+        (bsReplace "flag(sse42)" "False")+    , mk+        "name:                   hw-prim-bits\nversion:                0.1.0.1\nsynopsis:               Primitive support for bit manipulation\ndescription:            Please see README.md\nhomepage:               https://github.com/githubuser/hw-prim-bits#readme\nlicen"+        (Fingerprint 6870520675313101180 14553457351296240636)+        (Fingerprint 12481021059537696455 14711088786769892762)+        (bsReplace "flag(sse42)" "False")+    , -- leading zeros in version digits+      -- https://github.com/haskell-infra/hackage-trustees/issues/128+      -- https://github.com/haskell/cabal/issues/5092+      -- https://github.com/haskell/cabal/issues/5138+      mk+        "name:            Sit\nversion:         0.2017.02.26\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Anonymous\nmaintainer:      Anonymous\nhomepage:        NONE\ncategory:        Dependent"+        (Fingerprint 8458530898096910998 3228538743646501413)+        (Fingerprint 14470502514907936793 17514354054641875371)+        (bsReplace "0.2017.02.26" "0.2017.2.26")+    , mk+        "name:            Sit\nversion:         0.2017.05.01\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Andreas Abel <andreas.abel@gu.se>\nmaintainer:      Andreas Abel <andreas.abel@gu.se>\n"+        (Fingerprint 1450130849535097473 11742099607098860444)+        (Fingerprint 16679762943850814021 4253724355613883542)+        (bsReplace "0.2017.05.01" "0.2017.5.1")+    , mk+        "name:            Sit\nversion:         0.2017.05.02\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Andreas Abel <andreas.abel@gu.se>\nmaintainer:      Andreas Abel <andreas.abel@gu.se>\n"+        (Fingerprint 297248532398492441 17322625167861324800)+        (Fingerprint 634812045126693280 1755581866539318862)+        (bsReplace "0.2017.05.02" "0.2017.5.2")+    , mk+        "name:            Sit\nversion:         0.2017.5.02\nx-revision: 1\n-- x-revision:1 see https://github.com/haskell-infra/hackage-trustees/issues/128\nbuild-type:      Simple\ncabal-version:   >= 1.8\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor: "+        (Fingerprint 3697869560530373941 3942982281026987312)+        (Fingerprint 14344526114710295386 16386400353475114712)+        (bsReplace "0.2017.5.02" "0.2017.5.2")+    , mk+        "name:            MiniAgda\nversion:         0.2017.02.18\nbuild-type:      Simple\ncabal-version:   >= 1.22\nlicense:         OtherLicense\nlicense-file:    LICENSE\nauthor:          Andreas Abel and Karl Mehltretter\nmaintainer:      Andreas Abel <andreas.abel@i"+        (Fingerprint 17167128953451088679 4300350537748753465)+        (Fingerprint 12402236925293025673 7715084875284020606)+        (bsReplace "0.2017.02.18" "0.2017.2.18")+    , mk+        "cabal-version:\n  2.0\nname:\n  fast-downward\nversion:\n  0.1.0.0\nbuild-type:\n  Simple\nsynopsis:\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n  @fast-downward@ is a library for modelling classical planning probl"+        (Fingerprint 11256076039027887363 6867903407496243216)+        (Fingerprint 12159816716813155434 5278015399212299853)+        (bsReplace "1.2.03.0" "1.2.3.0")+    , mk+        "cabal-version:\r\n  2.0\r\nname:\r\n  fast-downward\r\nversion:\r\n  0.1.0.0\r\nx-revision: \r\n  1\r\nbuild-type:\r\n  Simple\r\nsynopsis:\r\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\r\ndescription:\r\n  @fast-downward@ is a library for mode"+        (Fingerprint 9216193973149680231 893446343655828508)+        (Fingerprint 10020169545407746427 1828336750379510675)+        (bsReplace "1.2.03.0" "1.2.3.0")+    , mk+        "cabal-version:\n  2.0\nname:\n  fast-downward\nversion:\n  0.1.0.1\nbuild-type:\n  Simple\nsynopsis:\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n  @fast-downward@ is a library for modelling classical planning probl"+        (Fingerprint 9899886602574848632 5980433644983783334)+        (Fingerprint 12007469255857289958 8321466548645225439)+        (bsReplace "1.2.03.0" "1.2.3.0")+    , mk+        "cabal-version:\n  2.0\nname:\n  fast-downward\nversion:\n  0.1.1.0\nbuild-type:\n  Simple\nsynopsis:\n  Solve classical planning problems (STRIPS/SAS+) using Haskell & Fast Downward.\ndescription:\n  @fast-downward@ is a library for modelling classical planning probl"+        (Fingerprint 12694656661460787751 1902242956706735615)+        (Fingerprint 15433152131513403849 2284712791516353264)+        (bsReplace "1.2.03.0" "1.2.3.0")+    , -- 9 digits limit+      mk+        "Name:                SGplus\nVersion:             1.1\nSynopsis:            (updated) Small geometry library for dealing with vectors and collision detection\nLicense:             BSD3\nLicense-file:        LICENSE\nAuthor:              Neil Brown\nMaintainer:  "+        (Fingerprint 17735649550442248029 11493772714725351354)+        (Fingerprint 9565458801063261772 15955773698774721052)+        (bsReplace "1000000000" "100000000")+    , mk+        "-- Initial control-dotdotdot.cabal generated by cabal init.  For further \n-- documentation, see http://haskell.org/cabal/users-guide/\n\nname:                control-dotdotdot\nversion:             0.1.0.1\nsynopsis:            Haskell operator\n               "+        (Fingerprint 1514257173776509942 7756050823377346485)+        (Fingerprint 14082092642045505999 18415918653404121035)+        (bsReplace "9223372036854775807" "5")+    , mk+        "name:                data-foldapp\r\nversion:             0.1.1.0\r\nsynopsis:            Fold function applications. Framework for variadic functions.\r\ndescription:         Fold function applications. Framework for variadic functions.\r\nhomepage:            ht"+        (Fingerprint 4511234156311243251 11701153011544112556)+        (Fingerprint 11820542702491924189 4902231447612406724)+        (bsReplace "9223372036854775807" "999" . bsReplace "9223372036854775807" "999")+    , mk+        "-- Initial data-list-zigzag.cabal generated by cabal init.  For further \r\n-- documentation, see http://haskell.org/cabal/users-guide/\r\n\r\nname:                data-list-zigzag\r\nversion:             0.1.1.1\r\nsynopsis:            A list but with a balanced en"+        (Fingerprint 12475837388692175691 18053834261188158945)+        (Fingerprint 16279938253437334942 15753349540193002309)+        (bsReplace "9223372036854775807" "999")+    , -- Not UTF8+      mk+        "Name:                     nat\nVersion:                  0.1\nDescription:            Implementation of natural numbers and integers by a binary\n                                representation. The implementation is supposed to be lazy and\n                   "+        (Fingerprint 9222512268705577108 13085311382746579495)+        (Fingerprint 17468921266614378430 13221316288008291892)+        (bsReplace "\xf6" "\xc3\xb6")+    , -- cabal-version: 2+      mk+        "name:                streaming-bracketed\nversion:             0.1.0.0\nsynopsis:            A resource management decorator for \"streaming\".        \ndescription:         This package provides a decorator for the Stream type from\n                     the \"st"+        (Fingerprint 14670044663153191927 1427497586294143829)+        (Fingerprint 9233007756654759985 6571998449003682006)+        (bsReplace "cabal-version:       2" "cabal-version: 2.0")+    , mk+        "name:                streaming-bracketed\nversion:             0.1.0.1\nsynopsis:            A resource management decorator for \"streaming\".        \ndescription:         This package provides a decorator for the Stream type from\n                     \"stream"+        (Fingerprint 7298738862909203815 10141693276062967842)+        (Fingerprint 1349949738792220441 3593683359695349293)+        (bsReplace "cabal-version:       2" "cabal-version: 2.0")+    , mk+        "name:           zsyntax\nversion:        0.2.0.0\ndescription:    An automated theorem prover for Zsyntax, a\n                logical calculus for molecular biology inspired by linear logic,\n                that can be used to automatically verify biological\n"+        (Fingerprint 17812331267506881875 3005293725141563863)+        (Fingerprint 3445957263137759540 12472369104312474458)+        (bsReplace "cabal-version:  2" "cabal-version: 2.0")+    , -- Empty filepath in not license-file or data-dir+      -- These have hs-source-dirs: ""+      mk+        "\nname:                wai-middleware-hmac-client\nversion:             0.1.0.1\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Christopher Reichert\nmaintainer:          creichert07@gmail.com\ncopyright:           (c) 2015, Christo"+        (Fingerprint 3112606538775065787 11984607507024462091)+        (Fingerprint 6916432989977230500 6621389616675138128)+        (bsReplace "\"\"" ".")+    , mk+        "\nname:                wai-middleware-hmac-client\nversion:             0.1.0.2\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Christopher Reichert\nmaintainer:          creichert07@gmail.com\ncopyright:           (c) 2015, Christo"+        (Fingerprint 12566783342663020458 17562089389615949789)+        (Fingerprint 15745683452603944938 10556498036622072844)+        (bsReplace "\"\"" ".")+    , -- absolute license-file+      mk+        "name: reheat\nversion: 0.1.4\ncabal-version: >=1.8\nbuild-type: Simple\nlicense: GPL\nlicense-file: /home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt\ncopyright: GPL\nmaintainer: Ingolf Wagner <palipalo9@gmail.com>\nstability: experimental\nhomepage: h"+        (Fingerprint 9155400339287317061 14812953666990892802)+        (Fingerprint 7687053346032173923 15384472501136606592)+        (bsReplace "/home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt" "")+    , mk+        "name: reheat\nversion: 0.1.5\ncabal-version: >=1.8\nbuild-type: Simple\nlicense: GPL\nlicense-file: /home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt\ncopyright: GPL\nmaintainer: Ingolf Wagner <palipalo9@gmail.com>\nstability: experimental\nhomepage: h"+        (Fingerprint 2984391146441073709 11728234882049907993)+        (Fingerprint 12058479081855347701 14017937756688869826)+        (bsReplace "/home/palo/dev/haskell-workspace/playground/reheat/gpl-3.0.txt" "")     ]   where     mk a b c d = ((a, b), (c, d))@@ -296,45 +353,52 @@ -- | Helper to create entries in patches _makePatchKey :: FilePath -> (BS.ByteString -> BS.ByteString) -> IO () _makePatchKey fp transform = do-    contents <- BS.readFile fp-    let output = transform contents-    let Fingerprint hi lo = md5 contents-    let Fingerprint hi' lo' = md5 output-    putStrLn-        $ showString "    , mk "-        . shows (BS.take 256 contents)-        . showString "\n         (Fingerprint "-        . shows hi-        . showString " "-        . shows lo-        . showString ")\n         (Fingerprint "-        . shows hi'-        . showString " "-        . shows lo'-        . showString ")"-        $ ""+  contents <- BS.readFile fp+  let output = transform contents+  let Fingerprint hi lo = md5 contents+  let Fingerprint hi' lo' = md5 output+  putStrLn+    $ showString "    , mk "+      . shows (BS.take 256 contents)+      . showString "\n         (Fingerprint "+      . shows hi+      . showString " "+      . shows lo+      . showString ")\n         (Fingerprint "+      . shows hi'+      . showString " "+      . shows lo'+      . showString ")"+    $ ""  ------------------------------------------------------------------------------- -- Patch helpers -------------------------------------------------------------------------------  bsRemove-    :: BS.ByteString  -- ^ needle-    -> BS.ByteString -> BS.ByteString+  :: BS.ByteString+  -- ^ needle+  -> BS.ByteString+  -> BS.ByteString bsRemove needle haystack = case BS.breakSubstring needle haystack of-    (h, t) -> BS.append h (BS.drop (BS.length needle) t)+  (h, t) -> BS.append h (BS.drop (BS.length needle) t)  bsReplace-    :: BS.ByteString -- ^ needle-    -> BS.ByteString -- ^ replacement-    -> BS.ByteString -> BS.ByteString+  :: BS.ByteString+  -- ^ needle+  -> BS.ByteString+  -- ^ replacement+  -> BS.ByteString+  -> BS.ByteString bsReplace needle repl haystack = case BS.breakSubstring needle haystack of-    (h, t)-        | not (BS.null t) -> BS.append h (BS.append repl (BS.drop (BS.length needle) t))-        | otherwise -> haystack+  (h, t)+    | not (BS.null t) -> BS.append h (BS.append repl (BS.drop (BS.length needle) t))+    | otherwise -> haystack  bsRemoveStarting-    :: BS.ByteString  -- ^ needle-    -> BS.ByteString -> BS.ByteString+  :: BS.ByteString+  -- ^ needle+  -> BS.ByteString+  -> BS.ByteString bsRemoveStarting needle haystack = case BS.breakSubstring needle haystack of-    (h, _) -> h+  (h, _) -> h
src/Distribution/PackageDescription/Utils.hs view
@@ -1,4 +1,5 @@ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.PackageDescription.Utils --@@ -6,9 +7,9 @@ -- Portability :  portable -- -- Common utils used by modules under Distribution.PackageDescription.*.--module Distribution.PackageDescription.Utils (-  cabalBug, userBug+module Distribution.PackageDescription.Utils+  ( cabalBug+  , userBug   ) where  -- ----------------------------------------------------------------------------@@ -18,6 +19,9 @@ userBug msg = error $ msg ++ ". This is a bug in your .cabal file."  cabalBug :: String -> a-cabalBug msg = error $ msg ++ ". This is possibly a bug in Cabal.\n"-               ++ "Please report it to the developers: "-               ++ "https://github.com/haskell/cabal/issues/new"+cabalBug msg =+  error $+    msg+      ++ ". This is possibly a bug in Cabal.\n"+      ++ "Please report it to the developers: "+      ++ "https://github.com/haskell/cabal/issues/new"
src/Distribution/Parsec.hs view
@@ -1,69 +1,74 @@-{-# LANGUAGE BangPatterns        #-}-{-# LANGUAGE CPP                 #-}-{-# LANGUAGE FlexibleContexts    #-}-{-# LANGUAGE GADTs               #-}-{-# LANGUAGE RankNTypes          #-}+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}-module Distribution.Parsec (-    Parsec(..),-    ParsecParser (..),-    runParsecParser,-    runParsecParser',-    simpleParsec,-    simpleParsecBS,-    simpleParsec',-    simpleParsecW',-    lexemeParsec,-    eitherParsec,-    explicitEitherParsec,-    explicitEitherParsec',++module Distribution.Parsec+  ( Parsec (..)+  , ParsecParser (..)+  , runParsecParser+  , runParsecParser'+  , simpleParsec+  , simpleParsecBS+  , simpleParsec'+  , simpleParsecW'+  , lexemeParsec+  , eitherParsec+  , explicitEitherParsec+  , explicitEitherParsec'+     -- * CabalParsing and diagnostics-    CabalParsing (..),+  , CabalParsing (..)+     -- ** Warnings-    PWarnType (..),-    PWarning (..),-    showPWarning,+  , PWarnType (..)+  , PWarning (..)+  , showPWarning+     -- ** Errors-    PError (..),-    showPError,+  , PError (..)+  , showPError+     -- * Position-    Position (..),-    incPos,-    retPos,-    showPos,-    zeroPos,+  , Position (..)+  , incPos+  , retPos+  , showPos+  , zeroPos+     -- * Utilities-    parsecToken,-    parsecToken',-    parsecFilePath,-    parsecQuoted,-    parsecMaybeQuoted,-    parsecCommaList,-    parsecCommaNonEmpty,-    parsecLeadingCommaList,-    parsecLeadingCommaNonEmpty,-    parsecOptCommaList,-    parsecLeadingOptCommaList,-    parsecStandard,-    parsecUnqualComponentName,-    ) where+  , parsecToken+  , parsecToken'+  , parsecFilePath+  , parsecQuoted+  , parsecMaybeQuoted+  , parsecCommaList+  , parsecCommaNonEmpty+  , parsecLeadingCommaList+  , parsecLeadingCommaNonEmpty+  , parsecOptCommaList+  , parsecLeadingOptCommaList+  , parsecStandard+  , parsecUnqualComponentName+  ) where -import Data.ByteString                     (ByteString)-import Data.Char                           (digitToInt, intToDigit)-import Data.List                           (transpose)+import Data.ByteString (ByteString)+import Data.Char (digitToInt, intToDigit)+import Data.List (transpose) import Distribution.CabalSpecVersion import Distribution.Compat.Prelude-import Distribution.Parsec.Error           (PError (..), showPError)+import Distribution.Parsec.Error (PError (..), showPError) import Distribution.Parsec.FieldLineStream (FieldLineStream, fieldLineStreamFromBS, fieldLineStreamFromString)-import Distribution.Parsec.Position        (Position (..), incPos, retPos, showPos, zeroPos)-import Distribution.Parsec.Warning         (PWarnType (..), PWarning (..), showPWarning)-import Numeric                             (showIntAtBase)+import Distribution.Parsec.Position (Position (..), incPos, retPos, showPos, zeroPos)+import Distribution.Parsec.Warning (PWarnType (..), PWarning (..), showPWarning)+import Numeric (showIntAtBase) import Prelude ()  import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.Compat.DList       as DList-import qualified Distribution.Compat.MonadFail   as Fail-import qualified Text.Parsec                     as Parsec+import qualified Distribution.Compat.DList as DList+import qualified Distribution.Compat.MonadFail as Fail+import qualified Text.Parsec as Parsec  ------------------------------------------------------------------------------- -- Class@@ -72,118 +77,114 @@ -- | Class for parsing with @parsec@. Mainly used for @.cabal@ file fields. -- -- For parsing @.cabal@ like file structure, see "Distribution.Fields".--- class Parsec a where-    parsec :: CabalParsing m => m a+  parsec :: CabalParsing m => m a  -- | Parsing class which -- -- * can report Cabal parser warnings. -- -- * knows @cabal-version@ we work with--- class (P.CharParsing m, MonadPlus m, Fail.MonadFail m) => CabalParsing m where-    parsecWarning :: PWarnType -> String -> m ()+  parsecWarning :: PWarnType -> String -> m () -    parsecHaskellString :: m String-    parsecHaskellString = stringLiteral+  parsecHaskellString :: m String+  parsecHaskellString = stringLiteral -    askCabalSpecVersion :: m CabalSpecVersion+  askCabalSpecVersion :: m CabalSpecVersion  -- | 'parsec' /could/ consume trailing spaces, this function /will/ consume. lexemeParsec :: (CabalParsing m, Parsec a) => m a lexemeParsec = parsec <* P.spaces -newtype ParsecParser a = PP { unPP-    :: CabalSpecVersion -> Parsec.Parsec FieldLineStream [PWarning] a-    }+newtype ParsecParser a = PP+  { unPP+      :: CabalSpecVersion+      -> Parsec.Parsec FieldLineStream [PWarning] a+  }  liftParsec :: Parsec.Parsec FieldLineStream [PWarning] a -> ParsecParser a liftParsec p = PP $ \_ -> p  instance Functor ParsecParser where-    fmap f p = PP $ \v -> fmap f (unPP p v)-    {-# INLINE fmap #-}+  fmap f p = PP $ \v -> fmap f (unPP p v)+  {-# INLINE fmap #-} -    x <$ p = PP $ \v -> x <$ unPP p v-    {-# INLINE (<$) #-}+  x <$ p = PP $ \v -> x <$ unPP p v+  {-# INLINE (<$) #-}  instance Applicative ParsecParser where-    pure = liftParsec . pure-    {-# INLINE pure #-}+  pure = liftParsec . pure+  {-# INLINE pure #-} -    f <*> x = PP $ \v -> unPP f v <*> unPP x v-    {-# INLINE (<*>) #-}-    f  *> x = PP $ \v -> unPP f v  *> unPP x v-    {-# INLINE (*>) #-}-    f <*  x = PP $ \v -> unPP f v <*  unPP x v-    {-# INLINE (<*) #-}+  f <*> x = PP $ \v -> unPP f v <*> unPP x v+  {-# INLINE (<*>) #-}+  f *> x = PP $ \v -> unPP f v *> unPP x v+  {-# INLINE (*>) #-}+  f <* x = PP $ \v -> unPP f v <* unPP x v+  {-# INLINE (<*) #-}  instance Alternative ParsecParser where-    empty = liftParsec empty+  empty = liftParsec empty -    a <|> b = PP $ \v -> unPP a v <|> unPP b v-    {-# INLINE (<|>) #-}+  a <|> b = PP $ \v -> unPP a v <|> unPP b v+  {-# INLINE (<|>) #-} -    many p = PP $ \v -> many (unPP p v)-    {-# INLINE many #-}+  many p = PP $ \v -> many (unPP p v)+  {-# INLINE many #-} -    some p = PP $ \v -> some (unPP p v)-    {-# INLINE some #-}+  some p = PP $ \v -> some (unPP p v)+  {-# INLINE some #-}  instance Monad ParsecParser where-    return = pure--    m >>= k = PP $ \v -> unPP m v >>= \x -> unPP (k x) v-    {-# INLINE (>>=) #-}-    (>>) = (*>)-    {-# INLINE (>>) #-}+  return = pure -#if !(MIN_VERSION_base(4,13,0))-    fail = Fail.fail-#endif+  m >>= k = PP $ \v -> unPP m v >>= \x -> unPP (k x) v+  {-# INLINE (>>=) #-}+  (>>) = (*>)+  {-# INLINE (>>) #-}  instance MonadPlus ParsecParser where-    mzero = empty-    mplus = (<|>)+  mzero = empty+  mplus = (<|>)  instance Fail.MonadFail ParsecParser where-    fail = P.unexpected+  fail = P.unexpected  instance P.Parsing ParsecParser where-    try p           = PP $ \v -> P.try (unPP p v)-    p <?> d         = PP $ \v -> unPP p v P.<?> d-    skipMany p      = PP $ \v -> P.skipMany (unPP p v)-    skipSome p      = PP $ \v -> P.skipSome (unPP p v)-    unexpected      = liftParsec . P.unexpected-    eof             = liftParsec P.eof-    notFollowedBy p = PP $ \v -> P.notFollowedBy (unPP p v)+  try p = PP $ \v -> P.try (unPP p v)+  p <?> d = PP $ \v -> unPP p v P.<?> d+  skipMany p = PP $ \v -> P.skipMany (unPP p v)+  skipSome p = PP $ \v -> P.skipSome (unPP p v)+  unexpected = liftParsec . P.unexpected+  eof = liftParsec P.eof+  notFollowedBy p = PP $ \v -> P.notFollowedBy (unPP p v)  instance P.CharParsing ParsecParser where-    satisfy   = liftParsec . P.satisfy-    char      = liftParsec . P.char-    notChar   = liftParsec . P.notChar-    anyChar   = liftParsec P.anyChar-    string    = liftParsec . P.string+  satisfy = liftParsec . P.satisfy+  char = liftParsec . P.char+  notChar = liftParsec . P.notChar+  anyChar = liftParsec P.anyChar+  string = liftParsec . P.string  instance CabalParsing ParsecParser where-    parsecWarning t w = liftParsec $ do-        spos <- Parsec.getPosition-        Parsec.modifyState-            (PWarning t (Position (Parsec.sourceLine spos) (Parsec.sourceColumn spos)) w :)-    askCabalSpecVersion = PP pure+  parsecWarning t w = liftParsec $ do+    spos <- Parsec.getPosition+    Parsec.modifyState+      (PWarning t (Position (Parsec.sourceLine spos) (Parsec.sourceColumn spos)) w :)+  askCabalSpecVersion = PP pure  -- | Parse a 'String' with 'lexemeParsec'. simpleParsec :: Parsec a => String -> Maybe a-simpleParsec-    = either (const Nothing) Just+simpleParsec =+  either (const Nothing) Just     . runParsecParser lexemeParsec "<simpleParsec>"     . fieldLineStreamFromString  -- | Like 'simpleParsec' but for 'ByteString' simpleParsecBS :: Parsec a => ByteString -> Maybe a-simpleParsecBS-    = either (const Nothing) Just+simpleParsecBS =+  either (const Nothing) Just     . runParsecParser lexemeParsec "<simpleParsec>"     . fieldLineStreamFromBS @@ -191,8 +192,8 @@ -- -- @since 3.4.0.0 simpleParsec' :: Parsec a => CabalSpecVersion -> String -> Maybe a-simpleParsec' spec-    = either (const Nothing) Just+simpleParsec' spec =+  either (const Nothing) Just     . runParsecParser' spec lexemeParsec "<simpleParsec>"     . fieldLineStreamFromString @@ -201,8 +202,8 @@ -- -- @since 3.4.0.0 simpleParsecW' :: Parsec a => CabalSpecVersion -> String -> Maybe a-simpleParsecW' spec-    = either (const Nothing) (\(x, ws) -> if null ws then Just x else Nothing)+simpleParsecW' spec =+  either (const Nothing) (\(x, ws) -> if null ws then Just x else Nothing)     . runParsecParser' spec ((,) <$> lexemeParsec <*> liftParsec Parsec.getState) "<simpleParsec>"     . fieldLineStreamFromString @@ -212,8 +213,8 @@  -- | Parse a 'String' with given 'ParsecParser'. Trailing whitespace is accepted. explicitEitherParsec :: ParsecParser a -> String -> Either String a-explicitEitherParsec parser-    = either (Left . show) Right+explicitEitherParsec parser =+  either (Left . show) Right     . runParsecParser (parser <* P.spaces) "<eitherParsec>"     . fieldLineStreamFromString @@ -221,10 +222,9 @@ -- See 'explicitEitherParsec'. -- -- @since 3.4.0.0--- explicitEitherParsec' :: CabalSpecVersion -> ParsecParser a -> String -> Either String a-explicitEitherParsec' spec parser-    = either (Left . show) Right+explicitEitherParsec' spec parser =+  either (Left . show) Right     . runParsecParser' spec (parser <* P.spaces) "<eitherParsec>"     . fieldLineStreamFromString @@ -235,44 +235,45 @@ -- | Like 'runParsecParser' but lets specify 'CabalSpecVersion' used. -- -- @since 3.0.0.0--- runParsecParser' :: CabalSpecVersion -> ParsecParser a -> FilePath -> FieldLineStream -> Either Parsec.ParseError a runParsecParser' v p n = Parsec.runParser (unPP p v <* P.eof) [] n  instance Parsec a => Parsec (Identity a) where-    parsec = Identity <$> parsec+  parsec = Identity <$> parsec  instance Parsec Bool where-    parsec = P.munch1 isAlpha >>= postprocess-      where-        postprocess str-            |  str == "True"  = pure True-            |  str == "False" = pure False-            | lstr == "true"  = parsecWarning PWTBoolCase caseWarning *> pure True-            | lstr == "false" = parsecWarning PWTBoolCase caseWarning *> pure False-            | otherwise       = fail $ "Not a boolean: " ++ str-          where-            lstr = map toLower str-            caseWarning =-                "Boolean values are case sensitive, use 'True' or 'False'."+  parsec = P.munch1 isAlpha >>= postprocess+    where+      postprocess str+        | str == "True" = pure True+        | str == "False" = pure False+        | lstr == "true" = parsecWarning PWTBoolCase caseWarning *> pure True+        | lstr == "false" = parsecWarning PWTBoolCase caseWarning *> pure False+        | otherwise = fail $ "Not a boolean: " ++ str+        where+          lstr = map toLower str+          caseWarning =+            "Boolean values are case sensitive, use 'True' or 'False'."  -- | @[^ ,]@ parsecToken :: CabalParsing m => m String-parsecToken = parsecHaskellString <|> ((P.munch1 (\x -> not (isSpace x) && x /= ',')  P.<?> "identifier" ) >>= checkNotDoubleDash)+parsecToken = parsecHaskellString <|> ((P.munch1 (\x -> not (isSpace x) && x /= ',') P.<?> "identifier") >>= checkNotDoubleDash)  -- | @[^ ]@ parsecToken' :: CabalParsing m => m String parsecToken' = parsecHaskellString <|> ((P.munch1 (not . isSpace) P.<?> "token") >>= checkNotDoubleDash) -checkNotDoubleDash ::  CabalParsing m => String -> m String+checkNotDoubleDash :: CabalParsing m => String -> m String checkNotDoubleDash s = do-    when (s == "--") $ parsecWarning PWTDoubleDash $ unwords+  when (s == "--") $+    parsecWarning PWTDoubleDash $+      unwords         [ "Double-dash token found."         , "Note: there are no end-of-line comments in .cabal files, only whole line comments."         , "Use \"--\" (quoted double dash) to silence this warning, if you actually want -- token"         ] -    return s+  return s  parsecFilePath :: CabalParsing m => m FilePath parsecFilePath = parsecToken@@ -280,17 +281,18 @@ -- | Parse a benchmark/test-suite types. parsecStandard :: (CabalParsing m, Parsec ver) => (ver -> String -> a) -> m a parsecStandard f = do-    cs   <- some $ P.try (component <* P.char '-')-    ver  <- parsec-    let name = map toLower (intercalate "-" cs)-    return $! f ver name+  cs <- some $ P.try (component <* P.char '-')+  ver <- parsec+  let name = map toLower (intercalate "-" cs)+  return $! f ver name   where     component = do       cs <- P.munch1 isAlphaNum       if all isDigit cs then fail "all digit component" else return cs-      -- each component must contain an alphabetic character, to avoid-      -- ambiguity in identifiers like foo-1 (the 1 is the version number). +-- each component must contain an alphabetic character, to avoid+-- ambiguity in identifiers like foo-1 (the 1 is the version number).+ parsecCommaList :: CabalParsing m => m a -> m [a] parsecCommaList p = P.sepBy (p <* P.spaces) (P.char ',' *> P.spaces P.<?> "comma") @@ -306,10 +308,10 @@ -- @ parsecLeadingCommaList :: CabalParsing m => m a -> m [a] parsecLeadingCommaList p = do-    c <- P.optional comma-    case c of-        Nothing -> toList <$> P.sepEndByNonEmpty lp comma <|> pure []-        Just _  -> toList <$> P.sepByNonEmpty lp comma+  c <- P.optional comma+  case c of+    Nothing -> toList <$> P.sepEndByNonEmpty lp comma <|> pure []+    Just _ -> toList <$> P.sepByNonEmpty lp comma   where     lp = p <* P.spaces     comma = P.char ',' *> P.spaces P.<?> "comma"@@ -319,10 +321,10 @@ -- @since 3.4.0.0 parsecLeadingCommaNonEmpty :: CabalParsing m => m a -> m (NonEmpty a) parsecLeadingCommaNonEmpty p = do-    c <- P.optional comma-    case c of-        Nothing -> P.sepEndByNonEmpty lp comma-        Just _  -> P.sepByNonEmpty lp comma+  c <- P.optional comma+  case c of+    Nothing -> P.sepEndByNonEmpty lp comma+    Just _ -> P.sepByNonEmpty lp comma   where     lp = p <* P.spaces     comma = P.char ',' *> P.spaces P.<?> "comma"@@ -345,23 +347,22 @@ -- @ -- -- @since 3.0.0.0--- parsecLeadingOptCommaList :: CabalParsing m => m a -> m [a] parsecLeadingOptCommaList p = do-    c <- P.optional comma-    case c of-        Nothing -> sepEndBy1Start <|> pure []-        Just _  -> toList <$> P.sepByNonEmpty lp comma+  c <- P.optional comma+  case c of+    Nothing -> sepEndBy1Start <|> pure []+    Just _ -> toList <$> P.sepByNonEmpty lp comma   where     lp = p <* P.spaces     comma = P.char ',' *> P.spaces P.<?> "comma"      sepEndBy1Start = do-        x <- lp-        c <- P.optional comma-        case c of-            Nothing -> (x :) <$> many lp-            Just _  -> (x :) <$> P.sepEndBy lp comma+      x <- lp+      c <- P.optional comma+      case c of+        Nothing -> (x :) <$> many lp+        Just _ -> (x :) <$> P.sepEndBy lp comma  -- | Content isn't unquoted parsecQuoted :: CabalParsing m => m a -> m a@@ -372,7 +373,8 @@ parsecMaybeQuoted p = parsecQuoted p <|> p  parsecUnqualComponentName :: forall m. CabalParsing m => m String-parsecUnqualComponentName = state0 DList.empty where+parsecUnqualComponentName = state0 DList.empty+  where     --     -- using @kleene@ package we can easily see that     -- we need only two states to recognize@@ -407,23 +409,25 @@      state0 :: DList.DList Char -> m String     state0 acc = do-        c <- ch -- <|> fail ("Invalid component, after " ++ DList.toList acc)-        case () of-            _ | isDigit c    -> state0 (DList.snoc acc c)-              | isAlphaNum c -> state1 (DList.snoc acc c)-              | c == '-'     -> fail ("Empty component, after " ++ DList.toList acc)-              | otherwise    -> fail ("Internal error, after " ++ DList.toList acc)+      c <- ch -- <|> fail ("Invalid component, after " ++ DList.toList acc)+      case () of+        _+          | isDigit c -> state0 (DList.snoc acc c)+          | isAlphaNum c -> state1 (DList.snoc acc c)+          | c == '-' -> fail ("Empty component, after " ++ DList.toList acc)+          | otherwise -> fail ("Internal error, after " ++ DList.toList acc)      state1 :: DList.DList Char -> m String     state1 acc = state1' acc `alt` return (DList.toList acc)      state1' :: DList.DList Char -> m String     state1' acc = do-        c <- ch-        case () of-            _ | isAlphaNum c -> state1 (DList.snoc acc c)-              | c == '-'     -> state0 (DList.snoc acc c)-              | otherwise    -> fail ("Internal error, after " ++ DList.toList acc)+      c <- ch+      case () of+        _+          | isAlphaNum c -> state1 (DList.snoc acc c)+          | c == '-' -> state0 (DList.snoc acc c)+          | otherwise -> fail ("Internal error, after " ++ DList.toList acc)      ch :: m Char     !ch = P.satisfy (\c -> isAlphaNum c || c == '-')@@ -432,24 +436,29 @@     !alt = (<|>)  stringLiteral :: forall m. P.CharParsing m => m String-stringLiteral = lit where+stringLiteral = lit+  where     lit :: m String-    lit = foldr (maybe id (:)) ""+    lit =+      foldr (maybe id (:)) ""         <$> P.between (P.char '"') (P.char '"' P.<?> "end of string") (many stringChar)         P.<?> "string"      stringChar :: m (Maybe Char)-    stringChar = Just <$> stringLetter-         <|> stringEscape-         P.<?> "string character"+    stringChar =+      Just <$> stringLetter+        <|> stringEscape+        P.<?> "string character"      stringLetter :: m Char     stringLetter = P.satisfy (\c -> (c /= '"') && (c /= '\\') && (c > '\026'))      stringEscape :: m (Maybe Char)-    stringEscape = P.char '\\' *> esc where+    stringEscape = P.char '\\' *> esc+      where         esc :: m (Maybe Char)-        esc = Nothing <$ escapeGap+        esc =+          Nothing <$ escapeGap             <|> Nothing <$ escapeEmpty             <|> Just <$> escapeCode @@ -460,65 +469,103 @@ escapeCode :: forall m. P.CharParsing m => m Char escapeCode = (charEsc <|> charNum <|> charAscii <|> charControl) P.<?> "escape code"   where-  charControl, charNum :: m Char-  charControl = (\c -> toEnum (fromEnum c - fromEnum '@')) <$> (P.char '^' *> (P.upper <|> P.char '@'))-  charNum = toEnum <$> num-    where-      num :: m Int-      num = bounded 10 maxchar-        <|> (P.char 'o' *> bounded 8 maxchar)-        <|> (P.char 'x' *> bounded 16 maxchar)-      maxchar = fromEnum (maxBound :: Char)+    charControl, charNum :: m Char+    charControl = (\c -> toEnum (fromEnum c - fromEnum '@')) <$> (P.char '^' *> (P.upper <|> P.char '@'))+    charNum = toEnum <$> num+      where+        num :: m Int+        num =+          bounded 10 maxchar+            <|> (P.char 'o' *> bounded 8 maxchar)+            <|> (P.char 'x' *> bounded 16 maxchar)+        maxchar = fromEnum (maxBound :: Char) -  bounded :: Int -> Int -> m Int-  bounded base bnd = foldl' (\x d -> base * x + digitToInt d) 0-                 <$> bounded' (take base thedigits) (map digitToInt $ showIntAtBase base intToDigit bnd "")-    where-      thedigits :: [m Char]-      thedigits = map P.char ['0'..'9'] ++ map P.oneOf (transpose [['A'..'F'],['a'..'f']])+    bounded :: Int -> Int -> m Int+    bounded base bnd =+      foldl' (\x d -> base * x + digitToInt d) 0+        <$> bounded' (take base thedigits) (map digitToInt $ showIntAtBase base intToDigit bnd "")+      where+        thedigits :: [m Char]+        thedigits = map P.char ['0' .. '9'] ++ map P.oneOf (transpose [['A' .. 'F'], ['a' .. 'f']]) -      toomuch :: m a-      toomuch = P.unexpected "out-of-range numeric escape sequence"+        toomuch :: m a+        toomuch = P.unexpected "out-of-range numeric escape sequence" -      bounded', bounded'' :: [m Char] -> [Int] -> m [Char]-      bounded' dps@(zero:_) bds = P.skipSome zero *> ([] <$ P.notFollowedBy (P.choice dps) <|> bounded'' dps bds)-                              <|> bounded'' dps bds-      bounded' []           _   = error "bounded called with base 0"-      bounded'' dps []         = [] <$ P.notFollowedBy (P.choice dps) <|> toomuch-      bounded'' dps (bd : bds) = let anyd :: m Char-                                     anyd = P.choice dps+        bounded', bounded'' :: [m Char] -> [Int] -> m [Char]+        bounded' dps@(zero : _) bds =+          P.skipSome zero *> ([] <$ P.notFollowedBy (P.choice dps) <|> bounded'' dps bds)+            <|> bounded'' dps bds+        bounded' [] _ = error "bounded called with base 0"+        bounded'' dps [] = [] <$ P.notFollowedBy (P.choice dps) <|> toomuch+        bounded'' dps (bd : bds) =+          let anyd :: m Char+              anyd = P.choice dps -                                     nomore :: m ()-                                     nomore = P.notFollowedBy anyd <|> toomuch+              nomore :: m ()+              nomore = P.notFollowedBy anyd <|> toomuch -                                     (low, ex, high) = case splitAt bd dps of-                                        (low', ex' : high') -> (low', ex', high')-                                        (_, _)              -> error "escapeCode: Logic error"-                                  in ((:) <$> P.choice low <*> atMost (length bds) anyd) <* nomore-                                     <|> ((:) <$> ex <*> ([] <$ nomore <|> bounded'' dps bds))-                                     <|> if not (null bds)-                                            then (:) <$> P.choice high <*> atMost (length bds - 1) anyd <* nomore-                                            else empty-      atMost n p | n <= 0    = pure []-                 | otherwise = ((:) <$> p <*> atMost (n - 1) p) <|> pure []+              (low, ex, high) = case splitAt bd dps of+                (low', ex' : high') -> (low', ex', high')+                (_, _) -> error "escapeCode: Logic error"+           in ((:) <$> P.choice low <*> atMost (length bds) anyd) <* nomore+                <|> ((:) <$> ex <*> ([] <$ nomore <|> bounded'' dps bds))+                <|> if not (null bds)+                  then (:) <$> P.choice high <*> atMost (length bds - 1) anyd <* nomore+                  else empty+        atMost n p+          | n <= 0 = pure []+          | otherwise = ((:) <$> p <*> atMost (n - 1) p) <|> pure [] -  charEsc :: m Char-  charEsc = P.choice $ parseEsc <$> escMap+    charEsc :: m Char+    charEsc = P.choice $ parseEsc <$> escMap -  parseEsc (c,code) = code <$ P.char c-  escMap = zip "abfnrtv\\\"\'" "\a\b\f\n\r\t\v\\\"\'"+    parseEsc (c, code) = code <$ P.char c+    escMap = zip "abfnrtv\\\"\'" "\a\b\f\n\r\t\v\\\"\'" -  charAscii :: m Char-  charAscii = P.choice $ parseAscii <$> asciiMap+    charAscii :: m Char+    charAscii = P.choice $ parseAscii <$> asciiMap -  parseAscii (asc,code) = P.try $ code <$ P.string asc-  asciiMap = zip (ascii3codes ++ ascii2codes) (ascii3 ++ ascii2)-  ascii2codes, ascii3codes :: [String]-  ascii2codes = [ "BS","HT","LF","VT","FF","CR","SO"-                , "SI","EM","FS","GS","RS","US","SP"]-  ascii3codes = ["NUL","SOH","STX","ETX","EOT","ENQ","ACK"-                ,"BEL","DLE","DC1","DC2","DC3","DC4","NAK"-                ,"SYN","ETB","CAN","SUB","ESC","DEL"]-  ascii2, ascii3 :: String-  ascii2 = "\BS\HT\LF\VT\FF\CR\SO\SI\EM\FS\GS\RS\US\SP"-  ascii3 = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK\BEL\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\SUB\ESC\DEL"+    parseAscii (asc, code) = P.try $ code <$ P.string asc+    asciiMap = zip (ascii3codes ++ ascii2codes) (ascii3 ++ ascii2)+    ascii2codes, ascii3codes :: [String]+    ascii2codes =+      [ "BS"+      , "HT"+      , "LF"+      , "VT"+      , "FF"+      , "CR"+      , "SO"+      , "SI"+      , "EM"+      , "FS"+      , "GS"+      , "RS"+      , "US"+      , "SP"+      ]+    ascii3codes =+      [ "NUL"+      , "SOH"+      , "STX"+      , "ETX"+      , "EOT"+      , "ENQ"+      , "ACK"+      , "BEL"+      , "DLE"+      , "DC1"+      , "DC2"+      , "DC3"+      , "DC4"+      , "NAK"+      , "SYN"+      , "ETB"+      , "CAN"+      , "SUB"+      , "ESC"+      , "DEL"+      ]+    ascii2, ascii3 :: String+    ascii2 = "\BS\HT\LF\VT\FF\CR\SO\SI\EM\FS\GS\RS\US\SP"+    ascii3 = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK\BEL\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\SUB\ESC\DEL"
src/Distribution/Parsec/Error.hs view
@@ -1,21 +1,22 @@ {-# LANGUAGE DeriveGeneric #-}-module Distribution.Parsec.Error (-    PError (..),-    showPError,-    ) where +module Distribution.Parsec.Error+  ( PError (..)+  , showPError+  ) where+ import Distribution.Compat.Prelude import Distribution.Parsec.Position+import System.FilePath (normalise) import Prelude ()-import System.FilePath              (normalise)  -- | Parser error. data PError = PError Position String-    deriving (Show, Generic)+  deriving (Show, Generic)  instance Binary PError instance NFData PError where rnf = genericRnf  showPError :: FilePath -> PError -> String showPError fpath (PError pos msg) =-    normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg+  normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg
src/Distribution/Parsec/FieldLineStream.hs view
@@ -1,29 +1,30 @@-{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings     #-}-{-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -Wall -Werror #-}-module Distribution.Parsec.FieldLineStream (-    FieldLineStream (..),-    fieldLineStreamFromString,-    fieldLineStreamFromBS,-    fieldLineStreamEnd,-    ) where +module Distribution.Parsec.FieldLineStream+  ( FieldLineStream (..)+  , fieldLineStreamFromString+  , fieldLineStreamFromBS+  , fieldLineStreamEnd+  ) where+ import Data.Bits-import Data.ByteString             (ByteString)+import Data.ByteString (ByteString) import Distribution.Compat.Prelude-import Distribution.Utils.Generic  (toUTF8BS)+import Distribution.Utils.Generic (toUTF8BS) import Prelude ()  import qualified Data.ByteString as BS-import qualified Text.Parsec     as Parsec+import qualified Text.Parsec as Parsec  -- | This is essentially a lazy bytestring, but chunks are glued with newline @\'\\n\'@. data FieldLineStream-    = FLSLast !ByteString-    | FLSCons {-# UNPACK #-} !ByteString FieldLineStream-  deriving Show+  = FLSLast !ByteString+  | FLSCons {-# UNPACK #-} !ByteString FieldLineStream+  deriving (Show)  fieldLineStreamEnd :: FieldLineStream fieldLineStreamEnd = FLSLast mempty@@ -38,54 +39,55 @@ fieldLineStreamFromBS = FLSLast  instance Monad m => Parsec.Stream FieldLineStream m Char where-    uncons (FLSLast bs) = return $ case BS.uncons bs of-        Nothing       -> Nothing-        Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSLast bs'') fieldLineStreamEnd)--    uncons (FLSCons bs s) = return $ case BS.uncons bs of-        -- as lines are glued with '\n', we return '\n' here!-        Nothing -> Just ('\n', s)-        Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSCons bs'' s) s)+  uncons (FLSLast bs) = return $ case BS.uncons bs of+    Nothing -> Nothing+    Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSLast bs'') fieldLineStreamEnd)+  uncons (FLSCons bs s) = return $ case BS.uncons bs of+    -- as lines are glued with '\n', we return '\n' here!+    Nothing -> Just ('\n', s)+    Just (c, bs') -> Just (unconsChar c bs' (\bs'' -> FLSCons bs'' s) s)  -- Based on implementation 'decodeStringUtf8' unconsChar :: forall a. Word8 -> ByteString -> (ByteString -> a) -> a -> (Char, a) unconsChar c0 bs0 f next-    | c0 <= 0x7F = (chr (fromIntegral c0), f bs0)-    | c0 <= 0xBF = (replacementChar, f bs0)-    | c0 <= 0xDF = twoBytes-    | c0 <= 0xEF = moreBytes 3 0x800     bs0 (fromIntegral $ c0 .&. 0xF)-    | c0 <= 0xF7 = moreBytes 4 0x10000   bs0 (fromIntegral $ c0 .&. 0x7)-    | c0 <= 0xFB = moreBytes 5 0x200000  bs0 (fromIntegral $ c0 .&. 0x3)-    | c0 <= 0xFD = moreBytes 6 0x4000000 bs0 (fromIntegral $ c0 .&. 0x1)-    | otherwise = error $ "not implemented " ++ show c0+  | c0 <= 0x7F = (chr (fromIntegral c0), f bs0)+  | c0 <= 0xBF = (replacementChar, f bs0)+  | c0 <= 0xDF = twoBytes+  | c0 <= 0xEF = moreBytes 3 0x800 bs0 (fromIntegral $ c0 .&. 0xF)+  | c0 <= 0xF7 = moreBytes 4 0x10000 bs0 (fromIntegral $ c0 .&. 0x7)+  | c0 <= 0xFB = moreBytes 5 0x200000 bs0 (fromIntegral $ c0 .&. 0x3)+  | c0 <= 0xFD = moreBytes 6 0x4000000 bs0 (fromIntegral $ c0 .&. 0x1)+  | otherwise = error $ "not implemented " ++ show c0   where     twoBytes = case BS.uncons bs0 of-        Nothing -> (replacementChar, next)-        Just (c1, bs1)-            | c1 .&. 0xC0 == 0x80 ->-                if d >= 0x80-                then  (chr d, f bs1)-                else  (replacementChar, f bs1)-            | otherwise -> (replacementChar, f bs1)-          where-            d = (fromIntegral (c0 .&. 0x1F) `shiftL` 6) .|. fromIntegral (c1 .&. 0x3F)+      Nothing -> (replacementChar, next)+      Just (c1, bs1)+        | c1 .&. 0xC0 == 0x80 ->+            if d >= 0x80+              then (chr d, f bs1)+              else (replacementChar, f bs1)+        | otherwise -> (replacementChar, f bs1)+        where+          d = (fromIntegral (c0 .&. 0x1F) `shiftL` 6) .|. fromIntegral (c1 .&. 0x3F)      moreBytes :: Int -> Int -> ByteString -> Int -> (Char, a)     moreBytes 1 overlong bs' acc-        | overlong <= acc, acc <= 0x10FFFF, acc < 0xD800 || 0xDFFF < acc-            = (chr acc, f bs')-        | otherwise-            = (replacementChar, f bs')-+      | overlong <= acc+      , acc <= 0x10FFFF+      , acc < 0xD800 || 0xDFFF < acc =+          (chr acc, f bs')+      | otherwise =+          (replacementChar, f bs')     moreBytes byteCount overlong bs' acc = case BS.uncons bs' of-        Nothing                   -> (replacementChar, f bs')-        Just (cn, bs1)-            | cn .&. 0xC0 == 0x80 -> moreBytes-                (byteCount-1)-                overlong-                bs1-                ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)-            | otherwise           -> (replacementChar, f bs1)+      Nothing -> (replacementChar, f bs')+      Just (cn, bs1)+        | cn .&. 0xC0 == 0x80 ->+            moreBytes+              (byteCount - 1)+              overlong+              bs1+              ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)+        | otherwise -> (replacementChar, f bs1)  replacementChar :: Char replacementChar = '\xfffd'
src/Distribution/Parsec/Position.hs view
@@ -1,21 +1,23 @@ {-# LANGUAGE DeriveGeneric #-}-module Distribution.Parsec.Position (-    Position (..),-    incPos,-    retPos,-    showPos,-    zeroPos,-    positionCol,-    positionRow,-    ) where +module Distribution.Parsec.Position+  ( Position (..)+  , incPos+  , retPos+  , showPos+  , zeroPos+  , positionCol+  , positionRow+  ) where+ import Distribution.Compat.Prelude import Prelude ()  -- | 1-indexed row and column positions in a file.-data Position = Position-    {-# UNPACK #-}  !Int           -- row-    {-# UNPACK #-}  !Int           -- column+data Position+  = Position+      {-# UNPACK #-} !Int -- row+      {-# UNPACK #-} !Int -- column   deriving (Eq, Ord, Show, Generic)  instance Binary Position
src/Distribution/Parsec/Warning.hs view
@@ -1,61 +1,78 @@ {-# LANGUAGE DeriveGeneric #-}-module Distribution.Parsec.Warning (-    PWarning (..),-    PWarnType (..),-    showPWarning,-    ) where +module Distribution.Parsec.Warning+  ( PWarning (..)+  , PWarnType (..)+  , showPWarning+  ) where+ import Distribution.Compat.Prelude import Distribution.Parsec.Position+import System.FilePath (normalise) import Prelude ()-import System.FilePath              (normalise)  -- | Type of parser warning. We do classify warnings. -- -- Different application may decide not to show some, or have fatal behaviour on others data PWarnType-    = PWTOther                 -- ^ Unclassified warning-    | PWTUTF                   -- ^ Invalid UTF encoding-    | PWTBoolCase              -- ^ @true@ or @false@, not @True@ or @False@-    | PWTVersionTag            -- ^ there are version with tags-    | PWTNewSyntax             -- ^ New syntax used, but no @cabal-version: >= 1.2@ specified-    | PWTOldSyntax             -- ^ Old syntax used, and @cabal-version >= 1.2@ specified-    | PWTDeprecatedField-    | PWTInvalidSubsection-    | PWTUnknownField-    | PWTUnknownSection-    | PWTTrailingFields-    | PWTExtraMainIs           -- ^ extra main-is field-    | PWTExtraTestModule       -- ^ extra test-module field-    | PWTExtraBenchmarkModule  -- ^ extra benchmark-module field-    | PWTLexNBSP-    | PWTLexBOM-    | PWTLexTab-    | PWTQuirkyCabalFile       -- ^ legacy cabal file that we know how to patch-    | PWTDoubleDash            -- ^ Double dash token, most likely it's a mistake - it's not a comment-    | PWTMultipleSingularField -- ^ e.g. name or version should be specified only once.-    | PWTBuildTypeDefault      -- ^ Workaround for derive-package having build-type: Default. See <https://github.com/haskell/cabal/issues/5020>.--    | PWTVersionOperator       -- ^ Version operators used (without cabal-version: 1.8)-    | PWTVersionWildcard       -- ^ Version wildcard used (without cabal-version: 1.6)--    | PWTSpecVersion           -- ^ Warnings about cabal-version format.--    | PWTEmptyFilePath         -- ^ Empty filepath, i.e. literally ""--    | PWTExperimental          -- ^ Experimental feature-    deriving (Eq, Ord, Show, Enum, Bounded, Generic)+  = -- | Unclassified warning+    PWTOther+  | -- | Invalid UTF encoding+    PWTUTF+  | -- | @true@ or @false@, not @True@ or @False@+    PWTBoolCase+  | -- | there are version with tags+    PWTVersionTag+  | -- | New syntax used, but no @cabal-version: >= 1.2@ specified+    PWTNewSyntax+  | -- | Old syntax used, and @cabal-version >= 1.2@ specified+    PWTOldSyntax+  | PWTDeprecatedField+  | PWTInvalidSubsection+  | PWTUnknownField+  | PWTUnknownSection+  | PWTTrailingFields+  | -- | extra main-is field+    PWTExtraMainIs+  | -- | extra test-module field+    PWTExtraTestModule+  | -- | extra benchmark-module field+    PWTExtraBenchmarkModule+  | PWTLexNBSP+  | PWTLexBOM+  | PWTLexTab+  | -- | legacy cabal file that we know how to patch+    PWTQuirkyCabalFile+  | -- | Double dash token, most likely it's a mistake - it's not a comment+    PWTDoubleDash+  | -- | e.g. name or version should be specified only once.+    PWTMultipleSingularField+  | -- | Workaround for derive-package having build-type: Default. See <https://github.com/haskell/cabal/issues/5020>.+    PWTBuildTypeDefault+  | -- | Version operators used (without cabal-version: 1.8)+    PWTVersionOperator+  | -- | Version wildcard used (without cabal-version: 1.6)+    PWTVersionWildcard+  | -- | Warnings about cabal-version format.+    PWTSpecVersion+  | -- | Empty filepath, i.e. literally ""+    PWTEmptyFilePath+  | -- | sections contents (sections and fields) are indented inconsistently+    PWTInconsistentIndentation+  | -- | Experimental feature+    PWTExperimental+  deriving (Eq, Ord, Show, Enum, Bounded, Generic)  instance Binary PWarnType instance NFData PWarnType where rnf = genericRnf  -- | Parser warning. data PWarning = PWarning !PWarnType !Position String-    deriving (Eq, Ord, Show, Generic)+  deriving (Eq, Ord, Show, Generic)  instance Binary PWarning instance NFData PWarning where rnf = genericRnf  showPWarning :: FilePath -> PWarning -> String showPWarning fpath (PWarning _ pos msg) =-    normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg+  normalise fpath ++ ":" ++ showPos pos ++ ": " ++ msg
src/Distribution/Pretty.hs view
@@ -1,17 +1,21 @@-module Distribution.Pretty (-    Pretty (..),-    prettyShow,-    defaultStyle,-    flatStyle,+module Distribution.Pretty+  ( Pretty (..)+  , prettyShow+  , defaultStyle+  , flatStyle+     -- * Utilities-    showFilePath,-    showToken,-    showTokenStr,-    showFreeText,-    showFreeTextV3,+  , showFilePath+  , showToken+  , showTokenStr+  , showFreeText+  , showFreeTextV3+  , commaSpaceSep+  , commaSep+     -- * Deprecated-    Separator,-    ) where+  , Separator+  ) where  import Distribution.CabalSpecVersion import Distribution.Compat.Prelude@@ -20,23 +24,23 @@ import qualified Text.PrettyPrint as PP  class Pretty a where-    pretty :: a -> PP.Doc+  pretty :: a -> PP.Doc -    prettyVersioned :: CabalSpecVersion -> a -> PP.Doc-    prettyVersioned _ = pretty+  prettyVersioned :: CabalSpecVersion -> a -> PP.Doc+  prettyVersioned _ = pretty  -- | @since 3.4.0.0 instance Pretty PP.Doc where-    pretty = id+  pretty = id  instance Pretty Bool where-    pretty = PP.text . show+  pretty = PP.text . show  instance Pretty Int where-    pretty = PP.text . show+  pretty = PP.text . show  instance Pretty a => Pretty (Identity a) where-    pretty = pretty . runIdentity+  pretty = pretty . runIdentity  prettyShow :: Pretty a => a -> String prettyShow = PP.renderStyle defaultStyle . pretty@@ -45,20 +49,29 @@ -- output. It has a fixed page width and adds line breaks -- automatically. defaultStyle :: PP.Style-defaultStyle = PP.Style { PP.mode           = PP.PageMode-                          , PP.lineLength     = 79-                          , PP.ribbonsPerLine = 1.0-                          }+defaultStyle =+  PP.Style+    { PP.mode = PP.PageMode+    , PP.lineLength = 79+    , PP.ribbonsPerLine = 1.0+    }  -- | A style for rendering all on one line. flatStyle :: PP.Style-flatStyle = PP.Style { PP.mode = PP.LeftMode-                       , PP.lineLength = err "lineLength"-                       , PP.ribbonsPerLine = err "ribbonsPerLine"-                       }+flatStyle =+  PP.Style+    { PP.mode = PP.LeftMode+    , PP.lineLength = err "lineLength"+    , PP.ribbonsPerLine = err "ribbonsPerLine"+    }   where-    err x = error ("flatStyle: tried to access " ++ x ++ " in LeftMode. " ++-                   "This should never happen and indicates a bug in Cabal.")+    err x =+      error+        ( "flatStyle: tried to access "+            ++ x+            ++ " in LeftMode. "+            ++ "This should never happen and indicates a bug in Cabal."+        )  ------------------------------------------------------------------------------- -- Utilities@@ -75,21 +88,20 @@  showTokenStr :: String -> String showTokenStr str-    -- if token looks like a comment (starts with --), print it in quotes-    | "--" `isPrefixOf` str                 = show str-    -- also if token ends with a colon (e.g. executable name), print it in quotes-    | ":" `isSuffixOf` str                  = show str-    | not (any dodgy str) && not (null str) = str-    | otherwise                             = show str+  -- if token looks like a comment (starts with --), print it in quotes+  | "--" `isPrefixOf` str = show str+  -- also if token ends with a colon (e.g. executable name), print it in quotes+  | ":" `isSuffixOf` str = show str+  | not (any dodgy str) && not (null str) = str+  | otherwise = show str   where     dodgy c = isSpace c || c == ',' - -- | Pretty-print free-format text, ensuring that it is vertically aligned, -- and with blank lines replaced by dots for correct re-parsing. showFreeText :: String -> PP.Doc showFreeText "" = mempty-showFreeText s  = PP.vcat [ PP.text (if null l then "." else l) | l <- lines_ s ]+showFreeText s = PP.vcat [PP.text (if null l then "." else l) | l <- lines_ s]  -- | Pretty-print free-format text. -- Since @cabal-version: 3.0@ we don't replace blank lines with dots.@@ -97,14 +109,22 @@ -- @since 3.0.0.0 showFreeTextV3 :: String -> PP.Doc showFreeTextV3 "" = mempty-showFreeTextV3 s  = PP.vcat [ PP.text l | l <- lines_ s ]+showFreeTextV3 s = PP.vcat [PP.text l | l <- lines_ s]  -- | 'lines_' breaks a string up into a list of strings at newline -- characters.  The resulting strings do not contain newlines.-lines_                   :: String -> [String]+lines_ :: String -> [String] lines_ [] = [""]-lines_ s  =-    let (l, s') = break (== '\n') s-    in  l : case s' of-        []      -> []-        (_:s'') -> lines_ s''+lines_ s =+  let (l, s') = break (== '\n') s+   in l : case s' of+        [] -> []+        (_ : s'') -> lines_ s''++-- | Separate a list of documents by commas and spaces.+commaSpaceSep :: Pretty a => [a] -> PP.Doc+commaSpaceSep = PP.hsep . PP.punctuate PP.comma . map pretty++-- | Separate a list of documents by commas.+commaSep :: Pretty a => [a] -> PP.Doc+commaSep = PP.hcat . PP.punctuate PP.comma . map pretty
src/Distribution/SPDX.hs view
@@ -1,40 +1,45 @@ -- | This module implements SPDX specification version 2.1 with a version 3.0 license list. -- -- Specification is available on <https://spdx.org/specifications>-module Distribution.SPDX (-    -- * License-    License (..),+module Distribution.SPDX+  ( -- * License+    License (..)+     -- * License expression-    LicenseExpression (..),-    SimpleLicenseExpression (..),-    simpleLicenseExpression,+  , LicenseExpression (..)+  , SimpleLicenseExpression (..)+  , simpleLicenseExpression+     -- * License identifier-    LicenseId (..),-    licenseId,-    licenseName,-    licenseIsOsiApproved,-    mkLicenseId,-    licenseIdList,+  , LicenseId (..)+  , licenseId+  , licenseName+  , licenseIsOsiApproved+  , mkLicenseId+  , licenseIdList+     -- * License exception-    LicenseExceptionId (..),-    licenseExceptionId,-    licenseExceptionName,-    mkLicenseExceptionId,-    licenseExceptionIdList,+  , LicenseExceptionId (..)+  , licenseExceptionId+  , licenseExceptionName+  , mkLicenseExceptionId+  , licenseExceptionIdList+     -- * License reference-    LicenseRef,-    licenseRef,-    licenseDocumentRef,-    mkLicenseRef,-    mkLicenseRef',+  , LicenseRef+  , licenseRef+  , licenseDocumentRef+  , mkLicenseRef+  , mkLicenseRef'+     -- * License list version-    LicenseListVersion (..),-    cabalSpecVersionToSPDXListVersion,-    ) where+  , LicenseListVersion (..)+  , cabalSpecVersionToSPDXListVersion+  ) where -import Distribution.SPDX.LicenseExceptionId import Distribution.SPDX.License-import Distribution.SPDX.LicenseId+import Distribution.SPDX.LicenseExceptionId import Distribution.SPDX.LicenseExpression-import Distribution.SPDX.LicenseReference+import Distribution.SPDX.LicenseId import Distribution.SPDX.LicenseListVersion+import Distribution.SPDX.LicenseReference
src/Distribution/SPDX/License.hs view
@@ -1,14 +1,15 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-module Distribution.SPDX.License (-    License (..),-    ) where -import Prelude ()+module Distribution.SPDX.License+  ( License (..)+  ) where+ import Distribution.Compat.Prelude+import Prelude () -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty import Distribution.SPDX.LicenseExpression  import qualified Distribution.Compat.CharParsing as P@@ -35,24 +36,23 @@ -- * @PublicDomain@ isn't covered. Consider using CC0. --   See <https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files> --   for more information.--- data License-    = NONE-      -- ^ if the package contains no license information whatsoever; or-    | License LicenseExpression-      -- ^ A valid SPDX License Expression as defined in Appendix IV.-  deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+  = -- | if the package contains no license information whatsoever; or+    NONE+  | -- | A valid SPDX License Expression as defined in Appendix IV.+    License LicenseExpression+  deriving (Show, Read, Eq, Ord, Data, Generic)  instance Binary License instance Structured License  instance NFData License where-    rnf NONE        = ()-    rnf (License l) = rnf l+  rnf NONE = ()+  rnf (License l) = rnf l  instance Pretty License where-    pretty NONE        = Disp.text "NONE"-    pretty (License l) = pretty l+  pretty NONE = Disp.text "NONE"+  pretty (License l) = pretty l  -- | -- >>> eitherParsec "BSD-3-Clause AND MIT" :: Either String License@@ -60,6 +60,5 @@ -- -- >>> eitherParsec "NONE" :: Either String License -- Right NONE--- instance Parsec License where-    parsec = NONE <$ P.try (P.string "NONE") <|> License <$> parsec+  parsec = NONE <$ P.try (P.string "NONE") <|> License <$> parsec
src/Distribution/SPDX/LicenseExceptionId.hs view
@@ -1,4 +1,5 @@ -- This file is generated. See Makefile's spdx rule+{- FOURMOLU_DISABLE -} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric      #-} module Distribution.SPDX.LicenseExceptionId (@@ -29,50 +30,88 @@ -- LicenseExceptionId ------------------------------------------------------------------------------- --- | SPDX License Exceptions identifiers list v3.16+-- | SPDX License Exceptions identifiers list v3.26 data LicenseExceptionId-    = DS389_exception -- ^ @389-exception@, 389 Directory Server Exception+    = N_389_exception -- ^ @389-exception@, 389 Directory Server Exception+    | Asterisk_exception -- ^ @Asterisk-exception@, Asterisk exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Asterisk_linking_protocols_exception -- ^ @Asterisk-linking-protocols-exception@, Asterisk linking protocols exception, SPDX License List 3.25, SPDX License List 3.26     | Autoconf_exception_2_0 -- ^ @Autoconf-exception-2.0@, Autoconf exception 2.0     | Autoconf_exception_3_0 -- ^ @Autoconf-exception-3.0@, Autoconf exception 3.0+    | Autoconf_exception_generic_3_0 -- ^ @Autoconf-exception-generic-3.0@, Autoconf generic exception for GPL-3.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Autoconf_exception_generic -- ^ @Autoconf-exception-generic@, Autoconf generic exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Autoconf_exception_macro -- ^ @Autoconf-exception-macro@, Autoconf macro exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Bison_exception_1_24 -- ^ @Bison-exception-1.24@, Bison exception 1.24, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | Bison_exception_2_2 -- ^ @Bison-exception-2.2@, Bison exception 2.2     | Bootloader_exception -- ^ @Bootloader-exception@, Bootloader Distribution Exception+    | CGAL_linking_exception -- ^ @CGAL-linking-exception@, CGAL Linking Exception, SPDX License List 3.26     | Classpath_exception_2_0 -- ^ @Classpath-exception-2.0@, Classpath exception 2.0     | CLISP_exception_2_0 -- ^ @CLISP-exception-2.0@, CLISP exception 2.0+    | Cryptsetup_OpenSSL_exception -- ^ @cryptsetup-OpenSSL-exception@, cryptsetup OpenSSL exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Digia_Qt_LGPL_exception_1_1 -- ^ @Digia-Qt-LGPL-exception-1.1@, Digia Qt LGPL Exception version 1.1, SPDX License List 3.26     | DigiRule_FOSS_exception -- ^ @DigiRule-FOSS-exception@, DigiRule FOSS License Exception     | ECos_exception_2_0 -- ^ @eCos-exception-2.0@, eCos exception 2.0+    | Erlang_otp_linking_exception -- ^ @erlang-otp-linking-exception@, Erlang/OTP Linking Exception, SPDX License List 3.25, SPDX License List 3.26     | Fawkes_Runtime_exception -- ^ @Fawkes-Runtime-exception@, Fawkes Runtime Exception     | FLTK_exception -- ^ @FLTK-exception@, FLTK exception+    | Fmt_exception -- ^ @fmt-exception@, fmt exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | Font_exception_2_0 -- ^ @Font-exception-2.0@, Font exception 2.0     | Freertos_exception_2_0 -- ^ @freertos-exception-2.0@, FreeRTOS Exception 2.0+    | GCC_exception_2_0_note -- ^ @GCC-exception-2.0-note@, GCC    Runtime Library exception 2.0 - note variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | GCC_exception_2_0 -- ^ @GCC-exception-2.0@, GCC Runtime Library exception 2.0     | GCC_exception_3_1 -- ^ @GCC-exception-3.1@, GCC Runtime Library exception 3.1+    | Gmsh_exception -- ^ @Gmsh-exception@, Gmsh exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GNAT_exception -- ^ @GNAT-exception@, GNAT exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GNOME_examples_exception -- ^ @GNOME-examples-exception@, GNOME examples exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GNU_compiler_exception -- ^ @GNU-compiler-exception@, GNU Compiler Exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | Gnu_javamail_exception -- ^ @gnu-javamail-exception@, GNU JavaMail exception-    | GPL_3_0_linking_exception -- ^ @GPL-3.0-linking-exception@, GPL-3.0 Linking Exception, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | GPL_3_0_linking_source_exception -- ^ @GPL-3.0-linking-source-exception@, GPL-3.0 Linking Exception (with Corresponding Source), SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | GPL_CC_1_0 -- ^ @GPL-CC-1.0@, GPL Cooperation Commitment 1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | GPL_3_0_389_ds_base_exception -- ^ @GPL-3.0-389-ds-base-exception@, GPL-3.0 389 DS Base Exception, SPDX License List 3.26+    | GPL_3_0_interface_exception -- ^ @GPL-3.0-interface-exception@, GPL-3.0 Interface Exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GPL_3_0_linking_exception -- ^ @GPL-3.0-linking-exception@, GPL-3.0 Linking Exception, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GPL_3_0_linking_source_exception -- ^ @GPL-3.0-linking-source-exception@, GPL-3.0 Linking Exception (with Corresponding Source), SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GPL_CC_1_0 -- ^ @GPL-CC-1.0@, GPL Cooperation Commitment 1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GStreamer_exception_2005 -- ^ @GStreamer-exception-2005@, GStreamer Exception (2005), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GStreamer_exception_2008 -- ^ @GStreamer-exception-2008@, GStreamer Exception (2008), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Harbour_exception -- ^ @harbour-exception@, harbour exception, SPDX License List 3.26     | I2p_gpl_java_exception -- ^ @i2p-gpl-java-exception@, i2p GPL+Java Exception-    | LGPL_3_0_linking_exception -- ^ @LGPL-3.0-linking-exception@, LGPL-3.0 Linking Exception, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | Independent_modules_exception -- ^ @Independent-modules-exception@, Independent Module Linking exception, SPDX License List 3.26+    | KiCad_libraries_exception -- ^ @KiCad-libraries-exception@, KiCad Libraries Exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LGPL_3_0_linking_exception -- ^ @LGPL-3.0-linking-exception@, LGPL-3.0 Linking Exception, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Libpri_OpenH323_exception -- ^ @libpri-OpenH323-exception@, libpri OpenH323 exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | Libtool_exception -- ^ @Libtool-exception@, Libtool Exception     | Linux_syscall_note -- ^ @Linux-syscall-note@, Linux Syscall Note-    | LLVM_exception -- ^ @LLVM-exception@, LLVM Exception, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | LLGPL -- ^ @LLGPL@, LLGPL Preamble, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LLVM_exception -- ^ @LLVM-exception@, LLVM Exception, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | LZMA_exception -- ^ @LZMA-exception@, LZMA exception     | Mif_exception -- ^ @mif-exception@, Macros and Inline Functions Exception     | Nokia_Qt_exception_1_1 -- ^ @Nokia-Qt-exception-1.1@, Nokia Qt LGPL exception 1.1, SPDX License List 3.0, SPDX License List 3.2-    | OCaml_LGPL_linking_exception -- ^ @OCaml-LGPL-linking-exception@, OCaml LGPL Linking Exception, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | Mxml_exception -- ^ @mxml-exception@, mxml Exception, SPDX License List 3.26+    | OCaml_LGPL_linking_exception -- ^ @OCaml-LGPL-linking-exception@, OCaml LGPL Linking Exception, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | OCCT_exception_1_0 -- ^ @OCCT-exception-1.0@, Open CASCADE Exception 1.0-    | OpenJDK_assembly_exception_1_0 -- ^ @OpenJDK-assembly-exception-1.0@, OpenJDK Assembly exception 1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | OpenJDK_assembly_exception_1_0 -- ^ @OpenJDK-assembly-exception-1.0@, OpenJDK Assembly exception 1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | Openvpn_openssl_exception -- ^ @openvpn-openssl-exception@, OpenVPN OpenSSL Exception-    | PS_or_PDF_font_exception_20170817 -- ^ @PS-or-PDF-font-exception-20170817@, PS/PDF font exception (2017-08-17), SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Qt_GPL_exception_1_0 -- ^ @Qt-GPL-exception-1.0@, Qt GPL exception 1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Qt_LGPL_exception_1_1 -- ^ @Qt-LGPL-exception-1.1@, Qt LGPL exception 1.1, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | PCRE2_exception -- ^ @PCRE2-exception@, PCRE2 exception, SPDX License List 3.25, SPDX License List 3.26+    | Polyparse_exception -- ^ @polyparse-exception@, Polyparse Exception, SPDX License List 3.26+    | PS_or_PDF_font_exception_20170817 -- ^ @PS-or-PDF-font-exception-20170817@, PS/PDF font exception (2017-08-17), SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | QPL_1_0_INRIA_2004_exception -- ^ @QPL-1.0-INRIA-2004-exception@, INRIA QPL 1.0 2004 variant exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Qt_GPL_exception_1_0 -- ^ @Qt-GPL-exception-1.0@, Qt GPL exception 1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Qt_LGPL_exception_1_1 -- ^ @Qt-LGPL-exception-1.1@, Qt LGPL exception 1.1, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | Qwt_exception_1_0 -- ^ @Qwt-exception-1.0@, Qwt exception 1.0-    | SHL_2_0 -- ^ @SHL-2.0@, Solderpad Hardware License v2.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | SHL_2_1 -- ^ @SHL-2.1@, Solderpad Hardware License v2.1, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Swift_exception -- ^ @Swift-exception@, Swift Exception, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | Romic_exception -- ^ @romic-exception@, Romic Exception, SPDX License List 3.25, SPDX License List 3.26+    | RRDtool_FLOSS_exception_2_0 -- ^ @RRDtool-FLOSS-exception-2.0@, RRDtool FLOSS exception 2.0, SPDX License List 3.25, SPDX License List 3.26+    | SANE_exception -- ^ @SANE-exception@, SANE Exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SHL_2_0 -- ^ @SHL-2.0@, Solderpad Hardware License v2.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SHL_2_1 -- ^ @SHL-2.1@, Solderpad Hardware License v2.1, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Stunnel_exception -- ^ @stunnel-exception@, stunnel Exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SWI_exception -- ^ @SWI-exception@, SWI exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Swift_exception -- ^ @Swift-exception@, Swift Exception, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Texinfo_exception -- ^ @Texinfo-exception@, Texinfo exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | U_boot_exception_2_0 -- ^ @u-boot-exception-2.0@, U-Boot exception 2.0-    | Universal_FOSS_exception_1_0 -- ^ @Universal-FOSS-exception-1.0@, Universal FOSS Exception, Version 1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16+    | UBDL_exception -- ^ @UBDL-exception@, Unmodified Binary Distribution exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Universal_FOSS_exception_1_0 -- ^ @Universal-FOSS-exception-1.0@, Universal FOSS Exception, Version 1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Vsftpd_openssl_exception -- ^ @vsftpd-openssl-exception@, vsftpd OpenSSL exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26     | WxWindows_exception_3_1 -- ^ @WxWindows-exception-3.1@, WxWindows Library Exception 3.1-  deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data, Generic)+    | X11vnc_openssl_exception -- ^ @x11vnc-openssl-exception@, x11vnc OpenSSL Exception, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+  deriving (Eq, Ord, Enum, Bounded, Show, Read, Data, Generic)  instance Binary LicenseExceptionId where     put = Binary.putWord8 . fromIntegral . fromEnum@@ -84,7 +123,7 @@  -- note: remember to bump version each time the definition changes instance Structured LicenseExceptionId where-    structure p = set typeVersion 306 $ nominalStructure p+    structure p = set typeVersion 307 $ nominalStructure p  instance Pretty LicenseExceptionId where     pretty = Disp.text . licenseExceptionId@@ -105,91 +144,167 @@  -- | License SPDX identifier, e.g. @"BSD-3-Clause"@. licenseExceptionId :: LicenseExceptionId -> String-licenseExceptionId DS389_exception = "389-exception"+licenseExceptionId N_389_exception = "389-exception"+licenseExceptionId Asterisk_exception = "Asterisk-exception"+licenseExceptionId Asterisk_linking_protocols_exception = "Asterisk-linking-protocols-exception" licenseExceptionId Autoconf_exception_2_0 = "Autoconf-exception-2.0" licenseExceptionId Autoconf_exception_3_0 = "Autoconf-exception-3.0"+licenseExceptionId Autoconf_exception_generic_3_0 = "Autoconf-exception-generic-3.0"+licenseExceptionId Autoconf_exception_generic = "Autoconf-exception-generic"+licenseExceptionId Autoconf_exception_macro = "Autoconf-exception-macro"+licenseExceptionId Bison_exception_1_24 = "Bison-exception-1.24" licenseExceptionId Bison_exception_2_2 = "Bison-exception-2.2" licenseExceptionId Bootloader_exception = "Bootloader-exception"+licenseExceptionId CGAL_linking_exception = "CGAL-linking-exception" licenseExceptionId Classpath_exception_2_0 = "Classpath-exception-2.0" licenseExceptionId CLISP_exception_2_0 = "CLISP-exception-2.0"+licenseExceptionId Cryptsetup_OpenSSL_exception = "cryptsetup-OpenSSL-exception"+licenseExceptionId Digia_Qt_LGPL_exception_1_1 = "Digia-Qt-LGPL-exception-1.1" licenseExceptionId DigiRule_FOSS_exception = "DigiRule-FOSS-exception" licenseExceptionId ECos_exception_2_0 = "eCos-exception-2.0"+licenseExceptionId Erlang_otp_linking_exception = "erlang-otp-linking-exception" licenseExceptionId Fawkes_Runtime_exception = "Fawkes-Runtime-exception" licenseExceptionId FLTK_exception = "FLTK-exception"+licenseExceptionId Fmt_exception = "fmt-exception" licenseExceptionId Font_exception_2_0 = "Font-exception-2.0" licenseExceptionId Freertos_exception_2_0 = "freertos-exception-2.0"+licenseExceptionId GCC_exception_2_0_note = "GCC-exception-2.0-note" licenseExceptionId GCC_exception_2_0 = "GCC-exception-2.0" licenseExceptionId GCC_exception_3_1 = "GCC-exception-3.1"+licenseExceptionId Gmsh_exception = "Gmsh-exception"+licenseExceptionId GNAT_exception = "GNAT-exception"+licenseExceptionId GNOME_examples_exception = "GNOME-examples-exception"+licenseExceptionId GNU_compiler_exception = "GNU-compiler-exception" licenseExceptionId Gnu_javamail_exception = "gnu-javamail-exception"+licenseExceptionId GPL_3_0_389_ds_base_exception = "GPL-3.0-389-ds-base-exception"+licenseExceptionId GPL_3_0_interface_exception = "GPL-3.0-interface-exception" licenseExceptionId GPL_3_0_linking_exception = "GPL-3.0-linking-exception" licenseExceptionId GPL_3_0_linking_source_exception = "GPL-3.0-linking-source-exception" licenseExceptionId GPL_CC_1_0 = "GPL-CC-1.0"+licenseExceptionId GStreamer_exception_2005 = "GStreamer-exception-2005"+licenseExceptionId GStreamer_exception_2008 = "GStreamer-exception-2008"+licenseExceptionId Harbour_exception = "harbour-exception" licenseExceptionId I2p_gpl_java_exception = "i2p-gpl-java-exception"+licenseExceptionId Independent_modules_exception = "Independent-modules-exception"+licenseExceptionId KiCad_libraries_exception = "KiCad-libraries-exception" licenseExceptionId LGPL_3_0_linking_exception = "LGPL-3.0-linking-exception"+licenseExceptionId Libpri_OpenH323_exception = "libpri-OpenH323-exception" licenseExceptionId Libtool_exception = "Libtool-exception" licenseExceptionId Linux_syscall_note = "Linux-syscall-note"+licenseExceptionId LLGPL = "LLGPL" licenseExceptionId LLVM_exception = "LLVM-exception" licenseExceptionId LZMA_exception = "LZMA-exception" licenseExceptionId Mif_exception = "mif-exception" licenseExceptionId Nokia_Qt_exception_1_1 = "Nokia-Qt-exception-1.1"+licenseExceptionId Mxml_exception = "mxml-exception" licenseExceptionId OCaml_LGPL_linking_exception = "OCaml-LGPL-linking-exception" licenseExceptionId OCCT_exception_1_0 = "OCCT-exception-1.0" licenseExceptionId OpenJDK_assembly_exception_1_0 = "OpenJDK-assembly-exception-1.0" licenseExceptionId Openvpn_openssl_exception = "openvpn-openssl-exception"+licenseExceptionId PCRE2_exception = "PCRE2-exception"+licenseExceptionId Polyparse_exception = "polyparse-exception" licenseExceptionId PS_or_PDF_font_exception_20170817 = "PS-or-PDF-font-exception-20170817"+licenseExceptionId QPL_1_0_INRIA_2004_exception = "QPL-1.0-INRIA-2004-exception" licenseExceptionId Qt_GPL_exception_1_0 = "Qt-GPL-exception-1.0" licenseExceptionId Qt_LGPL_exception_1_1 = "Qt-LGPL-exception-1.1" licenseExceptionId Qwt_exception_1_0 = "Qwt-exception-1.0"+licenseExceptionId Romic_exception = "romic-exception"+licenseExceptionId RRDtool_FLOSS_exception_2_0 = "RRDtool-FLOSS-exception-2.0"+licenseExceptionId SANE_exception = "SANE-exception" licenseExceptionId SHL_2_0 = "SHL-2.0" licenseExceptionId SHL_2_1 = "SHL-2.1"+licenseExceptionId Stunnel_exception = "stunnel-exception"+licenseExceptionId SWI_exception = "SWI-exception" licenseExceptionId Swift_exception = "Swift-exception"+licenseExceptionId Texinfo_exception = "Texinfo-exception" licenseExceptionId U_boot_exception_2_0 = "u-boot-exception-2.0"+licenseExceptionId UBDL_exception = "UBDL-exception" licenseExceptionId Universal_FOSS_exception_1_0 = "Universal-FOSS-exception-1.0"+licenseExceptionId Vsftpd_openssl_exception = "vsftpd-openssl-exception" licenseExceptionId WxWindows_exception_3_1 = "WxWindows-exception-3.1"+licenseExceptionId X11vnc_openssl_exception = "x11vnc-openssl-exception"  -- | License name, e.g. @"GNU General Public License v2.0 only"@ licenseExceptionName :: LicenseExceptionId -> String-licenseExceptionName DS389_exception = "389 Directory Server Exception"+licenseExceptionName N_389_exception = "389 Directory Server Exception"+licenseExceptionName Asterisk_exception = "Asterisk exception"+licenseExceptionName Asterisk_linking_protocols_exception = "Asterisk linking protocols exception" licenseExceptionName Autoconf_exception_2_0 = "Autoconf exception 2.0" licenseExceptionName Autoconf_exception_3_0 = "Autoconf exception 3.0"+licenseExceptionName Autoconf_exception_generic_3_0 = "Autoconf generic exception for GPL-3.0"+licenseExceptionName Autoconf_exception_generic = "Autoconf generic exception"+licenseExceptionName Autoconf_exception_macro = "Autoconf macro exception"+licenseExceptionName Bison_exception_1_24 = "Bison exception 1.24" licenseExceptionName Bison_exception_2_2 = "Bison exception 2.2" licenseExceptionName Bootloader_exception = "Bootloader Distribution Exception"+licenseExceptionName CGAL_linking_exception = "CGAL Linking Exception" licenseExceptionName Classpath_exception_2_0 = "Classpath exception 2.0" licenseExceptionName CLISP_exception_2_0 = "CLISP exception 2.0"+licenseExceptionName Cryptsetup_OpenSSL_exception = "cryptsetup OpenSSL exception"+licenseExceptionName Digia_Qt_LGPL_exception_1_1 = "Digia Qt LGPL Exception version 1.1" licenseExceptionName DigiRule_FOSS_exception = "DigiRule FOSS License Exception" licenseExceptionName ECos_exception_2_0 = "eCos exception 2.0"+licenseExceptionName Erlang_otp_linking_exception = "Erlang/OTP Linking Exception" licenseExceptionName Fawkes_Runtime_exception = "Fawkes Runtime Exception" licenseExceptionName FLTK_exception = "FLTK exception"+licenseExceptionName Fmt_exception = "fmt exception" licenseExceptionName Font_exception_2_0 = "Font exception 2.0" licenseExceptionName Freertos_exception_2_0 = "FreeRTOS Exception 2.0"+licenseExceptionName GCC_exception_2_0_note = "GCC    Runtime Library exception 2.0 - note variant" licenseExceptionName GCC_exception_2_0 = "GCC Runtime Library exception 2.0" licenseExceptionName GCC_exception_3_1 = "GCC Runtime Library exception 3.1"+licenseExceptionName Gmsh_exception = "Gmsh exception"+licenseExceptionName GNAT_exception = "GNAT exception"+licenseExceptionName GNOME_examples_exception = "GNOME examples exception"+licenseExceptionName GNU_compiler_exception = "GNU Compiler Exception" licenseExceptionName Gnu_javamail_exception = "GNU JavaMail exception"+licenseExceptionName GPL_3_0_389_ds_base_exception = "GPL-3.0 389 DS Base Exception"+licenseExceptionName GPL_3_0_interface_exception = "GPL-3.0 Interface Exception" licenseExceptionName GPL_3_0_linking_exception = "GPL-3.0 Linking Exception" licenseExceptionName GPL_3_0_linking_source_exception = "GPL-3.0 Linking Exception (with Corresponding Source)" licenseExceptionName GPL_CC_1_0 = "GPL Cooperation Commitment 1.0"+licenseExceptionName GStreamer_exception_2005 = "GStreamer Exception (2005)"+licenseExceptionName GStreamer_exception_2008 = "GStreamer Exception (2008)"+licenseExceptionName Harbour_exception = "harbour exception" licenseExceptionName I2p_gpl_java_exception = "i2p GPL+Java Exception"+licenseExceptionName Independent_modules_exception = "Independent Module Linking exception"+licenseExceptionName KiCad_libraries_exception = "KiCad Libraries Exception" licenseExceptionName LGPL_3_0_linking_exception = "LGPL-3.0 Linking Exception"+licenseExceptionName Libpri_OpenH323_exception = "libpri OpenH323 exception" licenseExceptionName Libtool_exception = "Libtool Exception" licenseExceptionName Linux_syscall_note = "Linux Syscall Note"+licenseExceptionName LLGPL = "LLGPL Preamble" licenseExceptionName LLVM_exception = "LLVM Exception" licenseExceptionName LZMA_exception = "LZMA exception" licenseExceptionName Mif_exception = "Macros and Inline Functions Exception" licenseExceptionName Nokia_Qt_exception_1_1 = "Nokia Qt LGPL exception 1.1"+licenseExceptionName Mxml_exception = "mxml Exception" licenseExceptionName OCaml_LGPL_linking_exception = "OCaml LGPL Linking Exception" licenseExceptionName OCCT_exception_1_0 = "Open CASCADE Exception 1.0" licenseExceptionName OpenJDK_assembly_exception_1_0 = "OpenJDK Assembly exception 1.0" licenseExceptionName Openvpn_openssl_exception = "OpenVPN OpenSSL Exception"+licenseExceptionName PCRE2_exception = "PCRE2 exception"+licenseExceptionName Polyparse_exception = "Polyparse Exception" licenseExceptionName PS_or_PDF_font_exception_20170817 = "PS/PDF font exception (2017-08-17)"+licenseExceptionName QPL_1_0_INRIA_2004_exception = "INRIA QPL 1.0 2004 variant exception" licenseExceptionName Qt_GPL_exception_1_0 = "Qt GPL exception 1.0" licenseExceptionName Qt_LGPL_exception_1_1 = "Qt LGPL exception 1.1" licenseExceptionName Qwt_exception_1_0 = "Qwt exception 1.0"+licenseExceptionName Romic_exception = "Romic Exception"+licenseExceptionName RRDtool_FLOSS_exception_2_0 = "RRDtool FLOSS exception 2.0"+licenseExceptionName SANE_exception = "SANE Exception" licenseExceptionName SHL_2_0 = "Solderpad Hardware License v2.0" licenseExceptionName SHL_2_1 = "Solderpad Hardware License v2.1"+licenseExceptionName Stunnel_exception = "stunnel Exception"+licenseExceptionName SWI_exception = "SWI exception" licenseExceptionName Swift_exception = "Swift Exception"+licenseExceptionName Texinfo_exception = "Texinfo exception" licenseExceptionName U_boot_exception_2_0 = "U-Boot exception 2.0"+licenseExceptionName UBDL_exception = "Unmodified Binary Distribution exception" licenseExceptionName Universal_FOSS_exception_1_0 = "Universal FOSS Exception, Version 1.0"+licenseExceptionName Vsftpd_openssl_exception = "vsftpd OpenSSL exception" licenseExceptionName WxWindows_exception_3_1 = "WxWindows Library Exception 3.1"+licenseExceptionName X11vnc_openssl_exception = "x11vnc OpenSSL Exception"  ------------------------------------------------------------------------------- -- Creation@@ -272,6 +387,152 @@     , Universal_FOSS_exception_1_0     ]     ++ bulkOfLicenses+licenseExceptionIdList LicenseListVersion_3_23 =+    [ Asterisk_exception+    , Autoconf_exception_generic_3_0+    , Autoconf_exception_generic+    , Autoconf_exception_macro+    , Bison_exception_1_24+    , Cryptsetup_OpenSSL_exception+    , Fmt_exception+    , GCC_exception_2_0_note+    , Gmsh_exception+    , GNAT_exception+    , GNOME_examples_exception+    , GNU_compiler_exception+    , GPL_3_0_interface_exception+    , GPL_3_0_linking_exception+    , GPL_3_0_linking_source_exception+    , GPL_CC_1_0+    , GStreamer_exception_2005+    , GStreamer_exception_2008+    , KiCad_libraries_exception+    , LGPL_3_0_linking_exception+    , Libpri_OpenH323_exception+    , LLGPL+    , LLVM_exception+    , OCaml_LGPL_linking_exception+    , OpenJDK_assembly_exception_1_0+    , PS_or_PDF_font_exception_20170817+    , QPL_1_0_INRIA_2004_exception+    , Qt_GPL_exception_1_0+    , Qt_LGPL_exception_1_1+    , SANE_exception+    , SHL_2_0+    , SHL_2_1+    , Stunnel_exception+    , SWI_exception+    , Swift_exception+    , Texinfo_exception+    , UBDL_exception+    , Universal_FOSS_exception_1_0+    , Vsftpd_openssl_exception+    , X11vnc_openssl_exception+    ]+    ++ bulkOfLicenses+licenseExceptionIdList LicenseListVersion_3_25 =+    [ Asterisk_exception+    , Asterisk_linking_protocols_exception+    , Autoconf_exception_generic_3_0+    , Autoconf_exception_generic+    , Autoconf_exception_macro+    , Bison_exception_1_24+    , Cryptsetup_OpenSSL_exception+    , Erlang_otp_linking_exception+    , Fmt_exception+    , GCC_exception_2_0_note+    , Gmsh_exception+    , GNAT_exception+    , GNOME_examples_exception+    , GNU_compiler_exception+    , GPL_3_0_interface_exception+    , GPL_3_0_linking_exception+    , GPL_3_0_linking_source_exception+    , GPL_CC_1_0+    , GStreamer_exception_2005+    , GStreamer_exception_2008+    , KiCad_libraries_exception+    , LGPL_3_0_linking_exception+    , Libpri_OpenH323_exception+    , LLGPL+    , LLVM_exception+    , OCaml_LGPL_linking_exception+    , OpenJDK_assembly_exception_1_0+    , PCRE2_exception+    , PS_or_PDF_font_exception_20170817+    , QPL_1_0_INRIA_2004_exception+    , Qt_GPL_exception_1_0+    , Qt_LGPL_exception_1_1+    , Romic_exception+    , RRDtool_FLOSS_exception_2_0+    , SANE_exception+    , SHL_2_0+    , SHL_2_1+    , Stunnel_exception+    , SWI_exception+    , Swift_exception+    , Texinfo_exception+    , UBDL_exception+    , Universal_FOSS_exception_1_0+    , Vsftpd_openssl_exception+    , X11vnc_openssl_exception+    ]+    ++ bulkOfLicenses+licenseExceptionIdList LicenseListVersion_3_26 =+    [ Asterisk_exception+    , Asterisk_linking_protocols_exception+    , Autoconf_exception_generic_3_0+    , Autoconf_exception_generic+    , Autoconf_exception_macro+    , Bison_exception_1_24+    , CGAL_linking_exception+    , Cryptsetup_OpenSSL_exception+    , Digia_Qt_LGPL_exception_1_1+    , Erlang_otp_linking_exception+    , Fmt_exception+    , GCC_exception_2_0_note+    , Gmsh_exception+    , GNAT_exception+    , GNOME_examples_exception+    , GNU_compiler_exception+    , GPL_3_0_389_ds_base_exception+    , GPL_3_0_interface_exception+    , GPL_3_0_linking_exception+    , GPL_3_0_linking_source_exception+    , GPL_CC_1_0+    , GStreamer_exception_2005+    , GStreamer_exception_2008+    , Harbour_exception+    , Independent_modules_exception+    , KiCad_libraries_exception+    , LGPL_3_0_linking_exception+    , Libpri_OpenH323_exception+    , LLGPL+    , LLVM_exception+    , Mxml_exception+    , OCaml_LGPL_linking_exception+    , OpenJDK_assembly_exception_1_0+    , PCRE2_exception+    , Polyparse_exception+    , PS_or_PDF_font_exception_20170817+    , QPL_1_0_INRIA_2004_exception+    , Qt_GPL_exception_1_0+    , Qt_LGPL_exception_1_1+    , Romic_exception+    , RRDtool_FLOSS_exception_2_0+    , SANE_exception+    , SHL_2_0+    , SHL_2_1+    , Stunnel_exception+    , SWI_exception+    , Swift_exception+    , Texinfo_exception+    , UBDL_exception+    , Universal_FOSS_exception_1_0+    , Vsftpd_openssl_exception+    , X11vnc_openssl_exception+    ]+    ++ bulkOfLicenses  -- | Create a 'LicenseExceptionId' from a 'String'. mkLicenseExceptionId :: LicenseListVersion -> String -> Maybe LicenseExceptionId@@ -281,6 +542,9 @@ mkLicenseExceptionId LicenseListVersion_3_9  s = Map.lookup s stringLookup_3_9 mkLicenseExceptionId LicenseListVersion_3_10 s = Map.lookup s stringLookup_3_10 mkLicenseExceptionId LicenseListVersion_3_16 s = Map.lookup s stringLookup_3_16+mkLicenseExceptionId LicenseListVersion_3_23 s = Map.lookup s stringLookup_3_23+mkLicenseExceptionId LicenseListVersion_3_25 s = Map.lookup s stringLookup_3_25+mkLicenseExceptionId LicenseListVersion_3_26 s = Map.lookup s stringLookup_3_26  stringLookup_3_0 :: Map String LicenseExceptionId stringLookup_3_0 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $@@ -306,10 +570,22 @@ stringLookup_3_16 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $     licenseExceptionIdList LicenseListVersion_3_16 +stringLookup_3_23 :: Map String LicenseExceptionId+stringLookup_3_23 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $+    licenseExceptionIdList LicenseListVersion_3_23++stringLookup_3_25 :: Map String LicenseExceptionId+stringLookup_3_25 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $+    licenseExceptionIdList LicenseListVersion_3_25++stringLookup_3_26 :: Map String LicenseExceptionId+stringLookup_3_26 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $+    licenseExceptionIdList LicenseListVersion_3_26+ --  | License exceptions in all SPDX License lists bulkOfLicenses :: [LicenseExceptionId] bulkOfLicenses =-    [ DS389_exception+    [ N_389_exception     , Autoconf_exception_2_0     , Autoconf_exception_3_0     , Bison_exception_2_2
src/Distribution/SPDX/LicenseExpression.hs view
@@ -1,11 +1,12 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-module Distribution.SPDX.LicenseExpression (-    LicenseExpression (..),-    SimpleLicenseExpression (..),-    simpleLicenseExpression,-    ) where+{-# LANGUAGE DeriveGeneric #-} +module Distribution.SPDX.LicenseExpression+  ( LicenseExpression (..)+  , SimpleLicenseExpression (..)+  , simpleLicenseExpression+  ) where+ import Distribution.Compat.Prelude import Prelude () @@ -15,10 +16,10 @@ import Distribution.SPDX.LicenseId import Distribution.SPDX.LicenseListVersion import Distribution.SPDX.LicenseReference-import Distribution.Utils.Generic           (isAsciiAlphaNum)+import Distribution.Utils.Generic (isAsciiAlphaNum)  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp  -- | SPDX License Expression. --@@ -39,20 +40,20 @@ -- license expression    = 1*1(simple expression / compound expression) -- @ data LicenseExpression-    = ELicense !SimpleLicenseExpression !(Maybe LicenseExceptionId)-    | EAnd !LicenseExpression !LicenseExpression-    | EOr !LicenseExpression !LicenseExpression-    deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+  = ELicense !SimpleLicenseExpression !(Maybe LicenseExceptionId)+  | EAnd !LicenseExpression !LicenseExpression+  | EOr !LicenseExpression !LicenseExpression+  deriving (Show, Read, Eq, Ord, Data, Generic)  -- | Simple License Expressions. data SimpleLicenseExpression-    = ELicenseId LicenseId-      -- ^ An SPDX License List Short Form Identifier. For example: @GPL-2.0-only@-    | ELicenseIdPlus LicenseId-      -- ^ An SPDX License List Short Form Identifier with a unary"+" operator suffix to represent the current version of the license or any later version.  For example: @GPL-2.0+@-    | ELicenseRef LicenseRef-      -- ^ A SPDX user defined license reference: For example: @LicenseRef-23@, @LicenseRef-MIT-Style-1@, or @DocumentRef-spdx-tool-1.2:LicenseRef-MIT-Style-2@-    deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+  = -- | An SPDX License List Short Form Identifier. For example: @GPL-2.0-only@+    ELicenseId LicenseId+  | -- | An SPDX License List Short Form Identifier with a unary"+" operator suffix to represent the current version of the license or any later version.  For example: @GPL-2.0+@+    ELicenseIdPlus LicenseId+  | -- | A SPDX user defined license reference: For example: @LicenseRef-23@, @LicenseRef-MIT-Style-1@, or @DocumentRef-spdx-tool-1.2:LicenseRef-MIT-Style-2@+    ELicenseRef LicenseRef+  deriving (Show, Read, Eq, Ord, Data, Generic)  simpleLicenseExpression :: LicenseId -> LicenseExpression simpleLicenseExpression i = ELicense (ELicenseId i) Nothing@@ -63,41 +64,42 @@ instance Structured LicenseExpression  instance Pretty LicenseExpression where-    pretty = go 0-      where-        go :: Int -> LicenseExpression -> Disp.Doc-        go _ (ELicense lic exc) =-            let doc = pretty lic-            in maybe id (\e d -> d <+> Disp.text "WITH" <+> pretty e) exc doc-        go d (EAnd e1 e2) = parens (d < 0) $ go 0 e1 <+> Disp.text "AND" <+> go 0 e2-        go d (EOr  e1 e2) = parens (d < 1) $ go 1 e1 <+> Disp.text "OR" <+> go 1 e2-+  pretty = go 0+    where+      go :: Int -> LicenseExpression -> Disp.Doc+      go _ (ELicense lic exc) =+        let doc = pretty lic+         in maybe id (\e d -> d <+> Disp.text "WITH" <+> pretty e) exc doc+      go d (EAnd e1 e2) = parens (d < 0) $ go 0 e1 <+> Disp.text "AND" <+> go 0 e2+      go d (EOr e1 e2) = parens (d < 1) $ go 1 e1 <+> Disp.text "OR" <+> go 1 e2 -        parens False doc = doc-        parens True  doc = Disp.parens doc+      parens False doc = doc+      parens True doc = Disp.parens doc  instance Pretty SimpleLicenseExpression where-    pretty (ELicenseId i)     = pretty i-    pretty (ELicenseIdPlus i) = pretty i <<>> Disp.char '+'-    pretty (ELicenseRef r)    = pretty r+  pretty (ELicenseId i) = pretty i+  pretty (ELicenseIdPlus i) = pretty i <<>> Disp.char '+'+  pretty (ELicenseRef r) = pretty r  instance Parsec SimpleLicenseExpression where-    parsec = idstring >>= simple where-        simple n-            | Just l <- "LicenseRef-" `isPrefixOfMaybe` n =-                maybe (fail $ "Incorrect LicenseRef format: " ++ n) (return . ELicenseRef) $ mkLicenseRef Nothing l-            | Just d <- "DocumentRef-" `isPrefixOfMaybe` n = do-                _ <- P.string ":LicenseRef-"-                l <- idstring-                maybe (fail $ "Incorrect LicenseRef format:" ++ n) (return . ELicenseRef) $ mkLicenseRef (Just d) l-            | otherwise = do-                v <- askCabalSpecVersion-                l <- maybe (fail $ "Unknown SPDX license identifier: '" ++  n ++ "' " ++ licenseIdMigrationMessage n) return $-                    mkLicenseId (cabalSpecVersionToSPDXListVersion v) n-                orLater <- isJust <$> P.optional (P.char '+')-                if orLater-                then return (ELicenseIdPlus l)-                else return (ELicenseId l)+  parsec = idstring >>= simple+    where+      simple n+        | Just l <- "LicenseRef-" `isPrefixOfMaybe` n =+            maybe (fail $ "Incorrect LicenseRef format: " ++ n) (return . ELicenseRef) $ mkLicenseRef Nothing l+        | Just d <- "DocumentRef-" `isPrefixOfMaybe` n = do+            _ <- P.string ":LicenseRef-"+            l <- idstring+            maybe (fail $ "Incorrect LicenseRef format:" ++ n) (return . ELicenseRef) $ mkLicenseRef (Just d) l+        | otherwise = do+            v <- askCabalSpecVersion+            l <-+              maybe (fail $ "Unknown SPDX license identifier: '" ++ n ++ "' " ++ licenseIdMigrationMessage n) return $+                mkLicenseId (cabalSpecVersionToSPDXListVersion v) n+            orLater <- isJust <$> P.optional (P.char '+')+            if orLater+              then return (ELicenseIdPlus l)+              else return (ELicenseId l)  idstring :: P.CharParsing m => m String idstring = P.munch1 $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'@@ -105,43 +107,43 @@ -- returns suffix part isPrefixOfMaybe :: Eq a => [a] -> [a] -> Maybe [a] isPrefixOfMaybe pfx s-    | pfx `isPrefixOf` s = Just (drop (length pfx) s)-    | otherwise          = Nothing+  | pfx `isPrefixOf` s = Just (drop (length pfx) s)+  | otherwise = Nothing  instance Parsec LicenseExpression where-    parsec = expr-      where-        expr = compoundOr+  parsec = expr+    where+      expr = compoundOr -        simple = do-            s <- parsec-            exc <- exception-            return $ ELicense s exc+      simple = do+        s <- parsec+        exc <- exception+        return $ ELicense s exc -        exception = P.optional $ P.try (spaces1 *> P.string "WITH" *> spaces1) *> parsec+      exception = P.optional $ P.try (spaces1 *> P.string "WITH" *> spaces1) *> parsec -        compoundOr = do-            x <- compoundAnd-            l <- P.optional $ P.try (spaces1 *> P.string "OR" *> spaces1) *> compoundOr-            return $ maybe id (flip EOr) l x+      compoundOr = do+        x <- compoundAnd+        l <- P.optional $ P.try (spaces1 *> P.string "OR" *> spaces1) *> compoundOr+        return $ maybe id (flip EOr) l x -        compoundAnd = do-            x <- compound-            l <- P.optional $ P.try (spaces1 *> P.string "AND" *> spaces1) *> compoundAnd-            return $ maybe id (flip EAnd) l x+      compoundAnd = do+        x <- compound+        l <- P.optional $ P.try (spaces1 *> P.string "AND" *> spaces1) *> compoundAnd+        return $ maybe id (flip EAnd) l x -        compound = braces <|> simple+      compound = braces <|> simple -        -- NOTE: we require that there's a space around AND & OR operators,-        -- i.e. @(MIT)AND(MIT)@ will cause parse-error.-        braces = do-            _ <- P.char '('-            _ <- P.spaces-            x <- expr-            _ <- P.char ')'-            return x+      -- NOTE: we require that there's a space around AND & OR operators,+      -- i.e. @(MIT)AND(MIT)@ will cause parse-error.+      braces = do+        _ <- P.char '('+        _ <- P.spaces+        x <- expr+        _ <- P.char ')'+        return x -        spaces1 = P.space *> P.spaces+      spaces1 = P.space *> P.spaces  -- notes: --@@ -152,11 +154,11 @@ -- We handle that by having greedy 'idstring' parser, so MITAND would parse as invalid license identifier.  instance NFData LicenseExpression where-    rnf (ELicense s e) = rnf s `seq` rnf e-    rnf (EAnd x y)     = rnf x `seq` rnf y-    rnf (EOr x y)      = rnf x `seq` rnf y+  rnf (ELicense s e) = rnf s `seq` rnf e+  rnf (EAnd x y) = rnf x `seq` rnf y+  rnf (EOr x y) = rnf x `seq` rnf y  instance NFData SimpleLicenseExpression where-    rnf (ELicenseId i)     = rnf i-    rnf (ELicenseIdPlus i) = rnf i-    rnf (ELicenseRef r)    = rnf r+  rnf (ELicenseId i) = rnf i+  rnf (ELicenseIdPlus i) = rnf i+  rnf (ELicenseRef r) = rnf r
src/Distribution/SPDX/LicenseId.hs view
@@ -1,2315 +1,3888 @@ -- This file is generated. See Makefile's spdx rule-{-# LANGUAGE DeriveDataTypeable #-}-module Distribution.SPDX.LicenseId (-    LicenseId (..),-    licenseId,-    licenseName,-    licenseIsOsiApproved,-    licenseIsFsfLibre,-    mkLicenseId,-    licenseIdList,-    -- * Helpers-    licenseIdMigrationMessage,-    ) where--import Distribution.Compat.Prelude-import Prelude ()--import Distribution.Compat.Lens (set)-import Distribution.Pretty-import Distribution.Parsec-import Distribution.Utils.Generic (isAsciiAlphaNum)-import Distribution.Utils.Structured (Structured (..), nominalStructure, typeVersion)-import Distribution.SPDX.LicenseListVersion--import qualified Data.Binary.Get as Binary-import qualified Data.Binary.Put as Binary-import qualified Data.Map.Strict as Map-import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint as Disp------------------------------------------------------------------------------------ LicenseId------------------------------------------------------------------------------------ | SPDX License identifiers list v3.16-data LicenseId-    = NullBSD -- ^ @0BSD@, BSD Zero Clause License-    | AAL -- ^ @AAL@, Attribution Assurance License-    | Abstyles -- ^ @Abstyles@, Abstyles License-    | Adobe_2006 -- ^ @Adobe-2006@, Adobe Systems Incorporated Source Code License Agreement-    | Adobe_Glyph -- ^ @Adobe-Glyph@, Adobe Glyph List License-    | ADSL -- ^ @ADSL@, Amazon Digital Services License-    | AFL_1_1 -- ^ @AFL-1.1@, Academic Free License v1.1-    | AFL_1_2 -- ^ @AFL-1.2@, Academic Free License v1.2-    | AFL_2_0 -- ^ @AFL-2.0@, Academic Free License v2.0-    | AFL_2_1 -- ^ @AFL-2.1@, Academic Free License v2.1-    | AFL_3_0 -- ^ @AFL-3.0@, Academic Free License v3.0-    | Afmparse -- ^ @Afmparse@, Afmparse License-    | AGPL_1_0 -- ^ @AGPL-1.0@, Affero General Public License v1.0, SPDX License List 3.0-    | AGPL_1_0_only -- ^ @AGPL-1.0-only@, Affero General Public License v1.0 only, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | AGPL_1_0_or_later -- ^ @AGPL-1.0-or-later@, Affero General Public License v1.0 or later, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | AGPL_3_0_only -- ^ @AGPL-3.0-only@, GNU Affero General Public License v3.0 only-    | AGPL_3_0_or_later -- ^ @AGPL-3.0-or-later@, GNU Affero General Public License v3.0 or later-    | Aladdin -- ^ @Aladdin@, Aladdin Free Public License-    | AMDPLPA -- ^ @AMDPLPA@, AMD's plpa_map.c License-    | AML -- ^ @AML@, Apple MIT License-    | AMPAS -- ^ @AMPAS@, Academy of Motion Picture Arts and Sciences BSD-    | ANTLR_PD_fallback -- ^ @ANTLR-PD-fallback@, ANTLR Software Rights Notice with license fallback, SPDX License List 3.16-    | ANTLR_PD -- ^ @ANTLR-PD@, ANTLR Software Rights Notice-    | Apache_1_0 -- ^ @Apache-1.0@, Apache License 1.0-    | Apache_1_1 -- ^ @Apache-1.1@, Apache License 1.1-    | Apache_2_0 -- ^ @Apache-2.0@, Apache License 2.0-    | APAFML -- ^ @APAFML@, Adobe Postscript AFM License-    | APL_1_0 -- ^ @APL-1.0@, Adaptive Public License 1.0-    | App_s2p -- ^ @App-s2p@, App::s2p License, SPDX License List 3.16-    | APSL_1_0 -- ^ @APSL-1.0@, Apple Public Source License 1.0-    | APSL_1_1 -- ^ @APSL-1.1@, Apple Public Source License 1.1-    | APSL_1_2 -- ^ @APSL-1.2@, Apple Public Source License 1.2-    | APSL_2_0 -- ^ @APSL-2.0@, Apple Public Source License 2.0-    | Artistic_1_0_cl8 -- ^ @Artistic-1.0-cl8@, Artistic License 1.0 w/clause 8-    | Artistic_1_0_Perl -- ^ @Artistic-1.0-Perl@, Artistic License 1.0 (Perl)-    | Artistic_1_0 -- ^ @Artistic-1.0@, Artistic License 1.0-    | Artistic_2_0 -- ^ @Artistic-2.0@, Artistic License 2.0-    | Bahyph -- ^ @Bahyph@, Bahyph License-    | Barr -- ^ @Barr@, Barr License-    | Beerware -- ^ @Beerware@, Beerware License-    | BitTorrent_1_0 -- ^ @BitTorrent-1.0@, BitTorrent Open Source License v1.0-    | BitTorrent_1_1 -- ^ @BitTorrent-1.1@, BitTorrent Open Source License v1.1-    | Blessing -- ^ @blessing@, SQLite Blessing, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | BlueOak_1_0_0 -- ^ @BlueOak-1.0.0@, Blue Oak Model License 1.0.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Borceux -- ^ @Borceux@, Borceux license-    | BSD_1_Clause -- ^ @BSD-1-Clause@, BSD 1-Clause License-    | BSD_2_Clause_FreeBSD -- ^ @BSD-2-Clause-FreeBSD@, BSD 2-Clause FreeBSD License, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9-    | BSD_2_Clause_NetBSD -- ^ @BSD-2-Clause-NetBSD@, BSD 2-Clause NetBSD License, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6-    | BSD_2_Clause_Patent -- ^ @BSD-2-Clause-Patent@, BSD-2-Clause Plus Patent License-    | BSD_2_Clause_Views -- ^ @BSD-2-Clause-Views@, BSD 2-Clause with views sentence, SPDX License List 3.10, SPDX License List 3.16-    | BSD_2_Clause -- ^ @BSD-2-Clause@, BSD 2-Clause "Simplified" License-    | BSD_3_Clause_Attribution -- ^ @BSD-3-Clause-Attribution@, BSD with attribution-    | BSD_3_Clause_Clear -- ^ @BSD-3-Clause-Clear@, BSD 3-Clause Clear License-    | BSD_3_Clause_LBNL -- ^ @BSD-3-Clause-LBNL@, Lawrence Berkeley National Labs BSD variant license-    | BSD_3_Clause_Modification -- ^ @BSD-3-Clause-Modification@, BSD 3-Clause Modification, SPDX License List 3.16-    | BSD_3_Clause_No_Military_License -- ^ @BSD-3-Clause-No-Military-License@, BSD 3-Clause No Military License, SPDX License List 3.16-    | BSD_3_Clause_No_Nuclear_License_2014 -- ^ @BSD-3-Clause-No-Nuclear-License-2014@, BSD 3-Clause No Nuclear License 2014-    | BSD_3_Clause_No_Nuclear_License -- ^ @BSD-3-Clause-No-Nuclear-License@, BSD 3-Clause No Nuclear License-    | BSD_3_Clause_No_Nuclear_Warranty -- ^ @BSD-3-Clause-No-Nuclear-Warranty@, BSD 3-Clause No Nuclear Warranty-    | BSD_3_Clause_Open_MPI -- ^ @BSD-3-Clause-Open-MPI@, BSD 3-Clause Open MPI variant, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | BSD_3_Clause -- ^ @BSD-3-Clause@, BSD 3-Clause "New" or "Revised" License-    | BSD_4_Clause_Shortened -- ^ @BSD-4-Clause-Shortened@, BSD 4 Clause Shortened, SPDX License List 3.16-    | BSD_4_Clause_UC -- ^ @BSD-4-Clause-UC@, BSD-4-Clause (University of California-Specific)-    | BSD_4_Clause -- ^ @BSD-4-Clause@, BSD 4-Clause "Original" or "Old" License-    | BSD_Protection -- ^ @BSD-Protection@, BSD Protection License-    | BSD_Source_Code -- ^ @BSD-Source-Code@, BSD Source Code Attribution-    | BSL_1_0 -- ^ @BSL-1.0@, Boost Software License 1.0-    | Bzip2_1_0_5 -- ^ @bzip2-1.0.5@, bzip2 and libbzip2 License v1.0.5, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10-    | BUSL_1_1 -- ^ @BUSL-1.1@, Business Source License 1.1, SPDX License List 3.16-    | Bzip2_1_0_6 -- ^ @bzip2-1.0.6@, bzip2 and libbzip2 License v1.0.6-    | C_UDA_1_0 -- ^ @C-UDA-1.0@, Computational Use of Data Agreement v1.0, SPDX License List 3.16-    | CAL_1_0_Combined_Work_Exception -- ^ @CAL-1.0-Combined-Work-Exception@, Cryptographic Autonomy License 1.0 (Combined Work Exception), SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CAL_1_0 -- ^ @CAL-1.0@, Cryptographic Autonomy License 1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Caldera -- ^ @Caldera@, Caldera License-    | CATOSL_1_1 -- ^ @CATOSL-1.1@, Computer Associates Trusted Open Source License 1.1-    | CC_BY_1_0 -- ^ @CC-BY-1.0@, Creative Commons Attribution 1.0 Generic-    | CC_BY_2_0 -- ^ @CC-BY-2.0@, Creative Commons Attribution 2.0 Generic-    | CC_BY_2_5_AU -- ^ @CC-BY-2.5-AU@, Creative Commons Attribution 2.5 Australia, SPDX License List 3.16-    | CC_BY_2_5 -- ^ @CC-BY-2.5@, Creative Commons Attribution 2.5 Generic-    | CC_BY_3_0_AT -- ^ @CC-BY-3.0-AT@, Creative Commons Attribution 3.0 Austria, SPDX License List 3.10, SPDX License List 3.16-    | CC_BY_3_0_DE -- ^ @CC-BY-3.0-DE@, Creative Commons Attribution 3.0 Germany, SPDX License List 3.16-    | CC_BY_3_0_NL -- ^ @CC-BY-3.0-NL@, Creative Commons Attribution 3.0 Netherlands, SPDX License List 3.16-    | CC_BY_3_0_US -- ^ @CC-BY-3.0-US@, Creative Commons Attribution 3.0 United States, SPDX License List 3.16-    | CC_BY_3_0 -- ^ @CC-BY-3.0@, Creative Commons Attribution 3.0 Unported-    | CC_BY_4_0 -- ^ @CC-BY-4.0@, Creative Commons Attribution 4.0 International-    | CC_BY_NC_1_0 -- ^ @CC-BY-NC-1.0@, Creative Commons Attribution Non Commercial 1.0 Generic-    | CC_BY_NC_2_0 -- ^ @CC-BY-NC-2.0@, Creative Commons Attribution Non Commercial 2.0 Generic-    | CC_BY_NC_2_5 -- ^ @CC-BY-NC-2.5@, Creative Commons Attribution Non Commercial 2.5 Generic-    | CC_BY_NC_3_0_DE -- ^ @CC-BY-NC-3.0-DE@, Creative Commons Attribution Non Commercial 3.0 Germany, SPDX License List 3.16-    | CC_BY_NC_3_0 -- ^ @CC-BY-NC-3.0@, Creative Commons Attribution Non Commercial 3.0 Unported-    | CC_BY_NC_4_0 -- ^ @CC-BY-NC-4.0@, Creative Commons Attribution Non Commercial 4.0 International-    | CC_BY_NC_ND_1_0 -- ^ @CC-BY-NC-ND-1.0@, Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic-    | CC_BY_NC_ND_2_0 -- ^ @CC-BY-NC-ND-2.0@, Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic-    | CC_BY_NC_ND_2_5 -- ^ @CC-BY-NC-ND-2.5@, Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic-    | CC_BY_NC_ND_3_0_DE -- ^ @CC-BY-NC-ND-3.0-DE@, Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany, SPDX License List 3.16-    | CC_BY_NC_ND_3_0_IGO -- ^ @CC-BY-NC-ND-3.0-IGO@, Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO, SPDX License List 3.10, SPDX License List 3.16-    | CC_BY_NC_ND_3_0 -- ^ @CC-BY-NC-ND-3.0@, Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported-    | CC_BY_NC_ND_4_0 -- ^ @CC-BY-NC-ND-4.0@, Creative Commons Attribution Non Commercial No Derivatives 4.0 International-    | CC_BY_NC_SA_1_0 -- ^ @CC-BY-NC-SA-1.0@, Creative Commons Attribution Non Commercial Share Alike 1.0 Generic-    | CC_BY_NC_SA_2_0_FR -- ^ @CC-BY-NC-SA-2.0-FR@, Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France, SPDX License List 3.16-    | CC_BY_NC_SA_2_0_UK -- ^ @CC-BY-NC-SA-2.0-UK@, Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales, SPDX License List 3.16-    | CC_BY_NC_SA_2_0 -- ^ @CC-BY-NC-SA-2.0@, Creative Commons Attribution Non Commercial Share Alike 2.0 Generic-    | CC_BY_NC_SA_2_5 -- ^ @CC-BY-NC-SA-2.5@, Creative Commons Attribution Non Commercial Share Alike 2.5 Generic-    | CC_BY_NC_SA_3_0_DE -- ^ @CC-BY-NC-SA-3.0-DE@, Creative Commons Attribution Non Commercial Share Alike 3.0 Germany, SPDX License List 3.16-    | CC_BY_NC_SA_3_0_IGO -- ^ @CC-BY-NC-SA-3.0-IGO@, Creative Commons Attribution Non Commercial Share Alike 3.0 IGO, SPDX License List 3.16-    | CC_BY_NC_SA_3_0 -- ^ @CC-BY-NC-SA-3.0@, Creative Commons Attribution Non Commercial Share Alike 3.0 Unported-    | CC_BY_NC_SA_4_0 -- ^ @CC-BY-NC-SA-4.0@, Creative Commons Attribution Non Commercial Share Alike 4.0 International-    | CC_BY_ND_1_0 -- ^ @CC-BY-ND-1.0@, Creative Commons Attribution No Derivatives 1.0 Generic-    | CC_BY_ND_2_0 -- ^ @CC-BY-ND-2.0@, Creative Commons Attribution No Derivatives 2.0 Generic-    | CC_BY_ND_2_5 -- ^ @CC-BY-ND-2.5@, Creative Commons Attribution No Derivatives 2.5 Generic-    | CC_BY_ND_3_0_DE -- ^ @CC-BY-ND-3.0-DE@, Creative Commons Attribution No Derivatives 3.0 Germany, SPDX License List 3.16-    | CC_BY_ND_3_0 -- ^ @CC-BY-ND-3.0@, Creative Commons Attribution No Derivatives 3.0 Unported-    | CC_BY_ND_4_0 -- ^ @CC-BY-ND-4.0@, Creative Commons Attribution No Derivatives 4.0 International-    | CC_BY_SA_1_0 -- ^ @CC-BY-SA-1.0@, Creative Commons Attribution Share Alike 1.0 Generic-    | CC_BY_SA_2_0_UK -- ^ @CC-BY-SA-2.0-UK@, Creative Commons Attribution Share Alike 2.0 England and Wales, SPDX License List 3.16-    | CC_BY_SA_2_0 -- ^ @CC-BY-SA-2.0@, Creative Commons Attribution Share Alike 2.0 Generic-    | CC_BY_SA_2_1_JP -- ^ @CC-BY-SA-2.1-JP@, Creative Commons Attribution Share Alike 2.1 Japan, SPDX License List 3.16-    | CC_BY_SA_2_5 -- ^ @CC-BY-SA-2.5@, Creative Commons Attribution Share Alike 2.5 Generic-    | CC_BY_SA_3_0_AT -- ^ @CC-BY-SA-3.0-AT@, Creative Commons Attribution Share Alike 3.0 Austria, SPDX License List 3.10, SPDX License List 3.16-    | CC_BY_SA_3_0_DE -- ^ @CC-BY-SA-3.0-DE@, Creative Commons Attribution Share Alike 3.0 Germany, SPDX License List 3.16-    | CC_BY_SA_3_0 -- ^ @CC-BY-SA-3.0@, Creative Commons Attribution Share Alike 3.0 Unported-    | CC_BY_SA_4_0 -- ^ @CC-BY-SA-4.0@, Creative Commons Attribution Share Alike 4.0 International-    | CC_PDDC -- ^ @CC-PDDC@, Creative Commons Public Domain Dedication and Certification, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CC0_1_0 -- ^ @CC0-1.0@, Creative Commons Zero v1.0 Universal-    | CDDL_1_0 -- ^ @CDDL-1.0@, Common Development and Distribution License 1.0-    | CDDL_1_1 -- ^ @CDDL-1.1@, Common Development and Distribution License 1.1-    | CDL_1_0 -- ^ @CDL-1.0@, Common Documentation License 1.0, SPDX License List 3.16-    | CDLA_Permissive_1_0 -- ^ @CDLA-Permissive-1.0@, Community Data License Agreement Permissive 1.0-    | CDLA_Permissive_2_0 -- ^ @CDLA-Permissive-2.0@, Community Data License Agreement Permissive 2.0, SPDX License List 3.16-    | CDLA_Sharing_1_0 -- ^ @CDLA-Sharing-1.0@, Community Data License Agreement Sharing 1.0-    | CECILL_1_0 -- ^ @CECILL-1.0@, CeCILL Free Software License Agreement v1.0-    | CECILL_1_1 -- ^ @CECILL-1.1@, CeCILL Free Software License Agreement v1.1-    | CECILL_2_0 -- ^ @CECILL-2.0@, CeCILL Free Software License Agreement v2.0-    | CECILL_2_1 -- ^ @CECILL-2.1@, CeCILL Free Software License Agreement v2.1-    | CECILL_B -- ^ @CECILL-B@, CeCILL-B Free Software License Agreement-    | CECILL_C -- ^ @CECILL-C@, CeCILL-C Free Software License Agreement-    | CERN_OHL_1_1 -- ^ @CERN-OHL-1.1@, CERN Open Hardware Licence v1.1, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CERN_OHL_1_2 -- ^ @CERN-OHL-1.2@, CERN Open Hardware Licence v1.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CERN_OHL_P_2_0 -- ^ @CERN-OHL-P-2.0@, CERN Open Hardware Licence Version 2 - Permissive, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CERN_OHL_S_2_0 -- ^ @CERN-OHL-S-2.0@, CERN Open Hardware Licence Version 2 - Strongly Reciprocal, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CERN_OHL_W_2_0 -- ^ @CERN-OHL-W-2.0@, CERN Open Hardware Licence Version 2 - Weakly Reciprocal, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | ClArtistic -- ^ @ClArtistic@, Clarified Artistic License-    | CNRI_Jython -- ^ @CNRI-Jython@, CNRI Jython License-    | CNRI_Python_GPL_Compatible -- ^ @CNRI-Python-GPL-Compatible@, CNRI Python Open Source GPL Compatible License Agreement-    | CNRI_Python -- ^ @CNRI-Python@, CNRI Python License-    | COIL_1_0 -- ^ @COIL-1.0@, Copyfree Open Innovation License, SPDX License List 3.16-    | Community_Spec_1_0 -- ^ @Community-Spec-1.0@, Community Specification License 1.0, SPDX License List 3.16-    | Condor_1_1 -- ^ @Condor-1.1@, Condor Public License v1.1-    | Copyleft_next_0_3_0 -- ^ @copyleft-next-0.3.0@, copyleft-next 0.3.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Copyleft_next_0_3_1 -- ^ @copyleft-next-0.3.1@, copyleft-next 0.3.1, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | CPAL_1_0 -- ^ @CPAL-1.0@, Common Public Attribution License 1.0-    | CPL_1_0 -- ^ @CPL-1.0@, Common Public License 1.0-    | CPOL_1_02 -- ^ @CPOL-1.02@, Code Project Open License 1.02-    | Crossword -- ^ @Crossword@, Crossword License-    | CrystalStacker -- ^ @CrystalStacker@, CrystalStacker License-    | CUA_OPL_1_0 -- ^ @CUA-OPL-1.0@, CUA Office Public License v1.0-    | Cube -- ^ @Cube@, Cube License-    | Curl -- ^ @curl@, curl License-    | D_FSL_1_0 -- ^ @D-FSL-1.0@, Deutsche Freie Software Lizenz-    | Diffmark -- ^ @diffmark@, diffmark license-    | DL_DE_BY_2_0 -- ^ @DL-DE-BY-2.0@, Data licence Germany – attribution – version 2.0, SPDX License List 3.16-    | DOC -- ^ @DOC@, DOC License-    | Dotseqn -- ^ @Dotseqn@, Dotseqn License-    | DRL_1_0 -- ^ @DRL-1.0@, Detection Rule License 1.0, SPDX License List 3.16-    | DSDP -- ^ @DSDP@, DSDP License-    | Dvipdfm -- ^ @dvipdfm@, dvipdfm License-    | ECL_1_0 -- ^ @ECL-1.0@, Educational Community License v1.0-    | ECL_2_0 -- ^ @ECL-2.0@, Educational Community License v2.0-    | EFL_1_0 -- ^ @EFL-1.0@, Eiffel Forum License v1.0-    | EFL_2_0 -- ^ @EFL-2.0@, Eiffel Forum License v2.0-    | EGenix -- ^ @eGenix@, eGenix.com Public License 1.1.0-    | Elastic_2_0 -- ^ @Elastic-2.0@, Elastic License 2.0, SPDX License List 3.16-    | Entessa -- ^ @Entessa@, Entessa Public License v1.0-    | EPICS -- ^ @EPICS@, EPICS Open License, SPDX License List 3.10, SPDX License List 3.16-    | EPL_1_0 -- ^ @EPL-1.0@, Eclipse Public License 1.0-    | EPL_2_0 -- ^ @EPL-2.0@, Eclipse Public License 2.0-    | ErlPL_1_1 -- ^ @ErlPL-1.1@, Erlang Public License v1.1-    | Etalab_2_0 -- ^ @etalab-2.0@, Etalab Open License 2.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | EUDatagrid -- ^ @EUDatagrid@, EU DataGrid Software License-    | EUPL_1_0 -- ^ @EUPL-1.0@, European Union Public License 1.0-    | EUPL_1_1 -- ^ @EUPL-1.1@, European Union Public License 1.1-    | EUPL_1_2 -- ^ @EUPL-1.2@, European Union Public License 1.2-    | Eurosym -- ^ @Eurosym@, Eurosym License-    | Fair -- ^ @Fair@, Fair License-    | FDK_AAC -- ^ @FDK-AAC@, Fraunhofer FDK AAC Codec Library, SPDX License List 3.16-    | Frameworx_1_0 -- ^ @Frameworx-1.0@, Frameworx Open License 1.0-    | FreeBSD_DOC -- ^ @FreeBSD-DOC@, FreeBSD Documentation License, SPDX License List 3.16-    | FreeImage -- ^ @FreeImage@, FreeImage Public License v1.0-    | FSFAP -- ^ @FSFAP@, FSF All Permissive License-    | FSFULLR -- ^ @FSFULLR@, FSF Unlimited License (with License Retention)-    | FSFUL -- ^ @FSFUL@, FSF Unlimited License-    | FTL -- ^ @FTL@, Freetype Project License-    | GD -- ^ @GD@, GD License, SPDX License List 3.16-    | GFDL_1_1_invariants_only -- ^ @GFDL-1.1-invariants-only@, GNU Free Documentation License v1.1 only - invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_1_invariants_or_later -- ^ @GFDL-1.1-invariants-or-later@, GNU Free Documentation License v1.1 or later - invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_1_no_invariants_only -- ^ @GFDL-1.1-no-invariants-only@, GNU Free Documentation License v1.1 only - no invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_1_no_invariants_or_later -- ^ @GFDL-1.1-no-invariants-or-later@, GNU Free Documentation License v1.1 or later - no invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_1_only -- ^ @GFDL-1.1-only@, GNU Free Documentation License v1.1 only-    | GFDL_1_1_or_later -- ^ @GFDL-1.1-or-later@, GNU Free Documentation License v1.1 or later-    | GFDL_1_2_invariants_only -- ^ @GFDL-1.2-invariants-only@, GNU Free Documentation License v1.2 only - invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_2_invariants_or_later -- ^ @GFDL-1.2-invariants-or-later@, GNU Free Documentation License v1.2 or later - invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_2_no_invariants_only -- ^ @GFDL-1.2-no-invariants-only@, GNU Free Documentation License v1.2 only - no invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_2_no_invariants_or_later -- ^ @GFDL-1.2-no-invariants-or-later@, GNU Free Documentation License v1.2 or later - no invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_2_only -- ^ @GFDL-1.2-only@, GNU Free Documentation License v1.2 only-    | GFDL_1_2_or_later -- ^ @GFDL-1.2-or-later@, GNU Free Documentation License v1.2 or later-    | GFDL_1_3_invariants_only -- ^ @GFDL-1.3-invariants-only@, GNU Free Documentation License v1.3 only - invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_3_invariants_or_later -- ^ @GFDL-1.3-invariants-or-later@, GNU Free Documentation License v1.3 or later - invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_3_no_invariants_only -- ^ @GFDL-1.3-no-invariants-only@, GNU Free Documentation License v1.3 only - no invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_3_no_invariants_or_later -- ^ @GFDL-1.3-no-invariants-or-later@, GNU Free Documentation License v1.3 or later - no invariants, SPDX License List 3.10, SPDX License List 3.16-    | GFDL_1_3_only -- ^ @GFDL-1.3-only@, GNU Free Documentation License v1.3 only-    | GFDL_1_3_or_later -- ^ @GFDL-1.3-or-later@, GNU Free Documentation License v1.3 or later-    | Giftware -- ^ @Giftware@, Giftware License-    | GL2PS -- ^ @GL2PS@, GL2PS License-    | Glide -- ^ @Glide@, 3dfx Glide License-    | Glulxe -- ^ @Glulxe@, Glulxe License-    | GLWTPL -- ^ @GLWTPL@, Good Luck With That Public License, SPDX License List 3.10, SPDX License List 3.16-    | Gnuplot -- ^ @gnuplot@, gnuplot License-    | GPL_1_0_only -- ^ @GPL-1.0-only@, GNU General Public License v1.0 only-    | GPL_1_0_or_later -- ^ @GPL-1.0-or-later@, GNU General Public License v1.0 or later-    | GPL_2_0_only -- ^ @GPL-2.0-only@, GNU General Public License v2.0 only-    | GPL_2_0_or_later -- ^ @GPL-2.0-or-later@, GNU General Public License v2.0 or later-    | GPL_3_0_only -- ^ @GPL-3.0-only@, GNU General Public License v3.0 only-    | GPL_3_0_or_later -- ^ @GPL-3.0-or-later@, GNU General Public License v3.0 or later-    | GSOAP_1_3b -- ^ @gSOAP-1.3b@, gSOAP Public License v1.3b-    | HaskellReport -- ^ @HaskellReport@, Haskell Language Report License-    | Hippocratic_2_1 -- ^ @Hippocratic-2.1@, Hippocratic License 2.1, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | HPND_sell_variant -- ^ @HPND-sell-variant@, Historical Permission Notice and Disclaimer - sell variant, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | HPND -- ^ @HPND@, Historical Permission Notice and Disclaimer-    | HTMLTIDY -- ^ @HTMLTIDY@, HTML Tidy License, SPDX License List 3.16-    | IBM_pibs -- ^ @IBM-pibs@, IBM PowerPC Initialization and Boot Software-    | ICU -- ^ @ICU@, ICU License-    | IJG -- ^ @IJG@, Independent JPEG Group License-    | ImageMagick -- ^ @ImageMagick@, ImageMagick License-    | IMatix -- ^ @iMatix@, iMatix Standard Function Library Agreement-    | Imlib2 -- ^ @Imlib2@, Imlib2 License-    | Info_ZIP -- ^ @Info-ZIP@, Info-ZIP License-    | Intel_ACPI -- ^ @Intel-ACPI@, Intel ACPI Software License Agreement-    | Intel -- ^ @Intel@, Intel Open Source License-    | Interbase_1_0 -- ^ @Interbase-1.0@, Interbase Public License v1.0-    | IPA -- ^ @IPA@, IPA Font License-    | IPL_1_0 -- ^ @IPL-1.0@, IBM Public License v1.0-    | ISC -- ^ @ISC@, ISC License-    | Jam -- ^ @Jam@, Jam License, SPDX License List 3.16-    | JasPer_2_0 -- ^ @JasPer-2.0@, JasPer License-    | JPNIC -- ^ @JPNIC@, Japan Network Information Center License, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | JSON -- ^ @JSON@, JSON License-    | LAL_1_2 -- ^ @LAL-1.2@, Licence Art Libre 1.2-    | LAL_1_3 -- ^ @LAL-1.3@, Licence Art Libre 1.3-    | Latex2e -- ^ @Latex2e@, Latex2e License-    | Leptonica -- ^ @Leptonica@, Leptonica License-    | LGPL_2_0_only -- ^ @LGPL-2.0-only@, GNU Library General Public License v2 only-    | LGPL_2_0_or_later -- ^ @LGPL-2.0-or-later@, GNU Library General Public License v2 or later-    | LGPL_2_1_only -- ^ @LGPL-2.1-only@, GNU Lesser General Public License v2.1 only-    | LGPL_2_1_or_later -- ^ @LGPL-2.1-or-later@, GNU Lesser General Public License v2.1 or later-    | LGPL_3_0_only -- ^ @LGPL-3.0-only@, GNU Lesser General Public License v3.0 only-    | LGPL_3_0_or_later -- ^ @LGPL-3.0-or-later@, GNU Lesser General Public License v3.0 or later-    | LGPLLR -- ^ @LGPLLR@, Lesser General Public License For Linguistic Resources-    | Libpng_2_0 -- ^ @libpng-2.0@, PNG Reference Library version 2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Libpng -- ^ @Libpng@, libpng License-    | Libselinux_1_0 -- ^ @libselinux-1.0@, libselinux public domain notice, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Libtiff -- ^ @libtiff@, libtiff License-    | LiLiQ_P_1_1 -- ^ @LiLiQ-P-1.1@, Licence Libre du Québec – Permissive version 1.1-    | LiLiQ_R_1_1 -- ^ @LiLiQ-R-1.1@, Licence Libre du Québec – Réciprocité version 1.1-    | LiLiQ_Rplus_1_1 -- ^ @LiLiQ-Rplus-1.1@, Licence Libre du Québec – Réciprocité forte version 1.1-    | Linux_man_pages_copyleft -- ^ @Linux-man-pages-copyleft@, Linux man-pages Copyleft, SPDX License List 3.16-    | Linux_OpenIB -- ^ @Linux-OpenIB@, Linux Kernel Variant of OpenIB.org license, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | LPL_1_02 -- ^ @LPL-1.02@, Lucent Public License v1.02-    | LPL_1_0 -- ^ @LPL-1.0@, Lucent Public License Version 1.0-    | LPPL_1_0 -- ^ @LPPL-1.0@, LaTeX Project Public License v1.0-    | LPPL_1_1 -- ^ @LPPL-1.1@, LaTeX Project Public License v1.1-    | LPPL_1_2 -- ^ @LPPL-1.2@, LaTeX Project Public License v1.2-    | LPPL_1_3a -- ^ @LPPL-1.3a@, LaTeX Project Public License v1.3a-    | LPPL_1_3c -- ^ @LPPL-1.3c@, LaTeX Project Public License v1.3c-    | MakeIndex -- ^ @MakeIndex@, MakeIndex License-    | MirOS -- ^ @MirOS@, The MirOS Licence-    | MIT_0 -- ^ @MIT-0@, MIT No Attribution, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | MIT_advertising -- ^ @MIT-advertising@, Enlightenment License (e16)-    | MIT_CMU -- ^ @MIT-CMU@, CMU License-    | MIT_enna -- ^ @MIT-enna@, enna License-    | MIT_feh -- ^ @MIT-feh@, feh License-    | MIT_Modern_Variant -- ^ @MIT-Modern-Variant@, MIT License Modern Variant, SPDX License List 3.16-    | MIT_open_group -- ^ @MIT-open-group@, MIT Open Group variant, SPDX License List 3.16-    | MITNFA -- ^ @MITNFA@, MIT +no-false-attribs license-    | MIT -- ^ @MIT@, MIT License-    | Motosoto -- ^ @Motosoto@, Motosoto License-    | Mpich2 -- ^ @mpich2@, mpich2 License-    | MPL_1_0 -- ^ @MPL-1.0@, Mozilla Public License 1.0-    | MPL_1_1 -- ^ @MPL-1.1@, Mozilla Public License 1.1-    | MPL_2_0_no_copyleft_exception -- ^ @MPL-2.0-no-copyleft-exception@, Mozilla Public License 2.0 (no copyleft exception)-    | MPL_2_0 -- ^ @MPL-2.0@, Mozilla Public License 2.0-    | MS_PL -- ^ @MS-PL@, Microsoft Public License-    | MS_RL -- ^ @MS-RL@, Microsoft Reciprocal License-    | MTLL -- ^ @MTLL@, Matrix Template Library License-    | MulanPSL_1_0 -- ^ @MulanPSL-1.0@, Mulan Permissive Software License, Version 1, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | MulanPSL_2_0 -- ^ @MulanPSL-2.0@, Mulan Permissive Software License, Version 2, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Multics -- ^ @Multics@, Multics License-    | Mup -- ^ @Mup@, Mup License-    | NAIST_2003 -- ^ @NAIST-2003@, Nara Institute of Science and Technology License (2003), SPDX License List 3.16-    | NASA_1_3 -- ^ @NASA-1.3@, NASA Open Source Agreement 1.3-    | Naumen -- ^ @Naumen@, Naumen Public License-    | NBPL_1_0 -- ^ @NBPL-1.0@, Net Boolean Public License v1-    | NCGL_UK_2_0 -- ^ @NCGL-UK-2.0@, Non-Commercial Government Licence, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | NCSA -- ^ @NCSA@, University of Illinois/NCSA Open Source License-    | Net_SNMP -- ^ @Net-SNMP@, Net-SNMP License-    | NetCDF -- ^ @NetCDF@, NetCDF license-    | Newsletr -- ^ @Newsletr@, Newsletr License-    | NGPL -- ^ @NGPL@, Nethack General Public License-    | NIST_PD_fallback -- ^ @NIST-PD-fallback@, NIST Public Domain Notice with license fallback, SPDX License List 3.10, SPDX License List 3.16-    | NIST_PD -- ^ @NIST-PD@, NIST Public Domain Notice, SPDX License List 3.10, SPDX License List 3.16-    | NLOD_1_0 -- ^ @NLOD-1.0@, Norwegian Licence for Open Government Data (NLOD) 1.0-    | NLOD_2_0 -- ^ @NLOD-2.0@, Norwegian Licence for Open Government Data (NLOD) 2.0, SPDX License List 3.16-    | NLPL -- ^ @NLPL@, No Limit Public License-    | Nokia -- ^ @Nokia@, Nokia Open Source License-    | NOSL -- ^ @NOSL@, Netizen Open Source License-    | Noweb -- ^ @Noweb@, Noweb License-    | NPL_1_0 -- ^ @NPL-1.0@, Netscape Public License v1.0-    | NPL_1_1 -- ^ @NPL-1.1@, Netscape Public License v1.1-    | NPOSL_3_0 -- ^ @NPOSL-3.0@, Non-Profit Open Software License 3.0-    | NRL -- ^ @NRL@, NRL License-    | NTP_0 -- ^ @NTP-0@, NTP No Attribution, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | NTP -- ^ @NTP@, NTP License-    | O_UDA_1_0 -- ^ @O-UDA-1.0@, Open Use of Data Agreement v1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OCCT_PL -- ^ @OCCT-PL@, Open CASCADE Technology Public License-    | OCLC_2_0 -- ^ @OCLC-2.0@, OCLC Research Public License 2.0-    | ODbL_1_0 -- ^ @ODbL-1.0@, Open Data Commons Open Database License v1.0-    | ODC_By_1_0 -- ^ @ODC-By-1.0@, Open Data Commons Attribution License v1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OFL_1_0_no_RFN -- ^ @OFL-1.0-no-RFN@, SIL Open Font License 1.0 with no Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OFL_1_0_RFN -- ^ @OFL-1.0-RFN@, SIL Open Font License 1.0 with Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OFL_1_0 -- ^ @OFL-1.0@, SIL Open Font License 1.0-    | OFL_1_1_no_RFN -- ^ @OFL-1.1-no-RFN@, SIL Open Font License 1.1 with no Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OFL_1_1_RFN -- ^ @OFL-1.1-RFN@, SIL Open Font License 1.1 with Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OFL_1_1 -- ^ @OFL-1.1@, SIL Open Font License 1.1-    | OGC_1_0 -- ^ @OGC-1.0@, OGC Software License, Version 1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OGDL_Taiwan_1_0 -- ^ @OGDL-Taiwan-1.0@, Taiwan Open Government Data License, version 1.0, SPDX License List 3.16-    | OGL_Canada_2_0 -- ^ @OGL-Canada-2.0@, Open Government Licence - Canada, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OGL_UK_1_0 -- ^ @OGL-UK-1.0@, Open Government Licence v1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OGL_UK_2_0 -- ^ @OGL-UK-2.0@, Open Government Licence v2.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OGL_UK_3_0 -- ^ @OGL-UK-3.0@, Open Government Licence v3.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | OGTSL -- ^ @OGTSL@, Open Group Test Suite License-    | OLDAP_1_1 -- ^ @OLDAP-1.1@, Open LDAP Public License v1.1-    | OLDAP_1_2 -- ^ @OLDAP-1.2@, Open LDAP Public License v1.2-    | OLDAP_1_3 -- ^ @OLDAP-1.3@, Open LDAP Public License v1.3-    | OLDAP_1_4 -- ^ @OLDAP-1.4@, Open LDAP Public License v1.4-    | OLDAP_2_0_1 -- ^ @OLDAP-2.0.1@, Open LDAP Public License v2.0.1-    | OLDAP_2_0 -- ^ @OLDAP-2.0@, Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)-    | OLDAP_2_1 -- ^ @OLDAP-2.1@, Open LDAP Public License v2.1-    | OLDAP_2_2_1 -- ^ @OLDAP-2.2.1@, Open LDAP Public License v2.2.1-    | OLDAP_2_2_2 -- ^ @OLDAP-2.2.2@, Open LDAP Public License 2.2.2-    | OLDAP_2_2 -- ^ @OLDAP-2.2@, Open LDAP Public License v2.2-    | OLDAP_2_3 -- ^ @OLDAP-2.3@, Open LDAP Public License v2.3-    | OLDAP_2_4 -- ^ @OLDAP-2.4@, Open LDAP Public License v2.4-    | OLDAP_2_5 -- ^ @OLDAP-2.5@, Open LDAP Public License v2.5-    | OLDAP_2_6 -- ^ @OLDAP-2.6@, Open LDAP Public License v2.6-    | OLDAP_2_7 -- ^ @OLDAP-2.7@, Open LDAP Public License v2.7-    | OLDAP_2_8 -- ^ @OLDAP-2.8@, Open LDAP Public License v2.8-    | OML -- ^ @OML@, Open Market License-    | OpenSSL -- ^ @OpenSSL@, OpenSSL License-    | OPL_1_0 -- ^ @OPL-1.0@, Open Public License v1.0-    | OPUBL_1_0 -- ^ @OPUBL-1.0@, Open Publication License v1.0, SPDX License List 3.16-    | OSET_PL_2_1 -- ^ @OSET-PL-2.1@, OSET Public License version 2.1-    | OSL_1_0 -- ^ @OSL-1.0@, Open Software License 1.0-    | OSL_1_1 -- ^ @OSL-1.1@, Open Software License 1.1-    | OSL_2_0 -- ^ @OSL-2.0@, Open Software License 2.0-    | OSL_2_1 -- ^ @OSL-2.1@, Open Software License 2.1-    | OSL_3_0 -- ^ @OSL-3.0@, Open Software License 3.0-    | Parity_6_0_0 -- ^ @Parity-6.0.0@, The Parity Public License 6.0.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Parity_7_0_0 -- ^ @Parity-7.0.0@, The Parity Public License 7.0.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | PDDL_1_0 -- ^ @PDDL-1.0@, Open Data Commons Public Domain Dedication & License 1.0-    | PHP_3_01 -- ^ @PHP-3.01@, PHP License v3.01-    | PHP_3_0 -- ^ @PHP-3.0@, PHP License v3.0-    | Plexus -- ^ @Plexus@, Plexus Classworlds License-    | PolyForm_Noncommercial_1_0_0 -- ^ @PolyForm-Noncommercial-1.0.0@, PolyForm Noncommercial License 1.0.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | PolyForm_Small_Business_1_0_0 -- ^ @PolyForm-Small-Business-1.0.0@, PolyForm Small Business License 1.0.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | PostgreSQL -- ^ @PostgreSQL@, PostgreSQL License-    | PSF_2_0 -- ^ @PSF-2.0@, Python Software Foundation License 2.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Psfrag -- ^ @psfrag@, psfrag License-    | Psutils -- ^ @psutils@, psutils License-    | Python_2_0 -- ^ @Python-2.0@, Python License 2.0-    | Qhull -- ^ @Qhull@, Qhull License-    | QPL_1_0 -- ^ @QPL-1.0@, Q Public License 1.0-    | Rdisc -- ^ @Rdisc@, Rdisc License-    | RHeCos_1_1 -- ^ @RHeCos-1.1@, Red Hat eCos Public License v1.1-    | RPL_1_1 -- ^ @RPL-1.1@, Reciprocal Public License 1.1-    | RPL_1_5 -- ^ @RPL-1.5@, Reciprocal Public License 1.5-    | RPSL_1_0 -- ^ @RPSL-1.0@, RealNetworks Public Source License v1.0-    | RSA_MD -- ^ @RSA-MD@, RSA Message-Digest License-    | RSCPL -- ^ @RSCPL@, Ricoh Source Code Public License-    | Ruby -- ^ @Ruby@, Ruby License-    | SAX_PD -- ^ @SAX-PD@, Sax Public Domain Notice-    | Saxpath -- ^ @Saxpath@, Saxpath License-    | SCEA -- ^ @SCEA@, SCEA Shared Source License-    | SchemeReport -- ^ @SchemeReport@, Scheme Language Report License, SPDX License List 3.16-    | Sendmail_8_23 -- ^ @Sendmail-8.23@, Sendmail License 8.23, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Sendmail -- ^ @Sendmail@, Sendmail License-    | SGI_B_1_0 -- ^ @SGI-B-1.0@, SGI Free Software License B v1.0-    | SGI_B_1_1 -- ^ @SGI-B-1.1@, SGI Free Software License B v1.1-    | SGI_B_2_0 -- ^ @SGI-B-2.0@, SGI Free Software License B v2.0-    | SHL_0_51 -- ^ @SHL-0.51@, Solderpad Hardware License, Version 0.51, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | SHL_0_5 -- ^ @SHL-0.5@, Solderpad Hardware License v0.5, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | SimPL_2_0 -- ^ @SimPL-2.0@, Simple Public License 2.0-    | SISSL_1_2 -- ^ @SISSL-1.2@, Sun Industry Standards Source License v1.2-    | SISSL -- ^ @SISSL@, Sun Industry Standards Source License v1.1-    | Sleepycat -- ^ @Sleepycat@, Sleepycat License-    | SMLNJ -- ^ @SMLNJ@, Standard ML of New Jersey License-    | SMPPL -- ^ @SMPPL@, Secure Messaging Protocol Public License-    | SNIA -- ^ @SNIA@, SNIA Public License 1.1-    | Spencer_86 -- ^ @Spencer-86@, Spencer License 86-    | Spencer_94 -- ^ @Spencer-94@, Spencer License 94-    | Spencer_99 -- ^ @Spencer-99@, Spencer License 99-    | SPL_1_0 -- ^ @SPL-1.0@, Sun Public License v1.0-    | SSH_OpenSSH -- ^ @SSH-OpenSSH@, SSH OpenSSH license, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | SSH_short -- ^ @SSH-short@, SSH short notice, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | SSPL_1_0 -- ^ @SSPL-1.0@, Server Side Public License, v 1, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | SugarCRM_1_1_3 -- ^ @SugarCRM-1.1.3@, SugarCRM Public License v1.1.3-    | SWL -- ^ @SWL@, Scheme Widget Library (SWL) Software License Agreement-    | TAPR_OHL_1_0 -- ^ @TAPR-OHL-1.0@, TAPR Open Hardware License v1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | TCL -- ^ @TCL@, TCL/TK License-    | TCP_wrappers -- ^ @TCP-wrappers@, TCP Wrappers License-    | TMate -- ^ @TMate@, TMate Open Source License-    | TORQUE_1_1 -- ^ @TORQUE-1.1@, TORQUE v2.5+ Software License v1.1-    | TOSL -- ^ @TOSL@, Trusster Open Source License-    | TU_Berlin_1_0 -- ^ @TU-Berlin-1.0@, Technische Universitaet Berlin License 1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | TU_Berlin_2_0 -- ^ @TU-Berlin-2.0@, Technische Universitaet Berlin License 2.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | UCL_1_0 -- ^ @UCL-1.0@, Upstream Compatibility License v1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16-    | Unicode_DFS_2015 -- ^ @Unicode-DFS-2015@, Unicode License Agreement - Data Files and Software (2015)-    | Unicode_DFS_2016 -- ^ @Unicode-DFS-2016@, Unicode License Agreement - Data Files and Software (2016)-    | Unicode_TOU -- ^ @Unicode-TOU@, Unicode Terms of Use-    | Unlicense -- ^ @Unlicense@, The Unlicense-    | UPL_1_0 -- ^ @UPL-1.0@, Universal Permissive License v1.0-    | Vim -- ^ @Vim@, Vim License-    | VOSTROM -- ^ @VOSTROM@, VOSTROM Public License for Open Source-    | VSL_1_0 -- ^ @VSL-1.0@, Vovida Software License v1.0-    | W3C_19980720 -- ^ @W3C-19980720@, W3C Software Notice and License (1998-07-20)-    | W3C_20150513 -- ^ @W3C-20150513@, W3C Software Notice and Document License (2015-05-13)-    | W3C -- ^ @W3C@, W3C Software Notice and License (2002-12-31)-    | Watcom_1_0 -- ^ @Watcom-1.0@, Sybase Open Watcom Public License 1.0-    | Wsuipa -- ^ @Wsuipa@, Wsuipa License-    | WTFPL -- ^ @WTFPL@, Do What The F*ck You Want To Public License-    | X11_distribute_modifications_variant -- ^ @X11-distribute-modifications-variant@, X11 License Distribution Modification Variant, SPDX License List 3.16-    | X11 -- ^ @X11@, X11 License-    | Xerox -- ^ @Xerox@, Xerox License-    | XFree86_1_1 -- ^ @XFree86-1.1@, XFree86 License 1.1-    | Xinetd -- ^ @xinetd@, xinetd License-    | Xnet -- ^ @Xnet@, X.Net License-    | Xpp -- ^ @xpp@, XPP License-    | XSkat -- ^ @XSkat@, XSkat License-    | YPL_1_0 -- ^ @YPL-1.0@, Yahoo! Public License v1.0-    | YPL_1_1 -- ^ @YPL-1.1@, Yahoo! Public License v1.1-    | Zed -- ^ @Zed@, Zed License-    | Zend_2_0 -- ^ @Zend-2.0@, Zend License v2.0-    | Zimbra_1_3 -- ^ @Zimbra-1.3@, Zimbra Public License v1.3-    | Zimbra_1_4 -- ^ @Zimbra-1.4@, Zimbra Public License v1.4-    | Zlib_acknowledgement -- ^ @zlib-acknowledgement@, zlib/libpng License with Acknowledgement-    | Zlib -- ^ @Zlib@, zlib License-    | ZPL_1_1 -- ^ @ZPL-1.1@, Zope Public License 1.1-    | ZPL_2_0 -- ^ @ZPL-2.0@, Zope Public License 2.0-    | ZPL_2_1 -- ^ @ZPL-2.1@, Zope Public License 2.1-  deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data)--instance Binary LicenseId where-    -- Word16 is encoded in big endianess-    -- https://github.com/kolmodin/binary/blob/master/src/Data/Binary/Class.hs#L220-LL227-    put = Binary.putWord16be . fromIntegral . fromEnum-    get = do-        i <- Binary.getWord16be-        if i > fromIntegral (fromEnum (maxBound :: LicenseId))-        then fail "Too large LicenseId tag"-        else return (toEnum (fromIntegral i))---- note: remember to bump version each time the definition changes-instance Structured LicenseId where-    structure p = set typeVersion 306 $ nominalStructure p--instance Pretty LicenseId where-    pretty = Disp.text . licenseId---- |--- >>> eitherParsec "BSD-3-Clause" :: Either String LicenseId--- Right BSD_3_Clause------ >>> eitherParsec "BSD3" :: Either String LicenseId--- Left "...Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?"----instance Parsec LicenseId where-    parsec = do-        n <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'-        v <- askCabalSpecVersion-        maybe (fail $ "Unknown SPDX license identifier: '" ++  n ++ "' " ++ licenseIdMigrationMessage n) return $-            mkLicenseId (cabalSpecVersionToSPDXListVersion v) n--instance NFData LicenseId where-    rnf l = l `seq` ()---- | Help message for migrating from non-SPDX license identifiers.------ Old 'License' is almost SPDX, except for 'BSD2', 'BSD3'. This function--- suggests SPDX variant:------ >>> licenseIdMigrationMessage "BSD3"--- "Do you mean BSD-3-Clause?"------ Also 'OtherLicense', 'AllRightsReserved', and 'PublicDomain' aren't--- valid SPDX identifiers------ >>> traverse_ (print . licenseIdMigrationMessage) [ "OtherLicense", "AllRightsReserved", "PublicDomain" ]--- "SPDX license list contains plenty of licenses. See https://spdx.org/licenses/. Also they can be combined into complex expressions with AND and OR."--- "You can use NONE as a value of license field."--- "Public Domain is a complex matter. See https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files. Consider using a proper license."------ SPDX License list version 3.0 introduced "-only" and "-or-later" variants for GNU family of licenses.--- See <https://spdx.org/news/news/2018/01/license-list-30-released>--- >>> licenseIdMigrationMessage "GPL-2.0"--- "SPDX license list 3.0 deprecated suffixless variants of GNU family of licenses. Use GPL-2.0-only or GPL-2.0-or-later."------ For other common licenses their old license format coincides with the SPDX identifiers:------ >>> traverse eitherParsec ["GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "MIT", "ISC", "MPL-2.0", "Apache-2.0"] :: Either String [LicenseId]--- Right [GPL_2_0_only,GPL_3_0_only,LGPL_2_1_only,MIT,ISC,MPL_2_0,Apache_2_0]----licenseIdMigrationMessage :: String -> String-licenseIdMigrationMessage = go where-    go l | gnuVariant l    = "SPDX license list 3.0 deprecated suffixless variants of GNU family of licenses. Use " ++ l ++ "-only or " ++ l ++ "-or-later."-    go "BSD3"              = "Do you mean BSD-3-Clause?"-    go "BSD2"              = "Do you mean BSD-2-Clause?"-    go "AllRightsReserved" = "You can use NONE as a value of license field."-    go "OtherLicense"      = "SPDX license list contains plenty of licenses. See https://spdx.org/licenses/. Also they can be combined into complex expressions with AND and OR."-    go "PublicDomain"      = "Public Domain is a complex matter. See https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files. Consider using a proper license."--    -- otherwise, we don't know-    go _ = ""--    gnuVariant = flip elem ["GPL-2.0", "GPL-3.0", "LGPL-2.1", "LGPL-3.0", "AGPL-3.0" ]------------------------------------------------------------------------------------ License Data------------------------------------------------------------------------------------ | License SPDX identifier, e.g. @"BSD-3-Clause"@.-licenseId :: LicenseId -> String-licenseId NullBSD = "0BSD"-licenseId AAL = "AAL"-licenseId Abstyles = "Abstyles"-licenseId Adobe_2006 = "Adobe-2006"-licenseId Adobe_Glyph = "Adobe-Glyph"-licenseId ADSL = "ADSL"-licenseId AFL_1_1 = "AFL-1.1"-licenseId AFL_1_2 = "AFL-1.2"-licenseId AFL_2_0 = "AFL-2.0"-licenseId AFL_2_1 = "AFL-2.1"-licenseId AFL_3_0 = "AFL-3.0"-licenseId Afmparse = "Afmparse"-licenseId AGPL_1_0 = "AGPL-1.0"-licenseId AGPL_1_0_only = "AGPL-1.0-only"-licenseId AGPL_1_0_or_later = "AGPL-1.0-or-later"-licenseId AGPL_3_0_only = "AGPL-3.0-only"-licenseId AGPL_3_0_or_later = "AGPL-3.0-or-later"-licenseId Aladdin = "Aladdin"-licenseId AMDPLPA = "AMDPLPA"-licenseId AML = "AML"-licenseId AMPAS = "AMPAS"-licenseId ANTLR_PD_fallback = "ANTLR-PD-fallback"-licenseId ANTLR_PD = "ANTLR-PD"-licenseId Apache_1_0 = "Apache-1.0"-licenseId Apache_1_1 = "Apache-1.1"-licenseId Apache_2_0 = "Apache-2.0"-licenseId APAFML = "APAFML"-licenseId APL_1_0 = "APL-1.0"-licenseId App_s2p = "App-s2p"-licenseId APSL_1_0 = "APSL-1.0"-licenseId APSL_1_1 = "APSL-1.1"-licenseId APSL_1_2 = "APSL-1.2"-licenseId APSL_2_0 = "APSL-2.0"-licenseId Artistic_1_0_cl8 = "Artistic-1.0-cl8"-licenseId Artistic_1_0_Perl = "Artistic-1.0-Perl"-licenseId Artistic_1_0 = "Artistic-1.0"-licenseId Artistic_2_0 = "Artistic-2.0"-licenseId Bahyph = "Bahyph"-licenseId Barr = "Barr"-licenseId Beerware = "Beerware"-licenseId BitTorrent_1_0 = "BitTorrent-1.0"-licenseId BitTorrent_1_1 = "BitTorrent-1.1"-licenseId Blessing = "blessing"-licenseId BlueOak_1_0_0 = "BlueOak-1.0.0"-licenseId Borceux = "Borceux"-licenseId BSD_1_Clause = "BSD-1-Clause"-licenseId BSD_2_Clause_FreeBSD = "BSD-2-Clause-FreeBSD"-licenseId BSD_2_Clause_NetBSD = "BSD-2-Clause-NetBSD"-licenseId BSD_2_Clause_Patent = "BSD-2-Clause-Patent"-licenseId BSD_2_Clause_Views = "BSD-2-Clause-Views"-licenseId BSD_2_Clause = "BSD-2-Clause"-licenseId BSD_3_Clause_Attribution = "BSD-3-Clause-Attribution"-licenseId BSD_3_Clause_Clear = "BSD-3-Clause-Clear"-licenseId BSD_3_Clause_LBNL = "BSD-3-Clause-LBNL"-licenseId BSD_3_Clause_Modification = "BSD-3-Clause-Modification"-licenseId BSD_3_Clause_No_Military_License = "BSD-3-Clause-No-Military-License"-licenseId BSD_3_Clause_No_Nuclear_License_2014 = "BSD-3-Clause-No-Nuclear-License-2014"-licenseId BSD_3_Clause_No_Nuclear_License = "BSD-3-Clause-No-Nuclear-License"-licenseId BSD_3_Clause_No_Nuclear_Warranty = "BSD-3-Clause-No-Nuclear-Warranty"-licenseId BSD_3_Clause_Open_MPI = "BSD-3-Clause-Open-MPI"-licenseId BSD_3_Clause = "BSD-3-Clause"-licenseId BSD_4_Clause_Shortened = "BSD-4-Clause-Shortened"-licenseId BSD_4_Clause_UC = "BSD-4-Clause-UC"-licenseId BSD_4_Clause = "BSD-4-Clause"-licenseId BSD_Protection = "BSD-Protection"-licenseId BSD_Source_Code = "BSD-Source-Code"-licenseId BSL_1_0 = "BSL-1.0"-licenseId Bzip2_1_0_5 = "bzip2-1.0.5"-licenseId BUSL_1_1 = "BUSL-1.1"-licenseId Bzip2_1_0_6 = "bzip2-1.0.6"-licenseId C_UDA_1_0 = "C-UDA-1.0"-licenseId CAL_1_0_Combined_Work_Exception = "CAL-1.0-Combined-Work-Exception"-licenseId CAL_1_0 = "CAL-1.0"-licenseId Caldera = "Caldera"-licenseId CATOSL_1_1 = "CATOSL-1.1"-licenseId CC_BY_1_0 = "CC-BY-1.0"-licenseId CC_BY_2_0 = "CC-BY-2.0"-licenseId CC_BY_2_5_AU = "CC-BY-2.5-AU"-licenseId CC_BY_2_5 = "CC-BY-2.5"-licenseId CC_BY_3_0_AT = "CC-BY-3.0-AT"-licenseId CC_BY_3_0_DE = "CC-BY-3.0-DE"-licenseId CC_BY_3_0_NL = "CC-BY-3.0-NL"-licenseId CC_BY_3_0_US = "CC-BY-3.0-US"-licenseId CC_BY_3_0 = "CC-BY-3.0"-licenseId CC_BY_4_0 = "CC-BY-4.0"-licenseId CC_BY_NC_1_0 = "CC-BY-NC-1.0"-licenseId CC_BY_NC_2_0 = "CC-BY-NC-2.0"-licenseId CC_BY_NC_2_5 = "CC-BY-NC-2.5"-licenseId CC_BY_NC_3_0_DE = "CC-BY-NC-3.0-DE"-licenseId CC_BY_NC_3_0 = "CC-BY-NC-3.0"-licenseId CC_BY_NC_4_0 = "CC-BY-NC-4.0"-licenseId CC_BY_NC_ND_1_0 = "CC-BY-NC-ND-1.0"-licenseId CC_BY_NC_ND_2_0 = "CC-BY-NC-ND-2.0"-licenseId CC_BY_NC_ND_2_5 = "CC-BY-NC-ND-2.5"-licenseId CC_BY_NC_ND_3_0_DE = "CC-BY-NC-ND-3.0-DE"-licenseId CC_BY_NC_ND_3_0_IGO = "CC-BY-NC-ND-3.0-IGO"-licenseId CC_BY_NC_ND_3_0 = "CC-BY-NC-ND-3.0"-licenseId CC_BY_NC_ND_4_0 = "CC-BY-NC-ND-4.0"-licenseId CC_BY_NC_SA_1_0 = "CC-BY-NC-SA-1.0"-licenseId CC_BY_NC_SA_2_0_FR = "CC-BY-NC-SA-2.0-FR"-licenseId CC_BY_NC_SA_2_0_UK = "CC-BY-NC-SA-2.0-UK"-licenseId CC_BY_NC_SA_2_0 = "CC-BY-NC-SA-2.0"-licenseId CC_BY_NC_SA_2_5 = "CC-BY-NC-SA-2.5"-licenseId CC_BY_NC_SA_3_0_DE = "CC-BY-NC-SA-3.0-DE"-licenseId CC_BY_NC_SA_3_0_IGO = "CC-BY-NC-SA-3.0-IGO"-licenseId CC_BY_NC_SA_3_0 = "CC-BY-NC-SA-3.0"-licenseId CC_BY_NC_SA_4_0 = "CC-BY-NC-SA-4.0"-licenseId CC_BY_ND_1_0 = "CC-BY-ND-1.0"-licenseId CC_BY_ND_2_0 = "CC-BY-ND-2.0"-licenseId CC_BY_ND_2_5 = "CC-BY-ND-2.5"-licenseId CC_BY_ND_3_0_DE = "CC-BY-ND-3.0-DE"-licenseId CC_BY_ND_3_0 = "CC-BY-ND-3.0"-licenseId CC_BY_ND_4_0 = "CC-BY-ND-4.0"-licenseId CC_BY_SA_1_0 = "CC-BY-SA-1.0"-licenseId CC_BY_SA_2_0_UK = "CC-BY-SA-2.0-UK"-licenseId CC_BY_SA_2_0 = "CC-BY-SA-2.0"-licenseId CC_BY_SA_2_1_JP = "CC-BY-SA-2.1-JP"-licenseId CC_BY_SA_2_5 = "CC-BY-SA-2.5"-licenseId CC_BY_SA_3_0_AT = "CC-BY-SA-3.0-AT"-licenseId CC_BY_SA_3_0_DE = "CC-BY-SA-3.0-DE"-licenseId CC_BY_SA_3_0 = "CC-BY-SA-3.0"-licenseId CC_BY_SA_4_0 = "CC-BY-SA-4.0"-licenseId CC_PDDC = "CC-PDDC"-licenseId CC0_1_0 = "CC0-1.0"-licenseId CDDL_1_0 = "CDDL-1.0"-licenseId CDDL_1_1 = "CDDL-1.1"-licenseId CDL_1_0 = "CDL-1.0"-licenseId CDLA_Permissive_1_0 = "CDLA-Permissive-1.0"-licenseId CDLA_Permissive_2_0 = "CDLA-Permissive-2.0"-licenseId CDLA_Sharing_1_0 = "CDLA-Sharing-1.0"-licenseId CECILL_1_0 = "CECILL-1.0"-licenseId CECILL_1_1 = "CECILL-1.1"-licenseId CECILL_2_0 = "CECILL-2.0"-licenseId CECILL_2_1 = "CECILL-2.1"-licenseId CECILL_B = "CECILL-B"-licenseId CECILL_C = "CECILL-C"-licenseId CERN_OHL_1_1 = "CERN-OHL-1.1"-licenseId CERN_OHL_1_2 = "CERN-OHL-1.2"-licenseId CERN_OHL_P_2_0 = "CERN-OHL-P-2.0"-licenseId CERN_OHL_S_2_0 = "CERN-OHL-S-2.0"-licenseId CERN_OHL_W_2_0 = "CERN-OHL-W-2.0"-licenseId ClArtistic = "ClArtistic"-licenseId CNRI_Jython = "CNRI-Jython"-licenseId CNRI_Python_GPL_Compatible = "CNRI-Python-GPL-Compatible"-licenseId CNRI_Python = "CNRI-Python"-licenseId COIL_1_0 = "COIL-1.0"-licenseId Community_Spec_1_0 = "Community-Spec-1.0"-licenseId Condor_1_1 = "Condor-1.1"-licenseId Copyleft_next_0_3_0 = "copyleft-next-0.3.0"-licenseId Copyleft_next_0_3_1 = "copyleft-next-0.3.1"-licenseId CPAL_1_0 = "CPAL-1.0"-licenseId CPL_1_0 = "CPL-1.0"-licenseId CPOL_1_02 = "CPOL-1.02"-licenseId Crossword = "Crossword"-licenseId CrystalStacker = "CrystalStacker"-licenseId CUA_OPL_1_0 = "CUA-OPL-1.0"-licenseId Cube = "Cube"-licenseId Curl = "curl"-licenseId D_FSL_1_0 = "D-FSL-1.0"-licenseId Diffmark = "diffmark"-licenseId DL_DE_BY_2_0 = "DL-DE-BY-2.0"-licenseId DOC = "DOC"-licenseId Dotseqn = "Dotseqn"-licenseId DRL_1_0 = "DRL-1.0"-licenseId DSDP = "DSDP"-licenseId Dvipdfm = "dvipdfm"-licenseId ECL_1_0 = "ECL-1.0"-licenseId ECL_2_0 = "ECL-2.0"-licenseId EFL_1_0 = "EFL-1.0"-licenseId EFL_2_0 = "EFL-2.0"-licenseId EGenix = "eGenix"-licenseId Elastic_2_0 = "Elastic-2.0"-licenseId Entessa = "Entessa"-licenseId EPICS = "EPICS"-licenseId EPL_1_0 = "EPL-1.0"-licenseId EPL_2_0 = "EPL-2.0"-licenseId ErlPL_1_1 = "ErlPL-1.1"-licenseId Etalab_2_0 = "etalab-2.0"-licenseId EUDatagrid = "EUDatagrid"-licenseId EUPL_1_0 = "EUPL-1.0"-licenseId EUPL_1_1 = "EUPL-1.1"-licenseId EUPL_1_2 = "EUPL-1.2"-licenseId Eurosym = "Eurosym"-licenseId Fair = "Fair"-licenseId FDK_AAC = "FDK-AAC"-licenseId Frameworx_1_0 = "Frameworx-1.0"-licenseId FreeBSD_DOC = "FreeBSD-DOC"-licenseId FreeImage = "FreeImage"-licenseId FSFAP = "FSFAP"-licenseId FSFULLR = "FSFULLR"-licenseId FSFUL = "FSFUL"-licenseId FTL = "FTL"-licenseId GD = "GD"-licenseId GFDL_1_1_invariants_only = "GFDL-1.1-invariants-only"-licenseId GFDL_1_1_invariants_or_later = "GFDL-1.1-invariants-or-later"-licenseId GFDL_1_1_no_invariants_only = "GFDL-1.1-no-invariants-only"-licenseId GFDL_1_1_no_invariants_or_later = "GFDL-1.1-no-invariants-or-later"-licenseId GFDL_1_1_only = "GFDL-1.1-only"-licenseId GFDL_1_1_or_later = "GFDL-1.1-or-later"-licenseId GFDL_1_2_invariants_only = "GFDL-1.2-invariants-only"-licenseId GFDL_1_2_invariants_or_later = "GFDL-1.2-invariants-or-later"-licenseId GFDL_1_2_no_invariants_only = "GFDL-1.2-no-invariants-only"-licenseId GFDL_1_2_no_invariants_or_later = "GFDL-1.2-no-invariants-or-later"-licenseId GFDL_1_2_only = "GFDL-1.2-only"-licenseId GFDL_1_2_or_later = "GFDL-1.2-or-later"-licenseId GFDL_1_3_invariants_only = "GFDL-1.3-invariants-only"-licenseId GFDL_1_3_invariants_or_later = "GFDL-1.3-invariants-or-later"-licenseId GFDL_1_3_no_invariants_only = "GFDL-1.3-no-invariants-only"-licenseId GFDL_1_3_no_invariants_or_later = "GFDL-1.3-no-invariants-or-later"-licenseId GFDL_1_3_only = "GFDL-1.3-only"-licenseId GFDL_1_3_or_later = "GFDL-1.3-or-later"-licenseId Giftware = "Giftware"-licenseId GL2PS = "GL2PS"-licenseId Glide = "Glide"-licenseId Glulxe = "Glulxe"-licenseId GLWTPL = "GLWTPL"-licenseId Gnuplot = "gnuplot"-licenseId GPL_1_0_only = "GPL-1.0-only"-licenseId GPL_1_0_or_later = "GPL-1.0-or-later"-licenseId GPL_2_0_only = "GPL-2.0-only"-licenseId GPL_2_0_or_later = "GPL-2.0-or-later"-licenseId GPL_3_0_only = "GPL-3.0-only"-licenseId GPL_3_0_or_later = "GPL-3.0-or-later"-licenseId GSOAP_1_3b = "gSOAP-1.3b"-licenseId HaskellReport = "HaskellReport"-licenseId Hippocratic_2_1 = "Hippocratic-2.1"-licenseId HPND_sell_variant = "HPND-sell-variant"-licenseId HPND = "HPND"-licenseId HTMLTIDY = "HTMLTIDY"-licenseId IBM_pibs = "IBM-pibs"-licenseId ICU = "ICU"-licenseId IJG = "IJG"-licenseId ImageMagick = "ImageMagick"-licenseId IMatix = "iMatix"-licenseId Imlib2 = "Imlib2"-licenseId Info_ZIP = "Info-ZIP"-licenseId Intel_ACPI = "Intel-ACPI"-licenseId Intel = "Intel"-licenseId Interbase_1_0 = "Interbase-1.0"-licenseId IPA = "IPA"-licenseId IPL_1_0 = "IPL-1.0"-licenseId ISC = "ISC"-licenseId Jam = "Jam"-licenseId JasPer_2_0 = "JasPer-2.0"-licenseId JPNIC = "JPNIC"-licenseId JSON = "JSON"-licenseId LAL_1_2 = "LAL-1.2"-licenseId LAL_1_3 = "LAL-1.3"-licenseId Latex2e = "Latex2e"-licenseId Leptonica = "Leptonica"-licenseId LGPL_2_0_only = "LGPL-2.0-only"-licenseId LGPL_2_0_or_later = "LGPL-2.0-or-later"-licenseId LGPL_2_1_only = "LGPL-2.1-only"-licenseId LGPL_2_1_or_later = "LGPL-2.1-or-later"-licenseId LGPL_3_0_only = "LGPL-3.0-only"-licenseId LGPL_3_0_or_later = "LGPL-3.0-or-later"-licenseId LGPLLR = "LGPLLR"-licenseId Libpng_2_0 = "libpng-2.0"-licenseId Libpng = "Libpng"-licenseId Libselinux_1_0 = "libselinux-1.0"-licenseId Libtiff = "libtiff"-licenseId LiLiQ_P_1_1 = "LiLiQ-P-1.1"-licenseId LiLiQ_R_1_1 = "LiLiQ-R-1.1"-licenseId LiLiQ_Rplus_1_1 = "LiLiQ-Rplus-1.1"-licenseId Linux_man_pages_copyleft = "Linux-man-pages-copyleft"-licenseId Linux_OpenIB = "Linux-OpenIB"-licenseId LPL_1_02 = "LPL-1.02"-licenseId LPL_1_0 = "LPL-1.0"-licenseId LPPL_1_0 = "LPPL-1.0"-licenseId LPPL_1_1 = "LPPL-1.1"-licenseId LPPL_1_2 = "LPPL-1.2"-licenseId LPPL_1_3a = "LPPL-1.3a"-licenseId LPPL_1_3c = "LPPL-1.3c"-licenseId MakeIndex = "MakeIndex"-licenseId MirOS = "MirOS"-licenseId MIT_0 = "MIT-0"-licenseId MIT_advertising = "MIT-advertising"-licenseId MIT_CMU = "MIT-CMU"-licenseId MIT_enna = "MIT-enna"-licenseId MIT_feh = "MIT-feh"-licenseId MIT_Modern_Variant = "MIT-Modern-Variant"-licenseId MIT_open_group = "MIT-open-group"-licenseId MITNFA = "MITNFA"-licenseId MIT = "MIT"-licenseId Motosoto = "Motosoto"-licenseId Mpich2 = "mpich2"-licenseId MPL_1_0 = "MPL-1.0"-licenseId MPL_1_1 = "MPL-1.1"-licenseId MPL_2_0_no_copyleft_exception = "MPL-2.0-no-copyleft-exception"-licenseId MPL_2_0 = "MPL-2.0"-licenseId MS_PL = "MS-PL"-licenseId MS_RL = "MS-RL"-licenseId MTLL = "MTLL"-licenseId MulanPSL_1_0 = "MulanPSL-1.0"-licenseId MulanPSL_2_0 = "MulanPSL-2.0"-licenseId Multics = "Multics"-licenseId Mup = "Mup"-licenseId NAIST_2003 = "NAIST-2003"-licenseId NASA_1_3 = "NASA-1.3"-licenseId Naumen = "Naumen"-licenseId NBPL_1_0 = "NBPL-1.0"-licenseId NCGL_UK_2_0 = "NCGL-UK-2.0"-licenseId NCSA = "NCSA"-licenseId Net_SNMP = "Net-SNMP"-licenseId NetCDF = "NetCDF"-licenseId Newsletr = "Newsletr"-licenseId NGPL = "NGPL"-licenseId NIST_PD_fallback = "NIST-PD-fallback"-licenseId NIST_PD = "NIST-PD"-licenseId NLOD_1_0 = "NLOD-1.0"-licenseId NLOD_2_0 = "NLOD-2.0"-licenseId NLPL = "NLPL"-licenseId Nokia = "Nokia"-licenseId NOSL = "NOSL"-licenseId Noweb = "Noweb"-licenseId NPL_1_0 = "NPL-1.0"-licenseId NPL_1_1 = "NPL-1.1"-licenseId NPOSL_3_0 = "NPOSL-3.0"-licenseId NRL = "NRL"-licenseId NTP_0 = "NTP-0"-licenseId NTP = "NTP"-licenseId O_UDA_1_0 = "O-UDA-1.0"-licenseId OCCT_PL = "OCCT-PL"-licenseId OCLC_2_0 = "OCLC-2.0"-licenseId ODbL_1_0 = "ODbL-1.0"-licenseId ODC_By_1_0 = "ODC-By-1.0"-licenseId OFL_1_0_no_RFN = "OFL-1.0-no-RFN"-licenseId OFL_1_0_RFN = "OFL-1.0-RFN"-licenseId OFL_1_0 = "OFL-1.0"-licenseId OFL_1_1_no_RFN = "OFL-1.1-no-RFN"-licenseId OFL_1_1_RFN = "OFL-1.1-RFN"-licenseId OFL_1_1 = "OFL-1.1"-licenseId OGC_1_0 = "OGC-1.0"-licenseId OGDL_Taiwan_1_0 = "OGDL-Taiwan-1.0"-licenseId OGL_Canada_2_0 = "OGL-Canada-2.0"-licenseId OGL_UK_1_0 = "OGL-UK-1.0"-licenseId OGL_UK_2_0 = "OGL-UK-2.0"-licenseId OGL_UK_3_0 = "OGL-UK-3.0"-licenseId OGTSL = "OGTSL"-licenseId OLDAP_1_1 = "OLDAP-1.1"-licenseId OLDAP_1_2 = "OLDAP-1.2"-licenseId OLDAP_1_3 = "OLDAP-1.3"-licenseId OLDAP_1_4 = "OLDAP-1.4"-licenseId OLDAP_2_0_1 = "OLDAP-2.0.1"-licenseId OLDAP_2_0 = "OLDAP-2.0"-licenseId OLDAP_2_1 = "OLDAP-2.1"-licenseId OLDAP_2_2_1 = "OLDAP-2.2.1"-licenseId OLDAP_2_2_2 = "OLDAP-2.2.2"-licenseId OLDAP_2_2 = "OLDAP-2.2"-licenseId OLDAP_2_3 = "OLDAP-2.3"-licenseId OLDAP_2_4 = "OLDAP-2.4"-licenseId OLDAP_2_5 = "OLDAP-2.5"-licenseId OLDAP_2_6 = "OLDAP-2.6"-licenseId OLDAP_2_7 = "OLDAP-2.7"-licenseId OLDAP_2_8 = "OLDAP-2.8"-licenseId OML = "OML"-licenseId OpenSSL = "OpenSSL"-licenseId OPL_1_0 = "OPL-1.0"-licenseId OPUBL_1_0 = "OPUBL-1.0"-licenseId OSET_PL_2_1 = "OSET-PL-2.1"-licenseId OSL_1_0 = "OSL-1.0"-licenseId OSL_1_1 = "OSL-1.1"-licenseId OSL_2_0 = "OSL-2.0"-licenseId OSL_2_1 = "OSL-2.1"-licenseId OSL_3_0 = "OSL-3.0"-licenseId Parity_6_0_0 = "Parity-6.0.0"-licenseId Parity_7_0_0 = "Parity-7.0.0"-licenseId PDDL_1_0 = "PDDL-1.0"-licenseId PHP_3_01 = "PHP-3.01"-licenseId PHP_3_0 = "PHP-3.0"-licenseId Plexus = "Plexus"-licenseId PolyForm_Noncommercial_1_0_0 = "PolyForm-Noncommercial-1.0.0"-licenseId PolyForm_Small_Business_1_0_0 = "PolyForm-Small-Business-1.0.0"-licenseId PostgreSQL = "PostgreSQL"-licenseId PSF_2_0 = "PSF-2.0"-licenseId Psfrag = "psfrag"-licenseId Psutils = "psutils"-licenseId Python_2_0 = "Python-2.0"-licenseId Qhull = "Qhull"-licenseId QPL_1_0 = "QPL-1.0"-licenseId Rdisc = "Rdisc"-licenseId RHeCos_1_1 = "RHeCos-1.1"-licenseId RPL_1_1 = "RPL-1.1"-licenseId RPL_1_5 = "RPL-1.5"-licenseId RPSL_1_0 = "RPSL-1.0"-licenseId RSA_MD = "RSA-MD"-licenseId RSCPL = "RSCPL"-licenseId Ruby = "Ruby"-licenseId SAX_PD = "SAX-PD"-licenseId Saxpath = "Saxpath"-licenseId SCEA = "SCEA"-licenseId SchemeReport = "SchemeReport"-licenseId Sendmail_8_23 = "Sendmail-8.23"-licenseId Sendmail = "Sendmail"-licenseId SGI_B_1_0 = "SGI-B-1.0"-licenseId SGI_B_1_1 = "SGI-B-1.1"-licenseId SGI_B_2_0 = "SGI-B-2.0"-licenseId SHL_0_51 = "SHL-0.51"-licenseId SHL_0_5 = "SHL-0.5"-licenseId SimPL_2_0 = "SimPL-2.0"-licenseId SISSL_1_2 = "SISSL-1.2"-licenseId SISSL = "SISSL"-licenseId Sleepycat = "Sleepycat"-licenseId SMLNJ = "SMLNJ"-licenseId SMPPL = "SMPPL"-licenseId SNIA = "SNIA"-licenseId Spencer_86 = "Spencer-86"-licenseId Spencer_94 = "Spencer-94"-licenseId Spencer_99 = "Spencer-99"-licenseId SPL_1_0 = "SPL-1.0"-licenseId SSH_OpenSSH = "SSH-OpenSSH"-licenseId SSH_short = "SSH-short"-licenseId SSPL_1_0 = "SSPL-1.0"-licenseId SugarCRM_1_1_3 = "SugarCRM-1.1.3"-licenseId SWL = "SWL"-licenseId TAPR_OHL_1_0 = "TAPR-OHL-1.0"-licenseId TCL = "TCL"-licenseId TCP_wrappers = "TCP-wrappers"-licenseId TMate = "TMate"-licenseId TORQUE_1_1 = "TORQUE-1.1"-licenseId TOSL = "TOSL"-licenseId TU_Berlin_1_0 = "TU-Berlin-1.0"-licenseId TU_Berlin_2_0 = "TU-Berlin-2.0"-licenseId UCL_1_0 = "UCL-1.0"-licenseId Unicode_DFS_2015 = "Unicode-DFS-2015"-licenseId Unicode_DFS_2016 = "Unicode-DFS-2016"-licenseId Unicode_TOU = "Unicode-TOU"-licenseId Unlicense = "Unlicense"-licenseId UPL_1_0 = "UPL-1.0"-licenseId Vim = "Vim"-licenseId VOSTROM = "VOSTROM"-licenseId VSL_1_0 = "VSL-1.0"-licenseId W3C_19980720 = "W3C-19980720"-licenseId W3C_20150513 = "W3C-20150513"-licenseId W3C = "W3C"-licenseId Watcom_1_0 = "Watcom-1.0"-licenseId Wsuipa = "Wsuipa"-licenseId WTFPL = "WTFPL"-licenseId X11_distribute_modifications_variant = "X11-distribute-modifications-variant"-licenseId X11 = "X11"-licenseId Xerox = "Xerox"-licenseId XFree86_1_1 = "XFree86-1.1"-licenseId Xinetd = "xinetd"-licenseId Xnet = "Xnet"-licenseId Xpp = "xpp"-licenseId XSkat = "XSkat"-licenseId YPL_1_0 = "YPL-1.0"-licenseId YPL_1_1 = "YPL-1.1"-licenseId Zed = "Zed"-licenseId Zend_2_0 = "Zend-2.0"-licenseId Zimbra_1_3 = "Zimbra-1.3"-licenseId Zimbra_1_4 = "Zimbra-1.4"-licenseId Zlib_acknowledgement = "zlib-acknowledgement"-licenseId Zlib = "Zlib"-licenseId ZPL_1_1 = "ZPL-1.1"-licenseId ZPL_2_0 = "ZPL-2.0"-licenseId ZPL_2_1 = "ZPL-2.1"---- | License name, e.g. @"GNU General Public License v2.0 only"@-licenseName :: LicenseId -> String-licenseName NullBSD = "BSD Zero Clause License"-licenseName AAL = "Attribution Assurance License"-licenseName Abstyles = "Abstyles License"-licenseName Adobe_2006 = "Adobe Systems Incorporated Source Code License Agreement"-licenseName Adobe_Glyph = "Adobe Glyph List License"-licenseName ADSL = "Amazon Digital Services License"-licenseName AFL_1_1 = "Academic Free License v1.1"-licenseName AFL_1_2 = "Academic Free License v1.2"-licenseName AFL_2_0 = "Academic Free License v2.0"-licenseName AFL_2_1 = "Academic Free License v2.1"-licenseName AFL_3_0 = "Academic Free License v3.0"-licenseName Afmparse = "Afmparse License"-licenseName AGPL_1_0 = "Affero General Public License v1.0"-licenseName AGPL_1_0_only = "Affero General Public License v1.0 only"-licenseName AGPL_1_0_or_later = "Affero General Public License v1.0 or later"-licenseName AGPL_3_0_only = "GNU Affero General Public License v3.0 only"-licenseName AGPL_3_0_or_later = "GNU Affero General Public License v3.0 or later"-licenseName Aladdin = "Aladdin Free Public License"-licenseName AMDPLPA = "AMD's plpa_map.c License"-licenseName AML = "Apple MIT License"-licenseName AMPAS = "Academy of Motion Picture Arts and Sciences BSD"-licenseName ANTLR_PD_fallback = "ANTLR Software Rights Notice with license fallback"-licenseName ANTLR_PD = "ANTLR Software Rights Notice"-licenseName Apache_1_0 = "Apache License 1.0"-licenseName Apache_1_1 = "Apache License 1.1"-licenseName Apache_2_0 = "Apache License 2.0"-licenseName APAFML = "Adobe Postscript AFM License"-licenseName APL_1_0 = "Adaptive Public License 1.0"-licenseName App_s2p = "App::s2p License"-licenseName APSL_1_0 = "Apple Public Source License 1.0"-licenseName APSL_1_1 = "Apple Public Source License 1.1"-licenseName APSL_1_2 = "Apple Public Source License 1.2"-licenseName APSL_2_0 = "Apple Public Source License 2.0"-licenseName Artistic_1_0_cl8 = "Artistic License 1.0 w/clause 8"-licenseName Artistic_1_0_Perl = "Artistic License 1.0 (Perl)"-licenseName Artistic_1_0 = "Artistic License 1.0"-licenseName Artistic_2_0 = "Artistic License 2.0"-licenseName Bahyph = "Bahyph License"-licenseName Barr = "Barr License"-licenseName Beerware = "Beerware License"-licenseName BitTorrent_1_0 = "BitTorrent Open Source License v1.0"-licenseName BitTorrent_1_1 = "BitTorrent Open Source License v1.1"-licenseName Blessing = "SQLite Blessing"-licenseName BlueOak_1_0_0 = "Blue Oak Model License 1.0.0"-licenseName Borceux = "Borceux license"-licenseName BSD_1_Clause = "BSD 1-Clause License"-licenseName BSD_2_Clause_FreeBSD = "BSD 2-Clause FreeBSD License"-licenseName BSD_2_Clause_NetBSD = "BSD 2-Clause NetBSD License"-licenseName BSD_2_Clause_Patent = "BSD-2-Clause Plus Patent License"-licenseName BSD_2_Clause_Views = "BSD 2-Clause with views sentence"-licenseName BSD_2_Clause = "BSD 2-Clause \"Simplified\" License"-licenseName BSD_3_Clause_Attribution = "BSD with attribution"-licenseName BSD_3_Clause_Clear = "BSD 3-Clause Clear License"-licenseName BSD_3_Clause_LBNL = "Lawrence Berkeley National Labs BSD variant license"-licenseName BSD_3_Clause_Modification = "BSD 3-Clause Modification"-licenseName BSD_3_Clause_No_Military_License = "BSD 3-Clause No Military License"-licenseName BSD_3_Clause_No_Nuclear_License_2014 = "BSD 3-Clause No Nuclear License 2014"-licenseName BSD_3_Clause_No_Nuclear_License = "BSD 3-Clause No Nuclear License"-licenseName BSD_3_Clause_No_Nuclear_Warranty = "BSD 3-Clause No Nuclear Warranty"-licenseName BSD_3_Clause_Open_MPI = "BSD 3-Clause Open MPI variant"-licenseName BSD_3_Clause = "BSD 3-Clause \"New\" or \"Revised\" License"-licenseName BSD_4_Clause_Shortened = "BSD 4 Clause Shortened"-licenseName BSD_4_Clause_UC = "BSD-4-Clause (University of California-Specific)"-licenseName BSD_4_Clause = "BSD 4-Clause \"Original\" or \"Old\" License"-licenseName BSD_Protection = "BSD Protection License"-licenseName BSD_Source_Code = "BSD Source Code Attribution"-licenseName BSL_1_0 = "Boost Software License 1.0"-licenseName Bzip2_1_0_5 = "bzip2 and libbzip2 License v1.0.5"-licenseName BUSL_1_1 = "Business Source License 1.1"-licenseName Bzip2_1_0_6 = "bzip2 and libbzip2 License v1.0.6"-licenseName C_UDA_1_0 = "Computational Use of Data Agreement v1.0"-licenseName CAL_1_0_Combined_Work_Exception = "Cryptographic Autonomy License 1.0 (Combined Work Exception)"-licenseName CAL_1_0 = "Cryptographic Autonomy License 1.0"-licenseName Caldera = "Caldera License"-licenseName CATOSL_1_1 = "Computer Associates Trusted Open Source License 1.1"-licenseName CC_BY_1_0 = "Creative Commons Attribution 1.0 Generic"-licenseName CC_BY_2_0 = "Creative Commons Attribution 2.0 Generic"-licenseName CC_BY_2_5_AU = "Creative Commons Attribution 2.5 Australia"-licenseName CC_BY_2_5 = "Creative Commons Attribution 2.5 Generic"-licenseName CC_BY_3_0_AT = "Creative Commons Attribution 3.0 Austria"-licenseName CC_BY_3_0_DE = "Creative Commons Attribution 3.0 Germany"-licenseName CC_BY_3_0_NL = "Creative Commons Attribution 3.0 Netherlands"-licenseName CC_BY_3_0_US = "Creative Commons Attribution 3.0 United States"-licenseName CC_BY_3_0 = "Creative Commons Attribution 3.0 Unported"-licenseName CC_BY_4_0 = "Creative Commons Attribution 4.0 International"-licenseName CC_BY_NC_1_0 = "Creative Commons Attribution Non Commercial 1.0 Generic"-licenseName CC_BY_NC_2_0 = "Creative Commons Attribution Non Commercial 2.0 Generic"-licenseName CC_BY_NC_2_5 = "Creative Commons Attribution Non Commercial 2.5 Generic"-licenseName CC_BY_NC_3_0_DE = "Creative Commons Attribution Non Commercial 3.0 Germany"-licenseName CC_BY_NC_3_0 = "Creative Commons Attribution Non Commercial 3.0 Unported"-licenseName CC_BY_NC_4_0 = "Creative Commons Attribution Non Commercial 4.0 International"-licenseName CC_BY_NC_ND_1_0 = "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic"-licenseName CC_BY_NC_ND_2_0 = "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic"-licenseName CC_BY_NC_ND_2_5 = "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic"-licenseName CC_BY_NC_ND_3_0_DE = "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany"-licenseName CC_BY_NC_ND_3_0_IGO = "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO"-licenseName CC_BY_NC_ND_3_0 = "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported"-licenseName CC_BY_NC_ND_4_0 = "Creative Commons Attribution Non Commercial No Derivatives 4.0 International"-licenseName CC_BY_NC_SA_1_0 = "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic"-licenseName CC_BY_NC_SA_2_0_FR = "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France"-licenseName CC_BY_NC_SA_2_0_UK = "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales"-licenseName CC_BY_NC_SA_2_0 = "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic"-licenseName CC_BY_NC_SA_2_5 = "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic"-licenseName CC_BY_NC_SA_3_0_DE = "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany"-licenseName CC_BY_NC_SA_3_0_IGO = "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO"-licenseName CC_BY_NC_SA_3_0 = "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported"-licenseName CC_BY_NC_SA_4_0 = "Creative Commons Attribution Non Commercial Share Alike 4.0 International"-licenseName CC_BY_ND_1_0 = "Creative Commons Attribution No Derivatives 1.0 Generic"-licenseName CC_BY_ND_2_0 = "Creative Commons Attribution No Derivatives 2.0 Generic"-licenseName CC_BY_ND_2_5 = "Creative Commons Attribution No Derivatives 2.5 Generic"-licenseName CC_BY_ND_3_0_DE = "Creative Commons Attribution No Derivatives 3.0 Germany"-licenseName CC_BY_ND_3_0 = "Creative Commons Attribution No Derivatives 3.0 Unported"-licenseName CC_BY_ND_4_0 = "Creative Commons Attribution No Derivatives 4.0 International"-licenseName CC_BY_SA_1_0 = "Creative Commons Attribution Share Alike 1.0 Generic"-licenseName CC_BY_SA_2_0_UK = "Creative Commons Attribution Share Alike 2.0 England and Wales"-licenseName CC_BY_SA_2_0 = "Creative Commons Attribution Share Alike 2.0 Generic"-licenseName CC_BY_SA_2_1_JP = "Creative Commons Attribution Share Alike 2.1 Japan"-licenseName CC_BY_SA_2_5 = "Creative Commons Attribution Share Alike 2.5 Generic"-licenseName CC_BY_SA_3_0_AT = "Creative Commons Attribution Share Alike 3.0 Austria"-licenseName CC_BY_SA_3_0_DE = "Creative Commons Attribution Share Alike 3.0 Germany"-licenseName CC_BY_SA_3_0 = "Creative Commons Attribution Share Alike 3.0 Unported"-licenseName CC_BY_SA_4_0 = "Creative Commons Attribution Share Alike 4.0 International"-licenseName CC_PDDC = "Creative Commons Public Domain Dedication and Certification"-licenseName CC0_1_0 = "Creative Commons Zero v1.0 Universal"-licenseName CDDL_1_0 = "Common Development and Distribution License 1.0"-licenseName CDDL_1_1 = "Common Development and Distribution License 1.1"-licenseName CDL_1_0 = "Common Documentation License 1.0"-licenseName CDLA_Permissive_1_0 = "Community Data License Agreement Permissive 1.0"-licenseName CDLA_Permissive_2_0 = "Community Data License Agreement Permissive 2.0"-licenseName CDLA_Sharing_1_0 = "Community Data License Agreement Sharing 1.0"-licenseName CECILL_1_0 = "CeCILL Free Software License Agreement v1.0"-licenseName CECILL_1_1 = "CeCILL Free Software License Agreement v1.1"-licenseName CECILL_2_0 = "CeCILL Free Software License Agreement v2.0"-licenseName CECILL_2_1 = "CeCILL Free Software License Agreement v2.1"-licenseName CECILL_B = "CeCILL-B Free Software License Agreement"-licenseName CECILL_C = "CeCILL-C Free Software License Agreement"-licenseName CERN_OHL_1_1 = "CERN Open Hardware Licence v1.1"-licenseName CERN_OHL_1_2 = "CERN Open Hardware Licence v1.2"-licenseName CERN_OHL_P_2_0 = "CERN Open Hardware Licence Version 2 - Permissive"-licenseName CERN_OHL_S_2_0 = "CERN Open Hardware Licence Version 2 - Strongly Reciprocal"-licenseName CERN_OHL_W_2_0 = "CERN Open Hardware Licence Version 2 - Weakly Reciprocal"-licenseName ClArtistic = "Clarified Artistic License"-licenseName CNRI_Jython = "CNRI Jython License"-licenseName CNRI_Python_GPL_Compatible = "CNRI Python Open Source GPL Compatible License Agreement"-licenseName CNRI_Python = "CNRI Python License"-licenseName COIL_1_0 = "Copyfree Open Innovation License"-licenseName Community_Spec_1_0 = "Community Specification License 1.0"-licenseName Condor_1_1 = "Condor Public License v1.1"-licenseName Copyleft_next_0_3_0 = "copyleft-next 0.3.0"-licenseName Copyleft_next_0_3_1 = "copyleft-next 0.3.1"-licenseName CPAL_1_0 = "Common Public Attribution License 1.0"-licenseName CPL_1_0 = "Common Public License 1.0"-licenseName CPOL_1_02 = "Code Project Open License 1.02"-licenseName Crossword = "Crossword License"-licenseName CrystalStacker = "CrystalStacker License"-licenseName CUA_OPL_1_0 = "CUA Office Public License v1.0"-licenseName Cube = "Cube License"-licenseName Curl = "curl License"-licenseName D_FSL_1_0 = "Deutsche Freie Software Lizenz"-licenseName Diffmark = "diffmark license"-licenseName DL_DE_BY_2_0 = "Data licence Germany \8211 attribution \8211 version 2.0"-licenseName DOC = "DOC License"-licenseName Dotseqn = "Dotseqn License"-licenseName DRL_1_0 = "Detection Rule License 1.0"-licenseName DSDP = "DSDP License"-licenseName Dvipdfm = "dvipdfm License"-licenseName ECL_1_0 = "Educational Community License v1.0"-licenseName ECL_2_0 = "Educational Community License v2.0"-licenseName EFL_1_0 = "Eiffel Forum License v1.0"-licenseName EFL_2_0 = "Eiffel Forum License v2.0"-licenseName EGenix = "eGenix.com Public License 1.1.0"-licenseName Elastic_2_0 = "Elastic License 2.0"-licenseName Entessa = "Entessa Public License v1.0"-licenseName EPICS = "EPICS Open License"-licenseName EPL_1_0 = "Eclipse Public License 1.0"-licenseName EPL_2_0 = "Eclipse Public License 2.0"-licenseName ErlPL_1_1 = "Erlang Public License v1.1"-licenseName Etalab_2_0 = "Etalab Open License 2.0"-licenseName EUDatagrid = "EU DataGrid Software License"-licenseName EUPL_1_0 = "European Union Public License 1.0"-licenseName EUPL_1_1 = "European Union Public License 1.1"-licenseName EUPL_1_2 = "European Union Public License 1.2"-licenseName Eurosym = "Eurosym License"-licenseName Fair = "Fair License"-licenseName FDK_AAC = "Fraunhofer FDK AAC Codec Library"-licenseName Frameworx_1_0 = "Frameworx Open License 1.0"-licenseName FreeBSD_DOC = "FreeBSD Documentation License"-licenseName FreeImage = "FreeImage Public License v1.0"-licenseName FSFAP = "FSF All Permissive License"-licenseName FSFULLR = "FSF Unlimited License (with License Retention)"-licenseName FSFUL = "FSF Unlimited License"-licenseName FTL = "Freetype Project License"-licenseName GD = "GD License"-licenseName GFDL_1_1_invariants_only = "GNU Free Documentation License v1.1 only - invariants"-licenseName GFDL_1_1_invariants_or_later = "GNU Free Documentation License v1.1 or later - invariants"-licenseName GFDL_1_1_no_invariants_only = "GNU Free Documentation License v1.1 only - no invariants"-licenseName GFDL_1_1_no_invariants_or_later = "GNU Free Documentation License v1.1 or later - no invariants"-licenseName GFDL_1_1_only = "GNU Free Documentation License v1.1 only"-licenseName GFDL_1_1_or_later = "GNU Free Documentation License v1.1 or later"-licenseName GFDL_1_2_invariants_only = "GNU Free Documentation License v1.2 only - invariants"-licenseName GFDL_1_2_invariants_or_later = "GNU Free Documentation License v1.2 or later - invariants"-licenseName GFDL_1_2_no_invariants_only = "GNU Free Documentation License v1.2 only - no invariants"-licenseName GFDL_1_2_no_invariants_or_later = "GNU Free Documentation License v1.2 or later - no invariants"-licenseName GFDL_1_2_only = "GNU Free Documentation License v1.2 only"-licenseName GFDL_1_2_or_later = "GNU Free Documentation License v1.2 or later"-licenseName GFDL_1_3_invariants_only = "GNU Free Documentation License v1.3 only - invariants"-licenseName GFDL_1_3_invariants_or_later = "GNU Free Documentation License v1.3 or later - invariants"-licenseName GFDL_1_3_no_invariants_only = "GNU Free Documentation License v1.3 only - no invariants"-licenseName GFDL_1_3_no_invariants_or_later = "GNU Free Documentation License v1.3 or later - no invariants"-licenseName GFDL_1_3_only = "GNU Free Documentation License v1.3 only"-licenseName GFDL_1_3_or_later = "GNU Free Documentation License v1.3 or later"-licenseName Giftware = "Giftware License"-licenseName GL2PS = "GL2PS License"-licenseName Glide = "3dfx Glide License"-licenseName Glulxe = "Glulxe License"-licenseName GLWTPL = "Good Luck With That Public License"-licenseName Gnuplot = "gnuplot License"-licenseName GPL_1_0_only = "GNU General Public License v1.0 only"-licenseName GPL_1_0_or_later = "GNU General Public License v1.0 or later"-licenseName GPL_2_0_only = "GNU General Public License v2.0 only"-licenseName GPL_2_0_or_later = "GNU General Public License v2.0 or later"-licenseName GPL_3_0_only = "GNU General Public License v3.0 only"-licenseName GPL_3_0_or_later = "GNU General Public License v3.0 or later"-licenseName GSOAP_1_3b = "gSOAP Public License v1.3b"-licenseName HaskellReport = "Haskell Language Report License"-licenseName Hippocratic_2_1 = "Hippocratic License 2.1"-licenseName HPND_sell_variant = "Historical Permission Notice and Disclaimer - sell variant"-licenseName HPND = "Historical Permission Notice and Disclaimer"-licenseName HTMLTIDY = "HTML Tidy License"-licenseName IBM_pibs = "IBM PowerPC Initialization and Boot Software"-licenseName ICU = "ICU License"-licenseName IJG = "Independent JPEG Group License"-licenseName ImageMagick = "ImageMagick License"-licenseName IMatix = "iMatix Standard Function Library Agreement"-licenseName Imlib2 = "Imlib2 License"-licenseName Info_ZIP = "Info-ZIP License"-licenseName Intel_ACPI = "Intel ACPI Software License Agreement"-licenseName Intel = "Intel Open Source License"-licenseName Interbase_1_0 = "Interbase Public License v1.0"-licenseName IPA = "IPA Font License"-licenseName IPL_1_0 = "IBM Public License v1.0"-licenseName ISC = "ISC License"-licenseName Jam = "Jam License"-licenseName JasPer_2_0 = "JasPer License"-licenseName JPNIC = "Japan Network Information Center License"-licenseName JSON = "JSON License"-licenseName LAL_1_2 = "Licence Art Libre 1.2"-licenseName LAL_1_3 = "Licence Art Libre 1.3"-licenseName Latex2e = "Latex2e License"-licenseName Leptonica = "Leptonica License"-licenseName LGPL_2_0_only = "GNU Library General Public License v2 only"-licenseName LGPL_2_0_or_later = "GNU Library General Public License v2 or later"-licenseName LGPL_2_1_only = "GNU Lesser General Public License v2.1 only"-licenseName LGPL_2_1_or_later = "GNU Lesser General Public License v2.1 or later"-licenseName LGPL_3_0_only = "GNU Lesser General Public License v3.0 only"-licenseName LGPL_3_0_or_later = "GNU Lesser General Public License v3.0 or later"-licenseName LGPLLR = "Lesser General Public License For Linguistic Resources"-licenseName Libpng_2_0 = "PNG Reference Library version 2"-licenseName Libpng = "libpng License"-licenseName Libselinux_1_0 = "libselinux public domain notice"-licenseName Libtiff = "libtiff License"-licenseName LiLiQ_P_1_1 = "Licence Libre du Qu\233bec \8211 Permissive version 1.1"-licenseName LiLiQ_R_1_1 = "Licence Libre du Qu\233bec \8211 R\233ciprocit\233 version 1.1"-licenseName LiLiQ_Rplus_1_1 = "Licence Libre du Qu\233bec \8211 R\233ciprocit\233 forte version 1.1"-licenseName Linux_man_pages_copyleft = "Linux man-pages Copyleft"-licenseName Linux_OpenIB = "Linux Kernel Variant of OpenIB.org license"-licenseName LPL_1_02 = "Lucent Public License v1.02"-licenseName LPL_1_0 = "Lucent Public License Version 1.0"-licenseName LPPL_1_0 = "LaTeX Project Public License v1.0"-licenseName LPPL_1_1 = "LaTeX Project Public License v1.1"-licenseName LPPL_1_2 = "LaTeX Project Public License v1.2"-licenseName LPPL_1_3a = "LaTeX Project Public License v1.3a"-licenseName LPPL_1_3c = "LaTeX Project Public License v1.3c"-licenseName MakeIndex = "MakeIndex License"-licenseName MirOS = "The MirOS Licence"-licenseName MIT_0 = "MIT No Attribution"-licenseName MIT_advertising = "Enlightenment License (e16)"-licenseName MIT_CMU = "CMU License"-licenseName MIT_enna = "enna License"-licenseName MIT_feh = "feh License"-licenseName MIT_Modern_Variant = "MIT License Modern Variant"-licenseName MIT_open_group = "MIT Open Group variant"-licenseName MITNFA = "MIT +no-false-attribs license"-licenseName MIT = "MIT License"-licenseName Motosoto = "Motosoto License"-licenseName Mpich2 = "mpich2 License"-licenseName MPL_1_0 = "Mozilla Public License 1.0"-licenseName MPL_1_1 = "Mozilla Public License 1.1"-licenseName MPL_2_0_no_copyleft_exception = "Mozilla Public License 2.0 (no copyleft exception)"-licenseName MPL_2_0 = "Mozilla Public License 2.0"-licenseName MS_PL = "Microsoft Public License"-licenseName MS_RL = "Microsoft Reciprocal License"-licenseName MTLL = "Matrix Template Library License"-licenseName MulanPSL_1_0 = "Mulan Permissive Software License, Version 1"-licenseName MulanPSL_2_0 = "Mulan Permissive Software License, Version 2"-licenseName Multics = "Multics License"-licenseName Mup = "Mup License"-licenseName NAIST_2003 = "Nara Institute of Science and Technology License (2003)"-licenseName NASA_1_3 = "NASA Open Source Agreement 1.3"-licenseName Naumen = "Naumen Public License"-licenseName NBPL_1_0 = "Net Boolean Public License v1"-licenseName NCGL_UK_2_0 = "Non-Commercial Government Licence"-licenseName NCSA = "University of Illinois/NCSA Open Source License"-licenseName Net_SNMP = "Net-SNMP License"-licenseName NetCDF = "NetCDF license"-licenseName Newsletr = "Newsletr License"-licenseName NGPL = "Nethack General Public License"-licenseName NIST_PD_fallback = "NIST Public Domain Notice with license fallback"-licenseName NIST_PD = "NIST Public Domain Notice"-licenseName NLOD_1_0 = "Norwegian Licence for Open Government Data (NLOD) 1.0"-licenseName NLOD_2_0 = "Norwegian Licence for Open Government Data (NLOD) 2.0"-licenseName NLPL = "No Limit Public License"-licenseName Nokia = "Nokia Open Source License"-licenseName NOSL = "Netizen Open Source License"-licenseName Noweb = "Noweb License"-licenseName NPL_1_0 = "Netscape Public License v1.0"-licenseName NPL_1_1 = "Netscape Public License v1.1"-licenseName NPOSL_3_0 = "Non-Profit Open Software License 3.0"-licenseName NRL = "NRL License"-licenseName NTP_0 = "NTP No Attribution"-licenseName NTP = "NTP License"-licenseName O_UDA_1_0 = "Open Use of Data Agreement v1.0"-licenseName OCCT_PL = "Open CASCADE Technology Public License"-licenseName OCLC_2_0 = "OCLC Research Public License 2.0"-licenseName ODbL_1_0 = "Open Data Commons Open Database License v1.0"-licenseName ODC_By_1_0 = "Open Data Commons Attribution License v1.0"-licenseName OFL_1_0_no_RFN = "SIL Open Font License 1.0 with no Reserved Font Name"-licenseName OFL_1_0_RFN = "SIL Open Font License 1.0 with Reserved Font Name"-licenseName OFL_1_0 = "SIL Open Font License 1.0"-licenseName OFL_1_1_no_RFN = "SIL Open Font License 1.1 with no Reserved Font Name"-licenseName OFL_1_1_RFN = "SIL Open Font License 1.1 with Reserved Font Name"-licenseName OFL_1_1 = "SIL Open Font License 1.1"-licenseName OGC_1_0 = "OGC Software License, Version 1.0"-licenseName OGDL_Taiwan_1_0 = "Taiwan Open Government Data License, version 1.0"-licenseName OGL_Canada_2_0 = "Open Government Licence - Canada"-licenseName OGL_UK_1_0 = "Open Government Licence v1.0"-licenseName OGL_UK_2_0 = "Open Government Licence v2.0"-licenseName OGL_UK_3_0 = "Open Government Licence v3.0"-licenseName OGTSL = "Open Group Test Suite License"-licenseName OLDAP_1_1 = "Open LDAP Public License v1.1"-licenseName OLDAP_1_2 = "Open LDAP Public License v1.2"-licenseName OLDAP_1_3 = "Open LDAP Public License v1.3"-licenseName OLDAP_1_4 = "Open LDAP Public License v1.4"-licenseName OLDAP_2_0_1 = "Open LDAP Public License v2.0.1"-licenseName OLDAP_2_0 = "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)"-licenseName OLDAP_2_1 = "Open LDAP Public License v2.1"-licenseName OLDAP_2_2_1 = "Open LDAP Public License v2.2.1"-licenseName OLDAP_2_2_2 = "Open LDAP Public License 2.2.2"-licenseName OLDAP_2_2 = "Open LDAP Public License v2.2"-licenseName OLDAP_2_3 = "Open LDAP Public License v2.3"-licenseName OLDAP_2_4 = "Open LDAP Public License v2.4"-licenseName OLDAP_2_5 = "Open LDAP Public License v2.5"-licenseName OLDAP_2_6 = "Open LDAP Public License v2.6"-licenseName OLDAP_2_7 = "Open LDAP Public License v2.7"-licenseName OLDAP_2_8 = "Open LDAP Public License v2.8"-licenseName OML = "Open Market License"-licenseName OpenSSL = "OpenSSL License"-licenseName OPL_1_0 = "Open Public License v1.0"-licenseName OPUBL_1_0 = "Open Publication License v1.0"-licenseName OSET_PL_2_1 = "OSET Public License version 2.1"-licenseName OSL_1_0 = "Open Software License 1.0"-licenseName OSL_1_1 = "Open Software License 1.1"-licenseName OSL_2_0 = "Open Software License 2.0"-licenseName OSL_2_1 = "Open Software License 2.1"-licenseName OSL_3_0 = "Open Software License 3.0"-licenseName Parity_6_0_0 = "The Parity Public License 6.0.0"-licenseName Parity_7_0_0 = "The Parity Public License 7.0.0"-licenseName PDDL_1_0 = "Open Data Commons Public Domain Dedication & License 1.0"-licenseName PHP_3_01 = "PHP License v3.01"-licenseName PHP_3_0 = "PHP License v3.0"-licenseName Plexus = "Plexus Classworlds License"-licenseName PolyForm_Noncommercial_1_0_0 = "PolyForm Noncommercial License 1.0.0"-licenseName PolyForm_Small_Business_1_0_0 = "PolyForm Small Business License 1.0.0"-licenseName PostgreSQL = "PostgreSQL License"-licenseName PSF_2_0 = "Python Software Foundation License 2.0"-licenseName Psfrag = "psfrag License"-licenseName Psutils = "psutils License"-licenseName Python_2_0 = "Python License 2.0"-licenseName Qhull = "Qhull License"-licenseName QPL_1_0 = "Q Public License 1.0"-licenseName Rdisc = "Rdisc License"-licenseName RHeCos_1_1 = "Red Hat eCos Public License v1.1"-licenseName RPL_1_1 = "Reciprocal Public License 1.1"-licenseName RPL_1_5 = "Reciprocal Public License 1.5"-licenseName RPSL_1_0 = "RealNetworks Public Source License v1.0"-licenseName RSA_MD = "RSA Message-Digest License"-licenseName RSCPL = "Ricoh Source Code Public License"-licenseName Ruby = "Ruby License"-licenseName SAX_PD = "Sax Public Domain Notice"-licenseName Saxpath = "Saxpath License"-licenseName SCEA = "SCEA Shared Source License"-licenseName SchemeReport = "Scheme Language Report License"-licenseName Sendmail_8_23 = "Sendmail License 8.23"-licenseName Sendmail = "Sendmail License"-licenseName SGI_B_1_0 = "SGI Free Software License B v1.0"-licenseName SGI_B_1_1 = "SGI Free Software License B v1.1"-licenseName SGI_B_2_0 = "SGI Free Software License B v2.0"-licenseName SHL_0_51 = "Solderpad Hardware License, Version 0.51"-licenseName SHL_0_5 = "Solderpad Hardware License v0.5"-licenseName SimPL_2_0 = "Simple Public License 2.0"-licenseName SISSL_1_2 = "Sun Industry Standards Source License v1.2"-licenseName SISSL = "Sun Industry Standards Source License v1.1"-licenseName Sleepycat = "Sleepycat License"-licenseName SMLNJ = "Standard ML of New Jersey License"-licenseName SMPPL = "Secure Messaging Protocol Public License"-licenseName SNIA = "SNIA Public License 1.1"-licenseName Spencer_86 = "Spencer License 86"-licenseName Spencer_94 = "Spencer License 94"-licenseName Spencer_99 = "Spencer License 99"-licenseName SPL_1_0 = "Sun Public License v1.0"-licenseName SSH_OpenSSH = "SSH OpenSSH license"-licenseName SSH_short = "SSH short notice"-licenseName SSPL_1_0 = "Server Side Public License, v 1"-licenseName SugarCRM_1_1_3 = "SugarCRM Public License v1.1.3"-licenseName SWL = "Scheme Widget Library (SWL) Software License Agreement"-licenseName TAPR_OHL_1_0 = "TAPR Open Hardware License v1.0"-licenseName TCL = "TCL/TK License"-licenseName TCP_wrappers = "TCP Wrappers License"-licenseName TMate = "TMate Open Source License"-licenseName TORQUE_1_1 = "TORQUE v2.5+ Software License v1.1"-licenseName TOSL = "Trusster Open Source License"-licenseName TU_Berlin_1_0 = "Technische Universitaet Berlin License 1.0"-licenseName TU_Berlin_2_0 = "Technische Universitaet Berlin License 2.0"-licenseName UCL_1_0 = "Upstream Compatibility License v1.0"-licenseName Unicode_DFS_2015 = "Unicode License Agreement - Data Files and Software (2015)"-licenseName Unicode_DFS_2016 = "Unicode License Agreement - Data Files and Software (2016)"-licenseName Unicode_TOU = "Unicode Terms of Use"-licenseName Unlicense = "The Unlicense"-licenseName UPL_1_0 = "Universal Permissive License v1.0"-licenseName Vim = "Vim License"-licenseName VOSTROM = "VOSTROM Public License for Open Source"-licenseName VSL_1_0 = "Vovida Software License v1.0"-licenseName W3C_19980720 = "W3C Software Notice and License (1998-07-20)"-licenseName W3C_20150513 = "W3C Software Notice and Document License (2015-05-13)"-licenseName W3C = "W3C Software Notice and License (2002-12-31)"-licenseName Watcom_1_0 = "Sybase Open Watcom Public License 1.0"-licenseName Wsuipa = "Wsuipa License"-licenseName WTFPL = "Do What The F*ck You Want To Public License"-licenseName X11_distribute_modifications_variant = "X11 License Distribution Modification Variant"-licenseName X11 = "X11 License"-licenseName Xerox = "Xerox License"-licenseName XFree86_1_1 = "XFree86 License 1.1"-licenseName Xinetd = "xinetd License"-licenseName Xnet = "X.Net License"-licenseName Xpp = "XPP License"-licenseName XSkat = "XSkat License"-licenseName YPL_1_0 = "Yahoo! Public License v1.0"-licenseName YPL_1_1 = "Yahoo! Public License v1.1"-licenseName Zed = "Zed License"-licenseName Zend_2_0 = "Zend License v2.0"-licenseName Zimbra_1_3 = "Zimbra Public License v1.3"-licenseName Zimbra_1_4 = "Zimbra Public License v1.4"-licenseName Zlib_acknowledgement = "zlib/libpng License with Acknowledgement"-licenseName Zlib = "zlib License"-licenseName ZPL_1_1 = "Zope Public License 1.1"-licenseName ZPL_2_0 = "Zope Public License 2.0"-licenseName ZPL_2_1 = "Zope Public License 2.1"---- | Whether the license is approved by Open Source Initiative (OSI).------ See <https://opensource.org/licenses/alphabetical>.-licenseIsOsiApproved :: LicenseId -> Bool-licenseIsOsiApproved NullBSD = True-licenseIsOsiApproved AAL = True-licenseIsOsiApproved AFL_1_1 = True-licenseIsOsiApproved AFL_1_2 = True-licenseIsOsiApproved AFL_2_0 = True-licenseIsOsiApproved AFL_2_1 = True-licenseIsOsiApproved AFL_3_0 = True-licenseIsOsiApproved AGPL_3_0_only = True-licenseIsOsiApproved AGPL_3_0_or_later = True-licenseIsOsiApproved Apache_1_1 = True-licenseIsOsiApproved Apache_2_0 = True-licenseIsOsiApproved APL_1_0 = True-licenseIsOsiApproved APSL_1_0 = True-licenseIsOsiApproved APSL_1_1 = True-licenseIsOsiApproved APSL_1_2 = True-licenseIsOsiApproved APSL_2_0 = True-licenseIsOsiApproved Artistic_1_0_cl8 = True-licenseIsOsiApproved Artistic_1_0_Perl = True-licenseIsOsiApproved Artistic_1_0 = True-licenseIsOsiApproved Artistic_2_0 = True-licenseIsOsiApproved BSD_1_Clause = True-licenseIsOsiApproved BSD_2_Clause_Patent = True-licenseIsOsiApproved BSD_2_Clause = True-licenseIsOsiApproved BSD_3_Clause_LBNL = True-licenseIsOsiApproved BSD_3_Clause = True-licenseIsOsiApproved BSL_1_0 = True-licenseIsOsiApproved CAL_1_0_Combined_Work_Exception = True-licenseIsOsiApproved CAL_1_0 = True-licenseIsOsiApproved CATOSL_1_1 = True-licenseIsOsiApproved CDDL_1_0 = True-licenseIsOsiApproved CECILL_2_1 = True-licenseIsOsiApproved CERN_OHL_P_2_0 = True-licenseIsOsiApproved CERN_OHL_S_2_0 = True-licenseIsOsiApproved CERN_OHL_W_2_0 = True-licenseIsOsiApproved CNRI_Python = True-licenseIsOsiApproved CPAL_1_0 = True-licenseIsOsiApproved CPL_1_0 = True-licenseIsOsiApproved CUA_OPL_1_0 = True-licenseIsOsiApproved ECL_1_0 = True-licenseIsOsiApproved ECL_2_0 = True-licenseIsOsiApproved EFL_1_0 = True-licenseIsOsiApproved EFL_2_0 = True-licenseIsOsiApproved Entessa = True-licenseIsOsiApproved EPL_1_0 = True-licenseIsOsiApproved EPL_2_0 = True-licenseIsOsiApproved EUDatagrid = True-licenseIsOsiApproved EUPL_1_1 = True-licenseIsOsiApproved EUPL_1_2 = True-licenseIsOsiApproved Fair = True-licenseIsOsiApproved Frameworx_1_0 = True-licenseIsOsiApproved GPL_2_0_only = True-licenseIsOsiApproved GPL_2_0_or_later = True-licenseIsOsiApproved GPL_3_0_only = True-licenseIsOsiApproved GPL_3_0_or_later = True-licenseIsOsiApproved HPND = True-licenseIsOsiApproved Intel = True-licenseIsOsiApproved IPA = True-licenseIsOsiApproved IPL_1_0 = True-licenseIsOsiApproved ISC = True-licenseIsOsiApproved LGPL_2_0_only = True-licenseIsOsiApproved LGPL_2_0_or_later = True-licenseIsOsiApproved LGPL_2_1_only = True-licenseIsOsiApproved LGPL_2_1_or_later = True-licenseIsOsiApproved LGPL_3_0_only = True-licenseIsOsiApproved LGPL_3_0_or_later = True-licenseIsOsiApproved LiLiQ_P_1_1 = True-licenseIsOsiApproved LiLiQ_R_1_1 = True-licenseIsOsiApproved LiLiQ_Rplus_1_1 = True-licenseIsOsiApproved LPL_1_02 = True-licenseIsOsiApproved LPL_1_0 = True-licenseIsOsiApproved LPPL_1_3c = True-licenseIsOsiApproved MirOS = True-licenseIsOsiApproved MIT_0 = True-licenseIsOsiApproved MIT_Modern_Variant = True-licenseIsOsiApproved MIT = True-licenseIsOsiApproved Motosoto = True-licenseIsOsiApproved MPL_1_0 = True-licenseIsOsiApproved MPL_1_1 = True-licenseIsOsiApproved MPL_2_0_no_copyleft_exception = True-licenseIsOsiApproved MPL_2_0 = True-licenseIsOsiApproved MS_PL = True-licenseIsOsiApproved MS_RL = True-licenseIsOsiApproved MulanPSL_2_0 = True-licenseIsOsiApproved Multics = True-licenseIsOsiApproved NASA_1_3 = True-licenseIsOsiApproved Naumen = True-licenseIsOsiApproved NCSA = True-licenseIsOsiApproved NGPL = True-licenseIsOsiApproved Nokia = True-licenseIsOsiApproved NPOSL_3_0 = True-licenseIsOsiApproved NTP = True-licenseIsOsiApproved OCLC_2_0 = True-licenseIsOsiApproved OFL_1_1_no_RFN = True-licenseIsOsiApproved OFL_1_1_RFN = True-licenseIsOsiApproved OFL_1_1 = True-licenseIsOsiApproved OGTSL = True-licenseIsOsiApproved OLDAP_2_8 = True-licenseIsOsiApproved OSET_PL_2_1 = True-licenseIsOsiApproved OSL_1_0 = True-licenseIsOsiApproved OSL_2_0 = True-licenseIsOsiApproved OSL_2_1 = True-licenseIsOsiApproved OSL_3_0 = True-licenseIsOsiApproved PHP_3_01 = True-licenseIsOsiApproved PHP_3_0 = True-licenseIsOsiApproved PostgreSQL = True-licenseIsOsiApproved Python_2_0 = True-licenseIsOsiApproved QPL_1_0 = True-licenseIsOsiApproved RPL_1_1 = True-licenseIsOsiApproved RPL_1_5 = True-licenseIsOsiApproved RPSL_1_0 = True-licenseIsOsiApproved RSCPL = True-licenseIsOsiApproved SimPL_2_0 = True-licenseIsOsiApproved SISSL = True-licenseIsOsiApproved Sleepycat = True-licenseIsOsiApproved SPL_1_0 = True-licenseIsOsiApproved UCL_1_0 = True-licenseIsOsiApproved Unicode_DFS_2016 = True-licenseIsOsiApproved Unlicense = True-licenseIsOsiApproved UPL_1_0 = True-licenseIsOsiApproved VSL_1_0 = True-licenseIsOsiApproved W3C = True-licenseIsOsiApproved Watcom_1_0 = True-licenseIsOsiApproved Xnet = True-licenseIsOsiApproved Zlib = True-licenseIsOsiApproved ZPL_2_0 = True-licenseIsOsiApproved ZPL_2_1 = True-licenseIsOsiApproved _ = False---- | Whether the license is considered libre by Free Software Foundation (FSF).------ See <https://www.gnu.org/licenses/license-list.en.html>------ @since 3.4.0.0----licenseIsFsfLibre :: LicenseId -> Bool-licenseIsFsfLibre AFL_1_1 = True-licenseIsFsfLibre AFL_1_2 = True-licenseIsFsfLibre AFL_2_0 = True-licenseIsFsfLibre AFL_2_1 = True-licenseIsFsfLibre AFL_3_0 = True-licenseIsFsfLibre AGPL_1_0 = True-licenseIsFsfLibre AGPL_3_0_only = True-licenseIsFsfLibre AGPL_3_0_or_later = True-licenseIsFsfLibre Apache_1_0 = True-licenseIsFsfLibre Apache_1_1 = True-licenseIsFsfLibre Apache_2_0 = True-licenseIsFsfLibre APSL_2_0 = True-licenseIsFsfLibre Artistic_2_0 = True-licenseIsFsfLibre BitTorrent_1_1 = True-licenseIsFsfLibre BSD_2_Clause_FreeBSD = True-licenseIsFsfLibre BSD_2_Clause = True-licenseIsFsfLibre BSD_3_Clause_Clear = True-licenseIsFsfLibre BSD_3_Clause = True-licenseIsFsfLibre BSD_4_Clause = True-licenseIsFsfLibre BSL_1_0 = True-licenseIsFsfLibre CC_BY_4_0 = True-licenseIsFsfLibre CC_BY_SA_4_0 = True-licenseIsFsfLibre CC0_1_0 = True-licenseIsFsfLibre CDDL_1_0 = True-licenseIsFsfLibre CECILL_2_0 = True-licenseIsFsfLibre CECILL_B = True-licenseIsFsfLibre CECILL_C = True-licenseIsFsfLibre ClArtistic = True-licenseIsFsfLibre Condor_1_1 = True-licenseIsFsfLibre CPAL_1_0 = True-licenseIsFsfLibre CPL_1_0 = True-licenseIsFsfLibre ECL_2_0 = True-licenseIsFsfLibre EFL_2_0 = True-licenseIsFsfLibre EPL_1_0 = True-licenseIsFsfLibre EPL_2_0 = True-licenseIsFsfLibre EUDatagrid = True-licenseIsFsfLibre EUPL_1_1 = True-licenseIsFsfLibre EUPL_1_2 = True-licenseIsFsfLibre FSFAP = True-licenseIsFsfLibre FTL = True-licenseIsFsfLibre GFDL_1_1_only = True-licenseIsFsfLibre GFDL_1_1_or_later = True-licenseIsFsfLibre GFDL_1_2_only = True-licenseIsFsfLibre GFDL_1_2_or_later = True-licenseIsFsfLibre GFDL_1_3_only = True-licenseIsFsfLibre GFDL_1_3_or_later = True-licenseIsFsfLibre Gnuplot = True-licenseIsFsfLibre GPL_2_0_only = True-licenseIsFsfLibre GPL_2_0_or_later = True-licenseIsFsfLibre GPL_3_0_only = True-licenseIsFsfLibre GPL_3_0_or_later = True-licenseIsFsfLibre HPND = True-licenseIsFsfLibre IJG = True-licenseIsFsfLibre IMatix = True-licenseIsFsfLibre Imlib2 = True-licenseIsFsfLibre Intel = True-licenseIsFsfLibre IPA = True-licenseIsFsfLibre IPL_1_0 = True-licenseIsFsfLibre ISC = True-licenseIsFsfLibre LGPL_2_1_only = True-licenseIsFsfLibre LGPL_2_1_or_later = True-licenseIsFsfLibre LGPL_3_0_only = True-licenseIsFsfLibre LGPL_3_0_or_later = True-licenseIsFsfLibre LPL_1_02 = True-licenseIsFsfLibre LPPL_1_2 = True-licenseIsFsfLibre LPPL_1_3a = True-licenseIsFsfLibre MIT = True-licenseIsFsfLibre MPL_1_1 = True-licenseIsFsfLibre MPL_2_0 = True-licenseIsFsfLibre MS_PL = True-licenseIsFsfLibre MS_RL = True-licenseIsFsfLibre NCSA = True-licenseIsFsfLibre Nokia = True-licenseIsFsfLibre NOSL = True-licenseIsFsfLibre NPL_1_0 = True-licenseIsFsfLibre NPL_1_1 = True-licenseIsFsfLibre ODbL_1_0 = True-licenseIsFsfLibre OFL_1_0 = True-licenseIsFsfLibre OFL_1_1 = True-licenseIsFsfLibre OLDAP_2_3 = True-licenseIsFsfLibre OLDAP_2_7 = True-licenseIsFsfLibre OpenSSL = True-licenseIsFsfLibre OSL_1_0 = True-licenseIsFsfLibre OSL_1_1 = True-licenseIsFsfLibre OSL_2_0 = True-licenseIsFsfLibre OSL_2_1 = True-licenseIsFsfLibre OSL_3_0 = True-licenseIsFsfLibre PHP_3_01 = True-licenseIsFsfLibre Python_2_0 = True-licenseIsFsfLibre QPL_1_0 = True-licenseIsFsfLibre RPSL_1_0 = True-licenseIsFsfLibre Ruby = True-licenseIsFsfLibre SGI_B_2_0 = True-licenseIsFsfLibre SISSL = True-licenseIsFsfLibre Sleepycat = True-licenseIsFsfLibre SMLNJ = True-licenseIsFsfLibre SPL_1_0 = True-licenseIsFsfLibre Unlicense = True-licenseIsFsfLibre UPL_1_0 = True-licenseIsFsfLibre Vim = True-licenseIsFsfLibre W3C = True-licenseIsFsfLibre WTFPL = True-licenseIsFsfLibre X11 = True-licenseIsFsfLibre XFree86_1_1 = True-licenseIsFsfLibre Xinetd = True-licenseIsFsfLibre YPL_1_1 = True-licenseIsFsfLibre Zend_2_0 = True-licenseIsFsfLibre Zimbra_1_3 = True-licenseIsFsfLibre Zlib = True-licenseIsFsfLibre ZPL_2_0 = True-licenseIsFsfLibre ZPL_2_1 = True-licenseIsFsfLibre _ = False------------------------------------------------------------------------------------ Creation----------------------------------------------------------------------------------licenseIdList :: LicenseListVersion -> [LicenseId]-licenseIdList LicenseListVersion_3_0 =-    [ AGPL_1_0-    , BSD_2_Clause_FreeBSD-    , BSD_2_Clause_NetBSD-    , Bzip2_1_0_5-    ]-    ++ bulkOfLicenses-licenseIdList LicenseListVersion_3_2 =-    [ AGPL_1_0_only-    , AGPL_1_0_or_later-    , BSD_2_Clause_FreeBSD-    , BSD_2_Clause_NetBSD-    , Bzip2_1_0_5-    , Linux_OpenIB-    , MIT_0-    , ODC_By_1_0-    , TU_Berlin_1_0-    , TU_Berlin_2_0-    ]-    ++ bulkOfLicenses-licenseIdList LicenseListVersion_3_6 =-    [ AGPL_1_0_only-    , AGPL_1_0_or_later-    , Blessing-    , BlueOak_1_0_0-    , BSD_2_Clause_FreeBSD-    , BSD_2_Clause_NetBSD-    , BSD_3_Clause_Open_MPI-    , Bzip2_1_0_5-    , CC_PDDC-    , CERN_OHL_1_1-    , CERN_OHL_1_2-    , Copyleft_next_0_3_0-    , Copyleft_next_0_3_1-    , HPND_sell_variant-    , JPNIC-    , Libpng_2_0-    , Linux_OpenIB-    , MIT_0-    , ODC_By_1_0-    , OGL_UK_1_0-    , OGL_UK_2_0-    , OGL_UK_3_0-    , Parity_6_0_0-    , Sendmail_8_23-    , SHL_0_51-    , SHL_0_5-    , SSPL_1_0-    , TAPR_OHL_1_0-    , TU_Berlin_1_0-    , TU_Berlin_2_0-    ]-    ++ bulkOfLicenses-licenseIdList LicenseListVersion_3_9 =-    [ AGPL_1_0_only-    , AGPL_1_0_or_later-    , Blessing-    , BlueOak_1_0_0-    , BSD_2_Clause_FreeBSD-    , BSD_3_Clause_Open_MPI-    , Bzip2_1_0_5-    , CAL_1_0_Combined_Work_Exception-    , CAL_1_0-    , CC_PDDC-    , CERN_OHL_1_1-    , CERN_OHL_1_2-    , CERN_OHL_P_2_0-    , CERN_OHL_S_2_0-    , CERN_OHL_W_2_0-    , Copyleft_next_0_3_0-    , Copyleft_next_0_3_1-    , Etalab_2_0-    , Hippocratic_2_1-    , HPND_sell_variant-    , JPNIC-    , Libpng_2_0-    , Libselinux_1_0-    , Linux_OpenIB-    , MIT_0-    , MulanPSL_1_0-    , MulanPSL_2_0-    , NCGL_UK_2_0-    , NTP_0-    , O_UDA_1_0-    , ODC_By_1_0-    , OFL_1_0_no_RFN-    , OFL_1_0_RFN-    , OFL_1_1_no_RFN-    , OFL_1_1_RFN-    , OGC_1_0-    , OGL_Canada_2_0-    , OGL_UK_1_0-    , OGL_UK_2_0-    , OGL_UK_3_0-    , Parity_6_0_0-    , Parity_7_0_0-    , PolyForm_Noncommercial_1_0_0-    , PolyForm_Small_Business_1_0_0-    , PSF_2_0-    , Sendmail_8_23-    , SHL_0_51-    , SHL_0_5-    , SSH_OpenSSH-    , SSH_short-    , SSPL_1_0-    , TAPR_OHL_1_0-    , TU_Berlin_1_0-    , TU_Berlin_2_0-    , UCL_1_0-    ]-    ++ bulkOfLicenses-licenseIdList LicenseListVersion_3_10 =-    [ AGPL_1_0_only-    , AGPL_1_0_or_later-    , Blessing-    , BlueOak_1_0_0-    , BSD_2_Clause_Views-    , BSD_3_Clause_Open_MPI-    , Bzip2_1_0_5-    , CAL_1_0_Combined_Work_Exception-    , CAL_1_0-    , CC_BY_3_0_AT-    , CC_BY_NC_ND_3_0_IGO-    , CC_BY_SA_3_0_AT-    , CC_PDDC-    , CERN_OHL_1_1-    , CERN_OHL_1_2-    , CERN_OHL_P_2_0-    , CERN_OHL_S_2_0-    , CERN_OHL_W_2_0-    , Copyleft_next_0_3_0-    , Copyleft_next_0_3_1-    , EPICS-    , Etalab_2_0-    , GFDL_1_1_invariants_only-    , GFDL_1_1_invariants_or_later-    , GFDL_1_1_no_invariants_only-    , GFDL_1_1_no_invariants_or_later-    , GFDL_1_2_invariants_only-    , GFDL_1_2_invariants_or_later-    , GFDL_1_2_no_invariants_only-    , GFDL_1_2_no_invariants_or_later-    , GFDL_1_3_invariants_only-    , GFDL_1_3_invariants_or_later-    , GFDL_1_3_no_invariants_only-    , GFDL_1_3_no_invariants_or_later-    , GLWTPL-    , Hippocratic_2_1-    , HPND_sell_variant-    , JPNIC-    , Libpng_2_0-    , Libselinux_1_0-    , Linux_OpenIB-    , MIT_0-    , MulanPSL_1_0-    , MulanPSL_2_0-    , NCGL_UK_2_0-    , NIST_PD_fallback-    , NIST_PD-    , NTP_0-    , O_UDA_1_0-    , ODC_By_1_0-    , OFL_1_0_no_RFN-    , OFL_1_0_RFN-    , OFL_1_1_no_RFN-    , OFL_1_1_RFN-    , OGC_1_0-    , OGL_Canada_2_0-    , OGL_UK_1_0-    , OGL_UK_2_0-    , OGL_UK_3_0-    , Parity_6_0_0-    , Parity_7_0_0-    , PolyForm_Noncommercial_1_0_0-    , PolyForm_Small_Business_1_0_0-    , PSF_2_0-    , Sendmail_8_23-    , SHL_0_51-    , SHL_0_5-    , SSH_OpenSSH-    , SSH_short-    , SSPL_1_0-    , TAPR_OHL_1_0-    , TU_Berlin_1_0-    , TU_Berlin_2_0-    , UCL_1_0-    ]-    ++ bulkOfLicenses-licenseIdList LicenseListVersion_3_16 =-    [ AGPL_1_0_only-    , AGPL_1_0_or_later-    , ANTLR_PD_fallback-    , App_s2p-    , Blessing-    , BlueOak_1_0_0-    , BSD_2_Clause_Views-    , BSD_3_Clause_Modification-    , BSD_3_Clause_No_Military_License-    , BSD_3_Clause_Open_MPI-    , BSD_4_Clause_Shortened-    , BUSL_1_1-    , C_UDA_1_0-    , CAL_1_0_Combined_Work_Exception-    , CAL_1_0-    , CC_BY_2_5_AU-    , CC_BY_3_0_AT-    , CC_BY_3_0_DE-    , CC_BY_3_0_NL-    , CC_BY_3_0_US-    , CC_BY_NC_3_0_DE-    , CC_BY_NC_ND_3_0_DE-    , CC_BY_NC_ND_3_0_IGO-    , CC_BY_NC_SA_2_0_FR-    , CC_BY_NC_SA_2_0_UK-    , CC_BY_NC_SA_3_0_DE-    , CC_BY_NC_SA_3_0_IGO-    , CC_BY_ND_3_0_DE-    , CC_BY_SA_2_0_UK-    , CC_BY_SA_2_1_JP-    , CC_BY_SA_3_0_AT-    , CC_BY_SA_3_0_DE-    , CC_PDDC-    , CDL_1_0-    , CDLA_Permissive_2_0-    , CERN_OHL_1_1-    , CERN_OHL_1_2-    , CERN_OHL_P_2_0-    , CERN_OHL_S_2_0-    , CERN_OHL_W_2_0-    , COIL_1_0-    , Community_Spec_1_0-    , Copyleft_next_0_3_0-    , Copyleft_next_0_3_1-    , DL_DE_BY_2_0-    , DRL_1_0-    , Elastic_2_0-    , EPICS-    , Etalab_2_0-    , FDK_AAC-    , FreeBSD_DOC-    , GD-    , GFDL_1_1_invariants_only-    , GFDL_1_1_invariants_or_later-    , GFDL_1_1_no_invariants_only-    , GFDL_1_1_no_invariants_or_later-    , GFDL_1_2_invariants_only-    , GFDL_1_2_invariants_or_later-    , GFDL_1_2_no_invariants_only-    , GFDL_1_2_no_invariants_or_later-    , GFDL_1_3_invariants_only-    , GFDL_1_3_invariants_or_later-    , GFDL_1_3_no_invariants_only-    , GFDL_1_3_no_invariants_or_later-    , GLWTPL-    , Hippocratic_2_1-    , HPND_sell_variant-    , HTMLTIDY-    , Jam-    , JPNIC-    , Libpng_2_0-    , Libselinux_1_0-    , Linux_man_pages_copyleft-    , Linux_OpenIB-    , MIT_0-    , MIT_Modern_Variant-    , MIT_open_group-    , MulanPSL_1_0-    , MulanPSL_2_0-    , NAIST_2003-    , NCGL_UK_2_0-    , NIST_PD_fallback-    , NIST_PD-    , NLOD_2_0-    , NTP_0-    , O_UDA_1_0-    , ODC_By_1_0-    , OFL_1_0_no_RFN-    , OFL_1_0_RFN-    , OFL_1_1_no_RFN-    , OFL_1_1_RFN-    , OGC_1_0-    , OGDL_Taiwan_1_0-    , OGL_Canada_2_0-    , OGL_UK_1_0-    , OGL_UK_2_0-    , OGL_UK_3_0-    , OPUBL_1_0-    , Parity_6_0_0-    , Parity_7_0_0-    , PolyForm_Noncommercial_1_0_0-    , PolyForm_Small_Business_1_0_0-    , PSF_2_0-    , SchemeReport-    , Sendmail_8_23-    , SHL_0_51-    , SHL_0_5-    , SSH_OpenSSH-    , SSH_short-    , SSPL_1_0-    , TAPR_OHL_1_0-    , TU_Berlin_1_0-    , TU_Berlin_2_0-    , UCL_1_0-    , X11_distribute_modifications_variant-    ]-    ++ bulkOfLicenses---- | Create a 'LicenseId' from a 'String'.-mkLicenseId :: LicenseListVersion -> String -> Maybe LicenseId-mkLicenseId LicenseListVersion_3_0  s = Map.lookup s stringLookup_3_0-mkLicenseId LicenseListVersion_3_2  s = Map.lookup s stringLookup_3_2-mkLicenseId LicenseListVersion_3_6  s = Map.lookup s stringLookup_3_6-mkLicenseId LicenseListVersion_3_9  s = Map.lookup s stringLookup_3_9-mkLicenseId LicenseListVersion_3_10 s = Map.lookup s stringLookup_3_10-mkLicenseId LicenseListVersion_3_16 s = Map.lookup s stringLookup_3_16--stringLookup_3_0 :: Map String LicenseId-stringLookup_3_0 = Map.fromList $ map (\i -> (licenseId i, i)) $-    licenseIdList LicenseListVersion_3_0--stringLookup_3_2 :: Map String LicenseId-stringLookup_3_2 = Map.fromList $ map (\i -> (licenseId i, i)) $-    licenseIdList LicenseListVersion_3_2--stringLookup_3_6 :: Map String LicenseId-stringLookup_3_6 = Map.fromList $ map (\i -> (licenseId i, i)) $-    licenseIdList LicenseListVersion_3_6--stringLookup_3_9 :: Map String LicenseId-stringLookup_3_9 = Map.fromList $ map (\i -> (licenseId i, i)) $-    licenseIdList LicenseListVersion_3_9--stringLookup_3_10 :: Map String LicenseId-stringLookup_3_10 = Map.fromList $ map (\i -> (licenseId i, i)) $-    licenseIdList LicenseListVersion_3_10--stringLookup_3_16 :: Map String LicenseId-stringLookup_3_16 = Map.fromList $ map (\i -> (licenseId i, i)) $-    licenseIdList LicenseListVersion_3_16----  | Licenses in all SPDX License lists-bulkOfLicenses :: [LicenseId]-bulkOfLicenses =-    [ NullBSD-    , AAL-    , Abstyles-    , Adobe_2006-    , Adobe_Glyph-    , ADSL-    , AFL_1_1-    , AFL_1_2-    , AFL_2_0-    , AFL_2_1-    , AFL_3_0-    , Afmparse-    , AGPL_3_0_only-    , AGPL_3_0_or_later-    , Aladdin-    , AMDPLPA-    , AML-    , AMPAS-    , ANTLR_PD-    , Apache_1_0-    , Apache_1_1-    , Apache_2_0-    , APAFML-    , APL_1_0-    , APSL_1_0-    , APSL_1_1-    , APSL_1_2-    , APSL_2_0-    , Artistic_1_0_cl8-    , Artistic_1_0_Perl-    , Artistic_1_0-    , Artistic_2_0-    , Bahyph-    , Barr-    , Beerware-    , BitTorrent_1_0-    , BitTorrent_1_1-    , Borceux-    , BSD_1_Clause-    , BSD_2_Clause_Patent-    , BSD_2_Clause-    , BSD_3_Clause_Attribution-    , BSD_3_Clause_Clear-    , BSD_3_Clause_LBNL-    , BSD_3_Clause_No_Nuclear_License_2014-    , BSD_3_Clause_No_Nuclear_License-    , BSD_3_Clause_No_Nuclear_Warranty-    , BSD_3_Clause-    , BSD_4_Clause_UC-    , BSD_4_Clause-    , BSD_Protection-    , BSD_Source_Code-    , BSL_1_0-    , Bzip2_1_0_6-    , Caldera-    , CATOSL_1_1-    , CC_BY_1_0-    , CC_BY_2_0-    , CC_BY_2_5-    , CC_BY_3_0-    , CC_BY_4_0-    , CC_BY_NC_1_0-    , CC_BY_NC_2_0-    , CC_BY_NC_2_5-    , CC_BY_NC_3_0-    , CC_BY_NC_4_0-    , CC_BY_NC_ND_1_0-    , CC_BY_NC_ND_2_0-    , CC_BY_NC_ND_2_5-    , CC_BY_NC_ND_3_0-    , CC_BY_NC_ND_4_0-    , CC_BY_NC_SA_1_0-    , CC_BY_NC_SA_2_0-    , CC_BY_NC_SA_2_5-    , CC_BY_NC_SA_3_0-    , CC_BY_NC_SA_4_0-    , CC_BY_ND_1_0-    , CC_BY_ND_2_0-    , CC_BY_ND_2_5-    , CC_BY_ND_3_0-    , CC_BY_ND_4_0-    , CC_BY_SA_1_0-    , CC_BY_SA_2_0-    , CC_BY_SA_2_5-    , CC_BY_SA_3_0-    , CC_BY_SA_4_0-    , CC0_1_0-    , CDDL_1_0-    , CDDL_1_1-    , CDLA_Permissive_1_0-    , CDLA_Sharing_1_0-    , CECILL_1_0-    , CECILL_1_1-    , CECILL_2_0-    , CECILL_2_1-    , CECILL_B-    , CECILL_C-    , ClArtistic-    , CNRI_Jython-    , CNRI_Python_GPL_Compatible-    , CNRI_Python-    , Condor_1_1-    , CPAL_1_0-    , CPL_1_0-    , CPOL_1_02-    , Crossword-    , CrystalStacker-    , CUA_OPL_1_0-    , Cube-    , Curl-    , D_FSL_1_0-    , Diffmark-    , DOC-    , Dotseqn-    , DSDP-    , Dvipdfm-    , ECL_1_0-    , ECL_2_0-    , EFL_1_0-    , EFL_2_0-    , EGenix-    , Entessa-    , EPL_1_0-    , EPL_2_0-    , ErlPL_1_1-    , EUDatagrid-    , EUPL_1_0-    , EUPL_1_1-    , EUPL_1_2-    , Eurosym-    , Fair-    , Frameworx_1_0-    , FreeImage-    , FSFAP-    , FSFULLR-    , FSFUL-    , FTL-    , GFDL_1_1_only-    , GFDL_1_1_or_later-    , GFDL_1_2_only-    , GFDL_1_2_or_later-    , GFDL_1_3_only-    , GFDL_1_3_or_later-    , Giftware-    , GL2PS-    , Glide-    , Glulxe-    , Gnuplot-    , GPL_1_0_only-    , GPL_1_0_or_later-    , GPL_2_0_only-    , GPL_2_0_or_later-    , GPL_3_0_only-    , GPL_3_0_or_later-    , GSOAP_1_3b-    , HaskellReport-    , HPND-    , IBM_pibs-    , ICU-    , IJG-    , ImageMagick-    , IMatix-    , Imlib2-    , Info_ZIP-    , Intel_ACPI-    , Intel-    , Interbase_1_0-    , IPA-    , IPL_1_0-    , ISC-    , JasPer_2_0-    , JSON-    , LAL_1_2-    , LAL_1_3-    , Latex2e-    , Leptonica-    , LGPL_2_0_only-    , LGPL_2_0_or_later-    , LGPL_2_1_only-    , LGPL_2_1_or_later-    , LGPL_3_0_only-    , LGPL_3_0_or_later-    , LGPLLR-    , Libpng-    , Libtiff-    , LiLiQ_P_1_1-    , LiLiQ_R_1_1-    , LiLiQ_Rplus_1_1-    , LPL_1_02-    , LPL_1_0-    , LPPL_1_0-    , LPPL_1_1-    , LPPL_1_2-    , LPPL_1_3a-    , LPPL_1_3c-    , MakeIndex-    , MirOS-    , MIT_advertising-    , MIT_CMU-    , MIT_enna-    , MIT_feh-    , MITNFA-    , MIT-    , Motosoto-    , Mpich2-    , MPL_1_0-    , MPL_1_1-    , MPL_2_0_no_copyleft_exception-    , MPL_2_0-    , MS_PL-    , MS_RL-    , MTLL-    , Multics-    , Mup-    , NASA_1_3-    , Naumen-    , NBPL_1_0-    , NCSA-    , Net_SNMP+{- FOURMOLU_DISABLE -}+{-# LANGUAGE DeriveDataTypeable #-}+module Distribution.SPDX.LicenseId (+    LicenseId (..),+    licenseId,+    licenseName,+    licenseIsOsiApproved,+    licenseIsFsfLibre,+    mkLicenseId,+    licenseIdList,+    -- * Helpers+    licenseIdMigrationMessage,+    ) where++import Distribution.Compat.Prelude+import Prelude ()++import Distribution.Compat.Lens (set)+import Distribution.Pretty+import Distribution.Parsec+import Distribution.Utils.Generic (isAsciiAlphaNum)+import Distribution.Utils.Structured (Structured (..), nominalStructure, typeVersion)+import Distribution.SPDX.LicenseListVersion++import qualified Data.Binary.Get as Binary+import qualified Data.Binary.Put as Binary+import qualified Data.Map.Strict as Map+import qualified Distribution.Compat.CharParsing as P+import qualified Text.PrettyPrint as Disp++-------------------------------------------------------------------------------+-- LicenseId+-------------------------------------------------------------------------------++-- | SPDX License identifiers list v3.26+data LicenseId+    = N_0BSD -- ^ @0BSD@, BSD Zero Clause License+    | N_3D_Slicer_1_0 -- ^ @3D-Slicer-1.0@, 3D Slicer License v1.0, SPDX License List 3.25, SPDX License List 3.26+    | AAL -- ^ @AAL@, Attribution Assurance License+    | Abstyles -- ^ @Abstyles@, Abstyles License+    | AdaCore_doc -- ^ @AdaCore-doc@, AdaCore Doc License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Adobe_2006 -- ^ @Adobe-2006@, Adobe Systems Incorporated Source Code License Agreement+    | Adobe_Display_PostScript -- ^ @Adobe-Display-PostScript@, Adobe Display PostScript License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Adobe_Glyph -- ^ @Adobe-Glyph@, Adobe Glyph List License+    | Adobe_Utopia -- ^ @Adobe-Utopia@, Adobe Utopia Font License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | ADSL -- ^ @ADSL@, Amazon Digital Services License+    | AFL_1_1 -- ^ @AFL-1.1@, Academic Free License v1.1+    | AFL_1_2 -- ^ @AFL-1.2@, Academic Free License v1.2+    | AFL_2_0 -- ^ @AFL-2.0@, Academic Free License v2.0+    | AFL_2_1 -- ^ @AFL-2.1@, Academic Free License v2.1+    | AFL_3_0 -- ^ @AFL-3.0@, Academic Free License v3.0+    | Afmparse -- ^ @Afmparse@, Afmparse License+    | AGPL_1_0 -- ^ @AGPL-1.0@, Affero General Public License v1.0, SPDX License List 3.0+    | AGPL_1_0_only -- ^ @AGPL-1.0-only@, Affero General Public License v1.0 only, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | AGPL_1_0_or_later -- ^ @AGPL-1.0-or-later@, Affero General Public License v1.0 or later, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | AGPL_3_0_only -- ^ @AGPL-3.0-only@, GNU Affero General Public License v3.0 only+    | AGPL_3_0_or_later -- ^ @AGPL-3.0-or-later@, GNU Affero General Public License v3.0 or later+    | Aladdin -- ^ @Aladdin@, Aladdin Free Public License+    | AMD_newlib -- ^ @AMD-newlib@, AMD newlib License, SPDX License List 3.25, SPDX License List 3.26+    | AMDPLPA -- ^ @AMDPLPA@, AMD's plpa_map.c License+    | AML_glslang -- ^ @AML-glslang@, AML glslang variant License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | AML -- ^ @AML@, Apple MIT License+    | AMPAS -- ^ @AMPAS@, Academy of Motion Picture Arts and Sciences BSD+    | ANTLR_PD_fallback -- ^ @ANTLR-PD-fallback@, ANTLR Software Rights Notice with license fallback, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | ANTLR_PD -- ^ @ANTLR-PD@, ANTLR Software Rights Notice+    | Any_OSI_perl_modules -- ^ @any-OSI-perl-modules@, Any OSI License - Perl Modules, SPDX License List 3.26+    | Any_OSI -- ^ @any-OSI@, Any OSI License, SPDX License List 3.25, SPDX License List 3.26+    | Apache_1_0 -- ^ @Apache-1.0@, Apache License 1.0+    | Apache_1_1 -- ^ @Apache-1.1@, Apache License 1.1+    | Apache_2_0 -- ^ @Apache-2.0@, Apache License 2.0+    | APAFML -- ^ @APAFML@, Adobe Postscript AFM License+    | APL_1_0 -- ^ @APL-1.0@, Adaptive Public License 1.0+    | App_s2p -- ^ @App-s2p@, App::s2p License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | APSL_1_0 -- ^ @APSL-1.0@, Apple Public Source License 1.0+    | APSL_1_1 -- ^ @APSL-1.1@, Apple Public Source License 1.1+    | APSL_1_2 -- ^ @APSL-1.2@, Apple Public Source License 1.2+    | APSL_2_0 -- ^ @APSL-2.0@, Apple Public Source License 2.0+    | Arphic_1999 -- ^ @Arphic-1999@, Arphic Public License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Artistic_1_0_cl8 -- ^ @Artistic-1.0-cl8@, Artistic License 1.0 w/clause 8+    | Artistic_1_0_Perl -- ^ @Artistic-1.0-Perl@, Artistic License 1.0 (Perl)+    | Artistic_1_0 -- ^ @Artistic-1.0@, Artistic License 1.0+    | Artistic_2_0 -- ^ @Artistic-2.0@, Artistic License 2.0+    | Artistic_dist -- ^ @Artistic-dist@, Artistic License 1.0 (dist), SPDX License List 3.26+    | Aspell_RU -- ^ @Aspell-RU@, Aspell Russian License, SPDX License List 3.26+    | ASWF_Digital_Assets_1_0 -- ^ @ASWF-Digital-Assets-1.0@, ASWF Digital Assets License version 1.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | ASWF_Digital_Assets_1_1 -- ^ @ASWF-Digital-Assets-1.1@, ASWF Digital Assets License 1.1, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Baekmuk -- ^ @Baekmuk@, Baekmuk License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Bahyph -- ^ @Bahyph@, Bahyph License+    | Barr -- ^ @Barr@, Barr License+    | Bcrypt_Solar_Designer -- ^ @bcrypt-Solar-Designer@, bcrypt Solar Designer License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Beerware -- ^ @Beerware@, Beerware License+    | Bitstream_Charter -- ^ @Bitstream-Charter@, Bitstream Charter Font License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Bitstream_Vera -- ^ @Bitstream-Vera@, Bitstream Vera Font License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BitTorrent_1_0 -- ^ @BitTorrent-1.0@, BitTorrent Open Source License v1.0+    | BitTorrent_1_1 -- ^ @BitTorrent-1.1@, BitTorrent Open Source License v1.1+    | Blessing -- ^ @blessing@, SQLite Blessing, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BlueOak_1_0_0 -- ^ @BlueOak-1.0.0@, Blue Oak Model License 1.0.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Boehm_GC_without_fee -- ^ @Boehm-GC-without-fee@, Boehm-Demers-Weiser GC License (without fee), SPDX License List 3.26+    | Boehm_GC -- ^ @Boehm-GC@, Boehm-Demers-Weiser GC License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Borceux -- ^ @Borceux@, Borceux license+    | Brian_Gladman_2_Clause -- ^ @Brian-Gladman-2-Clause@, Brian Gladman 2-Clause License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Brian_Gladman_3_Clause -- ^ @Brian-Gladman-3-Clause@, Brian Gladman 3-Clause License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_1_Clause -- ^ @BSD-1-Clause@, BSD 1-Clause License+    | BSD_2_Clause_FreeBSD -- ^ @BSD-2-Clause-FreeBSD@, BSD 2-Clause FreeBSD License, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9+    | BSD_2_Clause_NetBSD -- ^ @BSD-2-Clause-NetBSD@, BSD 2-Clause NetBSD License, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6+    | BSD_2_Clause_Darwin -- ^ @BSD-2-Clause-Darwin@, BSD 2-Clause - Ian Darwin variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_2_Clause_first_lines -- ^ @BSD-2-Clause-first-lines@, BSD 2-Clause - first lines requirement, SPDX License List 3.25, SPDX License List 3.26+    | BSD_2_Clause_Patent -- ^ @BSD-2-Clause-Patent@, BSD-2-Clause Plus Patent License+    | BSD_2_Clause_pkgconf_disclaimer -- ^ @BSD-2-Clause-pkgconf-disclaimer@, BSD 2-Clause pkgconf disclaimer variant, SPDX License List 3.26+    | BSD_2_Clause_Views -- ^ @BSD-2-Clause-Views@, BSD 2-Clause with views sentence, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_2_Clause -- ^ @BSD-2-Clause@, BSD 2-Clause "Simplified" License+    | BSD_3_Clause_acpica -- ^ @BSD-3-Clause-acpica@, BSD 3-Clause acpica variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause_Attribution -- ^ @BSD-3-Clause-Attribution@, BSD with attribution+    | BSD_3_Clause_Clear -- ^ @BSD-3-Clause-Clear@, BSD 3-Clause Clear License+    | BSD_3_Clause_flex -- ^ @BSD-3-Clause-flex@, BSD 3-Clause Flex variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause_HP -- ^ @BSD-3-Clause-HP@, Hewlett-Packard BSD variant license, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause_LBNL -- ^ @BSD-3-Clause-LBNL@, Lawrence Berkeley National Labs BSD variant license+    | BSD_3_Clause_Modification -- ^ @BSD-3-Clause-Modification@, BSD 3-Clause Modification, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause_No_Military_License -- ^ @BSD-3-Clause-No-Military-License@, BSD 3-Clause No Military License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause_No_Nuclear_License_2014 -- ^ @BSD-3-Clause-No-Nuclear-License-2014@, BSD 3-Clause No Nuclear License 2014+    | BSD_3_Clause_No_Nuclear_License -- ^ @BSD-3-Clause-No-Nuclear-License@, BSD 3-Clause No Nuclear License+    | BSD_3_Clause_No_Nuclear_Warranty -- ^ @BSD-3-Clause-No-Nuclear-Warranty@, BSD 3-Clause No Nuclear Warranty+    | BSD_3_Clause_Open_MPI -- ^ @BSD-3-Clause-Open-MPI@, BSD 3-Clause Open MPI variant, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause_Sun -- ^ @BSD-3-Clause-Sun@, BSD 3-Clause Sun Microsystems, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_3_Clause -- ^ @BSD-3-Clause@, BSD 3-Clause "New" or "Revised" License+    | BSD_4_Clause_Shortened -- ^ @BSD-4-Clause-Shortened@, BSD 4 Clause Shortened, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_4_Clause_UC -- ^ @BSD-4-Clause-UC@, BSD-4-Clause (University of California-Specific)+    | BSD_4_Clause -- ^ @BSD-4-Clause@, BSD 4-Clause "Original" or "Old" License+    | BSD_4_3RENO -- ^ @BSD-4.3RENO@, BSD 4.3 RENO License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_4_3TAHOE -- ^ @BSD-4.3TAHOE@, BSD 4.3 TAHOE License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_Advertising_Acknowledgement -- ^ @BSD-Advertising-Acknowledgement@, BSD Advertising Acknowledgement License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_Attribution_HPND_disclaimer -- ^ @BSD-Attribution-HPND-disclaimer@, BSD with Attribution and HPND disclaimer, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_Inferno_Nettverk -- ^ @BSD-Inferno-Nettverk@, BSD-Inferno-Nettverk, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_Protection -- ^ @BSD-Protection@, BSD Protection License+    | BSD_Source_beginning_file -- ^ @BSD-Source-beginning-file@, BSD Source Code Attribution - beginning of file variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_Source_Code -- ^ @BSD-Source-Code@, BSD Source Code Attribution+    | BSD_Systemics_W3Works -- ^ @BSD-Systemics-W3Works@, Systemics W3Works BSD variant license, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSD_Systemics -- ^ @BSD-Systemics@, Systemics BSD variant license, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | BSL_1_0 -- ^ @BSL-1.0@, Boost Software License 1.0+    | Bzip2_1_0_5 -- ^ @bzip2-1.0.5@, bzip2 and libbzip2 License v1.0.5, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10+    | BUSL_1_1 -- ^ @BUSL-1.1@, Business Source License 1.1, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Bzip2_1_0_6 -- ^ @bzip2-1.0.6@, bzip2 and libbzip2 License v1.0.6+    | C_UDA_1_0 -- ^ @C-UDA-1.0@, Computational Use of Data Agreement v1.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CAL_1_0_Combined_Work_Exception -- ^ @CAL-1.0-Combined-Work-Exception@, Cryptographic Autonomy License 1.0 (Combined Work Exception), SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CAL_1_0 -- ^ @CAL-1.0@, Cryptographic Autonomy License 1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Caldera_no_preamble -- ^ @Caldera-no-preamble@, Caldera License (without preamble), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Caldera -- ^ @Caldera@, Caldera License+    | Catharon -- ^ @Catharon@, Catharon License, SPDX License List 3.25, SPDX License List 3.26+    | CATOSL_1_1 -- ^ @CATOSL-1.1@, Computer Associates Trusted Open Source License 1.1+    | CC_BY_1_0 -- ^ @CC-BY-1.0@, Creative Commons Attribution 1.0 Generic+    | CC_BY_2_0 -- ^ @CC-BY-2.0@, Creative Commons Attribution 2.0 Generic+    | CC_BY_2_5_AU -- ^ @CC-BY-2.5-AU@, Creative Commons Attribution 2.5 Australia, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_2_5 -- ^ @CC-BY-2.5@, Creative Commons Attribution 2.5 Generic+    | CC_BY_3_0_AT -- ^ @CC-BY-3.0-AT@, Creative Commons Attribution 3.0 Austria, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_3_0_AU -- ^ @CC-BY-3.0-AU@, Creative Commons Attribution 3.0 Australia, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_3_0_DE -- ^ @CC-BY-3.0-DE@, Creative Commons Attribution 3.0 Germany, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_3_0_IGO -- ^ @CC-BY-3.0-IGO@, Creative Commons Attribution 3.0 IGO, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_3_0_NL -- ^ @CC-BY-3.0-NL@, Creative Commons Attribution 3.0 Netherlands, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_3_0_US -- ^ @CC-BY-3.0-US@, Creative Commons Attribution 3.0 United States, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_3_0 -- ^ @CC-BY-3.0@, Creative Commons Attribution 3.0 Unported+    | CC_BY_4_0 -- ^ @CC-BY-4.0@, Creative Commons Attribution 4.0 International+    | CC_BY_NC_1_0 -- ^ @CC-BY-NC-1.0@, Creative Commons Attribution Non Commercial 1.0 Generic+    | CC_BY_NC_2_0 -- ^ @CC-BY-NC-2.0@, Creative Commons Attribution Non Commercial 2.0 Generic+    | CC_BY_NC_2_5 -- ^ @CC-BY-NC-2.5@, Creative Commons Attribution Non Commercial 2.5 Generic+    | CC_BY_NC_3_0_DE -- ^ @CC-BY-NC-3.0-DE@, Creative Commons Attribution Non Commercial 3.0 Germany, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_3_0 -- ^ @CC-BY-NC-3.0@, Creative Commons Attribution Non Commercial 3.0 Unported+    | CC_BY_NC_4_0 -- ^ @CC-BY-NC-4.0@, Creative Commons Attribution Non Commercial 4.0 International+    | CC_BY_NC_ND_1_0 -- ^ @CC-BY-NC-ND-1.0@, Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic+    | CC_BY_NC_ND_2_0 -- ^ @CC-BY-NC-ND-2.0@, Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic+    | CC_BY_NC_ND_2_5 -- ^ @CC-BY-NC-ND-2.5@, Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic+    | CC_BY_NC_ND_3_0_DE -- ^ @CC-BY-NC-ND-3.0-DE@, Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_ND_3_0_IGO -- ^ @CC-BY-NC-ND-3.0-IGO@, Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_ND_3_0 -- ^ @CC-BY-NC-ND-3.0@, Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported+    | CC_BY_NC_ND_4_0 -- ^ @CC-BY-NC-ND-4.0@, Creative Commons Attribution Non Commercial No Derivatives 4.0 International+    | CC_BY_NC_SA_1_0 -- ^ @CC-BY-NC-SA-1.0@, Creative Commons Attribution Non Commercial Share Alike 1.0 Generic+    | CC_BY_NC_SA_2_0_DE -- ^ @CC-BY-NC-SA-2.0-DE@, Creative Commons Attribution Non Commercial Share Alike 2.0 Germany, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_SA_2_0_FR -- ^ @CC-BY-NC-SA-2.0-FR@, Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_SA_2_0_UK -- ^ @CC-BY-NC-SA-2.0-UK@, Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_SA_2_0 -- ^ @CC-BY-NC-SA-2.0@, Creative Commons Attribution Non Commercial Share Alike 2.0 Generic+    | CC_BY_NC_SA_2_5 -- ^ @CC-BY-NC-SA-2.5@, Creative Commons Attribution Non Commercial Share Alike 2.5 Generic+    | CC_BY_NC_SA_3_0_DE -- ^ @CC-BY-NC-SA-3.0-DE@, Creative Commons Attribution Non Commercial Share Alike 3.0 Germany, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_SA_3_0_IGO -- ^ @CC-BY-NC-SA-3.0-IGO@, Creative Commons Attribution Non Commercial Share Alike 3.0 IGO, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_NC_SA_3_0 -- ^ @CC-BY-NC-SA-3.0@, Creative Commons Attribution Non Commercial Share Alike 3.0 Unported+    | CC_BY_NC_SA_4_0 -- ^ @CC-BY-NC-SA-4.0@, Creative Commons Attribution Non Commercial Share Alike 4.0 International+    | CC_BY_ND_1_0 -- ^ @CC-BY-ND-1.0@, Creative Commons Attribution No Derivatives 1.0 Generic+    | CC_BY_ND_2_0 -- ^ @CC-BY-ND-2.0@, Creative Commons Attribution No Derivatives 2.0 Generic+    | CC_BY_ND_2_5 -- ^ @CC-BY-ND-2.5@, Creative Commons Attribution No Derivatives 2.5 Generic+    | CC_BY_ND_3_0_DE -- ^ @CC-BY-ND-3.0-DE@, Creative Commons Attribution No Derivatives 3.0 Germany, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_ND_3_0 -- ^ @CC-BY-ND-3.0@, Creative Commons Attribution No Derivatives 3.0 Unported+    | CC_BY_ND_4_0 -- ^ @CC-BY-ND-4.0@, Creative Commons Attribution No Derivatives 4.0 International+    | CC_BY_SA_1_0 -- ^ @CC-BY-SA-1.0@, Creative Commons Attribution Share Alike 1.0 Generic+    | CC_BY_SA_2_0_UK -- ^ @CC-BY-SA-2.0-UK@, Creative Commons Attribution Share Alike 2.0 England and Wales, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_SA_2_0 -- ^ @CC-BY-SA-2.0@, Creative Commons Attribution Share Alike 2.0 Generic+    | CC_BY_SA_2_1_JP -- ^ @CC-BY-SA-2.1-JP@, Creative Commons Attribution Share Alike 2.1 Japan, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_SA_2_5 -- ^ @CC-BY-SA-2.5@, Creative Commons Attribution Share Alike 2.5 Generic+    | CC_BY_SA_3_0_AT -- ^ @CC-BY-SA-3.0-AT@, Creative Commons Attribution Share Alike 3.0 Austria, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_SA_3_0_DE -- ^ @CC-BY-SA-3.0-DE@, Creative Commons Attribution Share Alike 3.0 Germany, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_SA_3_0_IGO -- ^ @CC-BY-SA-3.0-IGO@, Creative Commons Attribution-ShareAlike 3.0 IGO, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_BY_SA_3_0 -- ^ @CC-BY-SA-3.0@, Creative Commons Attribution Share Alike 3.0 Unported+    | CC_BY_SA_4_0 -- ^ @CC-BY-SA-4.0@, Creative Commons Attribution Share Alike 4.0 International+    | CC_PDDC -- ^ @CC-PDDC@, Creative Commons Public Domain Dedication and Certification, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CC_PDM_1_0 -- ^ @CC-PDM-1.0@, Creative    Commons Public Domain Mark 1.0 Universal, SPDX License List 3.26+    | CC_SA_1_0 -- ^ @CC-SA-1.0@, Creative Commons Share Alike 1.0 Generic, SPDX License List 3.26+    | CC0_1_0 -- ^ @CC0-1.0@, Creative Commons Zero v1.0 Universal+    | CDDL_1_0 -- ^ @CDDL-1.0@, Common Development and Distribution License 1.0+    | CDDL_1_1 -- ^ @CDDL-1.1@, Common Development and Distribution License 1.1+    | CDL_1_0 -- ^ @CDL-1.0@, Common Documentation License 1.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CDLA_Permissive_1_0 -- ^ @CDLA-Permissive-1.0@, Community Data License Agreement Permissive 1.0+    | CDLA_Permissive_2_0 -- ^ @CDLA-Permissive-2.0@, Community Data License Agreement Permissive 2.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CDLA_Sharing_1_0 -- ^ @CDLA-Sharing-1.0@, Community Data License Agreement Sharing 1.0+    | CECILL_1_0 -- ^ @CECILL-1.0@, CeCILL Free Software License Agreement v1.0+    | CECILL_1_1 -- ^ @CECILL-1.1@, CeCILL Free Software License Agreement v1.1+    | CECILL_2_0 -- ^ @CECILL-2.0@, CeCILL Free Software License Agreement v2.0+    | CECILL_2_1 -- ^ @CECILL-2.1@, CeCILL Free Software License Agreement v2.1+    | CECILL_B -- ^ @CECILL-B@, CeCILL-B Free Software License Agreement+    | CECILL_C -- ^ @CECILL-C@, CeCILL-C Free Software License Agreement+    | CERN_OHL_1_1 -- ^ @CERN-OHL-1.1@, CERN Open Hardware Licence v1.1, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CERN_OHL_1_2 -- ^ @CERN-OHL-1.2@, CERN Open Hardware Licence v1.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CERN_OHL_P_2_0 -- ^ @CERN-OHL-P-2.0@, CERN Open Hardware Licence Version 2 - Permissive, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CERN_OHL_S_2_0 -- ^ @CERN-OHL-S-2.0@, CERN Open Hardware Licence Version 2 - Strongly Reciprocal, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CERN_OHL_W_2_0 -- ^ @CERN-OHL-W-2.0@, CERN Open Hardware Licence Version 2 - Weakly Reciprocal, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CFITSIO -- ^ @CFITSIO@, CFITSIO License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Check_cvs -- ^ @check-cvs@, check-cvs License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Checkmk -- ^ @checkmk@, Checkmk License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | ClArtistic -- ^ @ClArtistic@, Clarified Artistic License+    | Clips -- ^ @Clips@, Clips License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CMU_Mach_nodoc -- ^ @CMU-Mach-nodoc@, CMU    Mach - no notices-in-documentation variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CMU_Mach -- ^ @CMU-Mach@, CMU Mach License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CNRI_Jython -- ^ @CNRI-Jython@, CNRI Jython License+    | CNRI_Python_GPL_Compatible -- ^ @CNRI-Python-GPL-Compatible@, CNRI Python Open Source GPL Compatible License Agreement+    | CNRI_Python -- ^ @CNRI-Python@, CNRI Python License+    | COIL_1_0 -- ^ @COIL-1.0@, Copyfree Open Innovation License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Community_Spec_1_0 -- ^ @Community-Spec-1.0@, Community Specification License 1.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Condor_1_1 -- ^ @Condor-1.1@, Condor Public License v1.1+    | Copyleft_next_0_3_0 -- ^ @copyleft-next-0.3.0@, copyleft-next 0.3.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Copyleft_next_0_3_1 -- ^ @copyleft-next-0.3.1@, copyleft-next 0.3.1, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Cornell_Lossless_JPEG -- ^ @Cornell-Lossless-JPEG@, Cornell Lossless JPEG License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | CPAL_1_0 -- ^ @CPAL-1.0@, Common Public Attribution License 1.0+    | CPL_1_0 -- ^ @CPL-1.0@, Common Public License 1.0+    | CPOL_1_02 -- ^ @CPOL-1.02@, Code Project Open License 1.02+    | Cronyx -- ^ @Cronyx@, Cronyx License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Crossword -- ^ @Crossword@, Crossword License+    | CryptoSwift -- ^ @CryptoSwift@, CryptoSwift License, SPDX License List 3.26+    | CrystalStacker -- ^ @CrystalStacker@, CrystalStacker License+    | CUA_OPL_1_0 -- ^ @CUA-OPL-1.0@, CUA Office Public License v1.0+    | Cube -- ^ @Cube@, Cube License+    | Curl -- ^ @curl@, curl License+    | Cve_tou -- ^ @cve-tou@, Common Vulnerability Enumeration ToU License, SPDX License List 3.25, SPDX License List 3.26+    | D_FSL_1_0 -- ^ @D-FSL-1.0@, Deutsche Freie Software Lizenz+    | DEC_3_Clause -- ^ @DEC-3-Clause@, DEC 3-Clause License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Diffmark -- ^ @diffmark@, diffmark license+    | DL_DE_BY_2_0 -- ^ @DL-DE-BY-2.0@, Data licence Germany – attribution – version 2.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | DL_DE_ZERO_2_0 -- ^ @DL-DE-ZERO-2.0@, Data licence Germany – zero – version 2.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | DocBook_DTD -- ^ @DocBook-DTD@, DocBook DTD License, SPDX License List 3.26+    | DocBook_Schema -- ^ @DocBook-Schema@, DocBook Schema License, SPDX License List 3.25, SPDX License List 3.26+    | DocBook_Stylesheet -- ^ @DocBook-Stylesheet@, DocBook Stylesheet License, SPDX License List 3.26+    | DocBook_XML -- ^ @DocBook-XML@, DocBook XML License, SPDX License List 3.25, SPDX License List 3.26+    | DOC -- ^ @DOC@, DOC License+    | Dotseqn -- ^ @Dotseqn@, Dotseqn License+    | DRL_1_0 -- ^ @DRL-1.0@, Detection Rule License 1.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | DRL_1_1 -- ^ @DRL-1.1@, Detection Rule License 1.1, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | DSDP -- ^ @DSDP@, DSDP License+    | Dtoa -- ^ @dtoa@, David M. Gay dtoa License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Dvipdfm -- ^ @dvipdfm@, dvipdfm License+    | ECL_1_0 -- ^ @ECL-1.0@, Educational Community License v1.0+    | ECL_2_0 -- ^ @ECL-2.0@, Educational Community License v2.0+    | EFL_1_0 -- ^ @EFL-1.0@, Eiffel Forum License v1.0+    | EFL_2_0 -- ^ @EFL-2.0@, Eiffel Forum License v2.0+    | EGenix -- ^ @eGenix@, eGenix.com Public License 1.1.0+    | Elastic_2_0 -- ^ @Elastic-2.0@, Elastic License 2.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Entessa -- ^ @Entessa@, Entessa Public License v1.0+    | EPICS -- ^ @EPICS@, EPICS Open License, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | EPL_1_0 -- ^ @EPL-1.0@, Eclipse Public License 1.0+    | EPL_2_0 -- ^ @EPL-2.0@, Eclipse Public License 2.0+    | ErlPL_1_1 -- ^ @ErlPL-1.1@, Erlang Public License v1.1+    | Etalab_2_0 -- ^ @etalab-2.0@, Etalab Open License 2.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | EUDatagrid -- ^ @EUDatagrid@, EU DataGrid Software License+    | EUPL_1_0 -- ^ @EUPL-1.0@, European Union Public License 1.0+    | EUPL_1_1 -- ^ @EUPL-1.1@, European Union Public License 1.1+    | EUPL_1_2 -- ^ @EUPL-1.2@, European Union Public License 1.2+    | Eurosym -- ^ @Eurosym@, Eurosym License+    | Fair -- ^ @Fair@, Fair License+    | FBM -- ^ @FBM@, Fuzzy Bitmap License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | FDK_AAC -- ^ @FDK-AAC@, Fraunhofer FDK AAC Codec Library, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Ferguson_Twofish -- ^ @Ferguson-Twofish@, Ferguson Twofish License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Frameworx_1_0 -- ^ @Frameworx-1.0@, Frameworx Open License 1.0+    | FreeBSD_DOC -- ^ @FreeBSD-DOC@, FreeBSD Documentation License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | FreeImage -- ^ @FreeImage@, FreeImage Public License v1.0+    | FSFAP_no_warranty_disclaimer -- ^ @FSFAP-no-warranty-disclaimer@, FSF All Permissive License (without Warranty), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | FSFAP -- ^ @FSFAP@, FSF All Permissive License+    | FSFULLRSD -- ^ @FSFULLRSD@, FSF Unlimited License (with License Retention and Short Disclaimer), SPDX License List 3.26+    | FSFULLRWD -- ^ @FSFULLRWD@, FSF Unlimited License (With License Retention and Warranty Disclaimer), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | FSFULLR -- ^ @FSFULLR@, FSF Unlimited License (with License Retention)+    | FSFUL -- ^ @FSFUL@, FSF Unlimited License+    | FSL_1_1_ALv2 -- ^ @FSL-1.1-ALv2@, Functional Source License, Version 1.1, ALv2 Future License, SPDX License List 3.26+    | FSL_1_1_MIT -- ^ @FSL-1.1-MIT@, Functional Source License, Version 1.1, MIT Future License, SPDX License List 3.26+    | FTL -- ^ @FTL@, Freetype Project License+    | Furuseth -- ^ @Furuseth@, Furuseth License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Fwlw -- ^ @fwlw@, fwlw License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Game_Programming_Gems -- ^ @Game-Programming-Gems@, Game Programming Gems License, SPDX License List 3.26+    | GCR_docs -- ^ @GCR-docs@, Gnome GCR Documentation License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GD -- ^ @GD@, GD License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Generic_xts -- ^ @generic-xts@, Generic XTS License, SPDX License List 3.26+    | GFDL_1_1_invariants_only -- ^ @GFDL-1.1-invariants-only@, GNU Free Documentation License v1.1 only - invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_1_invariants_or_later -- ^ @GFDL-1.1-invariants-or-later@, GNU Free Documentation License v1.1 or later - invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_1_no_invariants_only -- ^ @GFDL-1.1-no-invariants-only@, GNU Free Documentation License v1.1 only - no invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_1_no_invariants_or_later -- ^ @GFDL-1.1-no-invariants-or-later@, GNU Free Documentation License v1.1 or later - no invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_1_only -- ^ @GFDL-1.1-only@, GNU Free Documentation License v1.1 only+    | GFDL_1_1_or_later -- ^ @GFDL-1.1-or-later@, GNU Free Documentation License v1.1 or later+    | GFDL_1_2_invariants_only -- ^ @GFDL-1.2-invariants-only@, GNU Free Documentation License v1.2 only - invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_2_invariants_or_later -- ^ @GFDL-1.2-invariants-or-later@, GNU Free Documentation License v1.2 or later - invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_2_no_invariants_only -- ^ @GFDL-1.2-no-invariants-only@, GNU Free Documentation License v1.2 only - no invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_2_no_invariants_or_later -- ^ @GFDL-1.2-no-invariants-or-later@, GNU Free Documentation License v1.2 or later - no invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_2_only -- ^ @GFDL-1.2-only@, GNU Free Documentation License v1.2 only+    | GFDL_1_2_or_later -- ^ @GFDL-1.2-or-later@, GNU Free Documentation License v1.2 or later+    | GFDL_1_3_invariants_only -- ^ @GFDL-1.3-invariants-only@, GNU Free Documentation License v1.3 only - invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_3_invariants_or_later -- ^ @GFDL-1.3-invariants-or-later@, GNU Free Documentation License v1.3 or later - invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_3_no_invariants_only -- ^ @GFDL-1.3-no-invariants-only@, GNU Free Documentation License v1.3 only - no invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_3_no_invariants_or_later -- ^ @GFDL-1.3-no-invariants-or-later@, GNU Free Documentation License v1.3 or later - no invariants, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GFDL_1_3_only -- ^ @GFDL-1.3-only@, GNU Free Documentation License v1.3 only+    | GFDL_1_3_or_later -- ^ @GFDL-1.3-or-later@, GNU Free Documentation License v1.3 or later+    | Giftware -- ^ @Giftware@, Giftware License+    | GL2PS -- ^ @GL2PS@, GL2PS License+    | Glide -- ^ @Glide@, 3dfx Glide License+    | Glulxe -- ^ @Glulxe@, Glulxe License+    | GLWTPL -- ^ @GLWTPL@, Good Luck With That Public License, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Gnuplot -- ^ @gnuplot@, gnuplot License+    | GPL_1_0_only -- ^ @GPL-1.0-only@, GNU General Public License v1.0 only+    | GPL_1_0_or_later -- ^ @GPL-1.0-or-later@, GNU General Public License v1.0 or later+    | GPL_2_0_only -- ^ @GPL-2.0-only@, GNU General Public License v2.0 only+    | GPL_2_0_or_later -- ^ @GPL-2.0-or-later@, GNU General Public License v2.0 or later+    | GPL_3_0_only -- ^ @GPL-3.0-only@, GNU General Public License v3.0 only+    | GPL_3_0_or_later -- ^ @GPL-3.0-or-later@, GNU General Public License v3.0 or later+    | Graphics_Gems -- ^ @Graphics-Gems@, Graphics Gems License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | GSOAP_1_3b -- ^ @gSOAP-1.3b@, gSOAP Public License v1.3b+    | Gtkbook -- ^ @gtkbook@, gtkbook License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Gutmann -- ^ @Gutmann@, Gutmann License, SPDX License List 3.25, SPDX License List 3.26+    | HaskellReport -- ^ @HaskellReport@, Haskell Language Report License+    | HDF5 -- ^ @HDF5@, HDF5 License, SPDX License List 3.26+    | Hdparm -- ^ @hdparm@, hdparm License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HIDAPI -- ^ @HIDAPI@, HIDAPI License, SPDX License List 3.25, SPDX License List 3.26+    | Hippocratic_2_1 -- ^ @Hippocratic-2.1@, Hippocratic License 2.1, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HP_1986 -- ^ @HP-1986@, Hewlett-Packard 1986 License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HP_1989 -- ^ @HP-1989@, Hewlett-Packard 1989 License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_DEC -- ^ @HPND-DEC@, Historical Permission Notice and Disclaimer - DEC variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_doc_sell -- ^ @HPND-doc-sell@, Historical Permission Notice and Disclaimer - documentation sell variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_doc -- ^ @HPND-doc@, Historical Permission Notice and Disclaimer - documentation variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_export_US_acknowledgement -- ^ @HPND-export-US-acknowledgement@, HPND with US Government export control warning and acknowledgment, SPDX License List 3.25, SPDX License List 3.26+    | HPND_export_US_modify -- ^ @HPND-export-US-modify@, HPND with US Government export control warning and modification rqmt, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_export_US -- ^ @HPND-export-US@, HPND with US Government export control warning, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_export2_US -- ^ @HPND-export2-US@, HPND with US Government export control and 2 disclaimers, SPDX License List 3.25, SPDX License List 3.26+    | HPND_Fenneberg_Livingston -- ^ @HPND-Fenneberg-Livingston@, Historical Permission Notice and Disclaimer - Fenneberg-Livingston variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_INRIA_IMAG -- ^ @HPND-INRIA-IMAG@, Historical Permission Notice and Disclaimer    - INRIA-IMAG variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_Intel -- ^ @HPND-Intel@, Historical Permission Notice and Disclaimer - Intel variant, SPDX License List 3.25, SPDX License List 3.26+    | HPND_Kevlin_Henney -- ^ @HPND-Kevlin-Henney@, Historical Permission Notice and Disclaimer - Kevlin Henney variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_Markus_Kuhn -- ^ @HPND-Markus-Kuhn@, Historical Permission Notice and Disclaimer - Markus Kuhn variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_merchantability_variant -- ^ @HPND-merchantability-variant@, Historical Permission Notice and Disclaimer - merchantability variant, SPDX License List 3.25, SPDX License List 3.26+    | HPND_MIT_disclaimer -- ^ @HPND-MIT-disclaimer@, Historical Permission Notice and Disclaimer with MIT disclaimer, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_Netrek -- ^ @HPND-Netrek@, Historical Permission Notice and Disclaimer - Netrek variant, SPDX License List 3.25, SPDX License List 3.26+    | HPND_Pbmplus -- ^ @HPND-Pbmplus@, Historical Permission Notice and Disclaimer - Pbmplus variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_sell_MIT_disclaimer_xserver -- ^ @HPND-sell-MIT-disclaimer-xserver@, Historical Permission Notice and Disclaimer - sell xserver variant with MIT disclaimer, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_sell_regexpr -- ^ @HPND-sell-regexpr@, Historical Permission Notice and Disclaimer - sell regexpr variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_sell_variant_MIT_disclaimer_rev -- ^ @HPND-sell-variant-MIT-disclaimer-rev@, HPND sell variant with MIT disclaimer - reverse, SPDX License List 3.25, SPDX License List 3.26+    | HPND_sell_variant_MIT_disclaimer -- ^ @HPND-sell-variant-MIT-disclaimer@, HPND sell variant with MIT disclaimer, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_sell_variant -- ^ @HPND-sell-variant@, Historical Permission Notice and Disclaimer - sell variant, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND_UC_export_US -- ^ @HPND-UC-export-US@, Historical Permission Notice and Disclaimer - University of California, US export warning, SPDX License List 3.25, SPDX License List 3.26+    | HPND_UC -- ^ @HPND-UC@, Historical Permission Notice and Disclaimer - University of California variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | HPND -- ^ @HPND@, Historical Permission Notice and Disclaimer+    | HTMLTIDY -- ^ @HTMLTIDY@, HTML Tidy License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | IBM_pibs -- ^ @IBM-pibs@, IBM PowerPC Initialization and Boot Software+    | ICU -- ^ @ICU@, ICU License+    | IEC_Code_Components_EULA -- ^ @IEC-Code-Components-EULA@, IEC    Code Components End-user licence agreement, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | IJG_short -- ^ @IJG-short@, Independent JPEG Group License - short, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | IJG -- ^ @IJG@, Independent JPEG Group License+    | ImageMagick -- ^ @ImageMagick@, ImageMagick License+    | IMatix -- ^ @iMatix@, iMatix Standard Function Library Agreement+    | Imlib2 -- ^ @Imlib2@, Imlib2 License+    | Info_ZIP -- ^ @Info-ZIP@, Info-ZIP License+    | Inner_Net_2_0 -- ^ @Inner-Net-2.0@, Inner Net License v2.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | InnoSetup -- ^ @InnoSetup@, Inno Setup License, SPDX License List 3.26+    | Intel_ACPI -- ^ @Intel-ACPI@, Intel ACPI Software License Agreement+    | Intel -- ^ @Intel@, Intel Open Source License+    | Interbase_1_0 -- ^ @Interbase-1.0@, Interbase Public License v1.0+    | IPA -- ^ @IPA@, IPA Font License+    | IPL_1_0 -- ^ @IPL-1.0@, IBM Public License v1.0+    | ISC_Veillard -- ^ @ISC-Veillard@, ISC Veillard variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | ISC -- ^ @ISC@, ISC License+    | Jam -- ^ @Jam@, Jam License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | JasPer_2_0 -- ^ @JasPer-2.0@, JasPer License+    | Jove -- ^ @jove@, Jove License, SPDX License List 3.26+    | JPL_image -- ^ @JPL-image@, JPL Image Use Policy, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | JPNIC -- ^ @JPNIC@, Japan Network Information Center License, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | JSON -- ^ @JSON@, JSON License+    | Kastrup -- ^ @Kastrup@, Kastrup License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Kazlib -- ^ @Kazlib@, Kazlib License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Knuth_CTAN -- ^ @Knuth-CTAN@, Knuth CTAN License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LAL_1_2 -- ^ @LAL-1.2@, Licence Art Libre 1.2+    | LAL_1_3 -- ^ @LAL-1.3@, Licence Art Libre 1.3+    | Latex2e_translated_notice -- ^ @Latex2e-translated-notice@, Latex2e with translated notice permission, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Latex2e -- ^ @Latex2e@, Latex2e License+    | Leptonica -- ^ @Leptonica@, Leptonica License+    | LGPL_2_0_only -- ^ @LGPL-2.0-only@, GNU Library General Public License v2 only+    | LGPL_2_0_or_later -- ^ @LGPL-2.0-or-later@, GNU Library General Public License v2 or later+    | LGPL_2_1_only -- ^ @LGPL-2.1-only@, GNU Lesser General Public License v2.1 only+    | LGPL_2_1_or_later -- ^ @LGPL-2.1-or-later@, GNU Lesser General Public License v2.1 or later+    | LGPL_3_0_only -- ^ @LGPL-3.0-only@, GNU Lesser General Public License v3.0 only+    | LGPL_3_0_or_later -- ^ @LGPL-3.0-or-later@, GNU Lesser General Public License v3.0 or later+    | LGPLLR -- ^ @LGPLLR@, Lesser General Public License For Linguistic Resources+    | Libpng_1_6_35 -- ^ @libpng-1.6.35@, PNG Reference Library License v1 (for libpng 0.5 through 1.6.35, SPDX License List 3.26+    | Libpng_2_0 -- ^ @libpng-2.0@, PNG Reference Library version 2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Libpng -- ^ @Libpng@, libpng License+    | Libselinux_1_0 -- ^ @libselinux-1.0@, libselinux public domain notice, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Libtiff -- ^ @libtiff@, libtiff License+    | Libutil_David_Nugent -- ^ @libutil-David-Nugent@, libutil David Nugent License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LiLiQ_P_1_1 -- ^ @LiLiQ-P-1.1@, Licence Libre du Québec – Permissive version 1.1+    | LiLiQ_R_1_1 -- ^ @LiLiQ-R-1.1@, Licence Libre du Québec – Réciprocité version 1.1+    | LiLiQ_Rplus_1_1 -- ^ @LiLiQ-Rplus-1.1@, Licence Libre du Québec – Réciprocité forte version 1.1+    | Linux_man_pages_1_para -- ^ @Linux-man-pages-1-para@, Linux man-pages - 1 paragraph, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Linux_man_pages_copyleft_2_para -- ^ @Linux-man-pages-copyleft-2-para@, Linux man-pages Copyleft - 2 paragraphs, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Linux_man_pages_copyleft_var -- ^ @Linux-man-pages-copyleft-var@, Linux man-pages Copyleft Variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Linux_man_pages_copyleft -- ^ @Linux-man-pages-copyleft@, Linux man-pages Copyleft, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Linux_OpenIB -- ^ @Linux-OpenIB@, Linux Kernel Variant of OpenIB.org license, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LOOP -- ^ @LOOP@, Common Lisp LOOP License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LPD_document -- ^ @LPD-document@, LPD Documentation License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LPL_1_02 -- ^ @LPL-1.02@, Lucent Public License v1.02+    | LPL_1_0 -- ^ @LPL-1.0@, Lucent Public License Version 1.0+    | LPPL_1_0 -- ^ @LPPL-1.0@, LaTeX Project Public License v1.0+    | LPPL_1_1 -- ^ @LPPL-1.1@, LaTeX Project Public License v1.1+    | LPPL_1_2 -- ^ @LPPL-1.2@, LaTeX Project Public License v1.2+    | LPPL_1_3a -- ^ @LPPL-1.3a@, LaTeX Project Public License v1.3a+    | LPPL_1_3c -- ^ @LPPL-1.3c@, LaTeX Project Public License v1.3c+    | Lsof -- ^ @lsof@, lsof License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Lucida_Bitmap_Fonts -- ^ @Lucida-Bitmap-Fonts@, Lucida Bitmap Fonts License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LZMA_SDK_9_11_to_9_20 -- ^ @LZMA-SDK-9.11-to-9.20@, LZMA SDK License (versions 9.11 to 9.20), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | LZMA_SDK_9_22 -- ^ @LZMA-SDK-9.22@, LZMA SDK License (versions 9.22 and beyond), SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Mackerras_3_Clause_acknowledgment -- ^ @Mackerras-3-Clause-acknowledgment@, Mackerras 3-Clause - acknowledgment variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Mackerras_3_Clause -- ^ @Mackerras-3-Clause@, Mackerras 3-Clause License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Magaz -- ^ @magaz@, magaz License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Mailprio -- ^ @mailprio@, mailprio License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MakeIndex -- ^ @MakeIndex@, MakeIndex License+    | Man2html -- ^ @man2html@, man2html License, SPDX License List 3.26+    | Martin_Birgmeier -- ^ @Martin-Birgmeier@, Martin Birgmeier License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | McPhee_slideshow -- ^ @McPhee-slideshow@, McPhee Slideshow License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Metamail -- ^ @metamail@, metamail License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Minpack -- ^ @Minpack@, Minpack License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MIPS -- ^ @MIPS@, MIPS License, SPDX License List 3.26+    | MirOS -- ^ @MirOS@, The MirOS Licence+    | MIT_0 -- ^ @MIT-0@, MIT No Attribution, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MIT_advertising -- ^ @MIT-advertising@, Enlightenment License (e16)+    | MIT_Click -- ^ @MIT-Click@, MIT Click License, SPDX License List 3.26+    | MIT_CMU -- ^ @MIT-CMU@, CMU License+    | MIT_enna -- ^ @MIT-enna@, enna License+    | MIT_feh -- ^ @MIT-feh@, feh License+    | MIT_Festival -- ^ @MIT-Festival@, MIT Festival Variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MIT_Khronos_old -- ^ @MIT-Khronos-old@, MIT Khronos - old variant, SPDX License List 3.25, SPDX License List 3.26+    | MIT_Modern_Variant -- ^ @MIT-Modern-Variant@, MIT License Modern Variant, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MIT_open_group -- ^ @MIT-open-group@, MIT Open Group variant, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MIT_testregex -- ^ @MIT-testregex@, MIT testregex Variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MIT_Wu -- ^ @MIT-Wu@, MIT Tom Wu Variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MITNFA -- ^ @MITNFA@, MIT +no-false-attribs license+    | MIT -- ^ @MIT@, MIT License+    | MMIXware -- ^ @MMIXware@, MMIXware License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Motosoto -- ^ @Motosoto@, Motosoto License+    | MPEG_SSG -- ^ @MPEG-SSG@, MPEG Software Simulation, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Mpi_permissive -- ^ @mpi-permissive@, mpi Permissive License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Mpich2 -- ^ @mpich2@, mpich2 License+    | MPL_1_0 -- ^ @MPL-1.0@, Mozilla Public License 1.0+    | MPL_1_1 -- ^ @MPL-1.1@, Mozilla Public License 1.1+    | MPL_2_0_no_copyleft_exception -- ^ @MPL-2.0-no-copyleft-exception@, Mozilla Public License 2.0 (no copyleft exception)+    | MPL_2_0 -- ^ @MPL-2.0@, Mozilla Public License 2.0+    | Mplus -- ^ @mplus@, mplus Font License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MS_LPL -- ^ @MS-LPL@, Microsoft Limited Public License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MS_PL -- ^ @MS-PL@, Microsoft Public License+    | MS_RL -- ^ @MS-RL@, Microsoft Reciprocal License+    | MTLL -- ^ @MTLL@, Matrix Template Library License+    | MulanPSL_1_0 -- ^ @MulanPSL-1.0@, Mulan Permissive Software License, Version 1, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | MulanPSL_2_0 -- ^ @MulanPSL-2.0@, Mulan Permissive Software License, Version 2, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Multics -- ^ @Multics@, Multics License+    | Mup -- ^ @Mup@, Mup License+    | NAIST_2003 -- ^ @NAIST-2003@, Nara Institute of Science and Technology License (2003), SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NASA_1_3 -- ^ @NASA-1.3@, NASA Open Source Agreement 1.3+    | Naumen -- ^ @Naumen@, Naumen Public License+    | NBPL_1_0 -- ^ @NBPL-1.0@, Net Boolean Public License v1+    | NCBI_PD -- ^ @NCBI-PD@, NCBI Public Domain Notice, SPDX License List 3.25, SPDX License List 3.26+    | NCGL_UK_2_0 -- ^ @NCGL-UK-2.0@, Non-Commercial Government Licence, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NCL -- ^ @NCL@, NCL Source Code License, SPDX License List 3.25, SPDX License List 3.26+    | NCSA -- ^ @NCSA@, University of Illinois/NCSA Open Source License+    | Net_SNMP -- ^ @Net-SNMP@, Net-SNMP License, SPDX License List 3.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23+    | NetCDF -- ^ @NetCDF@, NetCDF license+    | Newsletr -- ^ @Newsletr@, Newsletr License+    | NGPL -- ^ @NGPL@, Nethack General Public License+    | Ngrep -- ^ @ngrep@, ngrep License, SPDX License List 3.26+    | NICTA_1_0 -- ^ @NICTA-1.0@, NICTA Public Software License, Version 1.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NIST_PD_fallback -- ^ @NIST-PD-fallback@, NIST Public Domain Notice with license fallback, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NIST_PD -- ^ @NIST-PD@, NIST Public Domain Notice, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NIST_Software -- ^ @NIST-Software@, NIST Software License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NLOD_1_0 -- ^ @NLOD-1.0@, Norwegian Licence for Open Government Data (NLOD) 1.0+    | NLOD_2_0 -- ^ @NLOD-2.0@, Norwegian Licence for Open Government Data (NLOD) 2.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NLPL -- ^ @NLPL@, No Limit Public License+    | Nokia -- ^ @Nokia@, Nokia Open Source License+    | NOSL -- ^ @NOSL@, Netizen Open Source License+    | Noweb -- ^ @Noweb@, Noweb License+    | NPL_1_0 -- ^ @NPL-1.0@, Netscape Public License v1.0+    | NPL_1_1 -- ^ @NPL-1.1@, Netscape Public License v1.1+    | NPOSL_3_0 -- ^ @NPOSL-3.0@, Non-Profit Open Software License 3.0+    | NRL -- ^ @NRL@, NRL License+    | NTIA_PD -- ^ @NTIA-PD@, NTIA Public Domain Notice, SPDX License List 3.26+    | NTP_0 -- ^ @NTP-0@, NTP No Attribution, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | NTP -- ^ @NTP@, NTP License+    | O_UDA_1_0 -- ^ @O-UDA-1.0@, Open Use of Data Agreement v1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OAR -- ^ @OAR@, OAR License, SPDX License List 3.25, SPDX License List 3.26+    | OCCT_PL -- ^ @OCCT-PL@, Open CASCADE Technology Public License+    | OCLC_2_0 -- ^ @OCLC-2.0@, OCLC Research Public License 2.0+    | ODbL_1_0 -- ^ @ODbL-1.0@, Open Data Commons Open Database License v1.0+    | ODC_By_1_0 -- ^ @ODC-By-1.0@, Open Data Commons Attribution License v1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OFFIS -- ^ @OFFIS@, OFFIS License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OFL_1_0_no_RFN -- ^ @OFL-1.0-no-RFN@, SIL Open Font License 1.0 with no Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OFL_1_0_RFN -- ^ @OFL-1.0-RFN@, SIL Open Font License 1.0 with Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OFL_1_0 -- ^ @OFL-1.0@, SIL Open Font License 1.0+    | OFL_1_1_no_RFN -- ^ @OFL-1.1-no-RFN@, SIL Open Font License 1.1 with no Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OFL_1_1_RFN -- ^ @OFL-1.1-RFN@, SIL Open Font License 1.1 with Reserved Font Name, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OFL_1_1 -- ^ @OFL-1.1@, SIL Open Font License 1.1+    | OGC_1_0 -- ^ @OGC-1.0@, OGC Software License, Version 1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OGDL_Taiwan_1_0 -- ^ @OGDL-Taiwan-1.0@, Taiwan Open Government Data License, version 1.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OGL_Canada_2_0 -- ^ @OGL-Canada-2.0@, Open Government Licence - Canada, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OGL_UK_1_0 -- ^ @OGL-UK-1.0@, Open Government Licence v1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OGL_UK_2_0 -- ^ @OGL-UK-2.0@, Open Government Licence v2.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OGL_UK_3_0 -- ^ @OGL-UK-3.0@, Open Government Licence v3.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OGTSL -- ^ @OGTSL@, Open Group Test Suite License+    | OLDAP_1_1 -- ^ @OLDAP-1.1@, Open LDAP Public License v1.1+    | OLDAP_1_2 -- ^ @OLDAP-1.2@, Open LDAP Public License v1.2+    | OLDAP_1_3 -- ^ @OLDAP-1.3@, Open LDAP Public License v1.3+    | OLDAP_1_4 -- ^ @OLDAP-1.4@, Open LDAP Public License v1.4+    | OLDAP_2_0_1 -- ^ @OLDAP-2.0.1@, Open LDAP Public License v2.0.1+    | OLDAP_2_0 -- ^ @OLDAP-2.0@, Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)+    | OLDAP_2_1 -- ^ @OLDAP-2.1@, Open LDAP Public License v2.1+    | OLDAP_2_2_1 -- ^ @OLDAP-2.2.1@, Open LDAP Public License v2.2.1+    | OLDAP_2_2_2 -- ^ @OLDAP-2.2.2@, Open LDAP Public License 2.2.2+    | OLDAP_2_2 -- ^ @OLDAP-2.2@, Open LDAP Public License v2.2+    | OLDAP_2_3 -- ^ @OLDAP-2.3@, Open LDAP Public License v2.3+    | OLDAP_2_4 -- ^ @OLDAP-2.4@, Open LDAP Public License v2.4+    | OLDAP_2_5 -- ^ @OLDAP-2.5@, Open LDAP Public License v2.5+    | OLDAP_2_6 -- ^ @OLDAP-2.6@, Open LDAP Public License v2.6+    | OLDAP_2_7 -- ^ @OLDAP-2.7@, Open LDAP Public License v2.7+    | OLDAP_2_8 -- ^ @OLDAP-2.8@, Open LDAP Public License v2.8+    | OLFL_1_3 -- ^ @OLFL-1.3@, Open Logistics Foundation License Version 1.3, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OML -- ^ @OML@, Open Market License+    | OpenPBS_2_3 -- ^ @OpenPBS-2.3@, OpenPBS v2.3 Software License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OpenSSL_standalone -- ^ @OpenSSL-standalone@, OpenSSL License - standalone, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OpenSSL -- ^ @OpenSSL@, OpenSSL License+    | OpenVision -- ^ @OpenVision@, OpenVision License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OPL_1_0 -- ^ @OPL-1.0@, Open Public License v1.0+    | OPL_UK_3_0 -- ^ @OPL-UK-3.0@, United    Kingdom Open Parliament Licence v3.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OPUBL_1_0 -- ^ @OPUBL-1.0@, Open Publication License v1.0, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | OSET_PL_2_1 -- ^ @OSET-PL-2.1@, OSET Public License version 2.1+    | OSL_1_0 -- ^ @OSL-1.0@, Open Software License 1.0+    | OSL_1_1 -- ^ @OSL-1.1@, Open Software License 1.1+    | OSL_2_0 -- ^ @OSL-2.0@, Open Software License 2.0+    | OSL_2_1 -- ^ @OSL-2.1@, Open Software License 2.1+    | OSL_3_0 -- ^ @OSL-3.0@, Open Software License 3.0+    | PADL -- ^ @PADL@, PADL License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Parity_6_0_0 -- ^ @Parity-6.0.0@, The Parity Public License 6.0.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Parity_7_0_0 -- ^ @Parity-7.0.0@, The Parity Public License 7.0.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | PDDL_1_0 -- ^ @PDDL-1.0@, Open Data Commons Public Domain Dedication & License 1.0+    | PHP_3_01 -- ^ @PHP-3.01@, PHP License v3.01+    | PHP_3_0 -- ^ @PHP-3.0@, PHP License v3.0+    | Pixar -- ^ @Pixar@, Pixar License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Pkgconf -- ^ @pkgconf@, pkgconf License, SPDX License List 3.25, SPDX License List 3.26+    | Plexus -- ^ @Plexus@, Plexus Classworlds License+    | Pnmstitch -- ^ @pnmstitch@, pnmstitch License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | PolyForm_Noncommercial_1_0_0 -- ^ @PolyForm-Noncommercial-1.0.0@, PolyForm Noncommercial License 1.0.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | PolyForm_Small_Business_1_0_0 -- ^ @PolyForm-Small-Business-1.0.0@, PolyForm Small Business License 1.0.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | PostgreSQL -- ^ @PostgreSQL@, PostgreSQL License+    | PPL -- ^ @PPL@, Peer Production License, SPDX License List 3.25, SPDX License List 3.26+    | PSF_2_0 -- ^ @PSF-2.0@, Python Software Foundation License 2.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Psfrag -- ^ @psfrag@, psfrag License+    | Psutils -- ^ @psutils@, psutils License+    | Python_2_0_1 -- ^ @Python-2.0.1@, Python License 2.0.1, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Python_2_0 -- ^ @Python-2.0@, Python License 2.0+    | Python_ldap -- ^ @python-ldap@, Python ldap License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Qhull -- ^ @Qhull@, Qhull License+    | QPL_1_0_INRIA_2004 -- ^ @QPL-1.0-INRIA-2004@, Q Public License 1.0 - INRIA 2004 variant, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | QPL_1_0 -- ^ @QPL-1.0@, Q Public License 1.0+    | Radvd -- ^ @radvd@, radvd License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Rdisc -- ^ @Rdisc@, Rdisc License+    | RHeCos_1_1 -- ^ @RHeCos-1.1@, Red Hat eCos Public License v1.1+    | RPL_1_1 -- ^ @RPL-1.1@, Reciprocal Public License 1.1+    | RPL_1_5 -- ^ @RPL-1.5@, Reciprocal Public License 1.5+    | RPSL_1_0 -- ^ @RPSL-1.0@, RealNetworks Public Source License v1.0+    | RSA_MD -- ^ @RSA-MD@, RSA Message-Digest License+    | RSCPL -- ^ @RSCPL@, Ricoh Source Code Public License+    | Ruby_pty -- ^ @Ruby-pty@, Ruby pty extension license, SPDX License List 3.25, SPDX License List 3.26+    | Ruby -- ^ @Ruby@, Ruby License+    | SAX_PD_2_0 -- ^ @SAX-PD-2.0@, Sax Public Domain Notice 2.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SAX_PD -- ^ @SAX-PD@, Sax Public Domain Notice+    | Saxpath -- ^ @Saxpath@, Saxpath License+    | SCEA -- ^ @SCEA@, SCEA Shared Source License+    | SchemeReport -- ^ @SchemeReport@, Scheme Language Report License, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Sendmail_8_23 -- ^ @Sendmail-8.23@, Sendmail License 8.23, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Sendmail_Open_Source_1_1 -- ^ @Sendmail-Open-Source-1.1@, Sendmail Open Source License v1.1, SPDX License List 3.26+    | Sendmail -- ^ @Sendmail@, Sendmail License+    | SGI_B_1_0 -- ^ @SGI-B-1.0@, SGI Free Software License B v1.0+    | SGI_B_1_1 -- ^ @SGI-B-1.1@, SGI Free Software License B v1.1+    | SGI_B_2_0 -- ^ @SGI-B-2.0@, SGI Free Software License B v2.0+    | SGI_OpenGL -- ^ @SGI-OpenGL@, SGI OpenGL License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SGP4 -- ^ @SGP4@, SGP4 Permission Notice, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SHL_0_51 -- ^ @SHL-0.51@, Solderpad Hardware License, Version 0.51, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SHL_0_5 -- ^ @SHL-0.5@, Solderpad Hardware License v0.5, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SimPL_2_0 -- ^ @SimPL-2.0@, Simple Public License 2.0+    | SISSL_1_2 -- ^ @SISSL-1.2@, Sun Industry Standards Source License v1.2+    | SISSL -- ^ @SISSL@, Sun Industry Standards Source License v1.1+    | Sleepycat -- ^ @Sleepycat@, Sleepycat License+    | SL -- ^ @SL@, SL License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SMAIL_GPL -- ^ @SMAIL-GPL@, SMAIL General Public License, SPDX License List 3.26+    | SMLNJ -- ^ @SMLNJ@, Standard ML of New Jersey License+    | SMPPL -- ^ @SMPPL@, Secure Messaging Protocol Public License+    | SNIA -- ^ @SNIA@, SNIA Public License 1.1+    | Snprintf -- ^ @snprintf@, snprintf License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SOFA -- ^ @SOFA@, SOFA Software License, SPDX License List 3.26+    | SoftSurfer -- ^ @softSurfer@, softSurfer License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Soundex -- ^ @Soundex@, Soundex License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Spencer_86 -- ^ @Spencer-86@, Spencer License 86+    | Spencer_94 -- ^ @Spencer-94@, Spencer License 94+    | Spencer_99 -- ^ @Spencer-99@, Spencer License 99+    | SPL_1_0 -- ^ @SPL-1.0@, Sun Public License v1.0+    | Ssh_keyscan -- ^ @ssh-keyscan@, ssh-keyscan License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SSH_OpenSSH -- ^ @SSH-OpenSSH@, SSH OpenSSH license, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SSH_short -- ^ @SSH-short@, SSH short notice, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SSLeay_standalone -- ^ @SSLeay-standalone@, SSLeay License - standalone, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SSPL_1_0 -- ^ @SSPL-1.0@, Server Side Public License, v 1, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SugarCRM_1_1_3 -- ^ @SugarCRM-1.1.3@, SugarCRM Public License v1.1.3+    | Sun_PPP_2000 -- ^ @Sun-PPP-2000@, Sun PPP License (2000), SPDX License List 3.25, SPDX License List 3.26+    | Sun_PPP -- ^ @Sun-PPP@, Sun PPP License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SunPro -- ^ @SunPro@, SunPro License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | SWL -- ^ @SWL@, Scheme Widget Library (SWL) Software License Agreement+    | Swrule -- ^ @swrule@, swrule License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Symlinks -- ^ @Symlinks@, Symlinks License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TAPR_OHL_1_0 -- ^ @TAPR-OHL-1.0@, TAPR Open Hardware License v1.0, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TCL -- ^ @TCL@, TCL/TK License+    | TCP_wrappers -- ^ @TCP-wrappers@, TCP Wrappers License+    | TermReadKey -- ^ @TermReadKey@, TermReadKey License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TGPPL_1_0 -- ^ @TGPPL-1.0@, Transitive Grace Period Public Licence 1.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | ThirdEye -- ^ @ThirdEye@, ThirdEye License, SPDX License List 3.26+    | Threeparttable -- ^ @threeparttable@, threeparttable License, SPDX License List 3.25, SPDX License List 3.26+    | TMate -- ^ @TMate@, TMate Open Source License+    | TORQUE_1_1 -- ^ @TORQUE-1.1@, TORQUE v2.5+ Software License v1.1+    | TOSL -- ^ @TOSL@, Trusster Open Source License+    | TPDL -- ^ @TPDL@, Time::ParseDate License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TPL_1_0 -- ^ @TPL-1.0@, THOR Public License 1.0, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TrustedQSL -- ^ @TrustedQSL@, TrustedQSL License, SPDX License List 3.26+    | TTWL -- ^ @TTWL@, Text-Tabs+Wrap License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TTYP0 -- ^ @TTYP0@, TTYP0 License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TU_Berlin_1_0 -- ^ @TU-Berlin-1.0@, Technische Universitaet Berlin License 1.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | TU_Berlin_2_0 -- ^ @TU-Berlin-2.0@, Technische Universitaet Berlin License 2.0, SPDX License List 3.2, SPDX License List 3.6, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Ubuntu_font_1_0 -- ^ @Ubuntu-font-1.0@, Ubuntu Font Licence v1.0, SPDX License List 3.25, SPDX License List 3.26+    | UCAR -- ^ @UCAR@, UCAR License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | UCL_1_0 -- ^ @UCL-1.0@, Upstream Compatibility License v1.0, SPDX License List 3.9, SPDX License List 3.10, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Ulem -- ^ @ulem@, ulem License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | UMich_Merit -- ^ @UMich-Merit@, Michigan/Merit Networks License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Unicode_3_0 -- ^ @Unicode-3.0@, Unicode License v3, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Unicode_DFS_2015 -- ^ @Unicode-DFS-2015@, Unicode License Agreement - Data Files and Software (2015)+    | Unicode_DFS_2016 -- ^ @Unicode-DFS-2016@, Unicode License Agreement - Data Files and Software (2016)+    | Unicode_TOU -- ^ @Unicode-TOU@, Unicode Terms of Use+    | UnixCrypt -- ^ @UnixCrypt@, UnixCrypt License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Unlicense_libtelnet -- ^ @Unlicense-libtelnet@, Unlicense - libtelnet variant, SPDX License List 3.26+    | Unlicense_libwhirlpool -- ^ @Unlicense-libwhirlpool@, Unlicense - libwhirlpool variant, SPDX License List 3.26+    | Unlicense -- ^ @Unlicense@, The Unlicense+    | UPL_1_0 -- ^ @UPL-1.0@, Universal Permissive License v1.0+    | URT_RLE -- ^ @URT-RLE@, Utah Raster Toolkit Run Length Encoded License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Vim -- ^ @Vim@, Vim License+    | VOSTROM -- ^ @VOSTROM@, VOSTROM Public License for Open Source+    | VSL_1_0 -- ^ @VSL-1.0@, Vovida Software License v1.0+    | W3C_19980720 -- ^ @W3C-19980720@, W3C Software Notice and License (1998-07-20)+    | W3C_20150513 -- ^ @W3C-20150513@, W3C Software Notice and Document License (2015-05-13)+    | W3C -- ^ @W3C@, W3C Software Notice and License (2002-12-31)+    | W3m -- ^ @w3m@, w3m License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Watcom_1_0 -- ^ @Watcom-1.0@, Sybase Open Watcom Public License 1.0+    | Widget_Workshop -- ^ @Widget-Workshop@, Widget Workshop License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Wsuipa -- ^ @Wsuipa@, Wsuipa License+    | WTFPL -- ^ @WTFPL@, Do What The F*ck You Want To Public License+    | Wwl -- ^ @wwl@, WWL License, SPDX License List 3.26+    | X11_distribute_modifications_variant -- ^ @X11-distribute-modifications-variant@, X11 License Distribution Modification Variant, SPDX License List 3.16, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | X11_swapped -- ^ @X11-swapped@, X11 swapped final paragraphs, SPDX License List 3.25, SPDX License List 3.26+    | X11 -- ^ @X11@, X11 License+    | Xdebug_1_03 -- ^ @Xdebug-1.03@, Xdebug License v 1.03, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Xerox -- ^ @Xerox@, Xerox License+    | Xfig -- ^ @Xfig@, Xfig License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | XFree86_1_1 -- ^ @XFree86-1.1@, XFree86 License 1.1+    | Xinetd -- ^ @xinetd@, xinetd License+    | Xkeyboard_config_Zinoviev -- ^ @xkeyboard-config-Zinoviev@, xkeyboard-config Zinoviev License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Xlock -- ^ @xlock@, xlock License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Xnet -- ^ @Xnet@, X.Net License+    | Xpp -- ^ @xpp@, XPP License+    | XSkat -- ^ @XSkat@, XSkat License+    | Xzoom -- ^ @xzoom@, xzoom License, SPDX License List 3.25, SPDX License List 3.26+    | YPL_1_0 -- ^ @YPL-1.0@, Yahoo! Public License v1.0+    | YPL_1_1 -- ^ @YPL-1.1@, Yahoo! Public License v1.1+    | Zed -- ^ @Zed@, Zed License+    | Zeeff -- ^ @Zeeff@, Zeeff License, SPDX License List 3.23, SPDX License List 3.25, SPDX License List 3.26+    | Zend_2_0 -- ^ @Zend-2.0@, Zend License v2.0+    | Zimbra_1_3 -- ^ @Zimbra-1.3@, Zimbra Public License v1.3+    | Zimbra_1_4 -- ^ @Zimbra-1.4@, Zimbra Public License v1.4+    | Zlib_acknowledgement -- ^ @zlib-acknowledgement@, zlib/libpng License with Acknowledgement+    | Zlib -- ^ @Zlib@, zlib License+    | ZPL_1_1 -- ^ @ZPL-1.1@, Zope Public License 1.1+    | ZPL_2_0 -- ^ @ZPL-2.0@, Zope Public License 2.0+    | ZPL_2_1 -- ^ @ZPL-2.1@, Zope Public License 2.1+  deriving (Eq, Ord, Enum, Bounded, Show, Read, Data)++instance Binary LicenseId where+    -- Word16 is encoded in big endianness+    -- https://github.com/kolmodin/binary/blob/master/src/Data/Binary/Class.hs#L220-LL227+    put = Binary.putWord16be . fromIntegral . fromEnum+    get = do+        i <- Binary.getWord16be+        if i > fromIntegral (fromEnum (maxBound :: LicenseId))+        then fail "Too large LicenseId tag"+        else return (toEnum (fromIntegral i))++-- note: remember to bump version each time the definition changes+instance Structured LicenseId where+    structure p = set typeVersion 307 $ nominalStructure p++instance Pretty LicenseId where+    pretty = Disp.text . licenseId++-- |+-- >>> eitherParsec "BSD-3-Clause" :: Either String LicenseId+-- Right BSD_3_Clause+--+-- >>> eitherParsec "BSD3" :: Either String LicenseId+-- Left "...Unknown SPDX license identifier: 'BSD3' Do you mean BSD-3-Clause?"+--+instance Parsec LicenseId where+    parsec = do+        n <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'+        v <- askCabalSpecVersion+        maybe (fail $ "Unknown SPDX license identifier: '" ++  n ++ "' " ++ licenseIdMigrationMessage n) return $+            mkLicenseId (cabalSpecVersionToSPDXListVersion v) n++instance NFData LicenseId where+    rnf l = l `seq` ()++-- | Help message for migrating from non-SPDX license identifiers.+--+-- Old 'License' is almost SPDX, except for 'BSD2', 'BSD3'. This function+-- suggests SPDX variant:+--+-- >>> licenseIdMigrationMessage "BSD3"+-- "Do you mean BSD-3-Clause?"+--+-- Also 'OtherLicense', 'AllRightsReserved', and 'PublicDomain' aren't+-- valid SPDX identifiers+--+-- >>> traverse_ (print . licenseIdMigrationMessage) [ "OtherLicense", "AllRightsReserved", "PublicDomain" ]+-- "SPDX license list contains plenty of licenses. See https://spdx.org/licenses/. Also they can be combined into complex expressions with AND and OR."+-- "You can use NONE as a value of license field."+-- "Public Domain is a complex matter. See https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files. Consider using a proper license."+--+-- SPDX License list version 3.0 introduced "-only" and "-or-later" variants for GNU family of licenses.+-- See <https://spdx.org/news/news/2018/01/license-list-30-released>+-- >>> licenseIdMigrationMessage "GPL-2.0"+-- "SPDX license list 3.0 deprecated suffixless variants of GNU family of licenses. Use GPL-2.0-only or GPL-2.0-or-later."+--+-- For other common licenses their old license format coincides with the SPDX identifiers:+--+-- >>> traverse eitherParsec ["GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "MIT", "ISC", "MPL-2.0", "Apache-2.0"] :: Either String [LicenseId]+-- Right [GPL_2_0_only,GPL_3_0_only,LGPL_2_1_only,MIT,ISC,MPL_2_0,Apache_2_0]+--+licenseIdMigrationMessage :: String -> String+licenseIdMigrationMessage = go where+    go l | gnuVariant l    = "SPDX license list 3.0 deprecated suffixless variants of GNU family of licenses. Use " ++ l ++ "-only or " ++ l ++ "-or-later."+    go "BSD3"              = "Do you mean BSD-3-Clause?"+    go "BSD2"              = "Do you mean BSD-2-Clause?"+    go "AllRightsReserved" = "You can use NONE as a value of license field."+    go "OtherLicense"      = "SPDX license list contains plenty of licenses. See https://spdx.org/licenses/. Also they can be combined into complex expressions with AND and OR."+    go "PublicDomain"      = "Public Domain is a complex matter. See https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files. Consider using a proper license."++    -- otherwise, we don't know+    go _ = ""++    gnuVariant = flip elem ["GPL-2.0", "GPL-3.0", "LGPL-2.1", "LGPL-3.0", "AGPL-3.0" ]++-------------------------------------------------------------------------------+-- License Data+-------------------------------------------------------------------------------++-- | License SPDX identifier, e.g. @"BSD-3-Clause"@.+licenseId :: LicenseId -> String+licenseId N_0BSD = "0BSD"+licenseId N_3D_Slicer_1_0 = "3D-Slicer-1.0"+licenseId AAL = "AAL"+licenseId Abstyles = "Abstyles"+licenseId AdaCore_doc = "AdaCore-doc"+licenseId Adobe_2006 = "Adobe-2006"+licenseId Adobe_Display_PostScript = "Adobe-Display-PostScript"+licenseId Adobe_Glyph = "Adobe-Glyph"+licenseId Adobe_Utopia = "Adobe-Utopia"+licenseId ADSL = "ADSL"+licenseId AFL_1_1 = "AFL-1.1"+licenseId AFL_1_2 = "AFL-1.2"+licenseId AFL_2_0 = "AFL-2.0"+licenseId AFL_2_1 = "AFL-2.1"+licenseId AFL_3_0 = "AFL-3.0"+licenseId Afmparse = "Afmparse"+licenseId AGPL_1_0 = "AGPL-1.0"+licenseId AGPL_1_0_only = "AGPL-1.0-only"+licenseId AGPL_1_0_or_later = "AGPL-1.0-or-later"+licenseId AGPL_3_0_only = "AGPL-3.0-only"+licenseId AGPL_3_0_or_later = "AGPL-3.0-or-later"+licenseId Aladdin = "Aladdin"+licenseId AMD_newlib = "AMD-newlib"+licenseId AMDPLPA = "AMDPLPA"+licenseId AML_glslang = "AML-glslang"+licenseId AML = "AML"+licenseId AMPAS = "AMPAS"+licenseId ANTLR_PD_fallback = "ANTLR-PD-fallback"+licenseId ANTLR_PD = "ANTLR-PD"+licenseId Any_OSI_perl_modules = "any-OSI-perl-modules"+licenseId Any_OSI = "any-OSI"+licenseId Apache_1_0 = "Apache-1.0"+licenseId Apache_1_1 = "Apache-1.1"+licenseId Apache_2_0 = "Apache-2.0"+licenseId APAFML = "APAFML"+licenseId APL_1_0 = "APL-1.0"+licenseId App_s2p = "App-s2p"+licenseId APSL_1_0 = "APSL-1.0"+licenseId APSL_1_1 = "APSL-1.1"+licenseId APSL_1_2 = "APSL-1.2"+licenseId APSL_2_0 = "APSL-2.0"+licenseId Arphic_1999 = "Arphic-1999"+licenseId Artistic_1_0_cl8 = "Artistic-1.0-cl8"+licenseId Artistic_1_0_Perl = "Artistic-1.0-Perl"+licenseId Artistic_1_0 = "Artistic-1.0"+licenseId Artistic_2_0 = "Artistic-2.0"+licenseId Artistic_dist = "Artistic-dist"+licenseId Aspell_RU = "Aspell-RU"+licenseId ASWF_Digital_Assets_1_0 = "ASWF-Digital-Assets-1.0"+licenseId ASWF_Digital_Assets_1_1 = "ASWF-Digital-Assets-1.1"+licenseId Baekmuk = "Baekmuk"+licenseId Bahyph = "Bahyph"+licenseId Barr = "Barr"+licenseId Bcrypt_Solar_Designer = "bcrypt-Solar-Designer"+licenseId Beerware = "Beerware"+licenseId Bitstream_Charter = "Bitstream-Charter"+licenseId Bitstream_Vera = "Bitstream-Vera"+licenseId BitTorrent_1_0 = "BitTorrent-1.0"+licenseId BitTorrent_1_1 = "BitTorrent-1.1"+licenseId Blessing = "blessing"+licenseId BlueOak_1_0_0 = "BlueOak-1.0.0"+licenseId Boehm_GC_without_fee = "Boehm-GC-without-fee"+licenseId Boehm_GC = "Boehm-GC"+licenseId Borceux = "Borceux"+licenseId Brian_Gladman_2_Clause = "Brian-Gladman-2-Clause"+licenseId Brian_Gladman_3_Clause = "Brian-Gladman-3-Clause"+licenseId BSD_1_Clause = "BSD-1-Clause"+licenseId BSD_2_Clause_FreeBSD = "BSD-2-Clause-FreeBSD"+licenseId BSD_2_Clause_NetBSD = "BSD-2-Clause-NetBSD"+licenseId BSD_2_Clause_Darwin = "BSD-2-Clause-Darwin"+licenseId BSD_2_Clause_first_lines = "BSD-2-Clause-first-lines"+licenseId BSD_2_Clause_Patent = "BSD-2-Clause-Patent"+licenseId BSD_2_Clause_pkgconf_disclaimer = "BSD-2-Clause-pkgconf-disclaimer"+licenseId BSD_2_Clause_Views = "BSD-2-Clause-Views"+licenseId BSD_2_Clause = "BSD-2-Clause"+licenseId BSD_3_Clause_acpica = "BSD-3-Clause-acpica"+licenseId BSD_3_Clause_Attribution = "BSD-3-Clause-Attribution"+licenseId BSD_3_Clause_Clear = "BSD-3-Clause-Clear"+licenseId BSD_3_Clause_flex = "BSD-3-Clause-flex"+licenseId BSD_3_Clause_HP = "BSD-3-Clause-HP"+licenseId BSD_3_Clause_LBNL = "BSD-3-Clause-LBNL"+licenseId BSD_3_Clause_Modification = "BSD-3-Clause-Modification"+licenseId BSD_3_Clause_No_Military_License = "BSD-3-Clause-No-Military-License"+licenseId BSD_3_Clause_No_Nuclear_License_2014 = "BSD-3-Clause-No-Nuclear-License-2014"+licenseId BSD_3_Clause_No_Nuclear_License = "BSD-3-Clause-No-Nuclear-License"+licenseId BSD_3_Clause_No_Nuclear_Warranty = "BSD-3-Clause-No-Nuclear-Warranty"+licenseId BSD_3_Clause_Open_MPI = "BSD-3-Clause-Open-MPI"+licenseId BSD_3_Clause_Sun = "BSD-3-Clause-Sun"+licenseId BSD_3_Clause = "BSD-3-Clause"+licenseId BSD_4_Clause_Shortened = "BSD-4-Clause-Shortened"+licenseId BSD_4_Clause_UC = "BSD-4-Clause-UC"+licenseId BSD_4_Clause = "BSD-4-Clause"+licenseId BSD_4_3RENO = "BSD-4.3RENO"+licenseId BSD_4_3TAHOE = "BSD-4.3TAHOE"+licenseId BSD_Advertising_Acknowledgement = "BSD-Advertising-Acknowledgement"+licenseId BSD_Attribution_HPND_disclaimer = "BSD-Attribution-HPND-disclaimer"+licenseId BSD_Inferno_Nettverk = "BSD-Inferno-Nettverk"+licenseId BSD_Protection = "BSD-Protection"+licenseId BSD_Source_beginning_file = "BSD-Source-beginning-file"+licenseId BSD_Source_Code = "BSD-Source-Code"+licenseId BSD_Systemics_W3Works = "BSD-Systemics-W3Works"+licenseId BSD_Systemics = "BSD-Systemics"+licenseId BSL_1_0 = "BSL-1.0"+licenseId Bzip2_1_0_5 = "bzip2-1.0.5"+licenseId BUSL_1_1 = "BUSL-1.1"+licenseId Bzip2_1_0_6 = "bzip2-1.0.6"+licenseId C_UDA_1_0 = "C-UDA-1.0"+licenseId CAL_1_0_Combined_Work_Exception = "CAL-1.0-Combined-Work-Exception"+licenseId CAL_1_0 = "CAL-1.0"+licenseId Caldera_no_preamble = "Caldera-no-preamble"+licenseId Caldera = "Caldera"+licenseId Catharon = "Catharon"+licenseId CATOSL_1_1 = "CATOSL-1.1"+licenseId CC_BY_1_0 = "CC-BY-1.0"+licenseId CC_BY_2_0 = "CC-BY-2.0"+licenseId CC_BY_2_5_AU = "CC-BY-2.5-AU"+licenseId CC_BY_2_5 = "CC-BY-2.5"+licenseId CC_BY_3_0_AT = "CC-BY-3.0-AT"+licenseId CC_BY_3_0_AU = "CC-BY-3.0-AU"+licenseId CC_BY_3_0_DE = "CC-BY-3.0-DE"+licenseId CC_BY_3_0_IGO = "CC-BY-3.0-IGO"+licenseId CC_BY_3_0_NL = "CC-BY-3.0-NL"+licenseId CC_BY_3_0_US = "CC-BY-3.0-US"+licenseId CC_BY_3_0 = "CC-BY-3.0"+licenseId CC_BY_4_0 = "CC-BY-4.0"+licenseId CC_BY_NC_1_0 = "CC-BY-NC-1.0"+licenseId CC_BY_NC_2_0 = "CC-BY-NC-2.0"+licenseId CC_BY_NC_2_5 = "CC-BY-NC-2.5"+licenseId CC_BY_NC_3_0_DE = "CC-BY-NC-3.0-DE"+licenseId CC_BY_NC_3_0 = "CC-BY-NC-3.0"+licenseId CC_BY_NC_4_0 = "CC-BY-NC-4.0"+licenseId CC_BY_NC_ND_1_0 = "CC-BY-NC-ND-1.0"+licenseId CC_BY_NC_ND_2_0 = "CC-BY-NC-ND-2.0"+licenseId CC_BY_NC_ND_2_5 = "CC-BY-NC-ND-2.5"+licenseId CC_BY_NC_ND_3_0_DE = "CC-BY-NC-ND-3.0-DE"+licenseId CC_BY_NC_ND_3_0_IGO = "CC-BY-NC-ND-3.0-IGO"+licenseId CC_BY_NC_ND_3_0 = "CC-BY-NC-ND-3.0"+licenseId CC_BY_NC_ND_4_0 = "CC-BY-NC-ND-4.0"+licenseId CC_BY_NC_SA_1_0 = "CC-BY-NC-SA-1.0"+licenseId CC_BY_NC_SA_2_0_DE = "CC-BY-NC-SA-2.0-DE"+licenseId CC_BY_NC_SA_2_0_FR = "CC-BY-NC-SA-2.0-FR"+licenseId CC_BY_NC_SA_2_0_UK = "CC-BY-NC-SA-2.0-UK"+licenseId CC_BY_NC_SA_2_0 = "CC-BY-NC-SA-2.0"+licenseId CC_BY_NC_SA_2_5 = "CC-BY-NC-SA-2.5"+licenseId CC_BY_NC_SA_3_0_DE = "CC-BY-NC-SA-3.0-DE"+licenseId CC_BY_NC_SA_3_0_IGO = "CC-BY-NC-SA-3.0-IGO"+licenseId CC_BY_NC_SA_3_0 = "CC-BY-NC-SA-3.0"+licenseId CC_BY_NC_SA_4_0 = "CC-BY-NC-SA-4.0"+licenseId CC_BY_ND_1_0 = "CC-BY-ND-1.0"+licenseId CC_BY_ND_2_0 = "CC-BY-ND-2.0"+licenseId CC_BY_ND_2_5 = "CC-BY-ND-2.5"+licenseId CC_BY_ND_3_0_DE = "CC-BY-ND-3.0-DE"+licenseId CC_BY_ND_3_0 = "CC-BY-ND-3.0"+licenseId CC_BY_ND_4_0 = "CC-BY-ND-4.0"+licenseId CC_BY_SA_1_0 = "CC-BY-SA-1.0"+licenseId CC_BY_SA_2_0_UK = "CC-BY-SA-2.0-UK"+licenseId CC_BY_SA_2_0 = "CC-BY-SA-2.0"+licenseId CC_BY_SA_2_1_JP = "CC-BY-SA-2.1-JP"+licenseId CC_BY_SA_2_5 = "CC-BY-SA-2.5"+licenseId CC_BY_SA_3_0_AT = "CC-BY-SA-3.0-AT"+licenseId CC_BY_SA_3_0_DE = "CC-BY-SA-3.0-DE"+licenseId CC_BY_SA_3_0_IGO = "CC-BY-SA-3.0-IGO"+licenseId CC_BY_SA_3_0 = "CC-BY-SA-3.0"+licenseId CC_BY_SA_4_0 = "CC-BY-SA-4.0"+licenseId CC_PDDC = "CC-PDDC"+licenseId CC_PDM_1_0 = "CC-PDM-1.0"+licenseId CC_SA_1_0 = "CC-SA-1.0"+licenseId CC0_1_0 = "CC0-1.0"+licenseId CDDL_1_0 = "CDDL-1.0"+licenseId CDDL_1_1 = "CDDL-1.1"+licenseId CDL_1_0 = "CDL-1.0"+licenseId CDLA_Permissive_1_0 = "CDLA-Permissive-1.0"+licenseId CDLA_Permissive_2_0 = "CDLA-Permissive-2.0"+licenseId CDLA_Sharing_1_0 = "CDLA-Sharing-1.0"+licenseId CECILL_1_0 = "CECILL-1.0"+licenseId CECILL_1_1 = "CECILL-1.1"+licenseId CECILL_2_0 = "CECILL-2.0"+licenseId CECILL_2_1 = "CECILL-2.1"+licenseId CECILL_B = "CECILL-B"+licenseId CECILL_C = "CECILL-C"+licenseId CERN_OHL_1_1 = "CERN-OHL-1.1"+licenseId CERN_OHL_1_2 = "CERN-OHL-1.2"+licenseId CERN_OHL_P_2_0 = "CERN-OHL-P-2.0"+licenseId CERN_OHL_S_2_0 = "CERN-OHL-S-2.0"+licenseId CERN_OHL_W_2_0 = "CERN-OHL-W-2.0"+licenseId CFITSIO = "CFITSIO"+licenseId Check_cvs = "check-cvs"+licenseId Checkmk = "checkmk"+licenseId ClArtistic = "ClArtistic"+licenseId Clips = "Clips"+licenseId CMU_Mach_nodoc = "CMU-Mach-nodoc"+licenseId CMU_Mach = "CMU-Mach"+licenseId CNRI_Jython = "CNRI-Jython"+licenseId CNRI_Python_GPL_Compatible = "CNRI-Python-GPL-Compatible"+licenseId CNRI_Python = "CNRI-Python"+licenseId COIL_1_0 = "COIL-1.0"+licenseId Community_Spec_1_0 = "Community-Spec-1.0"+licenseId Condor_1_1 = "Condor-1.1"+licenseId Copyleft_next_0_3_0 = "copyleft-next-0.3.0"+licenseId Copyleft_next_0_3_1 = "copyleft-next-0.3.1"+licenseId Cornell_Lossless_JPEG = "Cornell-Lossless-JPEG"+licenseId CPAL_1_0 = "CPAL-1.0"+licenseId CPL_1_0 = "CPL-1.0"+licenseId CPOL_1_02 = "CPOL-1.02"+licenseId Cronyx = "Cronyx"+licenseId Crossword = "Crossword"+licenseId CryptoSwift = "CryptoSwift"+licenseId CrystalStacker = "CrystalStacker"+licenseId CUA_OPL_1_0 = "CUA-OPL-1.0"+licenseId Cube = "Cube"+licenseId Curl = "curl"+licenseId Cve_tou = "cve-tou"+licenseId D_FSL_1_0 = "D-FSL-1.0"+licenseId DEC_3_Clause = "DEC-3-Clause"+licenseId Diffmark = "diffmark"+licenseId DL_DE_BY_2_0 = "DL-DE-BY-2.0"+licenseId DL_DE_ZERO_2_0 = "DL-DE-ZERO-2.0"+licenseId DocBook_DTD = "DocBook-DTD"+licenseId DocBook_Schema = "DocBook-Schema"+licenseId DocBook_Stylesheet = "DocBook-Stylesheet"+licenseId DocBook_XML = "DocBook-XML"+licenseId DOC = "DOC"+licenseId Dotseqn = "Dotseqn"+licenseId DRL_1_0 = "DRL-1.0"+licenseId DRL_1_1 = "DRL-1.1"+licenseId DSDP = "DSDP"+licenseId Dtoa = "dtoa"+licenseId Dvipdfm = "dvipdfm"+licenseId ECL_1_0 = "ECL-1.0"+licenseId ECL_2_0 = "ECL-2.0"+licenseId EFL_1_0 = "EFL-1.0"+licenseId EFL_2_0 = "EFL-2.0"+licenseId EGenix = "eGenix"+licenseId Elastic_2_0 = "Elastic-2.0"+licenseId Entessa = "Entessa"+licenseId EPICS = "EPICS"+licenseId EPL_1_0 = "EPL-1.0"+licenseId EPL_2_0 = "EPL-2.0"+licenseId ErlPL_1_1 = "ErlPL-1.1"+licenseId Etalab_2_0 = "etalab-2.0"+licenseId EUDatagrid = "EUDatagrid"+licenseId EUPL_1_0 = "EUPL-1.0"+licenseId EUPL_1_1 = "EUPL-1.1"+licenseId EUPL_1_2 = "EUPL-1.2"+licenseId Eurosym = "Eurosym"+licenseId Fair = "Fair"+licenseId FBM = "FBM"+licenseId FDK_AAC = "FDK-AAC"+licenseId Ferguson_Twofish = "Ferguson-Twofish"+licenseId Frameworx_1_0 = "Frameworx-1.0"+licenseId FreeBSD_DOC = "FreeBSD-DOC"+licenseId FreeImage = "FreeImage"+licenseId FSFAP_no_warranty_disclaimer = "FSFAP-no-warranty-disclaimer"+licenseId FSFAP = "FSFAP"+licenseId FSFULLRSD = "FSFULLRSD"+licenseId FSFULLRWD = "FSFULLRWD"+licenseId FSFULLR = "FSFULLR"+licenseId FSFUL = "FSFUL"+licenseId FSL_1_1_ALv2 = "FSL-1.1-ALv2"+licenseId FSL_1_1_MIT = "FSL-1.1-MIT"+licenseId FTL = "FTL"+licenseId Furuseth = "Furuseth"+licenseId Fwlw = "fwlw"+licenseId Game_Programming_Gems = "Game-Programming-Gems"+licenseId GCR_docs = "GCR-docs"+licenseId GD = "GD"+licenseId Generic_xts = "generic-xts"+licenseId GFDL_1_1_invariants_only = "GFDL-1.1-invariants-only"+licenseId GFDL_1_1_invariants_or_later = "GFDL-1.1-invariants-or-later"+licenseId GFDL_1_1_no_invariants_only = "GFDL-1.1-no-invariants-only"+licenseId GFDL_1_1_no_invariants_or_later = "GFDL-1.1-no-invariants-or-later"+licenseId GFDL_1_1_only = "GFDL-1.1-only"+licenseId GFDL_1_1_or_later = "GFDL-1.1-or-later"+licenseId GFDL_1_2_invariants_only = "GFDL-1.2-invariants-only"+licenseId GFDL_1_2_invariants_or_later = "GFDL-1.2-invariants-or-later"+licenseId GFDL_1_2_no_invariants_only = "GFDL-1.2-no-invariants-only"+licenseId GFDL_1_2_no_invariants_or_later = "GFDL-1.2-no-invariants-or-later"+licenseId GFDL_1_2_only = "GFDL-1.2-only"+licenseId GFDL_1_2_or_later = "GFDL-1.2-or-later"+licenseId GFDL_1_3_invariants_only = "GFDL-1.3-invariants-only"+licenseId GFDL_1_3_invariants_or_later = "GFDL-1.3-invariants-or-later"+licenseId GFDL_1_3_no_invariants_only = "GFDL-1.3-no-invariants-only"+licenseId GFDL_1_3_no_invariants_or_later = "GFDL-1.3-no-invariants-or-later"+licenseId GFDL_1_3_only = "GFDL-1.3-only"+licenseId GFDL_1_3_or_later = "GFDL-1.3-or-later"+licenseId Giftware = "Giftware"+licenseId GL2PS = "GL2PS"+licenseId Glide = "Glide"+licenseId Glulxe = "Glulxe"+licenseId GLWTPL = "GLWTPL"+licenseId Gnuplot = "gnuplot"+licenseId GPL_1_0_only = "GPL-1.0-only"+licenseId GPL_1_0_or_later = "GPL-1.0-or-later"+licenseId GPL_2_0_only = "GPL-2.0-only"+licenseId GPL_2_0_or_later = "GPL-2.0-or-later"+licenseId GPL_3_0_only = "GPL-3.0-only"+licenseId GPL_3_0_or_later = "GPL-3.0-or-later"+licenseId Graphics_Gems = "Graphics-Gems"+licenseId GSOAP_1_3b = "gSOAP-1.3b"+licenseId Gtkbook = "gtkbook"+licenseId Gutmann = "Gutmann"+licenseId HaskellReport = "HaskellReport"+licenseId HDF5 = "HDF5"+licenseId Hdparm = "hdparm"+licenseId HIDAPI = "HIDAPI"+licenseId Hippocratic_2_1 = "Hippocratic-2.1"+licenseId HP_1986 = "HP-1986"+licenseId HP_1989 = "HP-1989"+licenseId HPND_DEC = "HPND-DEC"+licenseId HPND_doc_sell = "HPND-doc-sell"+licenseId HPND_doc = "HPND-doc"+licenseId HPND_export_US_acknowledgement = "HPND-export-US-acknowledgement"+licenseId HPND_export_US_modify = "HPND-export-US-modify"+licenseId HPND_export_US = "HPND-export-US"+licenseId HPND_export2_US = "HPND-export2-US"+licenseId HPND_Fenneberg_Livingston = "HPND-Fenneberg-Livingston"+licenseId HPND_INRIA_IMAG = "HPND-INRIA-IMAG"+licenseId HPND_Intel = "HPND-Intel"+licenseId HPND_Kevlin_Henney = "HPND-Kevlin-Henney"+licenseId HPND_Markus_Kuhn = "HPND-Markus-Kuhn"+licenseId HPND_merchantability_variant = "HPND-merchantability-variant"+licenseId HPND_MIT_disclaimer = "HPND-MIT-disclaimer"+licenseId HPND_Netrek = "HPND-Netrek"+licenseId HPND_Pbmplus = "HPND-Pbmplus"+licenseId HPND_sell_MIT_disclaimer_xserver = "HPND-sell-MIT-disclaimer-xserver"+licenseId HPND_sell_regexpr = "HPND-sell-regexpr"+licenseId HPND_sell_variant_MIT_disclaimer_rev = "HPND-sell-variant-MIT-disclaimer-rev"+licenseId HPND_sell_variant_MIT_disclaimer = "HPND-sell-variant-MIT-disclaimer"+licenseId HPND_sell_variant = "HPND-sell-variant"+licenseId HPND_UC_export_US = "HPND-UC-export-US"+licenseId HPND_UC = "HPND-UC"+licenseId HPND = "HPND"+licenseId HTMLTIDY = "HTMLTIDY"+licenseId IBM_pibs = "IBM-pibs"+licenseId ICU = "ICU"+licenseId IEC_Code_Components_EULA = "IEC-Code-Components-EULA"+licenseId IJG_short = "IJG-short"+licenseId IJG = "IJG"+licenseId ImageMagick = "ImageMagick"+licenseId IMatix = "iMatix"+licenseId Imlib2 = "Imlib2"+licenseId Info_ZIP = "Info-ZIP"+licenseId Inner_Net_2_0 = "Inner-Net-2.0"+licenseId InnoSetup = "InnoSetup"+licenseId Intel_ACPI = "Intel-ACPI"+licenseId Intel = "Intel"+licenseId Interbase_1_0 = "Interbase-1.0"+licenseId IPA = "IPA"+licenseId IPL_1_0 = "IPL-1.0"+licenseId ISC_Veillard = "ISC-Veillard"+licenseId ISC = "ISC"+licenseId Jam = "Jam"+licenseId JasPer_2_0 = "JasPer-2.0"+licenseId Jove = "jove"+licenseId JPL_image = "JPL-image"+licenseId JPNIC = "JPNIC"+licenseId JSON = "JSON"+licenseId Kastrup = "Kastrup"+licenseId Kazlib = "Kazlib"+licenseId Knuth_CTAN = "Knuth-CTAN"+licenseId LAL_1_2 = "LAL-1.2"+licenseId LAL_1_3 = "LAL-1.3"+licenseId Latex2e_translated_notice = "Latex2e-translated-notice"+licenseId Latex2e = "Latex2e"+licenseId Leptonica = "Leptonica"+licenseId LGPL_2_0_only = "LGPL-2.0-only"+licenseId LGPL_2_0_or_later = "LGPL-2.0-or-later"+licenseId LGPL_2_1_only = "LGPL-2.1-only"+licenseId LGPL_2_1_or_later = "LGPL-2.1-or-later"+licenseId LGPL_3_0_only = "LGPL-3.0-only"+licenseId LGPL_3_0_or_later = "LGPL-3.0-or-later"+licenseId LGPLLR = "LGPLLR"+licenseId Libpng_1_6_35 = "libpng-1.6.35"+licenseId Libpng_2_0 = "libpng-2.0"+licenseId Libpng = "Libpng"+licenseId Libselinux_1_0 = "libselinux-1.0"+licenseId Libtiff = "libtiff"+licenseId Libutil_David_Nugent = "libutil-David-Nugent"+licenseId LiLiQ_P_1_1 = "LiLiQ-P-1.1"+licenseId LiLiQ_R_1_1 = "LiLiQ-R-1.1"+licenseId LiLiQ_Rplus_1_1 = "LiLiQ-Rplus-1.1"+licenseId Linux_man_pages_1_para = "Linux-man-pages-1-para"+licenseId Linux_man_pages_copyleft_2_para = "Linux-man-pages-copyleft-2-para"+licenseId Linux_man_pages_copyleft_var = "Linux-man-pages-copyleft-var"+licenseId Linux_man_pages_copyleft = "Linux-man-pages-copyleft"+licenseId Linux_OpenIB = "Linux-OpenIB"+licenseId LOOP = "LOOP"+licenseId LPD_document = "LPD-document"+licenseId LPL_1_02 = "LPL-1.02"+licenseId LPL_1_0 = "LPL-1.0"+licenseId LPPL_1_0 = "LPPL-1.0"+licenseId LPPL_1_1 = "LPPL-1.1"+licenseId LPPL_1_2 = "LPPL-1.2"+licenseId LPPL_1_3a = "LPPL-1.3a"+licenseId LPPL_1_3c = "LPPL-1.3c"+licenseId Lsof = "lsof"+licenseId Lucida_Bitmap_Fonts = "Lucida-Bitmap-Fonts"+licenseId LZMA_SDK_9_11_to_9_20 = "LZMA-SDK-9.11-to-9.20"+licenseId LZMA_SDK_9_22 = "LZMA-SDK-9.22"+licenseId Mackerras_3_Clause_acknowledgment = "Mackerras-3-Clause-acknowledgment"+licenseId Mackerras_3_Clause = "Mackerras-3-Clause"+licenseId Magaz = "magaz"+licenseId Mailprio = "mailprio"+licenseId MakeIndex = "MakeIndex"+licenseId Man2html = "man2html"+licenseId Martin_Birgmeier = "Martin-Birgmeier"+licenseId McPhee_slideshow = "McPhee-slideshow"+licenseId Metamail = "metamail"+licenseId Minpack = "Minpack"+licenseId MIPS = "MIPS"+licenseId MirOS = "MirOS"+licenseId MIT_0 = "MIT-0"+licenseId MIT_advertising = "MIT-advertising"+licenseId MIT_Click = "MIT-Click"+licenseId MIT_CMU = "MIT-CMU"+licenseId MIT_enna = "MIT-enna"+licenseId MIT_feh = "MIT-feh"+licenseId MIT_Festival = "MIT-Festival"+licenseId MIT_Khronos_old = "MIT-Khronos-old"+licenseId MIT_Modern_Variant = "MIT-Modern-Variant"+licenseId MIT_open_group = "MIT-open-group"+licenseId MIT_testregex = "MIT-testregex"+licenseId MIT_Wu = "MIT-Wu"+licenseId MITNFA = "MITNFA"+licenseId MIT = "MIT"+licenseId MMIXware = "MMIXware"+licenseId Motosoto = "Motosoto"+licenseId MPEG_SSG = "MPEG-SSG"+licenseId Mpi_permissive = "mpi-permissive"+licenseId Mpich2 = "mpich2"+licenseId MPL_1_0 = "MPL-1.0"+licenseId MPL_1_1 = "MPL-1.1"+licenseId MPL_2_0_no_copyleft_exception = "MPL-2.0-no-copyleft-exception"+licenseId MPL_2_0 = "MPL-2.0"+licenseId Mplus = "mplus"+licenseId MS_LPL = "MS-LPL"+licenseId MS_PL = "MS-PL"+licenseId MS_RL = "MS-RL"+licenseId MTLL = "MTLL"+licenseId MulanPSL_1_0 = "MulanPSL-1.0"+licenseId MulanPSL_2_0 = "MulanPSL-2.0"+licenseId Multics = "Multics"+licenseId Mup = "Mup"+licenseId NAIST_2003 = "NAIST-2003"+licenseId NASA_1_3 = "NASA-1.3"+licenseId Naumen = "Naumen"+licenseId NBPL_1_0 = "NBPL-1.0"+licenseId NCBI_PD = "NCBI-PD"+licenseId NCGL_UK_2_0 = "NCGL-UK-2.0"+licenseId NCL = "NCL"+licenseId NCSA = "NCSA"+licenseId Net_SNMP = "Net-SNMP"+licenseId NetCDF = "NetCDF"+licenseId Newsletr = "Newsletr"+licenseId NGPL = "NGPL"+licenseId Ngrep = "ngrep"+licenseId NICTA_1_0 = "NICTA-1.0"+licenseId NIST_PD_fallback = "NIST-PD-fallback"+licenseId NIST_PD = "NIST-PD"+licenseId NIST_Software = "NIST-Software"+licenseId NLOD_1_0 = "NLOD-1.0"+licenseId NLOD_2_0 = "NLOD-2.0"+licenseId NLPL = "NLPL"+licenseId Nokia = "Nokia"+licenseId NOSL = "NOSL"+licenseId Noweb = "Noweb"+licenseId NPL_1_0 = "NPL-1.0"+licenseId NPL_1_1 = "NPL-1.1"+licenseId NPOSL_3_0 = "NPOSL-3.0"+licenseId NRL = "NRL"+licenseId NTIA_PD = "NTIA-PD"+licenseId NTP_0 = "NTP-0"+licenseId NTP = "NTP"+licenseId O_UDA_1_0 = "O-UDA-1.0"+licenseId OAR = "OAR"+licenseId OCCT_PL = "OCCT-PL"+licenseId OCLC_2_0 = "OCLC-2.0"+licenseId ODbL_1_0 = "ODbL-1.0"+licenseId ODC_By_1_0 = "ODC-By-1.0"+licenseId OFFIS = "OFFIS"+licenseId OFL_1_0_no_RFN = "OFL-1.0-no-RFN"+licenseId OFL_1_0_RFN = "OFL-1.0-RFN"+licenseId OFL_1_0 = "OFL-1.0"+licenseId OFL_1_1_no_RFN = "OFL-1.1-no-RFN"+licenseId OFL_1_1_RFN = "OFL-1.1-RFN"+licenseId OFL_1_1 = "OFL-1.1"+licenseId OGC_1_0 = "OGC-1.0"+licenseId OGDL_Taiwan_1_0 = "OGDL-Taiwan-1.0"+licenseId OGL_Canada_2_0 = "OGL-Canada-2.0"+licenseId OGL_UK_1_0 = "OGL-UK-1.0"+licenseId OGL_UK_2_0 = "OGL-UK-2.0"+licenseId OGL_UK_3_0 = "OGL-UK-3.0"+licenseId OGTSL = "OGTSL"+licenseId OLDAP_1_1 = "OLDAP-1.1"+licenseId OLDAP_1_2 = "OLDAP-1.2"+licenseId OLDAP_1_3 = "OLDAP-1.3"+licenseId OLDAP_1_4 = "OLDAP-1.4"+licenseId OLDAP_2_0_1 = "OLDAP-2.0.1"+licenseId OLDAP_2_0 = "OLDAP-2.0"+licenseId OLDAP_2_1 = "OLDAP-2.1"+licenseId OLDAP_2_2_1 = "OLDAP-2.2.1"+licenseId OLDAP_2_2_2 = "OLDAP-2.2.2"+licenseId OLDAP_2_2 = "OLDAP-2.2"+licenseId OLDAP_2_3 = "OLDAP-2.3"+licenseId OLDAP_2_4 = "OLDAP-2.4"+licenseId OLDAP_2_5 = "OLDAP-2.5"+licenseId OLDAP_2_6 = "OLDAP-2.6"+licenseId OLDAP_2_7 = "OLDAP-2.7"+licenseId OLDAP_2_8 = "OLDAP-2.8"+licenseId OLFL_1_3 = "OLFL-1.3"+licenseId OML = "OML"+licenseId OpenPBS_2_3 = "OpenPBS-2.3"+licenseId OpenSSL_standalone = "OpenSSL-standalone"+licenseId OpenSSL = "OpenSSL"+licenseId OpenVision = "OpenVision"+licenseId OPL_1_0 = "OPL-1.0"+licenseId OPL_UK_3_0 = "OPL-UK-3.0"+licenseId OPUBL_1_0 = "OPUBL-1.0"+licenseId OSET_PL_2_1 = "OSET-PL-2.1"+licenseId OSL_1_0 = "OSL-1.0"+licenseId OSL_1_1 = "OSL-1.1"+licenseId OSL_2_0 = "OSL-2.0"+licenseId OSL_2_1 = "OSL-2.1"+licenseId OSL_3_0 = "OSL-3.0"+licenseId PADL = "PADL"+licenseId Parity_6_0_0 = "Parity-6.0.0"+licenseId Parity_7_0_0 = "Parity-7.0.0"+licenseId PDDL_1_0 = "PDDL-1.0"+licenseId PHP_3_01 = "PHP-3.01"+licenseId PHP_3_0 = "PHP-3.0"+licenseId Pixar = "Pixar"+licenseId Pkgconf = "pkgconf"+licenseId Plexus = "Plexus"+licenseId Pnmstitch = "pnmstitch"+licenseId PolyForm_Noncommercial_1_0_0 = "PolyForm-Noncommercial-1.0.0"+licenseId PolyForm_Small_Business_1_0_0 = "PolyForm-Small-Business-1.0.0"+licenseId PostgreSQL = "PostgreSQL"+licenseId PPL = "PPL"+licenseId PSF_2_0 = "PSF-2.0"+licenseId Psfrag = "psfrag"+licenseId Psutils = "psutils"+licenseId Python_2_0_1 = "Python-2.0.1"+licenseId Python_2_0 = "Python-2.0"+licenseId Python_ldap = "python-ldap"+licenseId Qhull = "Qhull"+licenseId QPL_1_0_INRIA_2004 = "QPL-1.0-INRIA-2004"+licenseId QPL_1_0 = "QPL-1.0"+licenseId Radvd = "radvd"+licenseId Rdisc = "Rdisc"+licenseId RHeCos_1_1 = "RHeCos-1.1"+licenseId RPL_1_1 = "RPL-1.1"+licenseId RPL_1_5 = "RPL-1.5"+licenseId RPSL_1_0 = "RPSL-1.0"+licenseId RSA_MD = "RSA-MD"+licenseId RSCPL = "RSCPL"+licenseId Ruby_pty = "Ruby-pty"+licenseId Ruby = "Ruby"+licenseId SAX_PD_2_0 = "SAX-PD-2.0"+licenseId SAX_PD = "SAX-PD"+licenseId Saxpath = "Saxpath"+licenseId SCEA = "SCEA"+licenseId SchemeReport = "SchemeReport"+licenseId Sendmail_8_23 = "Sendmail-8.23"+licenseId Sendmail_Open_Source_1_1 = "Sendmail-Open-Source-1.1"+licenseId Sendmail = "Sendmail"+licenseId SGI_B_1_0 = "SGI-B-1.0"+licenseId SGI_B_1_1 = "SGI-B-1.1"+licenseId SGI_B_2_0 = "SGI-B-2.0"+licenseId SGI_OpenGL = "SGI-OpenGL"+licenseId SGP4 = "SGP4"+licenseId SHL_0_51 = "SHL-0.51"+licenseId SHL_0_5 = "SHL-0.5"+licenseId SimPL_2_0 = "SimPL-2.0"+licenseId SISSL_1_2 = "SISSL-1.2"+licenseId SISSL = "SISSL"+licenseId Sleepycat = "Sleepycat"+licenseId SL = "SL"+licenseId SMAIL_GPL = "SMAIL-GPL"+licenseId SMLNJ = "SMLNJ"+licenseId SMPPL = "SMPPL"+licenseId SNIA = "SNIA"+licenseId Snprintf = "snprintf"+licenseId SOFA = "SOFA"+licenseId SoftSurfer = "softSurfer"+licenseId Soundex = "Soundex"+licenseId Spencer_86 = "Spencer-86"+licenseId Spencer_94 = "Spencer-94"+licenseId Spencer_99 = "Spencer-99"+licenseId SPL_1_0 = "SPL-1.0"+licenseId Ssh_keyscan = "ssh-keyscan"+licenseId SSH_OpenSSH = "SSH-OpenSSH"+licenseId SSH_short = "SSH-short"+licenseId SSLeay_standalone = "SSLeay-standalone"+licenseId SSPL_1_0 = "SSPL-1.0"+licenseId SugarCRM_1_1_3 = "SugarCRM-1.1.3"+licenseId Sun_PPP_2000 = "Sun-PPP-2000"+licenseId Sun_PPP = "Sun-PPP"+licenseId SunPro = "SunPro"+licenseId SWL = "SWL"+licenseId Swrule = "swrule"+licenseId Symlinks = "Symlinks"+licenseId TAPR_OHL_1_0 = "TAPR-OHL-1.0"+licenseId TCL = "TCL"+licenseId TCP_wrappers = "TCP-wrappers"+licenseId TermReadKey = "TermReadKey"+licenseId TGPPL_1_0 = "TGPPL-1.0"+licenseId ThirdEye = "ThirdEye"+licenseId Threeparttable = "threeparttable"+licenseId TMate = "TMate"+licenseId TORQUE_1_1 = "TORQUE-1.1"+licenseId TOSL = "TOSL"+licenseId TPDL = "TPDL"+licenseId TPL_1_0 = "TPL-1.0"+licenseId TrustedQSL = "TrustedQSL"+licenseId TTWL = "TTWL"+licenseId TTYP0 = "TTYP0"+licenseId TU_Berlin_1_0 = "TU-Berlin-1.0"+licenseId TU_Berlin_2_0 = "TU-Berlin-2.0"+licenseId Ubuntu_font_1_0 = "Ubuntu-font-1.0"+licenseId UCAR = "UCAR"+licenseId UCL_1_0 = "UCL-1.0"+licenseId Ulem = "ulem"+licenseId UMich_Merit = "UMich-Merit"+licenseId Unicode_3_0 = "Unicode-3.0"+licenseId Unicode_DFS_2015 = "Unicode-DFS-2015"+licenseId Unicode_DFS_2016 = "Unicode-DFS-2016"+licenseId Unicode_TOU = "Unicode-TOU"+licenseId UnixCrypt = "UnixCrypt"+licenseId Unlicense_libtelnet = "Unlicense-libtelnet"+licenseId Unlicense_libwhirlpool = "Unlicense-libwhirlpool"+licenseId Unlicense = "Unlicense"+licenseId UPL_1_0 = "UPL-1.0"+licenseId URT_RLE = "URT-RLE"+licenseId Vim = "Vim"+licenseId VOSTROM = "VOSTROM"+licenseId VSL_1_0 = "VSL-1.0"+licenseId W3C_19980720 = "W3C-19980720"+licenseId W3C_20150513 = "W3C-20150513"+licenseId W3C = "W3C"+licenseId W3m = "w3m"+licenseId Watcom_1_0 = "Watcom-1.0"+licenseId Widget_Workshop = "Widget-Workshop"+licenseId Wsuipa = "Wsuipa"+licenseId WTFPL = "WTFPL"+licenseId Wwl = "wwl"+licenseId X11_distribute_modifications_variant = "X11-distribute-modifications-variant"+licenseId X11_swapped = "X11-swapped"+licenseId X11 = "X11"+licenseId Xdebug_1_03 = "Xdebug-1.03"+licenseId Xerox = "Xerox"+licenseId Xfig = "Xfig"+licenseId XFree86_1_1 = "XFree86-1.1"+licenseId Xinetd = "xinetd"+licenseId Xkeyboard_config_Zinoviev = "xkeyboard-config-Zinoviev"+licenseId Xlock = "xlock"+licenseId Xnet = "Xnet"+licenseId Xpp = "xpp"+licenseId XSkat = "XSkat"+licenseId Xzoom = "xzoom"+licenseId YPL_1_0 = "YPL-1.0"+licenseId YPL_1_1 = "YPL-1.1"+licenseId Zed = "Zed"+licenseId Zeeff = "Zeeff"+licenseId Zend_2_0 = "Zend-2.0"+licenseId Zimbra_1_3 = "Zimbra-1.3"+licenseId Zimbra_1_4 = "Zimbra-1.4"+licenseId Zlib_acknowledgement = "zlib-acknowledgement"+licenseId Zlib = "Zlib"+licenseId ZPL_1_1 = "ZPL-1.1"+licenseId ZPL_2_0 = "ZPL-2.0"+licenseId ZPL_2_1 = "ZPL-2.1"++-- | License name, e.g. @"GNU General Public License v2.0 only"@+licenseName :: LicenseId -> String+licenseName N_0BSD = "BSD Zero Clause License"+licenseName N_3D_Slicer_1_0 = "3D Slicer License v1.0"+licenseName AAL = "Attribution Assurance License"+licenseName Abstyles = "Abstyles License"+licenseName AdaCore_doc = "AdaCore Doc License"+licenseName Adobe_2006 = "Adobe Systems Incorporated Source Code License Agreement"+licenseName Adobe_Display_PostScript = "Adobe Display PostScript License"+licenseName Adobe_Glyph = "Adobe Glyph List License"+licenseName Adobe_Utopia = "Adobe Utopia Font License"+licenseName ADSL = "Amazon Digital Services License"+licenseName AFL_1_1 = "Academic Free License v1.1"+licenseName AFL_1_2 = "Academic Free License v1.2"+licenseName AFL_2_0 = "Academic Free License v2.0"+licenseName AFL_2_1 = "Academic Free License v2.1"+licenseName AFL_3_0 = "Academic Free License v3.0"+licenseName Afmparse = "Afmparse License"+licenseName AGPL_1_0 = "Affero General Public License v1.0"+licenseName AGPL_1_0_only = "Affero General Public License v1.0 only"+licenseName AGPL_1_0_or_later = "Affero General Public License v1.0 or later"+licenseName AGPL_3_0_only = "GNU Affero General Public License v3.0 only"+licenseName AGPL_3_0_or_later = "GNU Affero General Public License v3.0 or later"+licenseName Aladdin = "Aladdin Free Public License"+licenseName AMD_newlib = "AMD newlib License"+licenseName AMDPLPA = "AMD's plpa_map.c License"+licenseName AML_glslang = "AML glslang variant License"+licenseName AML = "Apple MIT License"+licenseName AMPAS = "Academy of Motion Picture Arts and Sciences BSD"+licenseName ANTLR_PD_fallback = "ANTLR Software Rights Notice with license fallback"+licenseName ANTLR_PD = "ANTLR Software Rights Notice"+licenseName Any_OSI_perl_modules = "Any OSI License - Perl Modules"+licenseName Any_OSI = "Any OSI License"+licenseName Apache_1_0 = "Apache License 1.0"+licenseName Apache_1_1 = "Apache License 1.1"+licenseName Apache_2_0 = "Apache License 2.0"+licenseName APAFML = "Adobe Postscript AFM License"+licenseName APL_1_0 = "Adaptive Public License 1.0"+licenseName App_s2p = "App::s2p License"+licenseName APSL_1_0 = "Apple Public Source License 1.0"+licenseName APSL_1_1 = "Apple Public Source License 1.1"+licenseName APSL_1_2 = "Apple Public Source License 1.2"+licenseName APSL_2_0 = "Apple Public Source License 2.0"+licenseName Arphic_1999 = "Arphic Public License"+licenseName Artistic_1_0_cl8 = "Artistic License 1.0 w/clause 8"+licenseName Artistic_1_0_Perl = "Artistic License 1.0 (Perl)"+licenseName Artistic_1_0 = "Artistic License 1.0"+licenseName Artistic_2_0 = "Artistic License 2.0"+licenseName Artistic_dist = "Artistic License 1.0 (dist)"+licenseName Aspell_RU = "Aspell Russian License"+licenseName ASWF_Digital_Assets_1_0 = "ASWF Digital Assets License version 1.0"+licenseName ASWF_Digital_Assets_1_1 = "ASWF Digital Assets License 1.1"+licenseName Baekmuk = "Baekmuk License"+licenseName Bahyph = "Bahyph License"+licenseName Barr = "Barr License"+licenseName Bcrypt_Solar_Designer = "bcrypt Solar Designer License"+licenseName Beerware = "Beerware License"+licenseName Bitstream_Charter = "Bitstream Charter Font License"+licenseName Bitstream_Vera = "Bitstream Vera Font License"+licenseName BitTorrent_1_0 = "BitTorrent Open Source License v1.0"+licenseName BitTorrent_1_1 = "BitTorrent Open Source License v1.1"+licenseName Blessing = "SQLite Blessing"+licenseName BlueOak_1_0_0 = "Blue Oak Model License 1.0.0"+licenseName Boehm_GC_without_fee = "Boehm-Demers-Weiser GC License (without fee)"+licenseName Boehm_GC = "Boehm-Demers-Weiser GC License"+licenseName Borceux = "Borceux license"+licenseName Brian_Gladman_2_Clause = "Brian Gladman 2-Clause License"+licenseName Brian_Gladman_3_Clause = "Brian Gladman 3-Clause License"+licenseName BSD_1_Clause = "BSD 1-Clause License"+licenseName BSD_2_Clause_FreeBSD = "BSD 2-Clause FreeBSD License"+licenseName BSD_2_Clause_NetBSD = "BSD 2-Clause NetBSD License"+licenseName BSD_2_Clause_Darwin = "BSD 2-Clause - Ian Darwin variant"+licenseName BSD_2_Clause_first_lines = "BSD 2-Clause - first lines requirement"+licenseName BSD_2_Clause_Patent = "BSD-2-Clause Plus Patent License"+licenseName BSD_2_Clause_pkgconf_disclaimer = "BSD 2-Clause pkgconf disclaimer variant"+licenseName BSD_2_Clause_Views = "BSD 2-Clause with views sentence"+licenseName BSD_2_Clause = "BSD 2-Clause \"Simplified\" License"+licenseName BSD_3_Clause_acpica = "BSD 3-Clause acpica variant"+licenseName BSD_3_Clause_Attribution = "BSD with attribution"+licenseName BSD_3_Clause_Clear = "BSD 3-Clause Clear License"+licenseName BSD_3_Clause_flex = "BSD 3-Clause Flex variant"+licenseName BSD_3_Clause_HP = "Hewlett-Packard BSD variant license"+licenseName BSD_3_Clause_LBNL = "Lawrence Berkeley National Labs BSD variant license"+licenseName BSD_3_Clause_Modification = "BSD 3-Clause Modification"+licenseName BSD_3_Clause_No_Military_License = "BSD 3-Clause No Military License"+licenseName BSD_3_Clause_No_Nuclear_License_2014 = "BSD 3-Clause No Nuclear License 2014"+licenseName BSD_3_Clause_No_Nuclear_License = "BSD 3-Clause No Nuclear License"+licenseName BSD_3_Clause_No_Nuclear_Warranty = "BSD 3-Clause No Nuclear Warranty"+licenseName BSD_3_Clause_Open_MPI = "BSD 3-Clause Open MPI variant"+licenseName BSD_3_Clause_Sun = "BSD 3-Clause Sun Microsystems"+licenseName BSD_3_Clause = "BSD 3-Clause \"New\" or \"Revised\" License"+licenseName BSD_4_Clause_Shortened = "BSD 4 Clause Shortened"+licenseName BSD_4_Clause_UC = "BSD-4-Clause (University of California-Specific)"+licenseName BSD_4_Clause = "BSD 4-Clause \"Original\" or \"Old\" License"+licenseName BSD_4_3RENO = "BSD 4.3 RENO License"+licenseName BSD_4_3TAHOE = "BSD 4.3 TAHOE License"+licenseName BSD_Advertising_Acknowledgement = "BSD Advertising Acknowledgement License"+licenseName BSD_Attribution_HPND_disclaimer = "BSD with Attribution and HPND disclaimer"+licenseName BSD_Inferno_Nettverk = "BSD-Inferno-Nettverk"+licenseName BSD_Protection = "BSD Protection License"+licenseName BSD_Source_beginning_file = "BSD Source Code Attribution - beginning of file variant"+licenseName BSD_Source_Code = "BSD Source Code Attribution"+licenseName BSD_Systemics_W3Works = "Systemics W3Works BSD variant license"+licenseName BSD_Systemics = "Systemics BSD variant license"+licenseName BSL_1_0 = "Boost Software License 1.0"+licenseName Bzip2_1_0_5 = "bzip2 and libbzip2 License v1.0.5"+licenseName BUSL_1_1 = "Business Source License 1.1"+licenseName Bzip2_1_0_6 = "bzip2 and libbzip2 License v1.0.6"+licenseName C_UDA_1_0 = "Computational Use of Data Agreement v1.0"+licenseName CAL_1_0_Combined_Work_Exception = "Cryptographic Autonomy License 1.0 (Combined Work Exception)"+licenseName CAL_1_0 = "Cryptographic Autonomy License 1.0"+licenseName Caldera_no_preamble = "Caldera License (without preamble)"+licenseName Caldera = "Caldera License"+licenseName Catharon = "Catharon License"+licenseName CATOSL_1_1 = "Computer Associates Trusted Open Source License 1.1"+licenseName CC_BY_1_0 = "Creative Commons Attribution 1.0 Generic"+licenseName CC_BY_2_0 = "Creative Commons Attribution 2.0 Generic"+licenseName CC_BY_2_5_AU = "Creative Commons Attribution 2.5 Australia"+licenseName CC_BY_2_5 = "Creative Commons Attribution 2.5 Generic"+licenseName CC_BY_3_0_AT = "Creative Commons Attribution 3.0 Austria"+licenseName CC_BY_3_0_AU = "Creative Commons Attribution 3.0 Australia"+licenseName CC_BY_3_0_DE = "Creative Commons Attribution 3.0 Germany"+licenseName CC_BY_3_0_IGO = "Creative Commons Attribution 3.0 IGO"+licenseName CC_BY_3_0_NL = "Creative Commons Attribution 3.0 Netherlands"+licenseName CC_BY_3_0_US = "Creative Commons Attribution 3.0 United States"+licenseName CC_BY_3_0 = "Creative Commons Attribution 3.0 Unported"+licenseName CC_BY_4_0 = "Creative Commons Attribution 4.0 International"+licenseName CC_BY_NC_1_0 = "Creative Commons Attribution Non Commercial 1.0 Generic"+licenseName CC_BY_NC_2_0 = "Creative Commons Attribution Non Commercial 2.0 Generic"+licenseName CC_BY_NC_2_5 = "Creative Commons Attribution Non Commercial 2.5 Generic"+licenseName CC_BY_NC_3_0_DE = "Creative Commons Attribution Non Commercial 3.0 Germany"+licenseName CC_BY_NC_3_0 = "Creative Commons Attribution Non Commercial 3.0 Unported"+licenseName CC_BY_NC_4_0 = "Creative Commons Attribution Non Commercial 4.0 International"+licenseName CC_BY_NC_ND_1_0 = "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic"+licenseName CC_BY_NC_ND_2_0 = "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic"+licenseName CC_BY_NC_ND_2_5 = "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic"+licenseName CC_BY_NC_ND_3_0_DE = "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany"+licenseName CC_BY_NC_ND_3_0_IGO = "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO"+licenseName CC_BY_NC_ND_3_0 = "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported"+licenseName CC_BY_NC_ND_4_0 = "Creative Commons Attribution Non Commercial No Derivatives 4.0 International"+licenseName CC_BY_NC_SA_1_0 = "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic"+licenseName CC_BY_NC_SA_2_0_DE = "Creative Commons Attribution Non Commercial Share Alike 2.0 Germany"+licenseName CC_BY_NC_SA_2_0_FR = "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France"+licenseName CC_BY_NC_SA_2_0_UK = "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales"+licenseName CC_BY_NC_SA_2_0 = "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic"+licenseName CC_BY_NC_SA_2_5 = "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic"+licenseName CC_BY_NC_SA_3_0_DE = "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany"+licenseName CC_BY_NC_SA_3_0_IGO = "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO"+licenseName CC_BY_NC_SA_3_0 = "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported"+licenseName CC_BY_NC_SA_4_0 = "Creative Commons Attribution Non Commercial Share Alike 4.0 International"+licenseName CC_BY_ND_1_0 = "Creative Commons Attribution No Derivatives 1.0 Generic"+licenseName CC_BY_ND_2_0 = "Creative Commons Attribution No Derivatives 2.0 Generic"+licenseName CC_BY_ND_2_5 = "Creative Commons Attribution No Derivatives 2.5 Generic"+licenseName CC_BY_ND_3_0_DE = "Creative Commons Attribution No Derivatives 3.0 Germany"+licenseName CC_BY_ND_3_0 = "Creative Commons Attribution No Derivatives 3.0 Unported"+licenseName CC_BY_ND_4_0 = "Creative Commons Attribution No Derivatives 4.0 International"+licenseName CC_BY_SA_1_0 = "Creative Commons Attribution Share Alike 1.0 Generic"+licenseName CC_BY_SA_2_0_UK = "Creative Commons Attribution Share Alike 2.0 England and Wales"+licenseName CC_BY_SA_2_0 = "Creative Commons Attribution Share Alike 2.0 Generic"+licenseName CC_BY_SA_2_1_JP = "Creative Commons Attribution Share Alike 2.1 Japan"+licenseName CC_BY_SA_2_5 = "Creative Commons Attribution Share Alike 2.5 Generic"+licenseName CC_BY_SA_3_0_AT = "Creative Commons Attribution Share Alike 3.0 Austria"+licenseName CC_BY_SA_3_0_DE = "Creative Commons Attribution Share Alike 3.0 Germany"+licenseName CC_BY_SA_3_0_IGO = "Creative Commons Attribution-ShareAlike 3.0 IGO"+licenseName CC_BY_SA_3_0 = "Creative Commons Attribution Share Alike 3.0 Unported"+licenseName CC_BY_SA_4_0 = "Creative Commons Attribution Share Alike 4.0 International"+licenseName CC_PDDC = "Creative Commons Public Domain Dedication and Certification"+licenseName CC_PDM_1_0 = "Creative    Commons Public Domain Mark 1.0 Universal"+licenseName CC_SA_1_0 = "Creative Commons Share Alike 1.0 Generic"+licenseName CC0_1_0 = "Creative Commons Zero v1.0 Universal"+licenseName CDDL_1_0 = "Common Development and Distribution License 1.0"+licenseName CDDL_1_1 = "Common Development and Distribution License 1.1"+licenseName CDL_1_0 = "Common Documentation License 1.0"+licenseName CDLA_Permissive_1_0 = "Community Data License Agreement Permissive 1.0"+licenseName CDLA_Permissive_2_0 = "Community Data License Agreement Permissive 2.0"+licenseName CDLA_Sharing_1_0 = "Community Data License Agreement Sharing 1.0"+licenseName CECILL_1_0 = "CeCILL Free Software License Agreement v1.0"+licenseName CECILL_1_1 = "CeCILL Free Software License Agreement v1.1"+licenseName CECILL_2_0 = "CeCILL Free Software License Agreement v2.0"+licenseName CECILL_2_1 = "CeCILL Free Software License Agreement v2.1"+licenseName CECILL_B = "CeCILL-B Free Software License Agreement"+licenseName CECILL_C = "CeCILL-C Free Software License Agreement"+licenseName CERN_OHL_1_1 = "CERN Open Hardware Licence v1.1"+licenseName CERN_OHL_1_2 = "CERN Open Hardware Licence v1.2"+licenseName CERN_OHL_P_2_0 = "CERN Open Hardware Licence Version 2 - Permissive"+licenseName CERN_OHL_S_2_0 = "CERN Open Hardware Licence Version 2 - Strongly Reciprocal"+licenseName CERN_OHL_W_2_0 = "CERN Open Hardware Licence Version 2 - Weakly Reciprocal"+licenseName CFITSIO = "CFITSIO License"+licenseName Check_cvs = "check-cvs License"+licenseName Checkmk = "Checkmk License"+licenseName ClArtistic = "Clarified Artistic License"+licenseName Clips = "Clips License"+licenseName CMU_Mach_nodoc = "CMU    Mach - no notices-in-documentation variant"+licenseName CMU_Mach = "CMU Mach License"+licenseName CNRI_Jython = "CNRI Jython License"+licenseName CNRI_Python_GPL_Compatible = "CNRI Python Open Source GPL Compatible License Agreement"+licenseName CNRI_Python = "CNRI Python License"+licenseName COIL_1_0 = "Copyfree Open Innovation License"+licenseName Community_Spec_1_0 = "Community Specification License 1.0"+licenseName Condor_1_1 = "Condor Public License v1.1"+licenseName Copyleft_next_0_3_0 = "copyleft-next 0.3.0"+licenseName Copyleft_next_0_3_1 = "copyleft-next 0.3.1"+licenseName Cornell_Lossless_JPEG = "Cornell Lossless JPEG License"+licenseName CPAL_1_0 = "Common Public Attribution License 1.0"+licenseName CPL_1_0 = "Common Public License 1.0"+licenseName CPOL_1_02 = "Code Project Open License 1.02"+licenseName Cronyx = "Cronyx License"+licenseName Crossword = "Crossword License"+licenseName CryptoSwift = "CryptoSwift License"+licenseName CrystalStacker = "CrystalStacker License"+licenseName CUA_OPL_1_0 = "CUA Office Public License v1.0"+licenseName Cube = "Cube License"+licenseName Curl = "curl License"+licenseName Cve_tou = "Common Vulnerability Enumeration ToU License"+licenseName D_FSL_1_0 = "Deutsche Freie Software Lizenz"+licenseName DEC_3_Clause = "DEC 3-Clause License"+licenseName Diffmark = "diffmark license"+licenseName DL_DE_BY_2_0 = "Data licence Germany \8211 attribution \8211 version 2.0"+licenseName DL_DE_ZERO_2_0 = "Data licence Germany \8211 zero \8211 version 2.0"+licenseName DocBook_DTD = "DocBook DTD License"+licenseName DocBook_Schema = "DocBook Schema License"+licenseName DocBook_Stylesheet = "DocBook Stylesheet License"+licenseName DocBook_XML = "DocBook XML License"+licenseName DOC = "DOC License"+licenseName Dotseqn = "Dotseqn License"+licenseName DRL_1_0 = "Detection Rule License 1.0"+licenseName DRL_1_1 = "Detection Rule License 1.1"+licenseName DSDP = "DSDP License"+licenseName Dtoa = "David M. Gay dtoa License"+licenseName Dvipdfm = "dvipdfm License"+licenseName ECL_1_0 = "Educational Community License v1.0"+licenseName ECL_2_0 = "Educational Community License v2.0"+licenseName EFL_1_0 = "Eiffel Forum License v1.0"+licenseName EFL_2_0 = "Eiffel Forum License v2.0"+licenseName EGenix = "eGenix.com Public License 1.1.0"+licenseName Elastic_2_0 = "Elastic License 2.0"+licenseName Entessa = "Entessa Public License v1.0"+licenseName EPICS = "EPICS Open License"+licenseName EPL_1_0 = "Eclipse Public License 1.0"+licenseName EPL_2_0 = "Eclipse Public License 2.0"+licenseName ErlPL_1_1 = "Erlang Public License v1.1"+licenseName Etalab_2_0 = "Etalab Open License 2.0"+licenseName EUDatagrid = "EU DataGrid Software License"+licenseName EUPL_1_0 = "European Union Public License 1.0"+licenseName EUPL_1_1 = "European Union Public License 1.1"+licenseName EUPL_1_2 = "European Union Public License 1.2"+licenseName Eurosym = "Eurosym License"+licenseName Fair = "Fair License"+licenseName FBM = "Fuzzy Bitmap License"+licenseName FDK_AAC = "Fraunhofer FDK AAC Codec Library"+licenseName Ferguson_Twofish = "Ferguson Twofish License"+licenseName Frameworx_1_0 = "Frameworx Open License 1.0"+licenseName FreeBSD_DOC = "FreeBSD Documentation License"+licenseName FreeImage = "FreeImage Public License v1.0"+licenseName FSFAP_no_warranty_disclaimer = "FSF All Permissive License (without Warranty)"+licenseName FSFAP = "FSF All Permissive License"+licenseName FSFULLRSD = "FSF Unlimited License (with License Retention and Short Disclaimer)"+licenseName FSFULLRWD = "FSF Unlimited License (With License Retention and Warranty Disclaimer)"+licenseName FSFULLR = "FSF Unlimited License (with License Retention)"+licenseName FSFUL = "FSF Unlimited License"+licenseName FSL_1_1_ALv2 = "Functional Source License, Version 1.1, ALv2 Future License"+licenseName FSL_1_1_MIT = "Functional Source License, Version 1.1, MIT Future License"+licenseName FTL = "Freetype Project License"+licenseName Furuseth = "Furuseth License"+licenseName Fwlw = "fwlw License"+licenseName Game_Programming_Gems = "Game Programming Gems License"+licenseName GCR_docs = "Gnome GCR Documentation License"+licenseName GD = "GD License"+licenseName Generic_xts = "Generic XTS License"+licenseName GFDL_1_1_invariants_only = "GNU Free Documentation License v1.1 only - invariants"+licenseName GFDL_1_1_invariants_or_later = "GNU Free Documentation License v1.1 or later - invariants"+licenseName GFDL_1_1_no_invariants_only = "GNU Free Documentation License v1.1 only - no invariants"+licenseName GFDL_1_1_no_invariants_or_later = "GNU Free Documentation License v1.1 or later - no invariants"+licenseName GFDL_1_1_only = "GNU Free Documentation License v1.1 only"+licenseName GFDL_1_1_or_later = "GNU Free Documentation License v1.1 or later"+licenseName GFDL_1_2_invariants_only = "GNU Free Documentation License v1.2 only - invariants"+licenseName GFDL_1_2_invariants_or_later = "GNU Free Documentation License v1.2 or later - invariants"+licenseName GFDL_1_2_no_invariants_only = "GNU Free Documentation License v1.2 only - no invariants"+licenseName GFDL_1_2_no_invariants_or_later = "GNU Free Documentation License v1.2 or later - no invariants"+licenseName GFDL_1_2_only = "GNU Free Documentation License v1.2 only"+licenseName GFDL_1_2_or_later = "GNU Free Documentation License v1.2 or later"+licenseName GFDL_1_3_invariants_only = "GNU Free Documentation License v1.3 only - invariants"+licenseName GFDL_1_3_invariants_or_later = "GNU Free Documentation License v1.3 or later - invariants"+licenseName GFDL_1_3_no_invariants_only = "GNU Free Documentation License v1.3 only - no invariants"+licenseName GFDL_1_3_no_invariants_or_later = "GNU Free Documentation License v1.3 or later - no invariants"+licenseName GFDL_1_3_only = "GNU Free Documentation License v1.3 only"+licenseName GFDL_1_3_or_later = "GNU Free Documentation License v1.3 or later"+licenseName Giftware = "Giftware License"+licenseName GL2PS = "GL2PS License"+licenseName Glide = "3dfx Glide License"+licenseName Glulxe = "Glulxe License"+licenseName GLWTPL = "Good Luck With That Public License"+licenseName Gnuplot = "gnuplot License"+licenseName GPL_1_0_only = "GNU General Public License v1.0 only"+licenseName GPL_1_0_or_later = "GNU General Public License v1.0 or later"+licenseName GPL_2_0_only = "GNU General Public License v2.0 only"+licenseName GPL_2_0_or_later = "GNU General Public License v2.0 or later"+licenseName GPL_3_0_only = "GNU General Public License v3.0 only"+licenseName GPL_3_0_or_later = "GNU General Public License v3.0 or later"+licenseName Graphics_Gems = "Graphics Gems License"+licenseName GSOAP_1_3b = "gSOAP Public License v1.3b"+licenseName Gtkbook = "gtkbook License"+licenseName Gutmann = "Gutmann License"+licenseName HaskellReport = "Haskell Language Report License"+licenseName HDF5 = "HDF5 License"+licenseName Hdparm = "hdparm License"+licenseName HIDAPI = "HIDAPI License"+licenseName Hippocratic_2_1 = "Hippocratic License 2.1"+licenseName HP_1986 = "Hewlett-Packard 1986 License"+licenseName HP_1989 = "Hewlett-Packard 1989 License"+licenseName HPND_DEC = "Historical Permission Notice and Disclaimer - DEC variant"+licenseName HPND_doc_sell = "Historical Permission Notice and Disclaimer - documentation sell variant"+licenseName HPND_doc = "Historical Permission Notice and Disclaimer - documentation variant"+licenseName HPND_export_US_acknowledgement = "HPND with US Government export control warning and acknowledgment"+licenseName HPND_export_US_modify = "HPND with US Government export control warning and modification rqmt"+licenseName HPND_export_US = "HPND with US Government export control warning"+licenseName HPND_export2_US = "HPND with US Government export control and 2 disclaimers"+licenseName HPND_Fenneberg_Livingston = "Historical Permission Notice and Disclaimer - Fenneberg-Livingston variant"+licenseName HPND_INRIA_IMAG = "Historical Permission Notice and Disclaimer    - INRIA-IMAG variant"+licenseName HPND_Intel = "Historical Permission Notice and Disclaimer - Intel variant"+licenseName HPND_Kevlin_Henney = "Historical Permission Notice and Disclaimer - Kevlin Henney variant"+licenseName HPND_Markus_Kuhn = "Historical Permission Notice and Disclaimer - Markus Kuhn variant"+licenseName HPND_merchantability_variant = "Historical Permission Notice and Disclaimer - merchantability variant"+licenseName HPND_MIT_disclaimer = "Historical Permission Notice and Disclaimer with MIT disclaimer"+licenseName HPND_Netrek = "Historical Permission Notice and Disclaimer - Netrek variant"+licenseName HPND_Pbmplus = "Historical Permission Notice and Disclaimer - Pbmplus variant"+licenseName HPND_sell_MIT_disclaimer_xserver = "Historical Permission Notice and Disclaimer - sell xserver variant with MIT disclaimer"+licenseName HPND_sell_regexpr = "Historical Permission Notice and Disclaimer - sell regexpr variant"+licenseName HPND_sell_variant_MIT_disclaimer_rev = "HPND sell variant with MIT disclaimer - reverse"+licenseName HPND_sell_variant_MIT_disclaimer = "HPND sell variant with MIT disclaimer"+licenseName HPND_sell_variant = "Historical Permission Notice and Disclaimer - sell variant"+licenseName HPND_UC_export_US = "Historical Permission Notice and Disclaimer - University of California, US export warning"+licenseName HPND_UC = "Historical Permission Notice and Disclaimer - University of California variant"+licenseName HPND = "Historical Permission Notice and Disclaimer"+licenseName HTMLTIDY = "HTML Tidy License"+licenseName IBM_pibs = "IBM PowerPC Initialization and Boot Software"+licenseName ICU = "ICU License"+licenseName IEC_Code_Components_EULA = "IEC    Code Components End-user licence agreement"+licenseName IJG_short = "Independent JPEG Group License - short"+licenseName IJG = "Independent JPEG Group License"+licenseName ImageMagick = "ImageMagick License"+licenseName IMatix = "iMatix Standard Function Library Agreement"+licenseName Imlib2 = "Imlib2 License"+licenseName Info_ZIP = "Info-ZIP License"+licenseName Inner_Net_2_0 = "Inner Net License v2.0"+licenseName InnoSetup = "Inno Setup License"+licenseName Intel_ACPI = "Intel ACPI Software License Agreement"+licenseName Intel = "Intel Open Source License"+licenseName Interbase_1_0 = "Interbase Public License v1.0"+licenseName IPA = "IPA Font License"+licenseName IPL_1_0 = "IBM Public License v1.0"+licenseName ISC_Veillard = "ISC Veillard variant"+licenseName ISC = "ISC License"+licenseName Jam = "Jam License"+licenseName JasPer_2_0 = "JasPer License"+licenseName Jove = "Jove License"+licenseName JPL_image = "JPL Image Use Policy"+licenseName JPNIC = "Japan Network Information Center License"+licenseName JSON = "JSON License"+licenseName Kastrup = "Kastrup License"+licenseName Kazlib = "Kazlib License"+licenseName Knuth_CTAN = "Knuth CTAN License"+licenseName LAL_1_2 = "Licence Art Libre 1.2"+licenseName LAL_1_3 = "Licence Art Libre 1.3"+licenseName Latex2e_translated_notice = "Latex2e with translated notice permission"+licenseName Latex2e = "Latex2e License"+licenseName Leptonica = "Leptonica License"+licenseName LGPL_2_0_only = "GNU Library General Public License v2 only"+licenseName LGPL_2_0_or_later = "GNU Library General Public License v2 or later"+licenseName LGPL_2_1_only = "GNU Lesser General Public License v2.1 only"+licenseName LGPL_2_1_or_later = "GNU Lesser General Public License v2.1 or later"+licenseName LGPL_3_0_only = "GNU Lesser General Public License v3.0 only"+licenseName LGPL_3_0_or_later = "GNU Lesser General Public License v3.0 or later"+licenseName LGPLLR = "Lesser General Public License For Linguistic Resources"+licenseName Libpng_1_6_35 = "PNG Reference Library License v1 (for libpng 0.5 through 1.6.35"+licenseName Libpng_2_0 = "PNG Reference Library version 2"+licenseName Libpng = "libpng License"+licenseName Libselinux_1_0 = "libselinux public domain notice"+licenseName Libtiff = "libtiff License"+licenseName Libutil_David_Nugent = "libutil David Nugent License"+licenseName LiLiQ_P_1_1 = "Licence Libre du Qu\233bec \8211 Permissive version 1.1"+licenseName LiLiQ_R_1_1 = "Licence Libre du Qu\233bec \8211 R\233ciprocit\233 version 1.1"+licenseName LiLiQ_Rplus_1_1 = "Licence Libre du Qu\233bec \8211 R\233ciprocit\233 forte version 1.1"+licenseName Linux_man_pages_1_para = "Linux man-pages - 1 paragraph"+licenseName Linux_man_pages_copyleft_2_para = "Linux man-pages Copyleft - 2 paragraphs"+licenseName Linux_man_pages_copyleft_var = "Linux man-pages Copyleft Variant"+licenseName Linux_man_pages_copyleft = "Linux man-pages Copyleft"+licenseName Linux_OpenIB = "Linux Kernel Variant of OpenIB.org license"+licenseName LOOP = "Common Lisp LOOP License"+licenseName LPD_document = "LPD Documentation License"+licenseName LPL_1_02 = "Lucent Public License v1.02"+licenseName LPL_1_0 = "Lucent Public License Version 1.0"+licenseName LPPL_1_0 = "LaTeX Project Public License v1.0"+licenseName LPPL_1_1 = "LaTeX Project Public License v1.1"+licenseName LPPL_1_2 = "LaTeX Project Public License v1.2"+licenseName LPPL_1_3a = "LaTeX Project Public License v1.3a"+licenseName LPPL_1_3c = "LaTeX Project Public License v1.3c"+licenseName Lsof = "lsof License"+licenseName Lucida_Bitmap_Fonts = "Lucida Bitmap Fonts License"+licenseName LZMA_SDK_9_11_to_9_20 = "LZMA SDK License (versions 9.11 to 9.20)"+licenseName LZMA_SDK_9_22 = "LZMA SDK License (versions 9.22 and beyond)"+licenseName Mackerras_3_Clause_acknowledgment = "Mackerras 3-Clause - acknowledgment variant"+licenseName Mackerras_3_Clause = "Mackerras 3-Clause License"+licenseName Magaz = "magaz License"+licenseName Mailprio = "mailprio License"+licenseName MakeIndex = "MakeIndex License"+licenseName Man2html = "man2html License"+licenseName Martin_Birgmeier = "Martin Birgmeier License"+licenseName McPhee_slideshow = "McPhee Slideshow License"+licenseName Metamail = "metamail License"+licenseName Minpack = "Minpack License"+licenseName MIPS = "MIPS License"+licenseName MirOS = "The MirOS Licence"+licenseName MIT_0 = "MIT No Attribution"+licenseName MIT_advertising = "Enlightenment License (e16)"+licenseName MIT_Click = "MIT Click License"+licenseName MIT_CMU = "CMU License"+licenseName MIT_enna = "enna License"+licenseName MIT_feh = "feh License"+licenseName MIT_Festival = "MIT Festival Variant"+licenseName MIT_Khronos_old = "MIT Khronos - old variant"+licenseName MIT_Modern_Variant = "MIT License Modern Variant"+licenseName MIT_open_group = "MIT Open Group variant"+licenseName MIT_testregex = "MIT testregex Variant"+licenseName MIT_Wu = "MIT Tom Wu Variant"+licenseName MITNFA = "MIT +no-false-attribs license"+licenseName MIT = "MIT License"+licenseName MMIXware = "MMIXware License"+licenseName Motosoto = "Motosoto License"+licenseName MPEG_SSG = "MPEG Software Simulation"+licenseName Mpi_permissive = "mpi Permissive License"+licenseName Mpich2 = "mpich2 License"+licenseName MPL_1_0 = "Mozilla Public License 1.0"+licenseName MPL_1_1 = "Mozilla Public License 1.1"+licenseName MPL_2_0_no_copyleft_exception = "Mozilla Public License 2.0 (no copyleft exception)"+licenseName MPL_2_0 = "Mozilla Public License 2.0"+licenseName Mplus = "mplus Font License"+licenseName MS_LPL = "Microsoft Limited Public License"+licenseName MS_PL = "Microsoft Public License"+licenseName MS_RL = "Microsoft Reciprocal License"+licenseName MTLL = "Matrix Template Library License"+licenseName MulanPSL_1_0 = "Mulan Permissive Software License, Version 1"+licenseName MulanPSL_2_0 = "Mulan Permissive Software License, Version 2"+licenseName Multics = "Multics License"+licenseName Mup = "Mup License"+licenseName NAIST_2003 = "Nara Institute of Science and Technology License (2003)"+licenseName NASA_1_3 = "NASA Open Source Agreement 1.3"+licenseName Naumen = "Naumen Public License"+licenseName NBPL_1_0 = "Net Boolean Public License v1"+licenseName NCBI_PD = "NCBI Public Domain Notice"+licenseName NCGL_UK_2_0 = "Non-Commercial Government Licence"+licenseName NCL = "NCL Source Code License"+licenseName NCSA = "University of Illinois/NCSA Open Source License"+licenseName Net_SNMP = "Net-SNMP License"+licenseName NetCDF = "NetCDF license"+licenseName Newsletr = "Newsletr License"+licenseName NGPL = "Nethack General Public License"+licenseName Ngrep = "ngrep License"+licenseName NICTA_1_0 = "NICTA Public Software License, Version 1.0"+licenseName NIST_PD_fallback = "NIST Public Domain Notice with license fallback"+licenseName NIST_PD = "NIST Public Domain Notice"+licenseName NIST_Software = "NIST Software License"+licenseName NLOD_1_0 = "Norwegian Licence for Open Government Data (NLOD) 1.0"+licenseName NLOD_2_0 = "Norwegian Licence for Open Government Data (NLOD) 2.0"+licenseName NLPL = "No Limit Public License"+licenseName Nokia = "Nokia Open Source License"+licenseName NOSL = "Netizen Open Source License"+licenseName Noweb = "Noweb License"+licenseName NPL_1_0 = "Netscape Public License v1.0"+licenseName NPL_1_1 = "Netscape Public License v1.1"+licenseName NPOSL_3_0 = "Non-Profit Open Software License 3.0"+licenseName NRL = "NRL License"+licenseName NTIA_PD = "NTIA Public Domain Notice"+licenseName NTP_0 = "NTP No Attribution"+licenseName NTP = "NTP License"+licenseName O_UDA_1_0 = "Open Use of Data Agreement v1.0"+licenseName OAR = "OAR License"+licenseName OCCT_PL = "Open CASCADE Technology Public License"+licenseName OCLC_2_0 = "OCLC Research Public License 2.0"+licenseName ODbL_1_0 = "Open Data Commons Open Database License v1.0"+licenseName ODC_By_1_0 = "Open Data Commons Attribution License v1.0"+licenseName OFFIS = "OFFIS License"+licenseName OFL_1_0_no_RFN = "SIL Open Font License 1.0 with no Reserved Font Name"+licenseName OFL_1_0_RFN = "SIL Open Font License 1.0 with Reserved Font Name"+licenseName OFL_1_0 = "SIL Open Font License 1.0"+licenseName OFL_1_1_no_RFN = "SIL Open Font License 1.1 with no Reserved Font Name"+licenseName OFL_1_1_RFN = "SIL Open Font License 1.1 with Reserved Font Name"+licenseName OFL_1_1 = "SIL Open Font License 1.1"+licenseName OGC_1_0 = "OGC Software License, Version 1.0"+licenseName OGDL_Taiwan_1_0 = "Taiwan Open Government Data License, version 1.0"+licenseName OGL_Canada_2_0 = "Open Government Licence - Canada"+licenseName OGL_UK_1_0 = "Open Government Licence v1.0"+licenseName OGL_UK_2_0 = "Open Government Licence v2.0"+licenseName OGL_UK_3_0 = "Open Government Licence v3.0"+licenseName OGTSL = "Open Group Test Suite License"+licenseName OLDAP_1_1 = "Open LDAP Public License v1.1"+licenseName OLDAP_1_2 = "Open LDAP Public License v1.2"+licenseName OLDAP_1_3 = "Open LDAP Public License v1.3"+licenseName OLDAP_1_4 = "Open LDAP Public License v1.4"+licenseName OLDAP_2_0_1 = "Open LDAP Public License v2.0.1"+licenseName OLDAP_2_0 = "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)"+licenseName OLDAP_2_1 = "Open LDAP Public License v2.1"+licenseName OLDAP_2_2_1 = "Open LDAP Public License v2.2.1"+licenseName OLDAP_2_2_2 = "Open LDAP Public License 2.2.2"+licenseName OLDAP_2_2 = "Open LDAP Public License v2.2"+licenseName OLDAP_2_3 = "Open LDAP Public License v2.3"+licenseName OLDAP_2_4 = "Open LDAP Public License v2.4"+licenseName OLDAP_2_5 = "Open LDAP Public License v2.5"+licenseName OLDAP_2_6 = "Open LDAP Public License v2.6"+licenseName OLDAP_2_7 = "Open LDAP Public License v2.7"+licenseName OLDAP_2_8 = "Open LDAP Public License v2.8"+licenseName OLFL_1_3 = "Open Logistics Foundation License Version 1.3"+licenseName OML = "Open Market License"+licenseName OpenPBS_2_3 = "OpenPBS v2.3 Software License"+licenseName OpenSSL_standalone = "OpenSSL License - standalone"+licenseName OpenSSL = "OpenSSL License"+licenseName OpenVision = "OpenVision License"+licenseName OPL_1_0 = "Open Public License v1.0"+licenseName OPL_UK_3_0 = "United    Kingdom Open Parliament Licence v3.0"+licenseName OPUBL_1_0 = "Open Publication License v1.0"+licenseName OSET_PL_2_1 = "OSET Public License version 2.1"+licenseName OSL_1_0 = "Open Software License 1.0"+licenseName OSL_1_1 = "Open Software License 1.1"+licenseName OSL_2_0 = "Open Software License 2.0"+licenseName OSL_2_1 = "Open Software License 2.1"+licenseName OSL_3_0 = "Open Software License 3.0"+licenseName PADL = "PADL License"+licenseName Parity_6_0_0 = "The Parity Public License 6.0.0"+licenseName Parity_7_0_0 = "The Parity Public License 7.0.0"+licenseName PDDL_1_0 = "Open Data Commons Public Domain Dedication & License 1.0"+licenseName PHP_3_01 = "PHP License v3.01"+licenseName PHP_3_0 = "PHP License v3.0"+licenseName Pixar = "Pixar License"+licenseName Pkgconf = "pkgconf License"+licenseName Plexus = "Plexus Classworlds License"+licenseName Pnmstitch = "pnmstitch License"+licenseName PolyForm_Noncommercial_1_0_0 = "PolyForm Noncommercial License 1.0.0"+licenseName PolyForm_Small_Business_1_0_0 = "PolyForm Small Business License 1.0.0"+licenseName PostgreSQL = "PostgreSQL License"+licenseName PPL = "Peer Production License"+licenseName PSF_2_0 = "Python Software Foundation License 2.0"+licenseName Psfrag = "psfrag License"+licenseName Psutils = "psutils License"+licenseName Python_2_0_1 = "Python License 2.0.1"+licenseName Python_2_0 = "Python License 2.0"+licenseName Python_ldap = "Python ldap License"+licenseName Qhull = "Qhull License"+licenseName QPL_1_0_INRIA_2004 = "Q Public License 1.0 - INRIA 2004 variant"+licenseName QPL_1_0 = "Q Public License 1.0"+licenseName Radvd = "radvd License"+licenseName Rdisc = "Rdisc License"+licenseName RHeCos_1_1 = "Red Hat eCos Public License v1.1"+licenseName RPL_1_1 = "Reciprocal Public License 1.1"+licenseName RPL_1_5 = "Reciprocal Public License 1.5"+licenseName RPSL_1_0 = "RealNetworks Public Source License v1.0"+licenseName RSA_MD = "RSA Message-Digest License"+licenseName RSCPL = "Ricoh Source Code Public License"+licenseName Ruby_pty = "Ruby pty extension license"+licenseName Ruby = "Ruby License"+licenseName SAX_PD_2_0 = "Sax Public Domain Notice 2.0"+licenseName SAX_PD = "Sax Public Domain Notice"+licenseName Saxpath = "Saxpath License"+licenseName SCEA = "SCEA Shared Source License"+licenseName SchemeReport = "Scheme Language Report License"+licenseName Sendmail_8_23 = "Sendmail License 8.23"+licenseName Sendmail_Open_Source_1_1 = "Sendmail Open Source License v1.1"+licenseName Sendmail = "Sendmail License"+licenseName SGI_B_1_0 = "SGI Free Software License B v1.0"+licenseName SGI_B_1_1 = "SGI Free Software License B v1.1"+licenseName SGI_B_2_0 = "SGI Free Software License B v2.0"+licenseName SGI_OpenGL = "SGI OpenGL License"+licenseName SGP4 = "SGP4 Permission Notice"+licenseName SHL_0_51 = "Solderpad Hardware License, Version 0.51"+licenseName SHL_0_5 = "Solderpad Hardware License v0.5"+licenseName SimPL_2_0 = "Simple Public License 2.0"+licenseName SISSL_1_2 = "Sun Industry Standards Source License v1.2"+licenseName SISSL = "Sun Industry Standards Source License v1.1"+licenseName Sleepycat = "Sleepycat License"+licenseName SL = "SL License"+licenseName SMAIL_GPL = "SMAIL General Public License"+licenseName SMLNJ = "Standard ML of New Jersey License"+licenseName SMPPL = "Secure Messaging Protocol Public License"+licenseName SNIA = "SNIA Public License 1.1"+licenseName Snprintf = "snprintf License"+licenseName SOFA = "SOFA Software License"+licenseName SoftSurfer = "softSurfer License"+licenseName Soundex = "Soundex License"+licenseName Spencer_86 = "Spencer License 86"+licenseName Spencer_94 = "Spencer License 94"+licenseName Spencer_99 = "Spencer License 99"+licenseName SPL_1_0 = "Sun Public License v1.0"+licenseName Ssh_keyscan = "ssh-keyscan License"+licenseName SSH_OpenSSH = "SSH OpenSSH license"+licenseName SSH_short = "SSH short notice"+licenseName SSLeay_standalone = "SSLeay License - standalone"+licenseName SSPL_1_0 = "Server Side Public License, v 1"+licenseName SugarCRM_1_1_3 = "SugarCRM Public License v1.1.3"+licenseName Sun_PPP_2000 = "Sun PPP License (2000)"+licenseName Sun_PPP = "Sun PPP License"+licenseName SunPro = "SunPro License"+licenseName SWL = "Scheme Widget Library (SWL) Software License Agreement"+licenseName Swrule = "swrule License"+licenseName Symlinks = "Symlinks License"+licenseName TAPR_OHL_1_0 = "TAPR Open Hardware License v1.0"+licenseName TCL = "TCL/TK License"+licenseName TCP_wrappers = "TCP Wrappers License"+licenseName TermReadKey = "TermReadKey License"+licenseName TGPPL_1_0 = "Transitive Grace Period Public Licence 1.0"+licenseName ThirdEye = "ThirdEye License"+licenseName Threeparttable = "threeparttable License"+licenseName TMate = "TMate Open Source License"+licenseName TORQUE_1_1 = "TORQUE v2.5+ Software License v1.1"+licenseName TOSL = "Trusster Open Source License"+licenseName TPDL = "Time::ParseDate License"+licenseName TPL_1_0 = "THOR Public License 1.0"+licenseName TrustedQSL = "TrustedQSL License"+licenseName TTWL = "Text-Tabs+Wrap License"+licenseName TTYP0 = "TTYP0 License"+licenseName TU_Berlin_1_0 = "Technische Universitaet Berlin License 1.0"+licenseName TU_Berlin_2_0 = "Technische Universitaet Berlin License 2.0"+licenseName Ubuntu_font_1_0 = "Ubuntu Font Licence v1.0"+licenseName UCAR = "UCAR License"+licenseName UCL_1_0 = "Upstream Compatibility License v1.0"+licenseName Ulem = "ulem License"+licenseName UMich_Merit = "Michigan/Merit Networks License"+licenseName Unicode_3_0 = "Unicode License v3"+licenseName Unicode_DFS_2015 = "Unicode License Agreement - Data Files and Software (2015)"+licenseName Unicode_DFS_2016 = "Unicode License Agreement - Data Files and Software (2016)"+licenseName Unicode_TOU = "Unicode Terms of Use"+licenseName UnixCrypt = "UnixCrypt License"+licenseName Unlicense_libtelnet = "Unlicense - libtelnet variant"+licenseName Unlicense_libwhirlpool = "Unlicense - libwhirlpool variant"+licenseName Unlicense = "The Unlicense"+licenseName UPL_1_0 = "Universal Permissive License v1.0"+licenseName URT_RLE = "Utah Raster Toolkit Run Length Encoded License"+licenseName Vim = "Vim License"+licenseName VOSTROM = "VOSTROM Public License for Open Source"+licenseName VSL_1_0 = "Vovida Software License v1.0"+licenseName W3C_19980720 = "W3C Software Notice and License (1998-07-20)"+licenseName W3C_20150513 = "W3C Software Notice and Document License (2015-05-13)"+licenseName W3C = "W3C Software Notice and License (2002-12-31)"+licenseName W3m = "w3m License"+licenseName Watcom_1_0 = "Sybase Open Watcom Public License 1.0"+licenseName Widget_Workshop = "Widget Workshop License"+licenseName Wsuipa = "Wsuipa License"+licenseName WTFPL = "Do What The F*ck You Want To Public License"+licenseName Wwl = "WWL License"+licenseName X11_distribute_modifications_variant = "X11 License Distribution Modification Variant"+licenseName X11_swapped = "X11 swapped final paragraphs"+licenseName X11 = "X11 License"+licenseName Xdebug_1_03 = "Xdebug License v 1.03"+licenseName Xerox = "Xerox License"+licenseName Xfig = "Xfig License"+licenseName XFree86_1_1 = "XFree86 License 1.1"+licenseName Xinetd = "xinetd License"+licenseName Xkeyboard_config_Zinoviev = "xkeyboard-config Zinoviev License"+licenseName Xlock = "xlock License"+licenseName Xnet = "X.Net License"+licenseName Xpp = "XPP License"+licenseName XSkat = "XSkat License"+licenseName Xzoom = "xzoom License"+licenseName YPL_1_0 = "Yahoo! Public License v1.0"+licenseName YPL_1_1 = "Yahoo! Public License v1.1"+licenseName Zed = "Zed License"+licenseName Zeeff = "Zeeff License"+licenseName Zend_2_0 = "Zend License v2.0"+licenseName Zimbra_1_3 = "Zimbra Public License v1.3"+licenseName Zimbra_1_4 = "Zimbra Public License v1.4"+licenseName Zlib_acknowledgement = "zlib/libpng License with Acknowledgement"+licenseName Zlib = "zlib License"+licenseName ZPL_1_1 = "Zope Public License 1.1"+licenseName ZPL_2_0 = "Zope Public License 2.0"+licenseName ZPL_2_1 = "Zope Public License 2.1"++-- | Whether the license is approved by Open Source Initiative (OSI).+--+-- See <https://opensource.org/licenses/alphabetical>.+licenseIsOsiApproved :: LicenseId -> Bool+licenseIsOsiApproved N_0BSD = True+licenseIsOsiApproved AAL = True+licenseIsOsiApproved AFL_1_1 = True+licenseIsOsiApproved AFL_1_2 = True+licenseIsOsiApproved AFL_2_0 = True+licenseIsOsiApproved AFL_2_1 = True+licenseIsOsiApproved AFL_3_0 = True+licenseIsOsiApproved AGPL_3_0_only = True+licenseIsOsiApproved AGPL_3_0_or_later = True+licenseIsOsiApproved Apache_1_1 = True+licenseIsOsiApproved Apache_2_0 = True+licenseIsOsiApproved APL_1_0 = True+licenseIsOsiApproved APSL_1_0 = True+licenseIsOsiApproved APSL_1_1 = True+licenseIsOsiApproved APSL_1_2 = True+licenseIsOsiApproved APSL_2_0 = True+licenseIsOsiApproved Artistic_1_0_cl8 = True+licenseIsOsiApproved Artistic_1_0_Perl = True+licenseIsOsiApproved Artistic_1_0 = True+licenseIsOsiApproved Artistic_2_0 = True+licenseIsOsiApproved BlueOak_1_0_0 = True+licenseIsOsiApproved BSD_1_Clause = True+licenseIsOsiApproved BSD_2_Clause_Patent = True+licenseIsOsiApproved BSD_2_Clause = True+licenseIsOsiApproved BSD_3_Clause_LBNL = True+licenseIsOsiApproved BSD_3_Clause = True+licenseIsOsiApproved BSL_1_0 = True+licenseIsOsiApproved CAL_1_0_Combined_Work_Exception = True+licenseIsOsiApproved CAL_1_0 = True+licenseIsOsiApproved CATOSL_1_1 = True+licenseIsOsiApproved CDDL_1_0 = True+licenseIsOsiApproved CECILL_2_1 = True+licenseIsOsiApproved CERN_OHL_P_2_0 = True+licenseIsOsiApproved CERN_OHL_S_2_0 = True+licenseIsOsiApproved CERN_OHL_W_2_0 = True+licenseIsOsiApproved CNRI_Python = True+licenseIsOsiApproved CPAL_1_0 = True+licenseIsOsiApproved CPL_1_0 = True+licenseIsOsiApproved CUA_OPL_1_0 = True+licenseIsOsiApproved ECL_1_0 = True+licenseIsOsiApproved ECL_2_0 = True+licenseIsOsiApproved EFL_1_0 = True+licenseIsOsiApproved EFL_2_0 = True+licenseIsOsiApproved Entessa = True+licenseIsOsiApproved EPL_1_0 = True+licenseIsOsiApproved EPL_2_0 = True+licenseIsOsiApproved EUDatagrid = True+licenseIsOsiApproved EUPL_1_1 = True+licenseIsOsiApproved EUPL_1_2 = True+licenseIsOsiApproved Fair = True+licenseIsOsiApproved Frameworx_1_0 = True+licenseIsOsiApproved GPL_2_0_only = True+licenseIsOsiApproved GPL_2_0_or_later = True+licenseIsOsiApproved GPL_3_0_only = True+licenseIsOsiApproved GPL_3_0_or_later = True+licenseIsOsiApproved HPND = True+licenseIsOsiApproved ICU = True+licenseIsOsiApproved Intel = True+licenseIsOsiApproved IPA = True+licenseIsOsiApproved IPL_1_0 = True+licenseIsOsiApproved ISC = True+licenseIsOsiApproved Jam = True+licenseIsOsiApproved LGPL_2_0_only = True+licenseIsOsiApproved LGPL_2_0_or_later = True+licenseIsOsiApproved LGPL_2_1_only = True+licenseIsOsiApproved LGPL_2_1_or_later = True+licenseIsOsiApproved LGPL_3_0_only = True+licenseIsOsiApproved LGPL_3_0_or_later = True+licenseIsOsiApproved LiLiQ_P_1_1 = True+licenseIsOsiApproved LiLiQ_R_1_1 = True+licenseIsOsiApproved LiLiQ_Rplus_1_1 = True+licenseIsOsiApproved LPL_1_02 = True+licenseIsOsiApproved LPL_1_0 = True+licenseIsOsiApproved LPPL_1_3c = True+licenseIsOsiApproved MirOS = True+licenseIsOsiApproved MIT_0 = True+licenseIsOsiApproved MIT_Modern_Variant = True+licenseIsOsiApproved MIT = True+licenseIsOsiApproved Motosoto = True+licenseIsOsiApproved MPL_1_0 = True+licenseIsOsiApproved MPL_1_1 = True+licenseIsOsiApproved MPL_2_0_no_copyleft_exception = True+licenseIsOsiApproved MPL_2_0 = True+licenseIsOsiApproved MS_PL = True+licenseIsOsiApproved MS_RL = True+licenseIsOsiApproved MulanPSL_2_0 = True+licenseIsOsiApproved Multics = True+licenseIsOsiApproved NASA_1_3 = True+licenseIsOsiApproved Naumen = True+licenseIsOsiApproved NCSA = True+licenseIsOsiApproved NGPL = True+licenseIsOsiApproved Nokia = True+licenseIsOsiApproved NPOSL_3_0 = True+licenseIsOsiApproved NTP = True+licenseIsOsiApproved OCLC_2_0 = True+licenseIsOsiApproved OFL_1_1_no_RFN = True+licenseIsOsiApproved OFL_1_1_RFN = True+licenseIsOsiApproved OFL_1_1 = True+licenseIsOsiApproved OGTSL = True+licenseIsOsiApproved OLDAP_2_8 = True+licenseIsOsiApproved OLFL_1_3 = True+licenseIsOsiApproved OSET_PL_2_1 = True+licenseIsOsiApproved OSL_1_0 = True+licenseIsOsiApproved OSL_2_0 = True+licenseIsOsiApproved OSL_2_1 = True+licenseIsOsiApproved OSL_3_0 = True+licenseIsOsiApproved PHP_3_01 = True+licenseIsOsiApproved PHP_3_0 = True+licenseIsOsiApproved PostgreSQL = True+licenseIsOsiApproved Python_2_0 = True+licenseIsOsiApproved QPL_1_0 = True+licenseIsOsiApproved RPL_1_1 = True+licenseIsOsiApproved RPL_1_5 = True+licenseIsOsiApproved RPSL_1_0 = True+licenseIsOsiApproved RSCPL = True+licenseIsOsiApproved SimPL_2_0 = True+licenseIsOsiApproved SISSL = True+licenseIsOsiApproved Sleepycat = True+licenseIsOsiApproved SPL_1_0 = True+licenseIsOsiApproved UCL_1_0 = True+licenseIsOsiApproved Unicode_3_0 = True+licenseIsOsiApproved Unicode_DFS_2016 = True+licenseIsOsiApproved Unlicense = True+licenseIsOsiApproved UPL_1_0 = True+licenseIsOsiApproved VSL_1_0 = True+licenseIsOsiApproved W3C_20150513 = True+licenseIsOsiApproved W3C = True+licenseIsOsiApproved Watcom_1_0 = True+licenseIsOsiApproved Xnet = True+licenseIsOsiApproved Zlib = True+licenseIsOsiApproved ZPL_2_0 = True+licenseIsOsiApproved ZPL_2_1 = True+licenseIsOsiApproved _ = False++-- | Whether the license is considered libre by Free Software Foundation (FSF).+--+-- See <https://www.gnu.org/licenses/license-list.en.html>+--+-- @since 3.4.0.0+--+licenseIsFsfLibre :: LicenseId -> Bool+licenseIsFsfLibre AFL_1_1 = True+licenseIsFsfLibre AFL_1_2 = True+licenseIsFsfLibre AFL_2_0 = True+licenseIsFsfLibre AFL_2_1 = True+licenseIsFsfLibre AFL_3_0 = True+licenseIsFsfLibre AGPL_1_0 = True+licenseIsFsfLibre AGPL_3_0_only = True+licenseIsFsfLibre AGPL_3_0_or_later = True+licenseIsFsfLibre Apache_1_0 = True+licenseIsFsfLibre Apache_1_1 = True+licenseIsFsfLibre Apache_2_0 = True+licenseIsFsfLibre APSL_2_0 = True+licenseIsFsfLibre Artistic_2_0 = True+licenseIsFsfLibre BitTorrent_1_1 = True+licenseIsFsfLibre BSD_2_Clause_FreeBSD = True+licenseIsFsfLibre BSD_2_Clause = True+licenseIsFsfLibre BSD_3_Clause_Clear = True+licenseIsFsfLibre BSD_3_Clause = True+licenseIsFsfLibre BSD_4_Clause = True+licenseIsFsfLibre BSL_1_0 = True+licenseIsFsfLibre CC_BY_4_0 = True+licenseIsFsfLibre CC_BY_SA_4_0 = True+licenseIsFsfLibre CC0_1_0 = True+licenseIsFsfLibre CDDL_1_0 = True+licenseIsFsfLibre CECILL_2_0 = True+licenseIsFsfLibre CECILL_B = True+licenseIsFsfLibre CECILL_C = True+licenseIsFsfLibre ClArtistic = True+licenseIsFsfLibre Condor_1_1 = True+licenseIsFsfLibre CPAL_1_0 = True+licenseIsFsfLibre CPL_1_0 = True+licenseIsFsfLibre ECL_2_0 = True+licenseIsFsfLibre EFL_2_0 = True+licenseIsFsfLibre EPL_1_0 = True+licenseIsFsfLibre EPL_2_0 = True+licenseIsFsfLibre EUDatagrid = True+licenseIsFsfLibre EUPL_1_1 = True+licenseIsFsfLibre EUPL_1_2 = True+licenseIsFsfLibre FSFAP = True+licenseIsFsfLibre FTL = True+licenseIsFsfLibre GFDL_1_1_only = True+licenseIsFsfLibre GFDL_1_1_or_later = True+licenseIsFsfLibre GFDL_1_2_only = True+licenseIsFsfLibre GFDL_1_2_or_later = True+licenseIsFsfLibre GFDL_1_3_only = True+licenseIsFsfLibre GFDL_1_3_or_later = True+licenseIsFsfLibre Gnuplot = True+licenseIsFsfLibre GPL_2_0_only = True+licenseIsFsfLibre GPL_2_0_or_later = True+licenseIsFsfLibre GPL_3_0_only = True+licenseIsFsfLibre GPL_3_0_or_later = True+licenseIsFsfLibre HPND = True+licenseIsFsfLibre IJG = True+licenseIsFsfLibre IMatix = True+licenseIsFsfLibre Imlib2 = True+licenseIsFsfLibre Intel = True+licenseIsFsfLibre IPA = True+licenseIsFsfLibre IPL_1_0 = True+licenseIsFsfLibre ISC = True+licenseIsFsfLibre LGPL_2_1_only = True+licenseIsFsfLibre LGPL_2_1_or_later = True+licenseIsFsfLibre LGPL_3_0_only = True+licenseIsFsfLibre LGPL_3_0_or_later = True+licenseIsFsfLibre LPL_1_02 = True+licenseIsFsfLibre LPPL_1_2 = True+licenseIsFsfLibre LPPL_1_3a = True+licenseIsFsfLibre MIT = True+licenseIsFsfLibre MPL_1_1 = True+licenseIsFsfLibre MPL_2_0 = True+licenseIsFsfLibre MS_PL = True+licenseIsFsfLibre MS_RL = True+licenseIsFsfLibre NCSA = True+licenseIsFsfLibre Nokia = True+licenseIsFsfLibre NOSL = True+licenseIsFsfLibre NPL_1_0 = True+licenseIsFsfLibre NPL_1_1 = True+licenseIsFsfLibre ODbL_1_0 = True+licenseIsFsfLibre OFL_1_0 = True+licenseIsFsfLibre OFL_1_1 = True+licenseIsFsfLibre OLDAP_2_3 = True+licenseIsFsfLibre OLDAP_2_7 = True+licenseIsFsfLibre OpenSSL = True+licenseIsFsfLibre OSL_1_0 = True+licenseIsFsfLibre OSL_1_1 = True+licenseIsFsfLibre OSL_2_0 = True+licenseIsFsfLibre OSL_2_1 = True+licenseIsFsfLibre OSL_3_0 = True+licenseIsFsfLibre PHP_3_01 = True+licenseIsFsfLibre Python_2_0 = True+licenseIsFsfLibre QPL_1_0 = True+licenseIsFsfLibre RPSL_1_0 = True+licenseIsFsfLibre Ruby = True+licenseIsFsfLibre SGI_B_2_0 = True+licenseIsFsfLibre SISSL = True+licenseIsFsfLibre Sleepycat = True+licenseIsFsfLibre SMLNJ = True+licenseIsFsfLibre SPL_1_0 = True+licenseIsFsfLibre Unlicense = True+licenseIsFsfLibre UPL_1_0 = True+licenseIsFsfLibre Vim = True+licenseIsFsfLibre W3C = True+licenseIsFsfLibre WTFPL = True+licenseIsFsfLibre X11 = True+licenseIsFsfLibre XFree86_1_1 = True+licenseIsFsfLibre Xinetd = True+licenseIsFsfLibre YPL_1_1 = True+licenseIsFsfLibre Zend_2_0 = True+licenseIsFsfLibre Zimbra_1_3 = True+licenseIsFsfLibre Zlib = True+licenseIsFsfLibre ZPL_2_0 = True+licenseIsFsfLibre ZPL_2_1 = True+licenseIsFsfLibre _ = False++-------------------------------------------------------------------------------+-- Creation+-------------------------------------------------------------------------------++licenseIdList :: LicenseListVersion -> [LicenseId]+licenseIdList LicenseListVersion_3_0 =+    [ AGPL_1_0+    , BSD_2_Clause_FreeBSD+    , BSD_2_Clause_NetBSD+    , Bzip2_1_0_5+    , Net_SNMP+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_2 =+    [ AGPL_1_0_only+    , AGPL_1_0_or_later+    , BSD_2_Clause_FreeBSD+    , BSD_2_Clause_NetBSD+    , Bzip2_1_0_5+    , Linux_OpenIB+    , MIT_0+    , Net_SNMP+    , ODC_By_1_0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_6 =+    [ AGPL_1_0_only+    , AGPL_1_0_or_later+    , Blessing+    , BlueOak_1_0_0+    , BSD_2_Clause_FreeBSD+    , BSD_2_Clause_NetBSD+    , BSD_3_Clause_Open_MPI+    , Bzip2_1_0_5+    , CC_PDDC+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , HPND_sell_variant+    , JPNIC+    , Libpng_2_0+    , Linux_OpenIB+    , MIT_0+    , Net_SNMP+    , ODC_By_1_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , Parity_6_0_0+    , Sendmail_8_23+    , SHL_0_51+    , SHL_0_5+    , SSPL_1_0+    , TAPR_OHL_1_0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_9 =+    [ AGPL_1_0_only+    , AGPL_1_0_or_later+    , Blessing+    , BlueOak_1_0_0+    , BSD_2_Clause_FreeBSD+    , BSD_3_Clause_Open_MPI+    , Bzip2_1_0_5+    , CAL_1_0_Combined_Work_Exception+    , CAL_1_0+    , CC_PDDC+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , CERN_OHL_P_2_0+    , CERN_OHL_S_2_0+    , CERN_OHL_W_2_0+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , Etalab_2_0+    , Hippocratic_2_1+    , HPND_sell_variant+    , JPNIC+    , Libpng_2_0+    , Libselinux_1_0+    , Linux_OpenIB+    , MIT_0+    , MulanPSL_1_0+    , MulanPSL_2_0+    , NCGL_UK_2_0+    , Net_SNMP+    , NTP_0+    , O_UDA_1_0+    , ODC_By_1_0+    , OFL_1_0_no_RFN+    , OFL_1_0_RFN+    , OFL_1_1_no_RFN+    , OFL_1_1_RFN+    , OGC_1_0+    , OGL_Canada_2_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , Parity_6_0_0+    , Parity_7_0_0+    , PolyForm_Noncommercial_1_0_0+    , PolyForm_Small_Business_1_0_0+    , PSF_2_0+    , Sendmail_8_23+    , SHL_0_51+    , SHL_0_5+    , SSH_OpenSSH+    , SSH_short+    , SSPL_1_0+    , TAPR_OHL_1_0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    , UCL_1_0+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_10 =+    [ AGPL_1_0_only+    , AGPL_1_0_or_later+    , Blessing+    , BlueOak_1_0_0+    , BSD_2_Clause_Views+    , BSD_3_Clause_Open_MPI+    , Bzip2_1_0_5+    , CAL_1_0_Combined_Work_Exception+    , CAL_1_0+    , CC_BY_3_0_AT+    , CC_BY_NC_ND_3_0_IGO+    , CC_BY_SA_3_0_AT+    , CC_PDDC+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , CERN_OHL_P_2_0+    , CERN_OHL_S_2_0+    , CERN_OHL_W_2_0+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , EPICS+    , Etalab_2_0+    , GFDL_1_1_invariants_only+    , GFDL_1_1_invariants_or_later+    , GFDL_1_1_no_invariants_only+    , GFDL_1_1_no_invariants_or_later+    , GFDL_1_2_invariants_only+    , GFDL_1_2_invariants_or_later+    , GFDL_1_2_no_invariants_only+    , GFDL_1_2_no_invariants_or_later+    , GFDL_1_3_invariants_only+    , GFDL_1_3_invariants_or_later+    , GFDL_1_3_no_invariants_only+    , GFDL_1_3_no_invariants_or_later+    , GLWTPL+    , Hippocratic_2_1+    , HPND_sell_variant+    , JPNIC+    , Libpng_2_0+    , Libselinux_1_0+    , Linux_OpenIB+    , MIT_0+    , MulanPSL_1_0+    , MulanPSL_2_0+    , NCGL_UK_2_0+    , Net_SNMP+    , NIST_PD_fallback+    , NIST_PD+    , NTP_0+    , O_UDA_1_0+    , ODC_By_1_0+    , OFL_1_0_no_RFN+    , OFL_1_0_RFN+    , OFL_1_1_no_RFN+    , OFL_1_1_RFN+    , OGC_1_0+    , OGL_Canada_2_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , Parity_6_0_0+    , Parity_7_0_0+    , PolyForm_Noncommercial_1_0_0+    , PolyForm_Small_Business_1_0_0+    , PSF_2_0+    , Sendmail_8_23+    , SHL_0_51+    , SHL_0_5+    , SSH_OpenSSH+    , SSH_short+    , SSPL_1_0+    , TAPR_OHL_1_0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    , UCL_1_0+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_16 =+    [ AGPL_1_0_only+    , AGPL_1_0_or_later+    , ANTLR_PD_fallback+    , App_s2p+    , Blessing+    , BlueOak_1_0_0+    , BSD_2_Clause_Views+    , BSD_3_Clause_Modification+    , BSD_3_Clause_No_Military_License+    , BSD_3_Clause_Open_MPI+    , BSD_4_Clause_Shortened+    , BUSL_1_1+    , C_UDA_1_0+    , CAL_1_0_Combined_Work_Exception+    , CAL_1_0+    , CC_BY_2_5_AU+    , CC_BY_3_0_AT+    , CC_BY_3_0_DE+    , CC_BY_3_0_NL+    , CC_BY_3_0_US+    , CC_BY_NC_3_0_DE+    , CC_BY_NC_ND_3_0_DE+    , CC_BY_NC_ND_3_0_IGO+    , CC_BY_NC_SA_2_0_FR+    , CC_BY_NC_SA_2_0_UK+    , CC_BY_NC_SA_3_0_DE+    , CC_BY_NC_SA_3_0_IGO+    , CC_BY_ND_3_0_DE+    , CC_BY_SA_2_0_UK+    , CC_BY_SA_2_1_JP+    , CC_BY_SA_3_0_AT+    , CC_BY_SA_3_0_DE+    , CC_PDDC+    , CDL_1_0+    , CDLA_Permissive_2_0+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , CERN_OHL_P_2_0+    , CERN_OHL_S_2_0+    , CERN_OHL_W_2_0+    , COIL_1_0+    , Community_Spec_1_0+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , DL_DE_BY_2_0+    , DRL_1_0+    , Elastic_2_0+    , EPICS+    , Etalab_2_0+    , FDK_AAC+    , FreeBSD_DOC+    , GD+    , GFDL_1_1_invariants_only+    , GFDL_1_1_invariants_or_later+    , GFDL_1_1_no_invariants_only+    , GFDL_1_1_no_invariants_or_later+    , GFDL_1_2_invariants_only+    , GFDL_1_2_invariants_or_later+    , GFDL_1_2_no_invariants_only+    , GFDL_1_2_no_invariants_or_later+    , GFDL_1_3_invariants_only+    , GFDL_1_3_invariants_or_later+    , GFDL_1_3_no_invariants_only+    , GFDL_1_3_no_invariants_or_later+    , GLWTPL+    , Hippocratic_2_1+    , HPND_sell_variant+    , HTMLTIDY+    , Jam+    , JPNIC+    , Libpng_2_0+    , Libselinux_1_0+    , Linux_man_pages_copyleft+    , Linux_OpenIB+    , MIT_0+    , MIT_Modern_Variant+    , MIT_open_group+    , MulanPSL_1_0+    , MulanPSL_2_0+    , NAIST_2003+    , NCGL_UK_2_0+    , Net_SNMP+    , NIST_PD_fallback+    , NIST_PD+    , NLOD_2_0+    , NTP_0+    , O_UDA_1_0+    , ODC_By_1_0+    , OFL_1_0_no_RFN+    , OFL_1_0_RFN+    , OFL_1_1_no_RFN+    , OFL_1_1_RFN+    , OGC_1_0+    , OGDL_Taiwan_1_0+    , OGL_Canada_2_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , OPUBL_1_0+    , Parity_6_0_0+    , Parity_7_0_0+    , PolyForm_Noncommercial_1_0_0+    , PolyForm_Small_Business_1_0_0+    , PSF_2_0+    , SchemeReport+    , Sendmail_8_23+    , SHL_0_51+    , SHL_0_5+    , SSH_OpenSSH+    , SSH_short+    , SSPL_1_0+    , TAPR_OHL_1_0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    , UCL_1_0+    , X11_distribute_modifications_variant+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_23 =+    [ AdaCore_doc+    , Adobe_Display_PostScript+    , Adobe_Utopia+    , AGPL_1_0_only+    , AGPL_1_0_or_later+    , AML_glslang+    , ANTLR_PD_fallback+    , App_s2p+    , Arphic_1999+    , ASWF_Digital_Assets_1_0+    , ASWF_Digital_Assets_1_1+    , Baekmuk+    , Bcrypt_Solar_Designer+    , Bitstream_Charter+    , Bitstream_Vera+    , Blessing+    , BlueOak_1_0_0+    , Boehm_GC+    , Brian_Gladman_2_Clause+    , Brian_Gladman_3_Clause+    , BSD_2_Clause_Darwin+    , BSD_2_Clause_Views+    , BSD_3_Clause_acpica+    , BSD_3_Clause_flex+    , BSD_3_Clause_HP+    , BSD_3_Clause_Modification+    , BSD_3_Clause_No_Military_License+    , BSD_3_Clause_Open_MPI+    , BSD_3_Clause_Sun+    , BSD_4_Clause_Shortened+    , BSD_4_3RENO+    , BSD_4_3TAHOE+    , BSD_Advertising_Acknowledgement+    , BSD_Attribution_HPND_disclaimer+    , BSD_Inferno_Nettverk+    , BSD_Source_beginning_file+    , BSD_Systemics_W3Works+    , BSD_Systemics+    , BUSL_1_1+    , C_UDA_1_0+    , CAL_1_0_Combined_Work_Exception+    , CAL_1_0+    , Caldera_no_preamble+    , CC_BY_2_5_AU+    , CC_BY_3_0_AT+    , CC_BY_3_0_AU+    , CC_BY_3_0_DE+    , CC_BY_3_0_IGO+    , CC_BY_3_0_NL+    , CC_BY_3_0_US+    , CC_BY_NC_3_0_DE+    , CC_BY_NC_ND_3_0_DE+    , CC_BY_NC_ND_3_0_IGO+    , CC_BY_NC_SA_2_0_DE+    , CC_BY_NC_SA_2_0_FR+    , CC_BY_NC_SA_2_0_UK+    , CC_BY_NC_SA_3_0_DE+    , CC_BY_NC_SA_3_0_IGO+    , CC_BY_ND_3_0_DE+    , CC_BY_SA_2_0_UK+    , CC_BY_SA_2_1_JP+    , CC_BY_SA_3_0_AT+    , CC_BY_SA_3_0_DE+    , CC_BY_SA_3_0_IGO+    , CC_PDDC+    , CDL_1_0+    , CDLA_Permissive_2_0+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , CERN_OHL_P_2_0+    , CERN_OHL_S_2_0+    , CERN_OHL_W_2_0+    , CFITSIO+    , Check_cvs+    , Checkmk+    , Clips+    , CMU_Mach_nodoc+    , CMU_Mach+    , COIL_1_0+    , Community_Spec_1_0+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , Cornell_Lossless_JPEG+    , Cronyx+    , DEC_3_Clause+    , DL_DE_BY_2_0+    , DL_DE_ZERO_2_0+    , DRL_1_0+    , DRL_1_1+    , Dtoa+    , Elastic_2_0+    , EPICS+    , Etalab_2_0+    , FBM+    , FDK_AAC+    , Ferguson_Twofish+    , FreeBSD_DOC+    , FSFAP_no_warranty_disclaimer+    , FSFULLRWD+    , Furuseth+    , Fwlw+    , GCR_docs+    , GD+    , GFDL_1_1_invariants_only+    , GFDL_1_1_invariants_or_later+    , GFDL_1_1_no_invariants_only+    , GFDL_1_1_no_invariants_or_later+    , GFDL_1_2_invariants_only+    , GFDL_1_2_invariants_or_later+    , GFDL_1_2_no_invariants_only+    , GFDL_1_2_no_invariants_or_later+    , GFDL_1_3_invariants_only+    , GFDL_1_3_invariants_or_later+    , GFDL_1_3_no_invariants_only+    , GFDL_1_3_no_invariants_or_later+    , GLWTPL+    , Graphics_Gems+    , Gtkbook+    , Hdparm+    , Hippocratic_2_1+    , HP_1986+    , HP_1989+    , HPND_DEC+    , HPND_doc_sell+    , HPND_doc+    , HPND_export_US_modify+    , HPND_export_US+    , HPND_Fenneberg_Livingston+    , HPND_INRIA_IMAG+    , HPND_Kevlin_Henney+    , HPND_Markus_Kuhn+    , HPND_MIT_disclaimer+    , HPND_Pbmplus+    , HPND_sell_MIT_disclaimer_xserver+    , HPND_sell_regexpr+    , HPND_sell_variant_MIT_disclaimer+    , HPND_sell_variant+    , HPND_UC+    , HTMLTIDY+    , IEC_Code_Components_EULA+    , IJG_short+    , Inner_Net_2_0+    , ISC_Veillard+    , Jam+    , JPL_image+    , JPNIC+    , Kastrup+    , Kazlib+    , Knuth_CTAN+    , Latex2e_translated_notice+    , Libpng_2_0+    , Libselinux_1_0+    , Libutil_David_Nugent+    , Linux_man_pages_1_para+    , Linux_man_pages_copyleft_2_para+    , Linux_man_pages_copyleft_var+    , Linux_man_pages_copyleft+    , Linux_OpenIB+    , LOOP+    , LPD_document+    , Lsof+    , Lucida_Bitmap_Fonts+    , LZMA_SDK_9_11_to_9_20+    , LZMA_SDK_9_22+    , Mackerras_3_Clause_acknowledgment+    , Mackerras_3_Clause+    , Magaz+    , Mailprio+    , Martin_Birgmeier+    , McPhee_slideshow+    , Metamail+    , Minpack+    , MIT_0+    , MIT_Festival+    , MIT_Modern_Variant+    , MIT_open_group+    , MIT_testregex+    , MIT_Wu+    , MMIXware+    , MPEG_SSG+    , Mpi_permissive+    , Mplus+    , MS_LPL+    , MulanPSL_1_0+    , MulanPSL_2_0+    , NAIST_2003+    , NCGL_UK_2_0+    , Net_SNMP+    , NICTA_1_0+    , NIST_PD_fallback+    , NIST_PD+    , NIST_Software+    , NLOD_2_0+    , NTP_0+    , O_UDA_1_0+    , ODC_By_1_0+    , OFFIS+    , OFL_1_0_no_RFN+    , OFL_1_0_RFN+    , OFL_1_1_no_RFN+    , OFL_1_1_RFN+    , OGC_1_0+    , OGDL_Taiwan_1_0+    , OGL_Canada_2_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , OLFL_1_3+    , OpenPBS_2_3+    , OpenSSL_standalone+    , OpenVision+    , OPL_UK_3_0+    , OPUBL_1_0+    , PADL+    , Parity_6_0_0+    , Parity_7_0_0+    , Pixar+    , Pnmstitch+    , PolyForm_Noncommercial_1_0_0+    , PolyForm_Small_Business_1_0_0+    , PSF_2_0+    , Python_2_0_1+    , Python_ldap+    , QPL_1_0_INRIA_2004+    , Radvd+    , SAX_PD_2_0+    , SchemeReport+    , Sendmail_8_23+    , SGI_OpenGL+    , SGP4+    , SHL_0_51+    , SHL_0_5+    , SL+    , Snprintf+    , SoftSurfer+    , Soundex+    , Ssh_keyscan+    , SSH_OpenSSH+    , SSH_short+    , SSLeay_standalone+    , SSPL_1_0+    , Sun_PPP+    , SunPro+    , Swrule+    , Symlinks+    , TAPR_OHL_1_0+    , TermReadKey+    , TGPPL_1_0+    , TPDL+    , TPL_1_0+    , TTWL+    , TTYP0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    , UCAR+    , UCL_1_0+    , Ulem+    , UMich_Merit+    , Unicode_3_0+    , UnixCrypt+    , URT_RLE+    , W3m+    , Widget_Workshop+    , X11_distribute_modifications_variant+    , Xdebug_1_03+    , Xfig+    , Xkeyboard_config_Zinoviev+    , Xlock+    , Zeeff+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_25 =+    [ N_3D_Slicer_1_0+    , AdaCore_doc+    , Adobe_Display_PostScript+    , Adobe_Utopia+    , AGPL_1_0_only+    , AGPL_1_0_or_later+    , AMD_newlib+    , AML_glslang+    , ANTLR_PD_fallback+    , Any_OSI+    , App_s2p+    , Arphic_1999+    , ASWF_Digital_Assets_1_0+    , ASWF_Digital_Assets_1_1+    , Baekmuk+    , Bcrypt_Solar_Designer+    , Bitstream_Charter+    , Bitstream_Vera+    , Blessing+    , BlueOak_1_0_0+    , Boehm_GC+    , Brian_Gladman_2_Clause+    , Brian_Gladman_3_Clause+    , BSD_2_Clause_Darwin+    , BSD_2_Clause_first_lines+    , BSD_2_Clause_Views+    , BSD_3_Clause_acpica+    , BSD_3_Clause_flex+    , BSD_3_Clause_HP+    , BSD_3_Clause_Modification+    , BSD_3_Clause_No_Military_License+    , BSD_3_Clause_Open_MPI+    , BSD_3_Clause_Sun+    , BSD_4_Clause_Shortened+    , BSD_4_3RENO+    , BSD_4_3TAHOE+    , BSD_Advertising_Acknowledgement+    , BSD_Attribution_HPND_disclaimer+    , BSD_Inferno_Nettverk+    , BSD_Source_beginning_file+    , BSD_Systemics_W3Works+    , BSD_Systemics+    , BUSL_1_1+    , C_UDA_1_0+    , CAL_1_0_Combined_Work_Exception+    , CAL_1_0+    , Caldera_no_preamble+    , Catharon+    , CC_BY_2_5_AU+    , CC_BY_3_0_AT+    , CC_BY_3_0_AU+    , CC_BY_3_0_DE+    , CC_BY_3_0_IGO+    , CC_BY_3_0_NL+    , CC_BY_3_0_US+    , CC_BY_NC_3_0_DE+    , CC_BY_NC_ND_3_0_DE+    , CC_BY_NC_ND_3_0_IGO+    , CC_BY_NC_SA_2_0_DE+    , CC_BY_NC_SA_2_0_FR+    , CC_BY_NC_SA_2_0_UK+    , CC_BY_NC_SA_3_0_DE+    , CC_BY_NC_SA_3_0_IGO+    , CC_BY_ND_3_0_DE+    , CC_BY_SA_2_0_UK+    , CC_BY_SA_2_1_JP+    , CC_BY_SA_3_0_AT+    , CC_BY_SA_3_0_DE+    , CC_BY_SA_3_0_IGO+    , CC_PDDC+    , CDL_1_0+    , CDLA_Permissive_2_0+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , CERN_OHL_P_2_0+    , CERN_OHL_S_2_0+    , CERN_OHL_W_2_0+    , CFITSIO+    , Check_cvs+    , Checkmk+    , Clips+    , CMU_Mach_nodoc+    , CMU_Mach+    , COIL_1_0+    , Community_Spec_1_0+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , Cornell_Lossless_JPEG+    , Cronyx+    , Cve_tou+    , DEC_3_Clause+    , DL_DE_BY_2_0+    , DL_DE_ZERO_2_0+    , DocBook_Schema+    , DocBook_XML+    , DRL_1_0+    , DRL_1_1+    , Dtoa+    , Elastic_2_0+    , EPICS+    , Etalab_2_0+    , FBM+    , FDK_AAC+    , Ferguson_Twofish+    , FreeBSD_DOC+    , FSFAP_no_warranty_disclaimer+    , FSFULLRWD+    , Furuseth+    , Fwlw+    , GCR_docs+    , GD+    , GFDL_1_1_invariants_only+    , GFDL_1_1_invariants_or_later+    , GFDL_1_1_no_invariants_only+    , GFDL_1_1_no_invariants_or_later+    , GFDL_1_2_invariants_only+    , GFDL_1_2_invariants_or_later+    , GFDL_1_2_no_invariants_only+    , GFDL_1_2_no_invariants_or_later+    , GFDL_1_3_invariants_only+    , GFDL_1_3_invariants_or_later+    , GFDL_1_3_no_invariants_only+    , GFDL_1_3_no_invariants_or_later+    , GLWTPL+    , Graphics_Gems+    , Gtkbook+    , Gutmann+    , Hdparm+    , HIDAPI+    , Hippocratic_2_1+    , HP_1986+    , HP_1989+    , HPND_DEC+    , HPND_doc_sell+    , HPND_doc+    , HPND_export_US_acknowledgement+    , HPND_export_US_modify+    , HPND_export_US+    , HPND_export2_US+    , HPND_Fenneberg_Livingston+    , HPND_INRIA_IMAG+    , HPND_Intel+    , HPND_Kevlin_Henney+    , HPND_Markus_Kuhn+    , HPND_merchantability_variant+    , HPND_MIT_disclaimer+    , HPND_Netrek+    , HPND_Pbmplus+    , HPND_sell_MIT_disclaimer_xserver+    , HPND_sell_regexpr+    , HPND_sell_variant_MIT_disclaimer_rev+    , HPND_sell_variant_MIT_disclaimer+    , HPND_sell_variant+    , HPND_UC_export_US+    , HPND_UC+    , HTMLTIDY+    , IEC_Code_Components_EULA+    , IJG_short+    , Inner_Net_2_0+    , ISC_Veillard+    , Jam+    , JPL_image+    , JPNIC+    , Kastrup+    , Kazlib+    , Knuth_CTAN+    , Latex2e_translated_notice+    , Libpng_2_0+    , Libselinux_1_0+    , Libutil_David_Nugent+    , Linux_man_pages_1_para+    , Linux_man_pages_copyleft_2_para+    , Linux_man_pages_copyleft_var+    , Linux_man_pages_copyleft+    , Linux_OpenIB+    , LOOP+    , LPD_document+    , Lsof+    , Lucida_Bitmap_Fonts+    , LZMA_SDK_9_11_to_9_20+    , LZMA_SDK_9_22+    , Mackerras_3_Clause_acknowledgment+    , Mackerras_3_Clause+    , Magaz+    , Mailprio+    , Martin_Birgmeier+    , McPhee_slideshow+    , Metamail+    , Minpack+    , MIT_0+    , MIT_Festival+    , MIT_Khronos_old+    , MIT_Modern_Variant+    , MIT_open_group+    , MIT_testregex+    , MIT_Wu+    , MMIXware+    , MPEG_SSG+    , Mpi_permissive+    , Mplus+    , MS_LPL+    , MulanPSL_1_0+    , MulanPSL_2_0+    , NAIST_2003+    , NCBI_PD+    , NCGL_UK_2_0+    , NCL+    , NICTA_1_0+    , NIST_PD_fallback+    , NIST_PD+    , NIST_Software+    , NLOD_2_0+    , NTP_0+    , O_UDA_1_0+    , OAR+    , ODC_By_1_0+    , OFFIS+    , OFL_1_0_no_RFN+    , OFL_1_0_RFN+    , OFL_1_1_no_RFN+    , OFL_1_1_RFN+    , OGC_1_0+    , OGDL_Taiwan_1_0+    , OGL_Canada_2_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , OLFL_1_3+    , OpenPBS_2_3+    , OpenSSL_standalone+    , OpenVision+    , OPL_UK_3_0+    , OPUBL_1_0+    , PADL+    , Parity_6_0_0+    , Parity_7_0_0+    , Pixar+    , Pkgconf+    , Pnmstitch+    , PolyForm_Noncommercial_1_0_0+    , PolyForm_Small_Business_1_0_0+    , PPL+    , PSF_2_0+    , Python_2_0_1+    , Python_ldap+    , QPL_1_0_INRIA_2004+    , Radvd+    , Ruby_pty+    , SAX_PD_2_0+    , SchemeReport+    , Sendmail_8_23+    , SGI_OpenGL+    , SGP4+    , SHL_0_51+    , SHL_0_5+    , SL+    , Snprintf+    , SoftSurfer+    , Soundex+    , Ssh_keyscan+    , SSH_OpenSSH+    , SSH_short+    , SSLeay_standalone+    , SSPL_1_0+    , Sun_PPP_2000+    , Sun_PPP+    , SunPro+    , Swrule+    , Symlinks+    , TAPR_OHL_1_0+    , TermReadKey+    , TGPPL_1_0+    , Threeparttable+    , TPDL+    , TPL_1_0+    , TTWL+    , TTYP0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    , Ubuntu_font_1_0+    , UCAR+    , UCL_1_0+    , Ulem+    , UMich_Merit+    , Unicode_3_0+    , UnixCrypt+    , URT_RLE+    , W3m+    , Widget_Workshop+    , X11_distribute_modifications_variant+    , X11_swapped+    , Xdebug_1_03+    , Xfig+    , Xkeyboard_config_Zinoviev+    , Xlock+    , Xzoom+    , Zeeff+    ]+    ++ bulkOfLicenses+licenseIdList LicenseListVersion_3_26 =+    [ N_3D_Slicer_1_0+    , AdaCore_doc+    , Adobe_Display_PostScript+    , Adobe_Utopia+    , AGPL_1_0_only+    , AGPL_1_0_or_later+    , AMD_newlib+    , AML_glslang+    , ANTLR_PD_fallback+    , Any_OSI_perl_modules+    , Any_OSI+    , App_s2p+    , Arphic_1999+    , Artistic_dist+    , Aspell_RU+    , ASWF_Digital_Assets_1_0+    , ASWF_Digital_Assets_1_1+    , Baekmuk+    , Bcrypt_Solar_Designer+    , Bitstream_Charter+    , Bitstream_Vera+    , Blessing+    , BlueOak_1_0_0+    , Boehm_GC_without_fee+    , Boehm_GC+    , Brian_Gladman_2_Clause+    , Brian_Gladman_3_Clause+    , BSD_2_Clause_Darwin+    , BSD_2_Clause_first_lines+    , BSD_2_Clause_pkgconf_disclaimer+    , BSD_2_Clause_Views+    , BSD_3_Clause_acpica+    , BSD_3_Clause_flex+    , BSD_3_Clause_HP+    , BSD_3_Clause_Modification+    , BSD_3_Clause_No_Military_License+    , BSD_3_Clause_Open_MPI+    , BSD_3_Clause_Sun+    , BSD_4_Clause_Shortened+    , BSD_4_3RENO+    , BSD_4_3TAHOE+    , BSD_Advertising_Acknowledgement+    , BSD_Attribution_HPND_disclaimer+    , BSD_Inferno_Nettverk+    , BSD_Source_beginning_file+    , BSD_Systemics_W3Works+    , BSD_Systemics+    , BUSL_1_1+    , C_UDA_1_0+    , CAL_1_0_Combined_Work_Exception+    , CAL_1_0+    , Caldera_no_preamble+    , Catharon+    , CC_BY_2_5_AU+    , CC_BY_3_0_AT+    , CC_BY_3_0_AU+    , CC_BY_3_0_DE+    , CC_BY_3_0_IGO+    , CC_BY_3_0_NL+    , CC_BY_3_0_US+    , CC_BY_NC_3_0_DE+    , CC_BY_NC_ND_3_0_DE+    , CC_BY_NC_ND_3_0_IGO+    , CC_BY_NC_SA_2_0_DE+    , CC_BY_NC_SA_2_0_FR+    , CC_BY_NC_SA_2_0_UK+    , CC_BY_NC_SA_3_0_DE+    , CC_BY_NC_SA_3_0_IGO+    , CC_BY_ND_3_0_DE+    , CC_BY_SA_2_0_UK+    , CC_BY_SA_2_1_JP+    , CC_BY_SA_3_0_AT+    , CC_BY_SA_3_0_DE+    , CC_BY_SA_3_0_IGO+    , CC_PDDC+    , CC_PDM_1_0+    , CC_SA_1_0+    , CDL_1_0+    , CDLA_Permissive_2_0+    , CERN_OHL_1_1+    , CERN_OHL_1_2+    , CERN_OHL_P_2_0+    , CERN_OHL_S_2_0+    , CERN_OHL_W_2_0+    , CFITSIO+    , Check_cvs+    , Checkmk+    , Clips+    , CMU_Mach_nodoc+    , CMU_Mach+    , COIL_1_0+    , Community_Spec_1_0+    , Copyleft_next_0_3_0+    , Copyleft_next_0_3_1+    , Cornell_Lossless_JPEG+    , Cronyx+    , CryptoSwift+    , Cve_tou+    , DEC_3_Clause+    , DL_DE_BY_2_0+    , DL_DE_ZERO_2_0+    , DocBook_DTD+    , DocBook_Schema+    , DocBook_Stylesheet+    , DocBook_XML+    , DRL_1_0+    , DRL_1_1+    , Dtoa+    , Elastic_2_0+    , EPICS+    , Etalab_2_0+    , FBM+    , FDK_AAC+    , Ferguson_Twofish+    , FreeBSD_DOC+    , FSFAP_no_warranty_disclaimer+    , FSFULLRSD+    , FSFULLRWD+    , FSL_1_1_ALv2+    , FSL_1_1_MIT+    , Furuseth+    , Fwlw+    , Game_Programming_Gems+    , GCR_docs+    , GD+    , Generic_xts+    , GFDL_1_1_invariants_only+    , GFDL_1_1_invariants_or_later+    , GFDL_1_1_no_invariants_only+    , GFDL_1_1_no_invariants_or_later+    , GFDL_1_2_invariants_only+    , GFDL_1_2_invariants_or_later+    , GFDL_1_2_no_invariants_only+    , GFDL_1_2_no_invariants_or_later+    , GFDL_1_3_invariants_only+    , GFDL_1_3_invariants_or_later+    , GFDL_1_3_no_invariants_only+    , GFDL_1_3_no_invariants_or_later+    , GLWTPL+    , Graphics_Gems+    , Gtkbook+    , Gutmann+    , HDF5+    , Hdparm+    , HIDAPI+    , Hippocratic_2_1+    , HP_1986+    , HP_1989+    , HPND_DEC+    , HPND_doc_sell+    , HPND_doc+    , HPND_export_US_acknowledgement+    , HPND_export_US_modify+    , HPND_export_US+    , HPND_export2_US+    , HPND_Fenneberg_Livingston+    , HPND_INRIA_IMAG+    , HPND_Intel+    , HPND_Kevlin_Henney+    , HPND_Markus_Kuhn+    , HPND_merchantability_variant+    , HPND_MIT_disclaimer+    , HPND_Netrek+    , HPND_Pbmplus+    , HPND_sell_MIT_disclaimer_xserver+    , HPND_sell_regexpr+    , HPND_sell_variant_MIT_disclaimer_rev+    , HPND_sell_variant_MIT_disclaimer+    , HPND_sell_variant+    , HPND_UC_export_US+    , HPND_UC+    , HTMLTIDY+    , IEC_Code_Components_EULA+    , IJG_short+    , Inner_Net_2_0+    , InnoSetup+    , ISC_Veillard+    , Jam+    , Jove+    , JPL_image+    , JPNIC+    , Kastrup+    , Kazlib+    , Knuth_CTAN+    , Latex2e_translated_notice+    , Libpng_1_6_35+    , Libpng_2_0+    , Libselinux_1_0+    , Libutil_David_Nugent+    , Linux_man_pages_1_para+    , Linux_man_pages_copyleft_2_para+    , Linux_man_pages_copyleft_var+    , Linux_man_pages_copyleft+    , Linux_OpenIB+    , LOOP+    , LPD_document+    , Lsof+    , Lucida_Bitmap_Fonts+    , LZMA_SDK_9_11_to_9_20+    , LZMA_SDK_9_22+    , Mackerras_3_Clause_acknowledgment+    , Mackerras_3_Clause+    , Magaz+    , Mailprio+    , Man2html+    , Martin_Birgmeier+    , McPhee_slideshow+    , Metamail+    , Minpack+    , MIPS+    , MIT_0+    , MIT_Click+    , MIT_Festival+    , MIT_Khronos_old+    , MIT_Modern_Variant+    , MIT_open_group+    , MIT_testregex+    , MIT_Wu+    , MMIXware+    , MPEG_SSG+    , Mpi_permissive+    , Mplus+    , MS_LPL+    , MulanPSL_1_0+    , MulanPSL_2_0+    , NAIST_2003+    , NCBI_PD+    , NCGL_UK_2_0+    , NCL+    , Ngrep+    , NICTA_1_0+    , NIST_PD_fallback+    , NIST_PD+    , NIST_Software+    , NLOD_2_0+    , NTIA_PD+    , NTP_0+    , O_UDA_1_0+    , OAR+    , ODC_By_1_0+    , OFFIS+    , OFL_1_0_no_RFN+    , OFL_1_0_RFN+    , OFL_1_1_no_RFN+    , OFL_1_1_RFN+    , OGC_1_0+    , OGDL_Taiwan_1_0+    , OGL_Canada_2_0+    , OGL_UK_1_0+    , OGL_UK_2_0+    , OGL_UK_3_0+    , OLFL_1_3+    , OpenPBS_2_3+    , OpenSSL_standalone+    , OpenVision+    , OPL_UK_3_0+    , OPUBL_1_0+    , PADL+    , Parity_6_0_0+    , Parity_7_0_0+    , Pixar+    , Pkgconf+    , Pnmstitch+    , PolyForm_Noncommercial_1_0_0+    , PolyForm_Small_Business_1_0_0+    , PPL+    , PSF_2_0+    , Python_2_0_1+    , Python_ldap+    , QPL_1_0_INRIA_2004+    , Radvd+    , Ruby_pty+    , SAX_PD_2_0+    , SchemeReport+    , Sendmail_8_23+    , Sendmail_Open_Source_1_1+    , SGI_OpenGL+    , SGP4+    , SHL_0_51+    , SHL_0_5+    , SL+    , SMAIL_GPL+    , Snprintf+    , SOFA+    , SoftSurfer+    , Soundex+    , Ssh_keyscan+    , SSH_OpenSSH+    , SSH_short+    , SSLeay_standalone+    , SSPL_1_0+    , Sun_PPP_2000+    , Sun_PPP+    , SunPro+    , Swrule+    , Symlinks+    , TAPR_OHL_1_0+    , TermReadKey+    , TGPPL_1_0+    , ThirdEye+    , Threeparttable+    , TPDL+    , TPL_1_0+    , TrustedQSL+    , TTWL+    , TTYP0+    , TU_Berlin_1_0+    , TU_Berlin_2_0+    , Ubuntu_font_1_0+    , UCAR+    , UCL_1_0+    , Ulem+    , UMich_Merit+    , Unicode_3_0+    , UnixCrypt+    , Unlicense_libtelnet+    , Unlicense_libwhirlpool+    , URT_RLE+    , W3m+    , Widget_Workshop+    , Wwl+    , X11_distribute_modifications_variant+    , X11_swapped+    , Xdebug_1_03+    , Xfig+    , Xkeyboard_config_Zinoviev+    , Xlock+    , Xzoom+    , Zeeff+    ]+    ++ bulkOfLicenses++-- | Create a 'LicenseId' from a 'String'.+mkLicenseId :: LicenseListVersion -> String -> Maybe LicenseId+mkLicenseId LicenseListVersion_3_0  s = Map.lookup s stringLookup_3_0+mkLicenseId LicenseListVersion_3_2  s = Map.lookup s stringLookup_3_2+mkLicenseId LicenseListVersion_3_6  s = Map.lookup s stringLookup_3_6+mkLicenseId LicenseListVersion_3_9  s = Map.lookup s stringLookup_3_9+mkLicenseId LicenseListVersion_3_10 s = Map.lookup s stringLookup_3_10+mkLicenseId LicenseListVersion_3_16 s = Map.lookup s stringLookup_3_16+mkLicenseId LicenseListVersion_3_23 s = Map.lookup s stringLookup_3_23+mkLicenseId LicenseListVersion_3_25 s = Map.lookup s stringLookup_3_25+mkLicenseId LicenseListVersion_3_26 s = Map.lookup s stringLookup_3_26++stringLookup_3_0 :: Map String LicenseId+stringLookup_3_0 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_0++stringLookup_3_2 :: Map String LicenseId+stringLookup_3_2 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_2++stringLookup_3_6 :: Map String LicenseId+stringLookup_3_6 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_6++stringLookup_3_9 :: Map String LicenseId+stringLookup_3_9 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_9++stringLookup_3_10 :: Map String LicenseId+stringLookup_3_10 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_10++stringLookup_3_16 :: Map String LicenseId+stringLookup_3_16 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_16++stringLookup_3_23 :: Map String LicenseId+stringLookup_3_23 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_23++stringLookup_3_25 :: Map String LicenseId+stringLookup_3_25 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_25++stringLookup_3_26 :: Map String LicenseId+stringLookup_3_26 = Map.fromList $ map (\i -> (licenseId i, i)) $+    licenseIdList LicenseListVersion_3_26++--  | Licenses in all SPDX License lists+bulkOfLicenses :: [LicenseId]+bulkOfLicenses =+    [ N_0BSD+    , AAL+    , Abstyles+    , Adobe_2006+    , Adobe_Glyph+    , ADSL+    , AFL_1_1+    , AFL_1_2+    , AFL_2_0+    , AFL_2_1+    , AFL_3_0+    , Afmparse+    , AGPL_3_0_only+    , AGPL_3_0_or_later+    , Aladdin+    , AMDPLPA+    , AML+    , AMPAS+    , ANTLR_PD+    , Apache_1_0+    , Apache_1_1+    , Apache_2_0+    , APAFML+    , APL_1_0+    , APSL_1_0+    , APSL_1_1+    , APSL_1_2+    , APSL_2_0+    , Artistic_1_0_cl8+    , Artistic_1_0_Perl+    , Artistic_1_0+    , Artistic_2_0+    , Bahyph+    , Barr+    , Beerware+    , BitTorrent_1_0+    , BitTorrent_1_1+    , Borceux+    , BSD_1_Clause+    , BSD_2_Clause_Patent+    , BSD_2_Clause+    , BSD_3_Clause_Attribution+    , BSD_3_Clause_Clear+    , BSD_3_Clause_LBNL+    , BSD_3_Clause_No_Nuclear_License_2014+    , BSD_3_Clause_No_Nuclear_License+    , BSD_3_Clause_No_Nuclear_Warranty+    , BSD_3_Clause+    , BSD_4_Clause_UC+    , BSD_4_Clause+    , BSD_Protection+    , BSD_Source_Code+    , BSL_1_0+    , Bzip2_1_0_6+    , Caldera+    , CATOSL_1_1+    , CC_BY_1_0+    , CC_BY_2_0+    , CC_BY_2_5+    , CC_BY_3_0+    , CC_BY_4_0+    , CC_BY_NC_1_0+    , CC_BY_NC_2_0+    , CC_BY_NC_2_5+    , CC_BY_NC_3_0+    , CC_BY_NC_4_0+    , CC_BY_NC_ND_1_0+    , CC_BY_NC_ND_2_0+    , CC_BY_NC_ND_2_5+    , CC_BY_NC_ND_3_0+    , CC_BY_NC_ND_4_0+    , CC_BY_NC_SA_1_0+    , CC_BY_NC_SA_2_0+    , CC_BY_NC_SA_2_5+    , CC_BY_NC_SA_3_0+    , CC_BY_NC_SA_4_0+    , CC_BY_ND_1_0+    , CC_BY_ND_2_0+    , CC_BY_ND_2_5+    , CC_BY_ND_3_0+    , CC_BY_ND_4_0+    , CC_BY_SA_1_0+    , CC_BY_SA_2_0+    , CC_BY_SA_2_5+    , CC_BY_SA_3_0+    , CC_BY_SA_4_0+    , CC0_1_0+    , CDDL_1_0+    , CDDL_1_1+    , CDLA_Permissive_1_0+    , CDLA_Sharing_1_0+    , CECILL_1_0+    , CECILL_1_1+    , CECILL_2_0+    , CECILL_2_1+    , CECILL_B+    , CECILL_C+    , ClArtistic+    , CNRI_Jython+    , CNRI_Python_GPL_Compatible+    , CNRI_Python+    , Condor_1_1+    , CPAL_1_0+    , CPL_1_0+    , CPOL_1_02+    , Crossword+    , CrystalStacker+    , CUA_OPL_1_0+    , Cube+    , Curl+    , D_FSL_1_0+    , Diffmark+    , DOC+    , Dotseqn+    , DSDP+    , Dvipdfm+    , ECL_1_0+    , ECL_2_0+    , EFL_1_0+    , EFL_2_0+    , EGenix+    , Entessa+    , EPL_1_0+    , EPL_2_0+    , ErlPL_1_1+    , EUDatagrid+    , EUPL_1_0+    , EUPL_1_1+    , EUPL_1_2+    , Eurosym+    , Fair+    , Frameworx_1_0+    , FreeImage+    , FSFAP+    , FSFULLR+    , FSFUL+    , FTL+    , GFDL_1_1_only+    , GFDL_1_1_or_later+    , GFDL_1_2_only+    , GFDL_1_2_or_later+    , GFDL_1_3_only+    , GFDL_1_3_or_later+    , Giftware+    , GL2PS+    , Glide+    , Glulxe+    , Gnuplot+    , GPL_1_0_only+    , GPL_1_0_or_later+    , GPL_2_0_only+    , GPL_2_0_or_later+    , GPL_3_0_only+    , GPL_3_0_or_later+    , GSOAP_1_3b+    , HaskellReport+    , HPND+    , IBM_pibs+    , ICU+    , IJG+    , ImageMagick+    , IMatix+    , Imlib2+    , Info_ZIP+    , Intel_ACPI+    , Intel+    , Interbase_1_0+    , IPA+    , IPL_1_0+    , ISC+    , JasPer_2_0+    , JSON+    , LAL_1_2+    , LAL_1_3+    , Latex2e+    , Leptonica+    , LGPL_2_0_only+    , LGPL_2_0_or_later+    , LGPL_2_1_only+    , LGPL_2_1_or_later+    , LGPL_3_0_only+    , LGPL_3_0_or_later+    , LGPLLR+    , Libpng+    , Libtiff+    , LiLiQ_P_1_1+    , LiLiQ_R_1_1+    , LiLiQ_Rplus_1_1+    , LPL_1_02+    , LPL_1_0+    , LPPL_1_0+    , LPPL_1_1+    , LPPL_1_2+    , LPPL_1_3a+    , LPPL_1_3c+    , MakeIndex+    , MirOS+    , MIT_advertising+    , MIT_CMU+    , MIT_enna+    , MIT_feh+    , MITNFA+    , MIT+    , Motosoto+    , Mpich2+    , MPL_1_0+    , MPL_1_1+    , MPL_2_0_no_copyleft_exception+    , MPL_2_0+    , MS_PL+    , MS_RL+    , MTLL+    , Multics+    , Mup+    , NASA_1_3+    , Naumen+    , NBPL_1_0+    , NCSA     , NetCDF     , Newsletr     , NGPL
src/Distribution/SPDX/LicenseListVersion.hs view
@@ -1,24 +1,30 @@-module Distribution.SPDX.LicenseListVersion (-    LicenseListVersion (..),-    cabalSpecVersionToSPDXListVersion,-    ) where+module Distribution.SPDX.LicenseListVersion+  ( LicenseListVersion (..)+  , cabalSpecVersionToSPDXListVersion+  ) where  import Distribution.CabalSpecVersion  -- | SPDX License List version @Cabal@ is aware of. data LicenseListVersion-    = LicenseListVersion_3_0-    | LicenseListVersion_3_2-    | LicenseListVersion_3_6-    | LicenseListVersion_3_9-    | LicenseListVersion_3_10-    | LicenseListVersion_3_16+  = LicenseListVersion_3_0+  | LicenseListVersion_3_2+  | LicenseListVersion_3_6+  | LicenseListVersion_3_9+  | LicenseListVersion_3_10+  | LicenseListVersion_3_16+  | LicenseListVersion_3_23+  | LicenseListVersion_3_25+  | LicenseListVersion_3_26   deriving (Eq, Ord, Show, Enum, Bounded)  cabalSpecVersionToSPDXListVersion :: CabalSpecVersion -> LicenseListVersion+cabalSpecVersionToSPDXListVersion CabalSpecV3_16 = LicenseListVersion_3_26+cabalSpecVersionToSPDXListVersion CabalSpecV3_14 = LicenseListVersion_3_25+cabalSpecVersionToSPDXListVersion CabalSpecV3_12 = LicenseListVersion_3_23 cabalSpecVersionToSPDXListVersion CabalSpecV3_8 = LicenseListVersion_3_16 cabalSpecVersionToSPDXListVersion CabalSpecV3_6 = LicenseListVersion_3_10 cabalSpecVersionToSPDXListVersion CabalSpecV3_4 = LicenseListVersion_3_9 cabalSpecVersionToSPDXListVersion CabalSpecV3_0 = LicenseListVersion_3_6 cabalSpecVersionToSPDXListVersion CabalSpecV2_4 = LicenseListVersion_3_2-cabalSpecVersionToSPDXListVersion _             = LicenseListVersion_3_0+cabalSpecVersionToSPDXListVersion _ = LicenseListVersion_3_0
src/Distribution/SPDX/LicenseReference.hs view
@@ -1,29 +1,30 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-module Distribution.SPDX.LicenseReference (-    LicenseRef,-    licenseRef,-    licenseDocumentRef,-    mkLicenseRef,-    mkLicenseRef',-    ) where -import Prelude ()+module Distribution.SPDX.LicenseReference+  ( LicenseRef+  , licenseRef+  , licenseDocumentRef+  , mkLicenseRef+  , mkLicenseRef'+  ) where+ import Distribution.Compat.Prelude+import Prelude () -import Distribution.Utils.Generic (isAsciiAlphaNum)-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty+import Distribution.Utils.Generic (isAsciiAlphaNum)  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp  -- | A user defined license reference denoted by @LicenseRef-[idstring]@ (for a license not on the SPDX License List); data LicenseRef = LicenseRef-    { _lrDocument :: !(Maybe String)-    , _lrLicense  :: !String-    }-  deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+  { _lrDocument :: !(Maybe String)+  , _lrLicense :: !String+  }+  deriving (Show, Read, Eq, Ord, Data, Generic)  -- | License reference. licenseRef :: LicenseRef -> String@@ -37,44 +38,45 @@ instance Structured LicenseRef  instance NFData LicenseRef where-    rnf (LicenseRef d l) = rnf d `seq` rnf l+  rnf (LicenseRef d l) = rnf d `seq` rnf l  instance Pretty LicenseRef where-    pretty (LicenseRef Nothing l) = Disp.text "LicenseRef-" <<>> Disp.text l-    pretty (LicenseRef (Just d) l) =-        Disp.text "DocumentRef-" <<>> Disp.text d <<>> Disp.char ':' <<>> Disp.text "LicenseRef-" <<>> Disp.text l+  pretty (LicenseRef Nothing l) = Disp.text "LicenseRef-" <<>> Disp.text l+  pretty (LicenseRef (Just d) l) =+    Disp.text "DocumentRef-" <<>> Disp.text d <<>> Disp.char ':' <<>> Disp.text "LicenseRef-" <<>> Disp.text l  instance Parsec LicenseRef where-    parsec = name <|> doc-      where-        name = do-            _ <- P.string "LicenseRef-"-            n <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'-            pure (LicenseRef Nothing n)+  parsec = name <|> doc+    where+      name = do+        _ <- P.string "LicenseRef-"+        n <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'+        pure (LicenseRef Nothing n) -        doc = do-            _ <- P.string "DocumentRef-"-            d <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'-            _ <- P.char ':'-            _ <- P.string "LicenseRef-"-            n <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'-            pure (LicenseRef (Just d) n)+      doc = do+        _ <- P.string "DocumentRef-"+        d <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'+        _ <- P.char ':'+        _ <- P.string "LicenseRef-"+        n <- some $ P.satisfy $ \c -> isAsciiAlphaNum c || c == '-' || c == '.'+        pure (LicenseRef (Just d) n)  -- | Create 'LicenseRef' from optional document ref and name. mkLicenseRef :: Maybe String -> String -> Maybe LicenseRef mkLicenseRef d l = do-    d' <- traverse checkIdString d-    l' <- checkIdString l-    pure (LicenseRef d' l')+  d' <- traverse checkIdString d+  l' <- checkIdString l+  pure (LicenseRef d' l')   where     checkIdString s-        | all (\c -> isAsciiAlphaNum c || c == '-' || c == '.') s = Just s-        | otherwise = Nothing+      | all (\c -> isAsciiAlphaNum c || c == '-' || c == '.') s = Just s+      | otherwise = Nothing  -- | Like 'mkLicenseRef' but convert invalid characters into @-@. mkLicenseRef' :: Maybe String -> String -> LicenseRef mkLicenseRef' d l = LicenseRef (fmap f d) (f l)   where     f = map g-    g c | isAsciiAlphaNum c || c == '-' || c == '.' = c-        | otherwise                                 = '-'+    g c+      | isAsciiAlphaNum c || c == '-' || c == '.' = c+      | otherwise = '-'
src/Distribution/System.hs view
@@ -1,9 +1,7 @@-{-# LANGUAGE CPP              #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} ------------------------------------------------------------------------------ -- | -- Module      :  Distribution.System -- Copyright   :  Duncan Coutts 2007-2008@@ -17,41 +15,36 @@ -- do not agree on using the same strings for the same platforms! (In -- particular see the controversy over \"windows\" vs \"mingw32\"). So to make it -- more consistent and easy to use we have an 'OS' enumeration.----module Distribution.System (-  -- * Operating System-  OS(..),-  buildOS,+module Distribution.System+  ( -- * Operating System+    OS (..)+  , buildOS -  -- * Machine Architecture-  Arch(..),-  buildArch,+    -- * Machine Architecture+  , Arch (..)+  , buildArch -  -- * Platform is a pair of arch and OS-  Platform(..),-  buildPlatform,-  platformFromTriple,+    -- * Platform is a pair of arch and OS+  , Platform (..)+  , buildPlatform+  , platformFromTriple -  -- * Internal-  knownOSs,-  knownArches,+    -- * Internal+  , knownOSs+  , knownArches -  -- * Classification-  ClassificationStrictness (..),-  classifyOS,-  classifyArch,+    -- * Classification+  , ClassificationStrictness (..)+  , classifyOS+  , classifyArch   ) where +import Control.Applicative (Applicative (..))+import Distribution.Compat.Prelude hiding (Applicative (..)) import Prelude ()-import Distribution.Compat.Prelude hiding (Applicative(..))-import Control.Applicative (Applicative(..)) -#if !MIN_VERSION_base(4,10,0)-import Control.Applicative (liftA2)-#endif--import qualified System.Info (os, arch) import Distribution.Utils.Generic (lowercase)+import qualified System.Info (arch, os)  import Distribution.Parsec import Distribution.Pretty@@ -75,11 +68,12 @@ -- The 'Compat' classification allows us to recognise aliases that are already -- in common use but it allows us to distinguish them from the canonical name -- which enables us to warn about such deprecated aliases.--- data ClassificationStrictness = Permissive | Compat | Strict  -- ------------------------------------------------------------+ -- * Operating System+ -- ------------------------------------------------------------  -- | These are the known OS names: Linux, Windows, OSX@@ -93,119 +87,176 @@ --    * Hurd alias: gnu --    * FreeBSD alias: kfreebsdgnu --    * Solaris alias: solaris2----data OS = Linux | Windows | OSX        -- tier 1 desktop OSs-        | FreeBSD | OpenBSD | NetBSD   -- other free Unix OSs-        | DragonFly-        | Solaris | AIX | HPUX | IRIX  -- ageing Unix OSs-        | HaLVM                        -- bare metal / VMs / hypervisors-        | Hurd                         -- GNU's microkernel-        | IOS  | Android               -- mobile OSs-        | Ghcjs-        | Wasi-        | OtherOS String-  deriving (Eq, Generic, Ord, Show, Read, Typeable, Data)+data OS+  = Linux+  | Windows+  | OSX -- tier 1 desktop OSs+  | FreeBSD+  | OpenBSD+  | NetBSD -- other free Unix OSs+  | DragonFly+  | Solaris+  | AIX+  | HPUX+  | IRIX -- ageing Unix OSs+  | HaLVM -- bare metal / VMs / hypervisors+  | Hurd -- GNU's microkernel+  | IOS+  | Android -- mobile OSs+  | Ghcjs+  | Wasi+  | Haiku+  | OtherOS String+  deriving (Eq, Generic, Ord, Show, Read, Data)  instance Binary OS instance Structured OS instance NFData OS where rnf = genericRnf  knownOSs :: [OS]-knownOSs = [Linux, Windows, OSX-           ,FreeBSD, OpenBSD, NetBSD, DragonFly-           ,Solaris, AIX, HPUX, IRIX-           ,HaLVM-           ,Hurd-           ,IOS, Android-           ,Ghcjs-           ,Wasi]+knownOSs =+  [ Linux+  , Windows+  , OSX+  , FreeBSD+  , OpenBSD+  , NetBSD+  , DragonFly+  , Solaris+  , AIX+  , HPUX+  , IRIX+  , HaLVM+  , Hurd+  , IOS+  , Android+  , Ghcjs+  , Wasi+  , Haiku+  ]  osAliases :: ClassificationStrictness -> OS -> [String] osAliases Permissive Windows = ["mingw32", "win32", "cygwin32"]-osAliases Compat     Windows = ["mingw32", "win32"]-osAliases _          OSX     = ["darwin"]-osAliases _          Hurd    = ["gnu"]+osAliases Compat Windows = ["mingw32", "win32"]+osAliases _ OSX = ["darwin"]+osAliases _ Hurd = ["gnu"] osAliases Permissive FreeBSD = ["kfreebsdgnu"]-osAliases Compat     FreeBSD = ["kfreebsdgnu"]+osAliases Compat FreeBSD = ["kfreebsdgnu"] osAliases Permissive Solaris = ["solaris2"]-osAliases Compat     Solaris = ["solaris2"]+osAliases Compat Solaris = ["solaris2"] osAliases Permissive Android = ["linux-android", "linux-androideabi", "linux-androideabihf"]-osAliases Compat     Android = ["linux-android"]-osAliases _          _       = []+osAliases Compat Android = ["linux-android"]+osAliases _ _ = []  instance Pretty OS where   pretty (OtherOS name) = Disp.text name-  pretty other          = Disp.text (lowercase (show other))+  pretty other = Disp.text (lowercase (show other))  instance Parsec OS where   parsec = classifyOS Compat <$> parsecIdent -- classifyOS :: ClassificationStrictness -> String -> OS classifyOS strictness s =   fromMaybe (OtherOS s) $ lookup (lowercase s) osMap   where-    osMap = [ (name, os)-            | os <- knownOSs-            , name <- prettyShow os : osAliases strictness os ]+    osMap =+      [ (name, os)+      | os <- knownOSs+      , name <- prettyShow os : osAliases strictness os+      ]  buildOS :: OS buildOS = classifyOS Permissive System.Info.os  -- ------------------------------------------------------------+ -- * Machine Architecture+ -- ------------------------------------------------------------ --- | These are the known Arches: I386, X86_64, PPC, PPC64, Sparc,--- Arm, AArch64, Mips, SH, IA64, S390, S390X, Alpha, Hppa, Rs6000,--- M68k, Vax, JavaScript and Wasm32.+-- | These are the known Arches: I386, X86_64, PPC, PPC64, PPC64LE, Sparc,+-- Sparc64, Arm, AArch64, Mips, SH, IA64, S390, S390X, Alpha, Hppa,+-- Rs6000, M68k, Vax, RISCV64, LoongArch64, JavaScript and Wasm32. -- -- The following aliases can also be used: --    * PPC alias: powerpc---    * PPC64 alias : powerpc64, powerpc64le---    * Sparc aliases: sparc64, sun4+--    * PPC64 alias : powerpc64+--    * PPC64LE alias : powerpc64le --    * Mips aliases: mipsel, mipseb --    * Arm aliases: armeb, armel --    * AArch64 aliases: arm64----data Arch = I386  | X86_64  | PPC  | PPC64 | Sparc-          | Arm   | AArch64 | Mips | SH-          | IA64  | S390    | S390X-          | Alpha | Hppa    | Rs6000-          | M68k  | Vax-          | JavaScript-          | Wasm32-          | OtherArch String-  deriving (Eq, Generic, Ord, Show, Read, Typeable, Data)+data Arch+  = I386+  | X86_64+  | PPC+  | PPC64+  | PPC64LE+  | Sparc+  | Sparc64+  | Arm+  | AArch64+  | Mips+  | SH+  | IA64+  | S390+  | S390X+  | Alpha+  | Hppa+  | Rs6000+  | M68k+  | Vax+  | RISCV64+  | LoongArch64+  | JavaScript+  | Wasm32+  | OtherArch String+  deriving (Eq, Generic, Ord, Show, Read, Data)  instance Binary Arch instance Structured Arch instance NFData Arch where rnf = genericRnf  knownArches :: [Arch]-knownArches = [I386, X86_64, PPC, PPC64, Sparc-              ,Arm, AArch64, Mips, SH-              ,IA64, S390, S390X-              ,Alpha, Hppa, Rs6000-              ,M68k, Vax-              ,JavaScript-              ,Wasm32]+knownArches =+  [ I386+  , X86_64+  , PPC+  , PPC64+  , PPC64LE+  , Sparc+  , Sparc64+  , Arm+  , AArch64+  , Mips+  , SH+  , IA64+  , S390+  , S390X+  , Alpha+  , Hppa+  , Rs6000+  , M68k+  , Vax+  , RISCV64+  , LoongArch64+  , JavaScript+  , Wasm32+  ]  archAliases :: ClassificationStrictness -> Arch -> [String]-archAliases Strict _       = []-archAliases Compat _       = []-archAliases _      PPC     = ["powerpc"]-archAliases _      PPC64   = ["powerpc64", "powerpc64le"]-archAliases _      Sparc   = ["sparc64", "sun4"]-archAliases _      Mips    = ["mipsel", "mipseb"]-archAliases _      Arm     = ["armeb", "armel"]-archAliases _      AArch64 = ["arm64"]-archAliases _      _       = []+archAliases Strict _ = []+archAliases Compat _ = []+archAliases _ PPC = ["powerpc"]+archAliases _ PPC64 = ["powerpc64"]+archAliases _ PPC64LE = ["powerpc64le"]+archAliases _ Mips = ["mipsel", "mipseb"]+archAliases _ Arm = ["armeb", "armel"]+archAliases _ AArch64 = ["arm64"]+archAliases _ _ = []  instance Pretty Arch where   pretty (OtherArch name) = Disp.text name-  pretty other            = Disp.text (lowercase (show other))+  pretty other = Disp.text (lowercase (show other))  instance Parsec Arch where   parsec = classifyArch Strict <$> parsecIdent@@ -214,19 +265,23 @@ classifyArch strictness s =   fromMaybe (OtherArch s) $ lookup (lowercase s) archMap   where-    archMap = [ (name, arch)-              | arch <- knownArches-              , name <- prettyShow arch : archAliases strictness arch ]+    archMap =+      [ (name, arch)+      | arch <- knownArches+      , name <- prettyShow arch : archAliases strictness arch+      ]  buildArch :: Arch buildArch = classifyArch Permissive System.Info.arch  -- ------------------------------------------------------------+ -- * Platform+ -- ------------------------------------------------------------  data Platform = Platform Arch OS-  deriving (Eq, Generic, Ord, Show, Read, Typeable, Data)+  deriving (Eq, Generic, Ord, Show, Read, Data)  instance Binary Platform instance Structured Platform@@ -236,25 +291,25 @@   pretty (Platform arch os) = pretty arch <<>> Disp.char '-' <<>> pretty os  instance Parsec Platform where-    -- TODO: there are ambiguous platforms like: `arch-word-os`-    -- which could be parsed as-    --   * Platform "arch-word" "os"-    --   * Platform "arch" "word-os"-    -- We could support that preferring variants 'OtherOS' or 'OtherArch'-    ---    -- For now we split into arch and os parts on the first dash.-    parsec = do-        arch <- parsecDashlessArch-        _ <- P.char '-'-        os <- parsec-        return (Platform arch os)-      where-        parsecDashlessArch = classifyArch Strict <$> dashlessIdent+  -- TODO: there are ambiguous platforms like: `arch-word-os`+  -- which could be parsed as+  --   * Platform "arch-word" "os"+  --   * Platform "arch" "word-os"+  -- We could support that preferring variants 'OtherOS' or 'OtherArch'+  --+  -- For now we split into arch and os parts on the first dash.+  parsec = do+    arch <- parsecDashlessArch+    _ <- P.char '-'+    os <- parsec+    return (Platform arch os)+    where+      parsecDashlessArch = classifyArch Strict <$> dashlessIdent -        dashlessIdent = liftA2 (:) firstChar rest-          where-            firstChar = P.satisfy isAlpha-            rest = P.munch (\c -> isAlphaNum c || c == '_')+      dashlessIdent = liftA2 (:) firstChar rest+        where+          firstChar = P.satisfy isAlpha+          rest = P.munch (\c -> isAlphaNum c || c == '_')  -- | The platform Cabal was compiled on. In most cases, -- @LocalBuildInfo.hostPlatform@ should be used instead (the platform we're@@ -268,17 +323,18 @@ parsecIdent = (:) <$> firstChar <*> rest   where     firstChar = P.satisfy isAlpha-    rest      = P.munch (\c -> isAlphaNum c || c == '_' || c == '-')+    rest = P.munch (\c -> isAlphaNum c || c == '_' || c == '-')  platformFromTriple :: String -> Maybe Platform platformFromTriple triple =-    either (const Nothing) Just $ explicitEitherParsec parseTriple triple-  where parseWord = P.munch1 (\c -> isAlphaNum c || c == '_')-        parseTriple = do-          arch <- fmap (classifyArch Permissive) parseWord-          _ <- P.char '-'-          _ <- parseWord -- Skip vendor-          _ <- P.char '-'-          os <- fmap (classifyOS Permissive) parsecIdent -- OS may have hyphens, like-                                               -- 'nto-qnx'-          return $ Platform arch os+  either (const Nothing) Just $ explicitEitherParsec parseTriple triple+  where+    parseWord = P.munch1 (\c -> isAlphaNum c || c == '_')+    parseTriple = do+      arch <- fmap (classifyArch Permissive) parseWord+      _ <- P.char '-'+      _ <- parseWord -- Skip vendor+      _ <- P.char '-'+      os <- fmap (classifyOS Permissive) parsecIdent -- OS may have hyphens, like+      -- 'nto-qnx'+      return $ Platform arch os
src/Distribution/Text.hs view
@@ -1,9 +1,10 @@ -- Since @3.0@ this is a compat module. module Distribution.Text (display, simpleParse) where+ {- {-# DEPRECATED "Use Distribution.Parsec or Distribution.Pretty" #-} -} -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  display :: Pretty a => a -> String display = prettyShow
src/Distribution/Types/AbiDependency.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.AbiDependency where  import Distribution.Compat.Prelude@@ -9,8 +9,8 @@ import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.Package            as Package-import qualified Text.PrettyPrint                as Disp+import qualified Distribution.Package as Package+import qualified Text.PrettyPrint as Disp  -- | An ABI dependency is a dependency on a library which also -- records the ABI hash ('abiHash') of the library it depends@@ -22,22 +22,22 @@ -- is critical if we are shadowing libraries; differences in the -- ABI hash let us know what packages get shadowed by the new version -- of a package.-data AbiDependency = AbiDependency {-        depUnitId  :: Package.UnitId,-        depAbiHash :: Package.AbiHash-    }-  deriving (Eq, Generic, Read, Show, Typeable)+data AbiDependency = AbiDependency+  { depUnitId :: Package.UnitId+  , depAbiHash :: Package.AbiHash+  }+  deriving (Eq, Generic, Read, Show)  instance Pretty AbiDependency where-    pretty (AbiDependency uid abi) =-        pretty uid <<>> Disp.char '=' <<>> pretty abi+  pretty (AbiDependency uid abi) =+    pretty uid <<>> Disp.char '=' <<>> pretty abi -instance  Parsec AbiDependency where-    parsec = do-        uid <- parsec-        _ <- P.char '='-        abi <- parsec-        return (AbiDependency uid abi)+instance Parsec AbiDependency where+  parsec = do+    uid <- parsec+    _ <- P.char '='+    abi <- parsec+    return (AbiDependency uid abi)  instance Binary AbiDependency instance Structured AbiDependency
src/Distribution/Types/AbiHash.hs view
@@ -1,18 +1,18 @@-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}  module Distribution.Types.AbiHash-  ( AbiHash, unAbiHash, mkAbiHash+  ( AbiHash+  , unAbiHash+  , mkAbiHash   ) where -import Prelude () import Distribution.Compat.Prelude import Distribution.Utils.ShortText+import Prelude ()  import qualified Distribution.Compat.CharParsing as P-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import Text.PrettyPrint (text) @@ -25,7 +25,7 @@ -- -- @since 2.0.0.2 newtype AbiHash = AbiHash ShortText-    deriving (Eq, Show, Read, Generic, Typeable)+  deriving (Eq, Show, Read, Generic)  -- | Convert 'AbiHash' to 'String' --@@ -48,14 +48,14 @@ -- -- @since 2.0.0.2 instance IsString AbiHash where-    fromString = mkAbiHash+  fromString = mkAbiHash  instance Binary AbiHash instance Structured AbiHash instance NFData AbiHash where rnf = genericRnf  instance Pretty AbiHash where-    pretty = text . unAbiHash+  pretty = text . unAbiHash  instance Parsec AbiHash where-    parsec = fmap mkAbiHash (P.munch isAlphaNum)+  parsec = fmap mkAbiHash (P.munch isAlphaNum)
src/Distribution/Types/Benchmark.hs view
@@ -1,20 +1,20 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.Benchmark (-    Benchmark(..),-    emptyBenchmark,-    benchmarkType,-    benchmarkModules,-    benchmarkModulesAutogen-) where+module Distribution.Types.Benchmark+  ( Benchmark (..)+  , emptyBenchmark+  , benchmarkType+  , benchmarkModules+  , benchmarkModulesAutogen+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.BuildInfo-import Distribution.Types.BenchmarkType import Distribution.Types.BenchmarkInterface+import Distribution.Types.BenchmarkType+import Distribution.Types.BuildInfo import Distribution.Types.UnqualComponentName  import Distribution.ModuleName@@ -22,49 +22,45 @@ import qualified Distribution.Types.BuildInfo.Lens as L  -- | A \"benchmark\" stanza in a cabal file.----data Benchmark = Benchmark {-        benchmarkName      :: UnqualComponentName,-        benchmarkInterface :: BenchmarkInterface,-        benchmarkBuildInfo :: BuildInfo-    }-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data Benchmark = Benchmark+  { benchmarkName :: UnqualComponentName+  , benchmarkInterface :: BenchmarkInterface+  , benchmarkBuildInfo :: BuildInfo+  }+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary Benchmark instance Structured Benchmark instance NFData Benchmark where rnf = genericRnf  instance L.HasBuildInfo Benchmark where-    buildInfo f (Benchmark x1 x2 x3) = fmap (\y1 -> Benchmark x1 x2 y1) (f x3)+  buildInfo f (Benchmark x1 x2 x3) = fmap (\y1 -> Benchmark x1 x2 y1) (f x3)  instance Monoid Benchmark where-    mempty = Benchmark {-        benchmarkName      = mempty,-        benchmarkInterface = mempty,-        benchmarkBuildInfo = mempty-    }-    mappend = (<>)+  mempty =+    Benchmark+      { benchmarkName = mempty+      , benchmarkInterface = mempty+      , benchmarkBuildInfo = mempty+      }+  mappend = (<>)  instance Semigroup Benchmark where-    a <> b = Benchmark {-        benchmarkName      = combine' benchmarkName,-        benchmarkInterface = combine  benchmarkInterface,-        benchmarkBuildInfo = combine  benchmarkBuildInfo-    }-        where combine  field = field a `mappend` field b-              combine' field = case ( unUnqualComponentName $ field a-                                    , unUnqualComponentName $ field b) of-                        ("", _) -> field b-                        (_, "") -> field a-                        (x, y) -> error $ "Ambiguous values for test field: '"-                            ++ x ++ "' and '" ++ y ++ "'"+  a <> b =+    Benchmark+      { benchmarkName = combineNames a b benchmarkName "benchmark"+      , benchmarkInterface = combine benchmarkInterface+      , benchmarkBuildInfo = combine benchmarkBuildInfo+      }+    where+      combine field = field a `mappend` field b  emptyBenchmark :: Benchmark emptyBenchmark = mempty  benchmarkType :: Benchmark -> BenchmarkType benchmarkType benchmark = case benchmarkInterface benchmark of-  BenchmarkExeV10 ver _              -> BenchmarkTypeExe ver+  BenchmarkExeV10 ver _ -> BenchmarkTypeExe ver   BenchmarkUnsupported benchmarktype -> benchmarktype  -- | Get all the module names from a benchmark.
src/Distribution/Types/Benchmark/Lens.hs view
@@ -1,27 +1,27 @@-module Distribution.Types.Benchmark.Lens (-    Benchmark,-    module Distribution.Types.Benchmark.Lens,-    ) where+module Distribution.Types.Benchmark.Lens+  ( Benchmark+  , module Distribution.Types.Benchmark.Lens+  ) where  import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Types.Benchmark           (Benchmark)-import Distribution.Types.BenchmarkInterface  (BenchmarkInterface)-import Distribution.Types.BuildInfo           (BuildInfo)+import Distribution.Types.Benchmark (Benchmark)+import Distribution.Types.BenchmarkInterface (BenchmarkInterface)+import Distribution.Types.BuildInfo (BuildInfo) import Distribution.Types.UnqualComponentName (UnqualComponentName)  import qualified Distribution.Types.Benchmark as T  benchmarkName :: Lens' Benchmark UnqualComponentName-benchmarkName f s = fmap (\x -> s { T.benchmarkName = x }) (f (T.benchmarkName s))+benchmarkName f s = fmap (\x -> s{T.benchmarkName = x}) (f (T.benchmarkName s)) {-# INLINE benchmarkName #-}  benchmarkInterface :: Lens' Benchmark BenchmarkInterface-benchmarkInterface f s = fmap (\x -> s { T.benchmarkInterface = x }) (f (T.benchmarkInterface s))+benchmarkInterface f s = fmap (\x -> s{T.benchmarkInterface = x}) (f (T.benchmarkInterface s)) {-# INLINE benchmarkInterface #-}  benchmarkBuildInfo :: Lens' Benchmark BuildInfo-benchmarkBuildInfo f s = fmap (\x -> s { T.benchmarkBuildInfo = x }) (f (T.benchmarkBuildInfo s))+benchmarkBuildInfo f s = fmap (\x -> s{T.benchmarkBuildInfo = x}) (f (T.benchmarkBuildInfo s)) {-# INLINE benchmarkBuildInfo #-}
src/Distribution/Types/BenchmarkInterface.hs view
@@ -1,45 +1,42 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.BenchmarkInterface (-    BenchmarkInterface(..),-) where+module Distribution.Types.BenchmarkInterface+  ( BenchmarkInterface (..)+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Types.BenchmarkType+import Distribution.Utils.Path import Distribution.Version  -- | The benchmark interfaces that are currently defined. -- -- More interfaces may be defined in future, either new revisions or -- totally new interfaces.----data BenchmarkInterface =--     -- | Benchmark interface \"exitcode-stdio-1.0\". The benchmark-     -- takes the form of an executable. It returns a zero exit code-     -- for success, non-zero for failure. The stdout and stderr-     -- channels may be logged. Test tooling may pass command line-     -- arguments and/or connect the stdin channel to the test.-     ---     BenchmarkExeV10 Version FilePath--     -- | A benchmark that does not conform to one of the above-     -- interfaces for the given reason (e.g. unknown benchmark type).-     ---   | BenchmarkUnsupported BenchmarkType-   deriving (Eq, Ord, Generic, Read, Show, Typeable, Data)+data BenchmarkInterface+  = -- | Benchmark interface \"exitcode-stdio-1.0\". The benchmark+    -- takes the form of an executable. It returns a zero exit code+    -- for success, non-zero for failure. The stdout and stderr+    -- channels may be logged. Test tooling may pass command line+    -- arguments and/or connect the stdin channel to the test.+    BenchmarkExeV10 Version (RelativePath Source File)+  | -- | A benchmark that does not conform to one of the above+    -- interfaces for the given reason (e.g. unknown benchmark type).+    BenchmarkUnsupported BenchmarkType+  deriving (Eq, Ord, Generic, Read, Show, Data)  instance Binary BenchmarkInterface instance Structured BenchmarkInterface instance NFData BenchmarkInterface where rnf = genericRnf  instance Monoid BenchmarkInterface where-    mempty  =  BenchmarkUnsupported (BenchmarkTypeUnknown mempty nullVersion)-    mappend = (<>)+  mempty = BenchmarkUnsupported (BenchmarkTypeUnknown mempty nullVersion)+  mappend = (<>)  instance Semigroup BenchmarkInterface where-    a <> (BenchmarkUnsupported _) = a-    _ <> b                        = b+  a <> (BenchmarkUnsupported _) = a+  _ <> b = b
src/Distribution/Types/BenchmarkType.hs view
@@ -1,12 +1,12 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-{-# LANGUAGE OverloadedStrings  #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.BenchmarkType (-    BenchmarkType(..),-    knownBenchmarkTypes,-    benchmarkTypeExe,-) where+module Distribution.Types.BenchmarkType+  ( BenchmarkType (..)+  , knownBenchmarkTypes+  , benchmarkTypeExe+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -14,31 +14,31 @@ import Distribution.Parsec import Distribution.Pretty import Distribution.Version-import Text.PrettyPrint     (char, text)+import Text.PrettyPrint (char, text)  -- | The \"benchmark-type\" field in the benchmark stanza.----data BenchmarkType = BenchmarkTypeExe Version-                     -- ^ \"type: exitcode-stdio-x.y\"-                   | BenchmarkTypeUnknown String Version-                     -- ^ Some unknown benchmark type e.g. \"type: foo\"-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data BenchmarkType+  = -- | \"type: exitcode-stdio-x.y\"+    BenchmarkTypeExe Version+  | -- | Some unknown benchmark type e.g. \"type: foo\"+    BenchmarkTypeUnknown String Version+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary BenchmarkType instance Structured BenchmarkType instance NFData BenchmarkType where rnf = genericRnf  knownBenchmarkTypes :: [BenchmarkType]-knownBenchmarkTypes = [ benchmarkTypeExe ]+knownBenchmarkTypes = [benchmarkTypeExe]  benchmarkTypeExe :: BenchmarkType-benchmarkTypeExe = BenchmarkTypeExe (mkVersion [1,0])+benchmarkTypeExe = BenchmarkTypeExe (mkVersion [1, 0])  instance Pretty BenchmarkType where-  pretty (BenchmarkTypeExe ver)          = text "exitcode-stdio-" <<>> pretty ver+  pretty (BenchmarkTypeExe ver) = text "exitcode-stdio-" <<>> pretty ver   pretty (BenchmarkTypeUnknown name ver) = text name <<>> char '-' <<>> pretty ver  instance Parsec BenchmarkType where-    parsec = parsecStandard $ \ver name -> case name of-       "exitcode-stdio" -> BenchmarkTypeExe ver-       _                -> BenchmarkTypeUnknown name ver+  parsec = parsecStandard $ \ver name -> case name of+    "exitcode-stdio" -> BenchmarkTypeExe ver+    _ -> BenchmarkTypeUnknown name ver
src/Distribution/Types/BuildInfo.hs view
@@ -1,223 +1,265 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.BuildInfo (-    BuildInfo(..),--    emptyBuildInfo,-    allLanguages,-    allExtensions,-    usedExtensions,-    usesTemplateHaskellOrQQ,--    hcOptions,-    hcProfOptions,-    hcSharedOptions,-    hcStaticOptions,-) where+module Distribution.Types.BuildInfo+  ( BuildInfo (..)+  , emptyBuildInfo+  , allLanguages+  , allExtensions+  , usedExtensions+  , usesTemplateHaskellOrQQ+  , hcOptions+  , hcProfOptions+  , hcSharedOptions+  , hcProfSharedOptions+  , hcStaticOptions+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.Mixin import Distribution.Types.Dependency import Distribution.Types.ExeDependency import Distribution.Types.LegacyExeDependency+import Distribution.Types.Mixin import Distribution.Types.PkgconfigDependency import Distribution.Utils.Path -import Distribution.ModuleName import Distribution.Compiler+import Distribution.ModuleName import Language.Haskell.Extension  -- Consider refactoring into executable and library versions.-data BuildInfo = BuildInfo {-        -- | component is buildable here-        buildable         :: Bool,-        -- | Tools needed to build this bit.-        ---        -- This is a legacy field that 'buildToolDepends' largely supersedes.-        ---        -- Unless use are very sure what you are doing, use the functions in-        -- "Distribution.Simple.BuildToolDepends" rather than accessing this-        -- field directly.-        buildTools        :: [LegacyExeDependency],-        -- | Haskell tools needed to build this bit-        ---        -- This field is better than 'buildTools' because it allows one to-        -- precisely specify an executable in a package.-        ---        -- Unless use are very sure what you are doing, use the functions in-        -- "Distribution.Simple.BuildToolDepends" rather than accessing this-        -- field directly.-        buildToolDepends  :: [ExeDependency],-        cppOptions        :: [String],  -- ^ options for pre-processing Haskell code-        asmOptions        :: [String],  -- ^ options for assembler-        cmmOptions        :: [String],  -- ^ options for C-- compiler-        ccOptions         :: [String],  -- ^ options for C compiler-        cxxOptions        :: [String],  -- ^ options for C++ compiler-        ldOptions         :: [String],  -- ^ options for linker-        hsc2hsOptions     :: [String],  -- ^ options for hsc2hs-        pkgconfigDepends  :: [PkgconfigDependency], -- ^ pkg-config packages that are used-        frameworks        :: [String], -- ^support frameworks for Mac OS X-        extraFrameworkDirs:: [String], -- ^ extra locations to find frameworks.-        asmSources        :: [FilePath], -- ^ Assembly files.-        cmmSources        :: [FilePath], -- ^ C-- files.-        cSources          :: [FilePath],-        cxxSources        :: [FilePath],-        jsSources         :: [FilePath],-        hsSourceDirs      :: [SymbolicPath PackageDir SourceDir], -- ^ where to look for the Haskell module hierarchy-        otherModules      :: [ModuleName], -- ^ non-exposed or non-main modules-        virtualModules    :: [ModuleName], -- ^ exposed modules that do not have a source file (e.g. @GHC.Prim@ from @ghc-prim@ package)-        autogenModules    :: [ModuleName], -- ^ not present on sdist, Paths_* or user-generated with a custom Setup.hs--        defaultLanguage   :: Maybe Language,-- ^ language used when not explicitly specified-        otherLanguages    :: [Language],    -- ^ other languages used within the package-        defaultExtensions :: [Extension],   -- ^ language extensions used by all modules-        otherExtensions   :: [Extension],   -- ^ other language extensions used within the package-        oldExtensions     :: [Extension],   -- ^ the old extensions field, treated same as 'defaultExtensions'--        extraLibs         :: [String], -- ^ what libraries to link with when compiling a program that uses your package-        extraLibsStatic   :: [String], -- ^ what libraries to link with when compiling a program fully statically that uses your package-        extraGHCiLibs     :: [String], -- ^ if present, overrides extraLibs when package is loaded with GHCi.-        extraBundledLibs  :: [String], -- ^ if present, adds libs to hs-libraries, which become part of the package.-                                       --   Example 1: the Cffi library shipping with the rts, alongside the HSrts-1.0.a,.o,...-                                       --   Example 2: a library that is being built by a foreign 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.  Otherwise cabal would need to learn 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-                                       --   should only be needed in very specific cases, e.g. the `rts` package, where-                                       --   there are multiple copies of slightly differently built libs.-        extraDynLibFlavours :: [String], -- ^ Hidden Flag. This set of strings will be appended to all /dynamic/-                                         --   libraries when copying. This is particularly useful with the `rts` package,-                                         --   where we want different dynamic flavours of the RTS library to be installed.-        extraLibDirs      :: [String],-        extraLibDirsStatic :: [String],-        includeDirs       :: [FilePath], -- ^directories to find .h files-        includes          :: [FilePath], -- ^ The .h files to be found in includeDirs-        autogenIncludes   :: [FilePath], -- ^ The .h files to be generated (e.g. by @autoconf@)-        installIncludes   :: [FilePath], -- ^ .h files to install with the package-        options           :: PerCompilerFlavor [String],-        profOptions       :: PerCompilerFlavor [String],-        sharedOptions     :: PerCompilerFlavor [String],-        staticOptions     :: PerCompilerFlavor [String],-        customFieldsBI    :: [(String,String)], -- ^Custom fields starting-                                                -- with x-, stored in a-                                                -- simple assoc-list.-        targetBuildDepends :: [Dependency], -- ^ Dependencies specific to a library or executable target-        mixins :: [Mixin]-    }-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data BuildInfo = BuildInfo+  { buildable :: Bool+  -- ^ component is buildable here+  , buildTools :: [LegacyExeDependency]+  -- ^ Tools needed to build this bit.+  --+  -- This is a legacy field that 'buildToolDepends' largely supersedes.+  --+  -- Unless use are very sure what you are doing, use the functions in+  -- "Distribution.Simple.BuildToolDepends" rather than accessing this+  -- field directly.+  , buildToolDepends :: [ExeDependency]+  -- ^ Haskell tools needed to build this bit+  --+  -- This field is better than 'buildTools' because it allows one to+  -- precisely specify an executable in a package.+  --+  -- Unless use are very sure what you are doing, use the functions in+  -- "Distribution.Simple.BuildToolDepends" rather than accessing this+  -- field directly.+  , cppOptions :: [String]+  -- ^ options for pre-processing Haskell code+  , asmOptions :: [String]+  -- ^ options for assembler+  , cmmOptions :: [String]+  -- ^ options for C-- compiler+  , ccOptions :: [String]+  -- ^ options for C compiler+  , cxxOptions :: [String]+  -- ^ options for C++ compiler+  , jsppOptions :: [String]+  -- ^ options for pre-processing JavaScript code @since 3.16.0.0+  , ldOptions :: [String]+  -- ^ options for linker+  , hsc2hsOptions :: [String]+  -- ^ options for hsc2hs+  , pkgconfigDepends :: [PkgconfigDependency]+  -- ^ pkg-config packages that are used+  , frameworks :: [RelativePath Framework File]+  -- ^ support frameworks for Mac OS X+  , extraFrameworkDirs :: [SymbolicPath Pkg (Dir Framework)]+  -- ^ extra locations to find frameworks.+  , asmSources :: [SymbolicPath Pkg File]+  -- ^ Assembly files.+  , cmmSources :: [SymbolicPath Pkg File]+  -- ^ C-- files.+  , cSources :: [SymbolicPath Pkg File]+  , cxxSources :: [SymbolicPath Pkg File]+  , jsSources :: [SymbolicPath Pkg File]+  , hsSourceDirs :: [SymbolicPath Pkg (Dir Source)]+  -- ^ where to look for the Haskell module hierarchy+  , -- NB: these are symbolic paths are not relative paths,+    -- because autogenerated modules might end up in an absolute path+    otherModules :: [ModuleName]+  -- ^ non-exposed or non-main modules+  , virtualModules :: [ModuleName]+  -- ^ exposed modules that do not have a source file (e.g. @GHC.Prim@ from @ghc-prim@ package)+  , autogenModules :: [ModuleName]+  -- ^ not present on sdist, Paths_* or user-generated with a custom Setup.hs+  , defaultLanguage :: Maybe Language+  -- ^ language used when not explicitly specified+  , otherLanguages :: [Language]+  -- ^ other languages used within the package+  , defaultExtensions :: [Extension]+  -- ^ language extensions used by all modules+  , otherExtensions :: [Extension]+  -- ^ other language extensions used within the package+  , oldExtensions :: [Extension]+  -- ^ the old extensions field, treated same as 'defaultExtensions'+  , extraLibs :: [String]+  -- ^ what libraries to link with when compiling a program that uses your package+  , extraLibsStatic :: [String]+  -- ^ what libraries to link with when compiling a program fully statically that uses your package+  , extraGHCiLibs :: [String]+  -- ^ if present, overrides extraLibs when package is loaded with GHCi.+  , extraBundledLibs :: [String]+  -- ^ if present, adds libs to hs-libraries, which become part of the package.+  --   Example 1: the Cffi library shipping with the rts, alongside the HSrts-1.0.a,.o,...+  --   Example 2: a library that is being built by a foreign 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.  Otherwise cabal would need to learn 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+  --   should only be needed in very specific cases, e.g. the `rts` package, where+  --   there are multiple copies of slightly differently built libs.+  , extraDynLibFlavours :: [String]+  -- ^ Hidden Flag. This set of strings will be appended to all /dynamic/+  --   libraries when copying. This is particularly useful with the `rts` package,+  --   where we want different dynamic flavours of the RTS library to be installed.+  , extraLibDirs :: [SymbolicPath Pkg (Dir Lib)]+  , extraLibDirsStatic :: [SymbolicPath Pkg (Dir Lib)]+  , includeDirs :: [SymbolicPath Pkg (Dir Include)]+  -- ^ directories to find .h files+  , includes :: [SymbolicPath Include File]+  -- ^ The .h files to be found in includeDirs+  , autogenIncludes :: [RelativePath Include File]+  -- ^ The .h files to be generated (e.g. by @autoconf@)+  , installIncludes :: [RelativePath Include File]+  -- ^ .h files to install with the package+  , options :: PerCompilerFlavor [String]+  , profOptions :: PerCompilerFlavor [String]+  , sharedOptions :: PerCompilerFlavor [String]+  , profSharedOptions :: PerCompilerFlavor [String]+  , staticOptions :: PerCompilerFlavor [String]+  , customFieldsBI :: [(String, String)]+  -- ^ Custom fields starting+  --  with x-, stored in a+  --  simple assoc-list.+  , targetBuildDepends :: [Dependency]+  -- ^ Dependencies specific to a library or executable target+  , mixins :: [Mixin]+  }+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary BuildInfo instance Structured BuildInfo instance NFData BuildInfo where rnf = genericRnf  instance Monoid BuildInfo where-  mempty = BuildInfo {-    buildable           = True,-    buildTools          = [],-    buildToolDepends    = [],-    cppOptions          = [],-    asmOptions          = [],-    cmmOptions          = [],-    ccOptions           = [],-    cxxOptions          = [],-    ldOptions           = [],-    hsc2hsOptions       = [],-    pkgconfigDepends    = [],-    frameworks          = [],-    extraFrameworkDirs  = [],-    asmSources          = [],-    cmmSources          = [],-    cSources            = [],-    cxxSources          = [],-    jsSources           = [],-    hsSourceDirs        = [],-    otherModules        = [],-    virtualModules      = [],-    autogenModules      = [],-    defaultLanguage     = Nothing,-    otherLanguages      = [],-    defaultExtensions   = [],-    otherExtensions     = [],-    oldExtensions       = [],-    extraLibs           = [],-    extraLibsStatic     = [],-    extraGHCiLibs       = [],-    extraBundledLibs    = [],-    extraLibFlavours    = [],-    extraDynLibFlavours = [],-    extraLibDirs        = [],-    extraLibDirsStatic  = [],-    includeDirs         = [],-    includes            = [],-    autogenIncludes     = [],-    installIncludes     = [],-    options             = mempty,-    profOptions         = mempty,-    sharedOptions       = mempty,-    staticOptions       = mempty,-    customFieldsBI      = [],-    targetBuildDepends  = [],-    mixins              = []-  }+  mempty =+    BuildInfo+      { buildable = True+      , buildTools = []+      , buildToolDepends = []+      , cppOptions = []+      , asmOptions = []+      , cmmOptions = []+      , ccOptions = []+      , cxxOptions = []+      , jsppOptions = []+      , ldOptions = []+      , hsc2hsOptions = []+      , pkgconfigDepends = []+      , frameworks = []+      , extraFrameworkDirs = []+      , asmSources = []+      , cmmSources = []+      , cSources = []+      , cxxSources = []+      , jsSources = []+      , hsSourceDirs = []+      , otherModules = []+      , virtualModules = []+      , autogenModules = []+      , defaultLanguage = Nothing+      , otherLanguages = []+      , defaultExtensions = []+      , otherExtensions = []+      , oldExtensions = []+      , extraLibs = []+      , extraLibsStatic = []+      , extraGHCiLibs = []+      , extraBundledLibs = []+      , extraLibFlavours = []+      , extraDynLibFlavours = []+      , extraLibDirs = []+      , extraLibDirsStatic = []+      , includeDirs = []+      , includes = []+      , autogenIncludes = []+      , installIncludes = []+      , options = mempty+      , profOptions = mempty+      , sharedOptions = mempty+      , profSharedOptions = mempty+      , staticOptions = mempty+      , customFieldsBI = []+      , targetBuildDepends = []+      , mixins = []+      }   mappend = (<>)  instance Semigroup BuildInfo where-  a <> b = BuildInfo {-    buildable           = buildable a && buildable b,-    buildTools          = combine    buildTools,-    buildToolDepends    = combine    buildToolDepends,-    cppOptions          = combine    cppOptions,-    asmOptions          = combine    asmOptions,-    cmmOptions          = combine    cmmOptions,-    ccOptions           = combine    ccOptions,-    cxxOptions          = combine    cxxOptions,-    ldOptions           = combine    ldOptions,-    hsc2hsOptions       = combine    hsc2hsOptions,-    pkgconfigDepends    = combine    pkgconfigDepends,-    frameworks          = combineNub frameworks,-    extraFrameworkDirs  = combineNub extraFrameworkDirs,-    asmSources          = combineNub asmSources,-    cmmSources          = combineNub cmmSources,-    cSources            = combineNub cSources,-    cxxSources          = combineNub cxxSources,-    jsSources           = combineNub jsSources,-    hsSourceDirs        = combineNub hsSourceDirs,-    otherModules        = combineNub otherModules,-    virtualModules      = combineNub virtualModules,-    autogenModules      = combineNub autogenModules,-    defaultLanguage     = combineMby defaultLanguage,-    otherLanguages      = combineNub otherLanguages,-    defaultExtensions   = combineNub defaultExtensions,-    otherExtensions     = combineNub otherExtensions,-    oldExtensions       = combineNub oldExtensions,-    extraLibs           = combine    extraLibs,-    extraLibsStatic     = combine    extraLibsStatic,-    extraGHCiLibs       = combine    extraGHCiLibs,-    extraBundledLibs    = combine    extraBundledLibs,-    extraLibFlavours    = combine    extraLibFlavours,-    extraDynLibFlavours = combine    extraDynLibFlavours,-    extraLibDirs        = combineNub extraLibDirs,-    extraLibDirsStatic  = combineNub extraLibDirsStatic,-    includeDirs         = combineNub includeDirs,-    includes            = combineNub includes,-    autogenIncludes     = combineNub autogenIncludes,-    installIncludes     = combineNub installIncludes,-    options             = combine    options,-    profOptions         = combine    profOptions,-    sharedOptions       = combine    sharedOptions,-    staticOptions       = combine    staticOptions,-    customFieldsBI      = combine    customFieldsBI,-    targetBuildDepends  = combineNub targetBuildDepends,-    mixins              = combine    mixins-  }+  a <> b =+    BuildInfo+      { buildable = buildable a && buildable b+      , buildTools = combine buildTools+      , buildToolDepends = combine buildToolDepends+      , cppOptions = combine cppOptions+      , asmOptions = combine asmOptions+      , cmmOptions = combine cmmOptions+      , ccOptions = combine ccOptions+      , cxxOptions = combine cxxOptions+      , jsppOptions = combine jsppOptions+      , ldOptions = combine ldOptions+      , hsc2hsOptions = combine hsc2hsOptions+      , pkgconfigDepends = combine pkgconfigDepends+      , frameworks = combineNub frameworks+      , extraFrameworkDirs = combineNub extraFrameworkDirs+      , asmSources = combineNub asmSources+      , cmmSources = combineNub cmmSources+      , cSources = combineNub cSources+      , cxxSources = combineNub cxxSources+      , jsSources = combineNub jsSources+      , hsSourceDirs = combineNub hsSourceDirs+      , otherModules = combineNub otherModules+      , virtualModules = combineNub virtualModules+      , autogenModules = combineNub autogenModules+      , defaultLanguage = combineMby defaultLanguage+      , otherLanguages = combineNub otherLanguages+      , defaultExtensions = combineNub defaultExtensions+      , otherExtensions = combineNub otherExtensions+      , oldExtensions = combineNub oldExtensions+      , extraLibs = combine extraLibs+      , extraLibsStatic = combine extraLibsStatic+      , extraGHCiLibs = combine extraGHCiLibs+      , extraBundledLibs = combine extraBundledLibs+      , extraLibFlavours = combine extraLibFlavours+      , extraDynLibFlavours = combine extraDynLibFlavours+      , extraLibDirs = combineNub extraLibDirs+      , extraLibDirsStatic = combineNub extraLibDirsStatic+      , includeDirs = combineNub includeDirs+      , includes = combineNub includes+      , autogenIncludes = combineNub autogenIncludes+      , installIncludes = combineNub installIncludes+      , options = combine options+      , profOptions = combine profOptions+      , sharedOptions = combine sharedOptions+      , profSharedOptions = combine profSharedOptions+      , staticOptions = combine staticOptions+      , customFieldsBI = combine customFieldsBI+      , targetBuildDepends = combineNub targetBuildDepends+      , mixins = combine mixins+      }     where-      combine    field = field a `mappend` field b+      combine field = field a `mappend` field b       combineNub field = nub (combine field)       combineMby field = field b `mplus` field a @@ -225,32 +267,33 @@ emptyBuildInfo = mempty  -- | The 'Language's used by this component--- allLanguages :: BuildInfo -> [Language]-allLanguages bi = maybeToList (defaultLanguage bi)-               ++ otherLanguages bi+allLanguages bi =+  maybeToList (defaultLanguage bi)+    ++ otherLanguages bi  -- | The 'Extension's that are used somewhere by this component--- allExtensions :: BuildInfo -> [Extension]-allExtensions bi = usedExtensions bi-                ++ otherExtensions bi+allExtensions bi =+  usedExtensions bi+    ++ otherExtensions bi  -- | The 'Extensions' that are used by all modules in this component--- usedExtensions :: BuildInfo -> [Extension]-usedExtensions bi = oldExtensions bi-                 ++ defaultExtensions bi+usedExtensions bi =+  oldExtensions bi+    ++ defaultExtensions bi  -- | Whether any modules in this component use Template Haskell or -- Quasi Quotes usesTemplateHaskellOrQQ :: BuildInfo -> Bool usesTemplateHaskellOrQQ bi = any p (allExtensions bi)   where-    p ex = ex `elem`-      [EnableExtension TemplateHaskell, EnableExtension QuasiQuotes]+    p ex =+      ex+        `elem` [EnableExtension TemplateHaskell, EnableExtension QuasiQuotes] --- |Select options for a particular Haskell compiler.+-- | Select options for a particular Haskell compiler. hcOptions :: CompilerFlavor -> BuildInfo -> [String] hcOptions = lookupHcOptions options @@ -260,13 +303,19 @@ hcSharedOptions :: CompilerFlavor -> BuildInfo -> [String] hcSharedOptions = lookupHcOptions sharedOptions +hcProfSharedOptions :: CompilerFlavor -> BuildInfo -> [String]+hcProfSharedOptions = lookupHcOptions profSharedOptions+ hcStaticOptions :: CompilerFlavor -> BuildInfo -> [String] hcStaticOptions = lookupHcOptions staticOptions -lookupHcOptions :: (BuildInfo -> PerCompilerFlavor [String])-                -> CompilerFlavor -> BuildInfo -> [String]+lookupHcOptions+  :: (BuildInfo -> PerCompilerFlavor [String])+  -> CompilerFlavor+  -> BuildInfo+  -> [String] lookupHcOptions f hc bi = case f bi of-    PerCompilerFlavor ghc ghcjs-        | hc == GHC   -> ghc-        | hc == GHCJS -> ghcjs-        | otherwise   -> mempty+  PerCompilerFlavor ghc ghcjs+    | hc == GHC -> ghc+    | hc == GHCJS -> ghcjs+    | otherwise -> mempty
src/Distribution/Types/BuildInfo/Lens.hs view
@@ -1,356 +1,371 @@-module Distribution.Types.BuildInfo.Lens (-    BuildInfo,-    HasBuildInfo (..),-    HasBuildInfos (..),-    ) where+{-# LANGUAGE DataKinds #-} +module Distribution.Types.BuildInfo.Lens+  ( BuildInfo+  , HasBuildInfo (..)+  , HasBuildInfos (..)+  ) where+ import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Compiler                  (PerCompilerFlavor)-import Distribution.ModuleName                (ModuleName)-import Distribution.Types.BuildInfo           (BuildInfo)-import Distribution.Types.Dependency          (Dependency)-import Distribution.Types.ExeDependency       (ExeDependency)+import Distribution.Compiler (PerCompilerFlavor)+import Distribution.ModuleName (ModuleName)+import Distribution.Types.BuildInfo (BuildInfo)+import Distribution.Types.Dependency (Dependency)+import Distribution.Types.ExeDependency (ExeDependency) import Distribution.Types.LegacyExeDependency (LegacyExeDependency)-import Distribution.Types.Mixin               (Mixin)+import Distribution.Types.Mixin (Mixin) import Distribution.Types.PkgconfigDependency (PkgconfigDependency) import Distribution.Utils.Path-import Language.Haskell.Extension             (Extension, Language)+import Language.Haskell.Extension (Extension, Language)  import qualified Distribution.Types.BuildInfo as T  -- | Classy lenses for 'BuildInfo'. class HasBuildInfo a where-   buildInfo :: Lens' a BuildInfo+  buildInfo :: Lens' a BuildInfo -   buildable :: Lens' a Bool-   buildable = buildInfo . buildable-   {-# INLINE buildable #-}+  buildable :: Lens' a Bool+  buildable = buildInfo . buildable+  {-# INLINE buildable #-} -   buildTools :: Lens' a [LegacyExeDependency]-   buildTools = buildInfo . buildTools-   {-# INLINE buildTools #-}+  buildTools :: Lens' a [LegacyExeDependency]+  buildTools = buildInfo . buildTools+  {-# INLINE buildTools #-} -   buildToolDepends :: Lens' a [ExeDependency]-   buildToolDepends = buildInfo . buildToolDepends-   {-# INLINE buildToolDepends #-}+  buildToolDepends :: Lens' a [ExeDependency]+  buildToolDepends = buildInfo . buildToolDepends+  {-# INLINE buildToolDepends #-} -   cppOptions :: Lens' a [String]-   cppOptions = buildInfo . cppOptions-   {-# INLINE cppOptions #-}+  cppOptions :: Lens' a [String]+  cppOptions = buildInfo . cppOptions+  {-# INLINE cppOptions #-} -   asmOptions :: Lens' a [String]-   asmOptions = buildInfo . asmOptions-   {-# INLINE asmOptions #-}+  asmOptions :: Lens' a [String]+  asmOptions = buildInfo . asmOptions+  {-# INLINE asmOptions #-} -   cmmOptions :: Lens' a [String]-   cmmOptions = buildInfo . cmmOptions-   {-# INLINE cmmOptions #-}+  cmmOptions :: Lens' a [String]+  cmmOptions = buildInfo . cmmOptions+  {-# INLINE cmmOptions #-} -   ccOptions :: Lens' a [String]-   ccOptions = buildInfo . ccOptions-   {-# INLINE ccOptions #-}+  ccOptions :: Lens' a [String]+  ccOptions = buildInfo . ccOptions+  {-# INLINE ccOptions #-} -   cxxOptions :: Lens' a [String]-   cxxOptions = buildInfo . cxxOptions-   {-# INLINE cxxOptions #-}+  cxxOptions :: Lens' a [String]+  cxxOptions = buildInfo . cxxOptions+  {-# INLINE cxxOptions #-} -   ldOptions :: Lens' a [String]-   ldOptions = buildInfo . ldOptions-   {-# INLINE ldOptions #-}+  jsppOptions :: Lens' a [String]+  jsppOptions = buildInfo . jsppOptions+  {-# INLINE jsppOptions #-} -   hsc2hsOptions :: Lens' a [String]-   hsc2hsOptions = buildInfo . hsc2hsOptions-   {-# INLINE hsc2hsOptions #-}+  ldOptions :: Lens' a [String]+  ldOptions = buildInfo . ldOptions+  {-# INLINE ldOptions #-} -   pkgconfigDepends :: Lens' a [PkgconfigDependency]-   pkgconfigDepends = buildInfo . pkgconfigDepends-   {-# INLINE pkgconfigDepends #-}+  hsc2hsOptions :: Lens' a [String]+  hsc2hsOptions = buildInfo . hsc2hsOptions+  {-# INLINE hsc2hsOptions #-} -   frameworks :: Lens' a [String]-   frameworks = buildInfo . frameworks-   {-# INLINE frameworks #-}+  pkgconfigDepends :: Lens' a [PkgconfigDependency]+  pkgconfigDepends = buildInfo . pkgconfigDepends+  {-# INLINE pkgconfigDepends #-} -   extraFrameworkDirs :: Lens' a [String]-   extraFrameworkDirs = buildInfo . extraFrameworkDirs-   {-# INLINE extraFrameworkDirs #-}+  frameworks :: Lens' a [RelativePath Framework File]+  frameworks = buildInfo . frameworks+  {-# INLINE frameworks #-} -   asmSources :: Lens' a [FilePath]-   asmSources = buildInfo . asmSources-   {-# INLINE asmSources #-}+  extraFrameworkDirs :: Lens' a [SymbolicPath Pkg (Dir Framework)]+  extraFrameworkDirs = buildInfo . extraFrameworkDirs+  {-# INLINE extraFrameworkDirs #-} -   cmmSources :: Lens' a [FilePath]-   cmmSources = buildInfo . cmmSources-   {-# INLINE cmmSources #-}+  asmSources :: Lens' a [SymbolicPath Pkg File]+  asmSources = buildInfo . asmSources+  {-# INLINE asmSources #-} -   cSources :: Lens' a [FilePath]-   cSources = buildInfo . cSources-   {-# INLINE cSources #-}+  cmmSources :: Lens' a [SymbolicPath Pkg File]+  cmmSources = buildInfo . cmmSources+  {-# INLINE cmmSources #-} -   cxxSources :: Lens' a [FilePath]-   cxxSources = buildInfo . cxxSources-   {-# INLINE cxxSources #-}+  cSources :: Lens' a [SymbolicPath Pkg File]+  cSources = buildInfo . cSources+  {-# INLINE cSources #-} -   jsSources :: Lens' a [FilePath]-   jsSources = buildInfo . jsSources-   {-# INLINE jsSources #-}+  cxxSources :: Lens' a [SymbolicPath Pkg File]+  cxxSources = buildInfo . cxxSources+  {-# INLINE cxxSources #-} -   hsSourceDirs :: Lens' a [SymbolicPath PackageDir SourceDir]-   hsSourceDirs = buildInfo . hsSourceDirs-   {-# INLINE hsSourceDirs #-}+  jsSources :: Lens' a [SymbolicPath Pkg File]+  jsSources = buildInfo . jsSources+  {-# INLINE jsSources #-} -   otherModules :: Lens' a [ModuleName]-   otherModules = buildInfo . otherModules-   {-# INLINE otherModules #-}+  hsSourceDirs :: Lens' a [SymbolicPath Pkg (Dir Source)]+  hsSourceDirs = buildInfo . hsSourceDirs+  {-# INLINE hsSourceDirs #-} -   virtualModules :: Lens' a [ModuleName]-   virtualModules = buildInfo . virtualModules-   {-# INLINE virtualModules #-}+  otherModules :: Lens' a [ModuleName]+  otherModules = buildInfo . otherModules+  {-# INLINE otherModules #-} -   autogenModules :: Lens' a [ModuleName]-   autogenModules = buildInfo . autogenModules-   {-# INLINE autogenModules #-}+  virtualModules :: Lens' a [ModuleName]+  virtualModules = buildInfo . virtualModules+  {-# INLINE virtualModules #-} -   defaultLanguage :: Lens' a (Maybe Language)-   defaultLanguage = buildInfo . defaultLanguage-   {-# INLINE defaultLanguage #-}+  autogenModules :: Lens' a [ModuleName]+  autogenModules = buildInfo . autogenModules+  {-# INLINE autogenModules #-} -   otherLanguages :: Lens' a [Language]-   otherLanguages = buildInfo . otherLanguages-   {-# INLINE otherLanguages #-}+  defaultLanguage :: Lens' a (Maybe Language)+  defaultLanguage = buildInfo . defaultLanguage+  {-# INLINE defaultLanguage #-} -   defaultExtensions :: Lens' a [Extension]-   defaultExtensions = buildInfo . defaultExtensions-   {-# INLINE defaultExtensions #-}+  otherLanguages :: Lens' a [Language]+  otherLanguages = buildInfo . otherLanguages+  {-# INLINE otherLanguages #-} -   otherExtensions :: Lens' a [Extension]-   otherExtensions = buildInfo . otherExtensions-   {-# INLINE otherExtensions #-}+  defaultExtensions :: Lens' a [Extension]+  defaultExtensions = buildInfo . defaultExtensions+  {-# INLINE defaultExtensions #-} -   oldExtensions :: Lens' a [Extension]-   oldExtensions = buildInfo . oldExtensions-   {-# INLINE oldExtensions #-}+  otherExtensions :: Lens' a [Extension]+  otherExtensions = buildInfo . otherExtensions+  {-# INLINE otherExtensions #-} -   extraLibs :: Lens' a [String]-   extraLibs = buildInfo . extraLibs-   {-# INLINE extraLibs #-}+  oldExtensions :: Lens' a [Extension]+  oldExtensions = buildInfo . oldExtensions+  {-# INLINE oldExtensions #-} -   extraLibsStatic :: Lens' a [String]-   extraLibsStatic = buildInfo . extraLibsStatic-   {-# INLINE extraLibsStatic #-}+  extraLibs :: Lens' a [String]+  extraLibs = buildInfo . extraLibs+  {-# INLINE extraLibs #-} -   extraGHCiLibs :: Lens' a [String]-   extraGHCiLibs = buildInfo . extraGHCiLibs-   {-# INLINE extraGHCiLibs #-}+  extraLibsStatic :: Lens' a [String]+  extraLibsStatic = buildInfo . extraLibsStatic+  {-# INLINE extraLibsStatic #-} -   extraBundledLibs :: Lens' a [String]-   extraBundledLibs = buildInfo . extraBundledLibs-   {-# INLINE extraBundledLibs #-}+  extraGHCiLibs :: Lens' a [String]+  extraGHCiLibs = buildInfo . extraGHCiLibs+  {-# INLINE extraGHCiLibs #-} -   extraLibFlavours :: Lens' a [String]-   extraLibFlavours = buildInfo . extraLibFlavours-   {-# INLINE extraLibFlavours #-}+  extraBundledLibs :: Lens' a [String]+  extraBundledLibs = buildInfo . extraBundledLibs+  {-# INLINE extraBundledLibs #-} -   extraDynLibFlavours :: Lens' a [String]-   extraDynLibFlavours = buildInfo . extraDynLibFlavours-   {-# INLINE extraDynLibFlavours #-}+  extraLibFlavours :: Lens' a [String]+  extraLibFlavours = buildInfo . extraLibFlavours+  {-# INLINE extraLibFlavours #-} -   extraLibDirs :: Lens' a [String]-   extraLibDirs = buildInfo . extraLibDirs-   {-# INLINE extraLibDirs #-}+  extraDynLibFlavours :: Lens' a [String]+  extraDynLibFlavours = buildInfo . extraDynLibFlavours+  {-# INLINE extraDynLibFlavours #-} -   extraLibDirsStatic :: Lens' a [String]-   extraLibDirsStatic = buildInfo . extraLibDirsStatic-   {-# INLINE extraLibDirsStatic #-}+  extraLibDirs :: Lens' a [SymbolicPath Pkg (Dir Lib)]+  extraLibDirs = buildInfo . extraLibDirs+  {-# INLINE extraLibDirs #-} -   includeDirs :: Lens' a [FilePath]-   includeDirs = buildInfo . includeDirs-   {-# INLINE includeDirs #-}+  extraLibDirsStatic :: Lens' a [SymbolicPath Pkg (Dir Lib)]+  extraLibDirsStatic = buildInfo . extraLibDirsStatic+  {-# INLINE extraLibDirsStatic #-} -   includes :: Lens' a [FilePath]-   includes = buildInfo . includes-   {-# INLINE includes #-}+  includeDirs :: Lens' a [SymbolicPath Pkg (Dir Include)]+  includeDirs = buildInfo . includeDirs+  {-# INLINE includeDirs #-} -   autogenIncludes :: Lens' a [FilePath]-   autogenIncludes = buildInfo . autogenIncludes-   {-# INLINE autogenIncludes #-}+  includes :: Lens' a [SymbolicPath Include File]+  includes = buildInfo . includes+  {-# INLINE includes #-} -   installIncludes :: Lens' a [FilePath]-   installIncludes = buildInfo . installIncludes-   {-# INLINE installIncludes #-}+  autogenIncludes :: Lens' a [RelativePath Include File]+  autogenIncludes = buildInfo . autogenIncludes+  {-# INLINE autogenIncludes #-} -   options :: Lens' a (PerCompilerFlavor [String])-   options = buildInfo . options-   {-# INLINE options #-}+  installIncludes :: Lens' a [RelativePath Include File]+  installIncludes = buildInfo . installIncludes+  {-# INLINE installIncludes #-} -   profOptions :: Lens' a (PerCompilerFlavor [String])-   profOptions = buildInfo . profOptions-   {-# INLINE profOptions #-}+  options :: Lens' a (PerCompilerFlavor [String])+  options = buildInfo . options+  {-# INLINE options #-} -   sharedOptions :: Lens' a (PerCompilerFlavor [String])-   sharedOptions = buildInfo . sharedOptions-   {-# INLINE sharedOptions #-}+  profOptions :: Lens' a (PerCompilerFlavor [String])+  profOptions = buildInfo . profOptions+  {-# INLINE profOptions #-} -   staticOptions :: Lens' a (PerCompilerFlavor [String])-   staticOptions = buildInfo . staticOptions-   {-# INLINE staticOptions #-}+  sharedOptions :: Lens' a (PerCompilerFlavor [String])+  sharedOptions = buildInfo . sharedOptions+  {-# INLINE sharedOptions #-} -   customFieldsBI :: Lens' a [(String,String)]-   customFieldsBI = buildInfo . customFieldsBI-   {-# INLINE customFieldsBI #-}+  profSharedOptions :: Lens' a (PerCompilerFlavor [String])+  profSharedOptions = buildInfo . profSharedOptions+  {-# INLINE profSharedOptions #-} -   targetBuildDepends :: Lens' a [Dependency]-   targetBuildDepends = buildInfo . targetBuildDepends-   {-# INLINE targetBuildDepends #-}+  staticOptions :: Lens' a (PerCompilerFlavor [String])+  staticOptions = buildInfo . staticOptions+  {-# INLINE staticOptions #-} -   mixins :: Lens' a [Mixin]-   mixins = buildInfo . mixins-   {-# INLINE mixins #-}+  customFieldsBI :: Lens' a [(String, String)]+  customFieldsBI = buildInfo . customFieldsBI+  {-# INLINE customFieldsBI #-} +  targetBuildDepends :: Lens' a [Dependency]+  targetBuildDepends = buildInfo . targetBuildDepends+  {-# INLINE targetBuildDepends #-} +  mixins :: Lens' a [Mixin]+  mixins = buildInfo . mixins+  {-# INLINE mixins #-}+ instance HasBuildInfo BuildInfo where-    buildInfo = id-    {-# INLINE buildInfo #-}+  buildInfo = id+  {-# INLINE buildInfo #-} -    buildable f s = fmap (\x -> s { T.buildable = x }) (f (T.buildable s))-    {-# INLINE buildable #-}+  buildable f s = fmap (\x -> s{T.buildable = x}) (f (T.buildable s))+  {-# INLINE buildable #-} -    buildTools f s = fmap (\x -> s { T.buildTools = x }) (f (T.buildTools s))-    {-# INLINE buildTools #-}+  buildTools f s = fmap (\x -> s{T.buildTools = x}) (f (T.buildTools s))+  {-# INLINE buildTools #-} -    buildToolDepends f s = fmap (\x -> s { T.buildToolDepends = x }) (f (T.buildToolDepends s))-    {-# INLINE buildToolDepends #-}+  buildToolDepends f s = fmap (\x -> s{T.buildToolDepends = x}) (f (T.buildToolDepends s))+  {-# INLINE buildToolDepends #-} -    cppOptions f s = fmap (\x -> s { T.cppOptions = x }) (f (T.cppOptions s))-    {-# INLINE cppOptions #-}+  cppOptions f s = fmap (\x -> s{T.cppOptions = x}) (f (T.cppOptions s))+  {-# INLINE cppOptions #-} -    asmOptions f s = fmap (\x -> s { T.asmOptions = x }) (f (T.asmOptions s))-    {-# INLINE asmOptions #-}+  asmOptions f s = fmap (\x -> s{T.asmOptions = x}) (f (T.asmOptions s))+  {-# INLINE asmOptions #-} -    cmmOptions f s = fmap (\x -> s { T.cmmOptions = x }) (f (T.cmmOptions s))-    {-# INLINE cmmOptions #-}+  cmmOptions f s = fmap (\x -> s{T.cmmOptions = x}) (f (T.cmmOptions s))+  {-# INLINE cmmOptions #-} -    ccOptions f s = fmap (\x -> s { T.ccOptions = x }) (f (T.ccOptions s))-    {-# INLINE ccOptions #-}+  ccOptions f s = fmap (\x -> s{T.ccOptions = x}) (f (T.ccOptions s))+  {-# INLINE ccOptions #-} -    cxxOptions f s = fmap (\x -> s { T.cxxOptions = x }) (f (T.cxxOptions s))-    {-# INLINE cxxOptions #-}+  cxxOptions f s = fmap (\x -> s{T.cxxOptions = x}) (f (T.cxxOptions s))+  {-# INLINE cxxOptions #-} -    ldOptions f s = fmap (\x -> s { T.ldOptions = x }) (f (T.ldOptions s))-    {-# INLINE ldOptions #-}+  jsppOptions f s = fmap (\x -> s{T.jsppOptions = x}) (f (T.jsppOptions s))+  {-# INLINE jsppOptions #-} -    hsc2hsOptions f s = fmap (\x -> s { T.hsc2hsOptions = x }) (f (T.hsc2hsOptions s))-    {-# INLINE hsc2hsOptions #-}+  ldOptions f s = fmap (\x -> s{T.ldOptions = x}) (f (T.ldOptions s))+  {-# INLINE ldOptions #-} -    pkgconfigDepends f s = fmap (\x -> s { T.pkgconfigDepends = x }) (f (T.pkgconfigDepends s))-    {-# INLINE pkgconfigDepends #-}+  hsc2hsOptions f s = fmap (\x -> s{T.hsc2hsOptions = x}) (f (T.hsc2hsOptions s))+  {-# INLINE hsc2hsOptions #-} -    frameworks f s = fmap (\x -> s { T.frameworks = x }) (f (T.frameworks s))-    {-# INLINE frameworks #-}+  pkgconfigDepends f s = fmap (\x -> s{T.pkgconfigDepends = x}) (f (T.pkgconfigDepends s))+  {-# INLINE pkgconfigDepends #-} -    extraFrameworkDirs f s = fmap (\x -> s { T.extraFrameworkDirs = x }) (f (T.extraFrameworkDirs s))-    {-# INLINE extraFrameworkDirs #-}+  frameworks f s = fmap (\x -> s{T.frameworks = x}) (f (T.frameworks s))+  {-# INLINE frameworks #-} -    asmSources f s = fmap (\x -> s { T.asmSources = x }) (f (T.asmSources s))-    {-# INLINE asmSources #-}+  extraFrameworkDirs f s = fmap (\x -> s{T.extraFrameworkDirs = x}) (f (T.extraFrameworkDirs s))+  {-# INLINE extraFrameworkDirs #-} -    cmmSources f s = fmap (\x -> s { T.cmmSources = x }) (f (T.cmmSources s))-    {-# INLINE cmmSources #-}+  asmSources f s = fmap (\x -> s{T.asmSources = x}) (f (T.asmSources s))+  {-# INLINE asmSources #-} -    cSources f s = fmap (\x -> s { T.cSources = x }) (f (T.cSources s))-    {-# INLINE cSources #-}+  cmmSources f s = fmap (\x -> s{T.cmmSources = x}) (f (T.cmmSources s))+  {-# INLINE cmmSources #-} -    cxxSources f s = fmap (\x -> s { T.cSources = x }) (f (T.cxxSources s))-    {-# INLINE cxxSources #-}+  cSources f s = fmap (\x -> s{T.cSources = x}) (f (T.cSources s))+  {-# INLINE cSources #-} -    jsSources f s = fmap (\x -> s { T.jsSources = x }) (f (T.jsSources s))-    {-# INLINE jsSources #-}+  cxxSources f s = fmap (\x -> s{T.cSources = x}) (f (T.cxxSources s))+  {-# INLINE cxxSources #-} -    hsSourceDirs f s = fmap (\x -> s { T.hsSourceDirs = x }) (f (T.hsSourceDirs s))-    {-# INLINE hsSourceDirs #-}+  jsSources f s = fmap (\x -> s{T.jsSources = x}) (f (T.jsSources s))+  {-# INLINE jsSources #-} -    otherModules f s = fmap (\x -> s { T.otherModules = x }) (f (T.otherModules s))-    {-# INLINE otherModules #-}+  hsSourceDirs f s = fmap (\x -> s{T.hsSourceDirs = x}) (f (T.hsSourceDirs s))+  {-# INLINE hsSourceDirs #-} -    virtualModules f s = fmap (\x -> s { T.virtualModules = x }) (f (T.virtualModules s))-    {-# INLINE virtualModules #-}+  otherModules f s = fmap (\x -> s{T.otherModules = x}) (f (T.otherModules s))+  {-# INLINE otherModules #-} -    autogenModules f s = fmap (\x -> s { T.autogenModules = x }) (f (T.autogenModules s))-    {-# INLINE autogenModules #-}+  virtualModules f s = fmap (\x -> s{T.virtualModules = x}) (f (T.virtualModules s))+  {-# INLINE virtualModules #-} -    defaultLanguage f s = fmap (\x -> s { T.defaultLanguage = x }) (f (T.defaultLanguage s))-    {-# INLINE defaultLanguage #-}+  autogenModules f s = fmap (\x -> s{T.autogenModules = x}) (f (T.autogenModules s))+  {-# INLINE autogenModules #-} -    otherLanguages f s = fmap (\x -> s { T.otherLanguages = x }) (f (T.otherLanguages s))-    {-# INLINE otherLanguages #-}+  defaultLanguage f s = fmap (\x -> s{T.defaultLanguage = x}) (f (T.defaultLanguage s))+  {-# INLINE defaultLanguage #-} -    defaultExtensions f s = fmap (\x -> s { T.defaultExtensions = x }) (f (T.defaultExtensions s))-    {-# INLINE defaultExtensions #-}+  otherLanguages f s = fmap (\x -> s{T.otherLanguages = x}) (f (T.otherLanguages s))+  {-# INLINE otherLanguages #-} -    otherExtensions f s = fmap (\x -> s { T.otherExtensions = x }) (f (T.otherExtensions s))-    {-# INLINE otherExtensions #-}+  defaultExtensions f s = fmap (\x -> s{T.defaultExtensions = x}) (f (T.defaultExtensions s))+  {-# INLINE defaultExtensions #-} -    oldExtensions f s = fmap (\x -> s { T.oldExtensions = x }) (f (T.oldExtensions s))-    {-# INLINE oldExtensions #-}+  otherExtensions f s = fmap (\x -> s{T.otherExtensions = x}) (f (T.otherExtensions s))+  {-# INLINE otherExtensions #-} -    extraLibs f s = fmap (\x -> s { T.extraLibs = x }) (f (T.extraLibs s))-    {-# INLINE extraLibs #-}+  oldExtensions f s = fmap (\x -> s{T.oldExtensions = x}) (f (T.oldExtensions s))+  {-# INLINE oldExtensions #-} -    extraLibsStatic f s = fmap (\x -> s { T.extraLibsStatic = x}) (f (T.extraLibsStatic s))-    {-# INLINE extraLibsStatic #-}+  extraLibs f s = fmap (\x -> s{T.extraLibs = x}) (f (T.extraLibs s))+  {-# INLINE extraLibs #-} -    extraGHCiLibs f s = fmap (\x -> s { T.extraGHCiLibs = x }) (f (T.extraGHCiLibs s))-    {-# INLINE extraGHCiLibs #-}+  extraLibsStatic f s = fmap (\x -> s{T.extraLibsStatic = x}) (f (T.extraLibsStatic s))+  {-# INLINE extraLibsStatic #-} -    extraBundledLibs f s = fmap (\x -> s { T.extraBundledLibs = x }) (f (T.extraBundledLibs s))-    {-# INLINE extraBundledLibs #-}+  extraGHCiLibs f s = fmap (\x -> s{T.extraGHCiLibs = x}) (f (T.extraGHCiLibs s))+  {-# INLINE extraGHCiLibs #-} -    extraLibFlavours f s = fmap (\x -> s { T.extraLibFlavours = x }) (f (T.extraLibFlavours s))-    {-# INLINE extraLibFlavours #-}+  extraBundledLibs f s = fmap (\x -> s{T.extraBundledLibs = x}) (f (T.extraBundledLibs s))+  {-# INLINE extraBundledLibs #-} -    extraDynLibFlavours f s = fmap (\x -> s { T.extraDynLibFlavours = x}) (f (T.extraDynLibFlavours s))-    {-# INLINE extraDynLibFlavours #-}+  extraLibFlavours f s = fmap (\x -> s{T.extraLibFlavours = x}) (f (T.extraLibFlavours s))+  {-# INLINE extraLibFlavours #-} -    extraLibDirs f s = fmap (\x -> s { T.extraLibDirs = x }) (f (T.extraLibDirs s))-    {-# INLINE extraLibDirs #-}+  extraDynLibFlavours f s = fmap (\x -> s{T.extraDynLibFlavours = x}) (f (T.extraDynLibFlavours s))+  {-# INLINE extraDynLibFlavours #-} -    extraLibDirsStatic f s = fmap (\x -> s { T.extraLibDirsStatic = x}) (f (T.extraLibDirsStatic s))-    {-# INLINE extraLibDirsStatic #-}+  extraLibDirs f s = fmap (\x -> s{T.extraLibDirs = x}) (f (T.extraLibDirs s))+  {-# INLINE extraLibDirs #-} -    includeDirs f s = fmap (\x -> s { T.includeDirs = x }) (f (T.includeDirs s))-    {-# INLINE includeDirs #-}+  extraLibDirsStatic f s = fmap (\x -> s{T.extraLibDirsStatic = x}) (f (T.extraLibDirsStatic s))+  {-# INLINE extraLibDirsStatic #-} -    includes f s = fmap (\x -> s { T.includes = x }) (f (T.includes s))-    {-# INLINE includes #-}+  includeDirs f s = fmap (\x -> s{T.includeDirs = x}) (f (T.includeDirs s))+  {-# INLINE includeDirs #-} -    autogenIncludes f s = fmap (\x -> s { T.autogenIncludes = x }) (f (T.autogenIncludes s))-    {-# INLINE autogenIncludes #-}+  includes f s = fmap (\x -> s{T.includes = x}) (f (T.includes s))+  {-# INLINE includes #-} -    installIncludes f s = fmap (\x -> s { T.installIncludes = x }) (f (T.installIncludes s))-    {-# INLINE installIncludes #-}+  autogenIncludes f s = fmap (\x -> s{T.autogenIncludes = x}) (f (T.autogenIncludes s))+  {-# INLINE autogenIncludes #-} -    options f s = fmap (\x -> s { T.options = x }) (f (T.options s))-    {-# INLINE options #-}+  installIncludes f s = fmap (\x -> s{T.installIncludes = x}) (f (T.installIncludes s))+  {-# INLINE installIncludes #-} -    profOptions f s = fmap (\x -> s { T.profOptions = x }) (f (T.profOptions s))-    {-# INLINE profOptions #-}+  options f s = fmap (\x -> s{T.options = x}) (f (T.options s))+  {-# INLINE options #-} -    sharedOptions f s = fmap (\x -> s { T.sharedOptions = x }) (f (T.sharedOptions s))-    {-# INLINE sharedOptions #-}+  profOptions f s = fmap (\x -> s{T.profOptions = x}) (f (T.profOptions s))+  {-# INLINE profOptions #-} -    staticOptions f s = fmap (\x -> s { T.staticOptions = x }) (f (T.staticOptions s))-    {-# INLINE staticOptions #-}+  sharedOptions f s = fmap (\x -> s{T.sharedOptions = x}) (f (T.sharedOptions s))+  {-# INLINE sharedOptions #-} -    customFieldsBI f s = fmap (\x -> s { T.customFieldsBI = x }) (f (T.customFieldsBI s))-    {-# INLINE customFieldsBI #-}+  profSharedOptions f s = fmap (\x -> s{T.profSharedOptions = x}) (f (T.profSharedOptions s))+  {-# INLINE profSharedOptions #-} -    targetBuildDepends f s = fmap (\x -> s { T.targetBuildDepends = x }) (f (T.targetBuildDepends s))-    {-# INLINE targetBuildDepends #-}+  staticOptions f s = fmap (\x -> s{T.staticOptions = x}) (f (T.staticOptions s))+  {-# INLINE staticOptions #-} -    mixins f s = fmap (\x -> s { T.mixins = x }) (f (T.mixins s))-    {-# INLINE mixins #-}+  customFieldsBI f s = fmap (\x -> s{T.customFieldsBI = x}) (f (T.customFieldsBI s))+  {-# INLINE customFieldsBI #-}++  targetBuildDepends f s = fmap (\x -> s{T.targetBuildDepends = x}) (f (T.targetBuildDepends s))+  {-# INLINE targetBuildDepends #-}++  mixins f s = fmap (\x -> s{T.mixins = x}) (f (T.mixins s))+  {-# INLINE mixins #-}  class HasBuildInfos a where   traverseBuildInfos :: Traversal' a BuildInfo
src/Distribution/Types/BuildType.hs view
@@ -2,37 +2,42 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.BuildType (-    BuildType(..),-    knownBuildTypes,-) where+module Distribution.Types.BuildType+  ( BuildType (..)+  , knownBuildTypes+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.CabalSpecVersion (CabalSpecVersion (..))-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp  -- | The type of build system used by this package. data BuildType-  = Simple      -- ^ calls @Distribution.Simple.defaultMain@-  | Configure   -- ^ calls @Distribution.Simple.defaultMainWithHooks defaultUserHooks@,-                -- which invokes @configure@ to generate additional build-                -- information used by later phases.-  | Make        -- ^ calls @Distribution.Make.defaultMain@-  | Custom      -- ^ uses user-supplied @Setup.hs@ or @Setup.lhs@ (default)-                deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+  = -- | calls @Distribution.Simple.defaultMain@+    Simple+  | -- | calls @Distribution.Simple.defaultMainWithHooks defaultUserHooks@,+    -- which invokes @configure@ to generate additional build+    -- information used by later phases.+    Configure+  | -- | calls @Distribution.Make.defaultMain@+    Make+  | -- | uses user-supplied @Setup.hs@ or @Setup.lhs@ (default)+    Custom+  | Hooks+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary BuildType instance Structured BuildType instance NFData BuildType where rnf = genericRnf  knownBuildTypes :: [BuildType]-knownBuildTypes = [Simple, Configure, Make, Custom]+knownBuildTypes = [Simple, Configure, Make, Custom, Hooks]  instance Pretty BuildType where   pretty = Disp.text . show@@ -41,15 +46,20 @@   parsec = do     name <- P.munch1 isAlphaNum     case name of-      "Simple"    -> return Simple+      "Simple" -> return Simple       "Configure" -> return Configure-      "Custom"    -> return Custom-      "Make"      -> return Make-      "Default"   -> do-          v <- askCabalSpecVersion-          if v <= CabalSpecV1_18 -- oldest version needing this, based on hackage-tests+      "Custom" -> return Custom+      "Make" -> return Make+      "Hooks" -> do+        v <- askCabalSpecVersion+        if v >= CabalSpecV3_14+          then return Hooks+          else fail "build-type: 'Hooks'. This feature requires cabal-version >= 3.14."+      "Default" -> do+        v <- askCabalSpecVersion+        if v <= CabalSpecV1_18 -- oldest version needing this, based on hackage-tests           then do-              parsecWarning PWTBuildTypeDefault "build-type: Default is parsed as Custom for legacy reasons. See https://github.com/haskell/cabal/issues/5020"-              return Custom+            parsecWarning PWTBuildTypeDefault "build-type: Default is parsed as Custom for legacy reasons. See https://github.com/haskell/cabal/issues/5020"+            return Custom           else fail ("unknown build-type: '" ++ name ++ "'")-      _           -> fail ("unknown build-type: '" ++ name ++ "'")+      _ -> fail ("unknown build-type: '" ++ name ++ "'")
src/Distribution/Types/Component.hs view
@@ -1,61 +1,66 @@ {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.Component (-    Component(..),-    foldComponent,-    componentBuildInfo,-    componentBuildable,-    componentName,-    partitionComponents,-) where+module Distribution.Types.Component+  ( Component (..)+  , foldComponent+  , componentBuildInfo+  , componentBuildable+  , componentName+  , partitionComponents+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.Library-import Distribution.Types.ForeignLib+import Distribution.Types.Benchmark import Distribution.Types.Executable+import Distribution.Types.ForeignLib+import Distribution.Types.Library import Distribution.Types.TestSuite-import Distribution.Types.Benchmark -import Distribution.Types.ComponentName import Distribution.Types.BuildInfo+import Distribution.Types.ComponentName  import qualified Distribution.Types.BuildInfo.Lens as L -data Component = CLib   Library-               | CFLib  ForeignLib-               | CExe   Executable-               | CTest  TestSuite-               | CBench Benchmark-               deriving (Show, Eq, Read)+data Component+  = CLib Library+  | CFLib ForeignLib+  | CExe Executable+  | CTest TestSuite+  | CBench Benchmark+  deriving (Generic, Show, Eq, Read) +instance Binary Component+instance Structured Component+ instance Semigroup Component where-    CLib   l <> CLib   l' = CLib   (l <> l')-    CFLib  l <> CFLib  l' = CFLib  (l <> l')-    CExe   e <> CExe   e' = CExe   (e <> e')-    CTest  t <> CTest  t' = CTest  (t <> t')-    CBench b <> CBench b' = CBench (b <> b')-    _        <> _         = error "Cannot merge Component"+  CLib l <> CLib l' = CLib (l <> l')+  CFLib l <> CFLib l' = CFLib (l <> l')+  CExe e <> CExe e' = CExe (e <> e')+  CTest t <> CTest t' = CTest (t <> t')+  CBench b <> CBench b' = CBench (b <> b')+  _ <> _ = error "Cannot merge Component"  instance L.HasBuildInfo Component where-    buildInfo f (CLib l)   = CLib <$> L.buildInfo f l-    buildInfo f (CFLib l)  = CFLib <$> L.buildInfo f l-    buildInfo f (CExe e)   = CExe <$> L.buildInfo f e-    buildInfo f (CTest t)  = CTest <$> L.buildInfo f t-    buildInfo f (CBench b) = CBench <$> L.buildInfo f b+  buildInfo f (CLib l) = CLib <$> L.buildInfo f l+  buildInfo f (CFLib l) = CFLib <$> L.buildInfo f l+  buildInfo f (CExe e) = CExe <$> L.buildInfo f e+  buildInfo f (CTest t) = CTest <$> L.buildInfo f t+  buildInfo f (CBench b) = CBench <$> L.buildInfo f b -foldComponent :: (Library -> a)-              -> (ForeignLib -> a)-              -> (Executable -> a)-              -> (TestSuite -> a)-              -> (Benchmark -> a)-              -> Component-              -> a-foldComponent f _ _ _ _ (CLib   lib) = f lib-foldComponent _ f _ _ _ (CFLib  flib)= f flib-foldComponent _ _ f _ _ (CExe   exe) = f exe-foldComponent _ _ _ f _ (CTest  tst) = f tst+foldComponent+  :: (Library -> a)+  -> (ForeignLib -> a)+  -> (Executable -> a)+  -> (TestSuite -> a)+  -> (Benchmark -> a)+  -> Component+  -> a+foldComponent f _ _ _ _ (CLib lib) = f lib+foldComponent _ f _ _ _ (CFLib flib) = f flib+foldComponent _ _ f _ _ (CExe exe) = f exe+foldComponent _ _ _ f _ (CTest tst) = f tst foldComponent _ _ _ _ f (CBench bch) = f bch  componentBuildInfo :: Component -> BuildInfo@@ -67,25 +72,25 @@ -- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components". -- -- @since 2.0.0.2--- componentBuildable :: Component -> Bool componentBuildable = buildable . componentBuildInfo  componentName :: Component -> ComponentName componentName =-  foldComponent (CLibName . libName)-                (CFLibName  . foreignLibName)-                (CExeName   . exeName)-                (CTestName  . testName)-                (CBenchName . benchmarkName)+  foldComponent+    (CLibName . libName)+    (CFLibName . foreignLibName)+    (CExeName . exeName)+    (CTestName . testName)+    (CBenchName . benchmarkName)  partitionComponents-    :: [Component]-    -> ([Library], [ForeignLib], [Executable], [TestSuite], [Benchmark])-partitionComponents = foldr (foldComponent fa fb fc fd fe) ([],[],[],[],[])+  :: [Component]+  -> ([Library], [ForeignLib], [Executable], [TestSuite], [Benchmark])+partitionComponents = foldr (foldComponent fa fb fc fd fe) ([], [], [], [], [])   where-    fa x ~(a,b,c,d,e) = (x:a,b,c,d,e)-    fb x ~(a,b,c,d,e) = (a,x:b,c,d,e)-    fc x ~(a,b,c,d,e) = (a,b,x:c,d,e)-    fd x ~(a,b,c,d,e) = (a,b,c,x:d,e)-    fe x ~(a,b,c,d,e) = (a,b,c,d,x:e)+    fa x ~(a, b, c, d, e) = (x : a, b, c, d, e)+    fb x ~(a, b, c, d, e) = (a, x : b, c, d, e)+    fc x ~(a, b, c, d, e) = (a, b, x : c, d, e)+    fd x ~(a, b, c, d, e) = (a, b, c, x : d, e)+    fe x ~(a, b, c, d, e) = (a, b, c, d, x : e)
src/Distribution/Types/ComponentId.hs view
@@ -1,17 +1,18 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}  module Distribution.Types.ComponentId-  ( ComponentId, unComponentId, mkComponentId+  ( ComponentId+  , unComponentId+  , mkComponentId   ) where -import Prelude () import Distribution.Compat.Prelude import Distribution.Utils.ShortText+import Prelude () -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P import Text.PrettyPrint (text)@@ -30,7 +31,7 @@ -- -- @since 2.0.0.2 newtype ComponentId = ComponentId ShortText-    deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+  deriving (Generic, Read, Show, Eq, Ord, Data)  -- | Construct a 'ComponentId' from a 'String' --@@ -53,7 +54,7 @@ -- -- @since 2.0.0.2 instance IsString ComponentId where-    fromString = mkComponentId+  fromString = mkComponentId  instance Binary ComponentId instance Structured ComponentId@@ -63,7 +64,8 @@  instance Parsec ComponentId where   parsec = mkComponentId `fmap` P.munch1 abi_char-   where abi_char c = isAlphaNum c || c `elem` "-_."+    where+      abi_char c = isAlphaNum c || c `elem` "-_."  instance NFData ComponentId where-    rnf = rnf . unComponentId+  rnf = rnf . unComponentId
src/Distribution/Types/ComponentName.hs view
@@ -1,46 +1,46 @@-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE PatternSynonyms #-} -module Distribution.Types.ComponentName (-  ComponentName(.., CFLibName, CExeName, CTestName, CBenchName),-  showComponentName,-  componentNameRaw,-  componentNameStanza,-  componentNameString,+module Distribution.Types.ComponentName+  ( ComponentName (.., CFLibName, CExeName, CTestName, CBenchName)+  , showComponentName+  , componentNameRaw+  , componentNameStanza+  , componentNameString   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.UnqualComponentName-import Distribution.Types.LibraryName-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty+import Distribution.Types.LibraryName+import Distribution.Types.UnqualComponentName -import qualified Text.PrettyPrint as Disp import qualified Distribution.Compat.CharParsing as P+import qualified Text.PrettyPrint as Disp  -- Libraries live in a separate namespace, so must distinguish-data ComponentName = CLibName   LibraryName-                   | CNotLibName NotLibComponentName-                   deriving (Eq, Generic, Ord, Read, Show, Typeable)+data ComponentName+  = CLibName LibraryName+  | CNotLibName NotLibComponentName+  deriving (Eq, Generic, Ord, Read, Show)  data NotLibComponentName-                   = CNLFLibName  { toCompName :: UnqualComponentName }-                   | CNLExeName   { toCompName :: UnqualComponentName }-                   | CNLTestName  { toCompName :: UnqualComponentName }-                   | CNLBenchName { toCompName :: UnqualComponentName }-                   deriving (Eq, Generic, Ord, Read, Show, Typeable)+  = CNLFLibName {toCompName :: UnqualComponentName}+  | CNLExeName {toCompName :: UnqualComponentName}+  | CNLTestName {toCompName :: UnqualComponentName}+  | CNLBenchName {toCompName :: UnqualComponentName}+  deriving (Eq, Generic, Ord, Read, Show)  pattern CFLibName :: UnqualComponentName -> ComponentName-pattern CFLibName  n = CNotLibName (CNLFLibName  n)+pattern CFLibName n = CNotLibName (CNLFLibName n)  pattern CExeName :: UnqualComponentName -> ComponentName-pattern CExeName   n = CNotLibName (CNLExeName   n)+pattern CExeName n = CNotLibName (CNLExeName n)  pattern CTestName :: UnqualComponentName -> ComponentName-pattern CTestName  n = CNotLibName (CNLTestName  n)+pattern CTestName n = CNotLibName (CNLTestName n)  pattern CBenchName :: UnqualComponentName -> ComponentName pattern CBenchName n = CNotLibName (CNLBenchName n)@@ -54,42 +54,43 @@  -- Build-target-ish syntax instance Pretty ComponentName where-    pretty (CLibName lib)    = prettyLibraryNameComponent lib-    pretty (CFLibName str)   = Disp.text "flib:" <<>> pretty str-    pretty (CExeName str)    = Disp.text "exe:" <<>> pretty str-    pretty (CTestName str)   = Disp.text "test:" <<>> pretty str-    pretty (CBenchName str)  = Disp.text "bench:" <<>> pretty str+  pretty (CLibName lib) = prettyLibraryNameComponent lib+  pretty (CFLibName str) = Disp.text "flib:" <<>> pretty str+  pretty (CExeName str) = Disp.text "exe:" <<>> pretty str+  pretty (CTestName str) = Disp.text "test:" <<>> pretty str+  pretty (CBenchName str) = Disp.text "bench:" <<>> pretty str  instance Parsec ComponentName where-    -- note: this works as lib/flib/... all start with different character!-    parsec = parseComposite <|> parseLib-      where-        parseLib = CLibName <$> parsecLibraryNameComponent-        parseComposite = do-            ctor <- P.choice-                [ P.string "flib:" >> return CFLibName-                , P.string "exe:" >> return CExeName-                , P.string "bench:" >> return CBenchName-                , P.string "test:" >> return CTestName-                ]-            ctor <$> parsec+  -- note: this works as lib/flib/... all start with different character!+  parsec = parseComposite <|> parseLib+    where+      parseLib = CLibName <$> parsecLibraryNameComponent+      parseComposite = do+        ctor <-+          P.choice+            [ P.string "flib:" >> return CFLibName+            , P.string "exe:" >> return CExeName+            , P.string "bench:" >> return CBenchName+            , P.string "test:" >> return CTestName+            ]+        ctor <$> parsec  showComponentName :: ComponentName -> String-showComponentName (CLibName lib)    = showLibraryName lib-showComponentName (CFLibName  name) = "foreign library '" ++ prettyShow name ++ "'"-showComponentName (CExeName   name) = "executable '" ++ prettyShow name ++ "'"-showComponentName (CTestName  name) = "test suite '" ++ prettyShow name ++ "'"+showComponentName (CLibName lib) = showLibraryName lib+showComponentName (CFLibName name) = "foreign library '" ++ prettyShow name ++ "'"+showComponentName (CExeName name) = "executable '" ++ prettyShow name ++ "'"+showComponentName (CTestName name) = "test suite '" ++ prettyShow name ++ "'" showComponentName (CBenchName name) = "benchmark '" ++ prettyShow name ++ "'"  componentNameRaw :: ComponentName -> String-componentNameRaw l@(CLibName  _) = showComponentName l+componentNameRaw l@(CLibName _) = showComponentName l componentNameRaw (CNotLibName x) = prettyShow $ toCompName x  componentNameStanza :: ComponentName -> String-componentNameStanza (CLibName lib)    = libraryNameStanza lib-componentNameStanza (CFLibName  name) = "foreign-library " ++ prettyShow name-componentNameStanza (CExeName   name) = "executable " ++ prettyShow name-componentNameStanza (CTestName  name) = "test-suite " ++ prettyShow name+componentNameStanza (CLibName lib) = libraryNameStanza lib+componentNameStanza (CFLibName name) = "foreign-library " ++ prettyShow name+componentNameStanza (CExeName name) = "executable " ++ prettyShow name+componentNameStanza (CTestName name) = "test-suite " ++ prettyShow name componentNameStanza (CBenchName name) = "benchmark " ++ prettyShow name  -- | This gets the underlying unqualified component name. In fact, it is@@ -97,5 +98,5 @@ -- @Nothing@ if the 'ComponentName' was for the public -- library. componentNameString :: ComponentName -> Maybe UnqualComponentName-componentNameString (CLibName  lib) = libraryNameString lib+componentNameString (CLibName lib) = libraryNameString lib componentNameString (CNotLibName x) = Just $ toCompName x
src/Distribution/Types/ComponentRequestedSpec.hs view
@@ -1,20 +1,17 @@-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-module Distribution.Types.ComponentRequestedSpec (-    -- $buildable_vs_enabled_components -    ComponentRequestedSpec(..),-    ComponentDisabledReason(..),--    defaultComponentRequestedSpec,-    componentNameRequested,--    componentEnabled,-    componentDisabledReason,-) where+module Distribution.Types.ComponentRequestedSpec+  ( -- $buildable_vs_enabled_components+    ComponentRequestedSpec (..)+  , ComponentDisabledReason (..)+  , defaultComponentRequestedSpec+  , componentNameRequested+  , componentEnabled+  , componentDisabledReason+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Types.Component -- TODO: maybe remove me? import Distribution.Types.ComponentName@@ -64,10 +61,12 @@ -- -- @since 2.0.0.2 data ComponentRequestedSpec-    = ComponentRequestedSpec { testsRequested      :: Bool-                             , benchmarksRequested :: Bool }-    | OneComponentRequestedSpec ComponentName-  deriving (Generic, Read, Show, Eq, Typeable)+  = ComponentRequestedSpec+      { testsRequested :: Bool+      , benchmarksRequested :: Bool+      }+  | OneComponentRequestedSpec ComponentName+  deriving (Generic, Read, Show, Eq)  instance Binary ComponentRequestedSpec instance Structured ComponentRequestedSpec@@ -96,32 +95,39 @@ -- | Is this component disabled, and if so, why? -- -- @since 2.0.0.2-componentDisabledReason :: ComponentRequestedSpec -> Component-                        -> Maybe ComponentDisabledReason+componentDisabledReason+  :: ComponentRequestedSpec+  -> Component+  -> Maybe ComponentDisabledReason componentDisabledReason enabled comp-    | not (componentBuildable comp) = Just DisabledComponent-    | otherwise = componentNameNotRequestedReason enabled (componentName comp)+  | not (componentBuildable comp) = Just DisabledComponent+  | otherwise = componentNameNotRequestedReason enabled (componentName comp)  -- | Is this component name disabled, and if so, why? -- -- @since 2.0.0.2-componentNameNotRequestedReason :: ComponentRequestedSpec -> ComponentName-                            -> Maybe ComponentDisabledReason componentNameNotRequestedReason-    ComponentRequestedSpec{ testsRequested      = False } (CTestName _)-    = Just DisabledAllTests+  :: ComponentRequestedSpec+  -> ComponentName+  -> Maybe ComponentDisabledReason componentNameNotRequestedReason-    ComponentRequestedSpec{ benchmarksRequested = False } (CBenchName _)-    = Just DisabledAllBenchmarks+  ComponentRequestedSpec{testsRequested = False}+  (CTestName _) =+    Just DisabledAllTests+componentNameNotRequestedReason+  ComponentRequestedSpec{benchmarksRequested = False}+  (CBenchName _) =+    Just DisabledAllBenchmarks componentNameNotRequestedReason ComponentRequestedSpec{} _ = Nothing componentNameNotRequestedReason (OneComponentRequestedSpec cname) c-    | c == cname = Nothing-    | otherwise = Just (DisabledAllButOne (prettyShow cname))+  | c == cname = Nothing+  | otherwise = Just (DisabledAllButOne (prettyShow cname))  -- | A reason explaining why a component is disabled. -- -- @since 2.0.0.2-data ComponentDisabledReason = DisabledComponent-                             | DisabledAllTests-                             | DisabledAllBenchmarks-                             | DisabledAllButOne String+data ComponentDisabledReason+  = DisabledComponent+  | DisabledAllTests+  | DisabledAllBenchmarks+  | DisabledAllButOne String
src/Distribution/Types/CondTree.hs view
@@ -1,37 +1,35 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE ScopedTypeVariables #-} -module Distribution.Types.CondTree (-    CondTree(..),-    CondBranch(..),-    condIfThen,-    condIfThenElse,-    foldCondTree,-    mapCondTree,-    mapTreeConstrs,-    mapTreeConds,-    mapTreeData,-    traverseCondTreeV,-    traverseCondBranchV,-    traverseCondTreeC,-    traverseCondBranchC,-    extractCondition,-    simplifyCondTree,-    ignoreConditions,-) where+module Distribution.Types.CondTree+  ( CondTree (..)+  , CondBranch (..)+  , condIfThen+  , condIfThenElse+  , foldCondTree+  , mapCondTree+  , mapTreeConstrs+  , mapTreeConds+  , mapTreeData+  , traverseCondTreeV+  , traverseCondBranchV+  , traverseCondTreeC+  , traverseCondBranchC+  , extractCondition+  , simplifyCondTree+  , simplifyCondBranch+  , ignoreConditions+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Types.Condition  import qualified Distribution.Compat.Lens as L - -- | A 'CondTree' is used to represent the conditional structure of -- a Cabal file, reflecting a syntax element subject to constraints, -- and then any number of sub-elements which may be enabled subject@@ -56,13 +54,12 @@ -- derived off of 'targetBuildInfo' (perhaps a good refactoring -- would be to convert this into an opaque type, with a smart -- constructor that pre-computes the dependencies.)--- data CondTree v c a = CondNode-    { condTreeData        :: a-    , condTreeConstraints :: c-    , condTreeComponents  :: [CondBranch v c a]-    }-    deriving (Show, Eq, Typeable, Data, Generic, Functor, Foldable, Traversable)+  { condTreeData :: a+  , condTreeConstraints :: c+  , condTreeComponents :: [CondBranch v c a]+  }+  deriving (Show, Eq, Data, Generic, Functor, Foldable, Traversable)  instance (Binary v, Binary c, Binary a) => Binary (CondTree v c a) instance (Structured v, Structured c, Structured a) => Structured (CondTree v c a)@@ -72,26 +69,25 @@   (CondNode a c bs) <> (CondNode a' c' bs') = CondNode (a <> a') (c <> c') (bs <> bs')  instance (Semigroup a, Semigroup c, Monoid a, Monoid c) => Monoid (CondTree v c a) where-   mappend = (<>)-   mempty = CondNode mempty mempty mempty+  mappend = (<>)+  mempty = CondNode mempty mempty mempty  -- | A 'CondBranch' represents a conditional branch, e.g., @if -- flag(foo)@ on some syntax @a@.  It also has an optional false -- branch.--- data CondBranch v c a = CondBranch-    { condBranchCondition :: Condition v-    , condBranchIfTrue    :: CondTree v c a-    , condBranchIfFalse   :: Maybe (CondTree v c a)-    }-    deriving (Show, Eq, Typeable, Data, Generic, Functor, Traversable)+  { condBranchCondition :: Condition v+  , condBranchIfTrue :: CondTree v c a+  , condBranchIfFalse :: Maybe (CondTree v c a)+  }+  deriving (Show, Eq, Data, Generic, Functor, Traversable)  -- This instance is written by hand because GHC 8.0.1/8.0.2 infinite -- loops when trying to derive it with optimizations.  See -- https://gitlab.haskell.org/ghc/ghc/-/issues/13056 instance Foldable (CondBranch v c) where-    foldMap f (CondBranch _ c Nothing) = foldMap f c-    foldMap f (CondBranch _ c (Just a)) = foldMap f c `mappend` foldMap f a+  foldMap f (CondBranch _ c Nothing) = foldMap f c+  foldMap f (CondBranch _ c (Just a)) = foldMap f c `mappend` foldMap f a  instance (Binary v, Binary c, Binary a) => Binary (CondBranch v c a) instance (Structured v, Structured c, Structured a) => Structured (CondBranch v c a)@@ -103,15 +99,20 @@ condIfThenElse :: Condition v -> CondTree v c a -> CondTree v c a -> CondBranch v c a condIfThenElse c t e = CondBranch c t (Just e) -mapCondTree :: (a -> b) -> (c -> d) -> (Condition v -> Condition w)-            -> CondTree v c a -> CondTree w d b+mapCondTree+  :: (a -> b)+  -> (c -> d)+  -> (Condition v -> Condition w)+  -> CondTree v c a+  -> CondTree w d b mapCondTree fa fc fcnd (CondNode a c ifs) =-    CondNode (fa a) (fc c) (map g ifs)+  CondNode (fa a) (fc c) (map g ifs)   where-    g (CondBranch cnd t me)-        = CondBranch (fcnd cnd)-                     (mapCondTree fa fc fcnd t)-                     (fmap (mapCondTree fa fc fcnd) me)+    g (CondBranch cnd t me) =+      CondBranch+        (fcnd cnd)+        (mapCondTree fa fc fcnd t)+        (fmap (mapCondTree fa fc fcnd) me)  mapTreeConstrs :: (c -> d) -> CondTree v c a -> CondTree v d a mapTreeConstrs f = mapCondTree id f id@@ -125,11 +126,12 @@ -- | @@Traversal@@ for the variables traverseCondTreeV :: L.Traversal (CondTree v c a) (CondTree w c a) v w traverseCondTreeV f (CondNode a c ifs) =-    CondNode a c <$> traverse (traverseCondBranchV f) ifs+  CondNode a c <$> traverse (traverseCondBranchV f) ifs  -- | @@Traversal@@ for the variables traverseCondBranchV :: L.Traversal (CondBranch v c a) (CondBranch w c a) v w-traverseCondBranchV f (CondBranch cnd t me) = CondBranch+traverseCondBranchV f (CondBranch cnd t me) =+  CondBranch     <$> traverse f cnd     <*> traverseCondTreeV f t     <*> traverse (traverseCondTreeV f) me@@ -137,15 +139,15 @@ -- | @@Traversal@@ for the aggregated constraints traverseCondTreeC :: L.Traversal (CondTree v c a) (CondTree v d a) c d traverseCondTreeC f (CondNode a c ifs) =-    CondNode a <$> f c <*> traverse (traverseCondBranchC f) ifs+  CondNode a <$> f c <*> traverse (traverseCondBranchC f) ifs  -- | @@Traversal@@ for the aggregated constraints traverseCondBranchC :: L.Traversal (CondBranch v c a) (CondBranch v d a) c d-traverseCondBranchC f (CondBranch cnd t me) = CondBranch cnd+traverseCondBranchC f (CondBranch cnd t me) =+  CondBranch cnd     <$> traverseCondTreeC f t     <*> traverse (traverseCondTreeC f) me - -- | Extract the condition matched by the given predicate from a cond tree. -- -- We use this mainly for extracting buildable conditions (see the Note in@@ -154,40 +156,50 @@ extractCondition :: Eq v => (a -> Bool) -> CondTree v c a -> Condition v extractCondition p = go   where-    go (CondNode x _ cs) | not (p x) = Lit False-                         | otherwise = goList cs+    go (CondNode x _ cs)+      | not (p x) = Lit False+      | otherwise = goList cs -    goList []               = Lit True+    goList [] = Lit True     goList (CondBranch c t e : cs) =       let         ct = go t         ce = maybe (Lit True) go e-      in+       in         ((c `cAnd` ct) `cOr` (CNot c `cAnd` ce)) `cAnd` goList cs --- | Flattens a CondTree using a partial flag assignment.  When a condition+-- | Flattens a CondTree using a partial flag assignment. When a condition -- cannot be evaluated, both branches are ignored.-simplifyCondTree :: (Semigroup a, Semigroup d) =>-                    (v -> Either v Bool)-                 -> CondTree v d a-                 -> (d, a)+simplifyCondTree+  :: (Semigroup a, Semigroup d)+  => (v -> Either v Bool)+  -> CondTree v d a+  -> (d, a) simplifyCondTree env (CondNode a d ifs) =-    foldl (<>) (d, a) $ mapMaybe simplifyIf ifs-  where-    simplifyIf (CondBranch cnd t me) =-        case simplifyCondition cnd env of-          (Lit True, _) -> Just $ simplifyCondTree env t-          (Lit False, _) -> fmap (simplifyCondTree env) me-          _ -> Nothing+  foldl (<>) (d, a) $ mapMaybe (simplifyCondBranch env) ifs +-- | Realizes a 'CondBranch' using partial flag assignment. When a condition+-- cannot be evaluated, returns 'Nothing'.+simplifyCondBranch+  :: (Semigroup a, Semigroup d)+  => (v -> Either v Bool)+  -> CondBranch v d a+  -> Maybe (d, a)+simplifyCondBranch env (CondBranch cnd t me) =+  case simplifyCondition cnd env of+    (Lit True, _) -> Just $ simplifyCondTree env t+    (Lit False, _) -> fmap (simplifyCondTree env) me+    _ -> Nothing+ -- | Flatten a CondTree.  This will resolve the CondTree by taking all --  possible paths into account.  Note that since branches represent exclusive --  choices this may not result in a \"sane\" result. ignoreConditions :: (Semigroup a, Semigroup c) => CondTree v c a -> (a, c) ignoreConditions (CondNode a c ifs) = foldl (<>) (a, c) $ concatMap f ifs-  where f (CondBranch _ t me) = ignoreConditions t-                       : maybeToList (fmap ignoreConditions me)-+  where+    f (CondBranch _ t me) =+      ignoreConditions t+        : maybeToList (fmap ignoreConditions me)  -- | Flatten a CondTree. This will traverse the CondTree by taking all --  possible paths into account, but merging inclusive when two paths
src/Distribution/Types/Condition.hs view
@@ -1,85 +1,87 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.Condition (-    Condition(..),-    cNot,-    cAnd,-    cOr,-    simplifyCondition,-) where+module Distribution.Types.Condition+  ( Condition (..)+  , cNot+  , cAnd+  , cOr+  , simplifyCondition+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  -- | A boolean expression parameterized over the variable type used.-data Condition c = Var c-                 | Lit Bool-                 | CNot (Condition c)-                 | COr (Condition c) (Condition c)-                 | CAnd (Condition c) (Condition c)-    deriving (Show, Eq, Typeable, Data, Generic)+data Condition c+  = Var c+  | Lit Bool+  | CNot (Condition c)+  | COr (Condition c) (Condition c)+  | CAnd (Condition c) (Condition c)+  deriving (Show, Eq, Data, Generic)  -- | Boolean negation of a 'Condition' value. cNot :: Condition a -> Condition a-cNot (Lit b)  = Lit (not b)+cNot (Lit b) = Lit (not b) cNot (CNot c) = c-cNot c        = CNot c+cNot c = CNot c  -- | Boolean AND of two 'Condition' values. cAnd :: Condition a -> Condition a -> Condition a-cAnd (Lit False) _           = Lit False-cAnd _           (Lit False) = Lit False-cAnd (Lit True)  x           = x-cAnd x           (Lit True)  = x-cAnd x           y           = CAnd x y+cAnd (Lit False) _ = Lit False+cAnd _ (Lit False) = Lit False+cAnd (Lit True) x = x+cAnd x (Lit True) = x+cAnd x y = CAnd x y  -- | Boolean OR of two 'Condition' values. cOr :: Eq v => Condition v -> Condition v -> Condition v-cOr  (Lit True)  _           = Lit True-cOr  _           (Lit True)  = Lit True-cOr  (Lit False) x           = x-cOr  x           (Lit False) = x-cOr  c           (CNot d)-  | c == d                   = Lit True-cOr  (CNot c)    d-  | c == d                   = Lit True-cOr  x           y           = COr x y+cOr (Lit True) _ = Lit True+cOr _ (Lit True) = Lit True+cOr (Lit False) x = x+cOr x (Lit False) = x+cOr c (CNot d)+  | c == d = Lit True+cOr (CNot c) d+  | c == d = Lit True+cOr x y = COr x y  instance Functor Condition where-  f `fmap` Var c    = Var (f c)-  _ `fmap` Lit c    = Lit c-  f `fmap` CNot c   = CNot (fmap f c)-  f `fmap` COr c d  = COr  (fmap f c) (fmap f d)+  f `fmap` Var c = Var (f c)+  _ `fmap` Lit c = Lit c+  f `fmap` CNot c = CNot (fmap f c)+  f `fmap` COr c d = COr (fmap f c) (fmap f d)   f `fmap` CAnd c d = CAnd (fmap f c) (fmap f d)  instance Foldable Condition where-  f `foldMap` Var c    = f c-  _ `foldMap` Lit _    = mempty-  f `foldMap` CNot c   = foldMap f c-  f `foldMap` COr c d  = foldMap f c `mappend` foldMap f d+  f `foldMap` Var c = f c+  _ `foldMap` Lit _ = mempty+  f `foldMap` CNot c = foldMap f c+  f `foldMap` COr c d = foldMap f c `mappend` foldMap f d   f `foldMap` CAnd c d = foldMap f c `mappend` foldMap f d  instance Traversable Condition where-  f `traverse` Var c    = Var `fmap` f c-  _ `traverse` Lit c    = pure $ Lit c-  f `traverse` CNot c   = CNot `fmap` traverse f c-  f `traverse` COr c d  = COr  `fmap` traverse f c <*> traverse f d+  f `traverse` Var c = Var `fmap` f c+  _ `traverse` Lit c = pure $ Lit c+  f `traverse` CNot c = CNot `fmap` traverse f c+  f `traverse` COr c d = COr `fmap` traverse f c <*> traverse f d   f `traverse` CAnd c d = CAnd `fmap` traverse f c <*> traverse f d  instance Applicative Condition where-  pure  = Var+  pure = Var   (<*>) = ap  instance Monad Condition where   return = pure+   -- Terminating cases   (>>=) (Lit x) _ = Lit x   (>>=) (Var x) f = f x   -- Recursing cases-  (>>=) (CNot  x  ) f = CNot (x >>= f)-  (>>=) (COr   x y) f = COr  (x >>= f) (y >>= f)-  (>>=) (CAnd  x y) f = CAnd (x >>= f) (y >>= f)+  (>>=) (CNot x) f = CNot (x >>= f)+  (>>=) (COr x y) f = COr (x >>= f) (y >>= f)+  (>>=) (CAnd x y) f = CAnd (x >>= f) (y >>= f)  instance Monoid (Condition a) where   mempty = Lit False@@ -101,35 +103,37 @@ instance NFData c => NFData (Condition c) where rnf = genericRnf  -- | Simplify the condition and return its free variables.-simplifyCondition :: Condition c-                  -> (c -> Either d Bool)   -- ^ (partial) variable assignment-                  -> (Condition d, [d])+simplifyCondition+  :: Condition c+  -> (c -> Either d Bool)+  -- ^ (partial) variable assignment+  -> (Condition d, [d]) simplifyCondition cond i = fv . walk $ cond   where     walk cnd = case cnd of-      Var v   -> either Var Lit (i v)-      Lit b   -> Lit b-      CNot c  -> case walk c of-                   Lit True -> Lit False-                   Lit False -> Lit True-                   c' -> CNot c'+      Var v -> either Var Lit (i v)+      Lit b -> Lit b+      CNot c -> case walk c of+        Lit True -> Lit False+        Lit False -> Lit True+        c' -> CNot c'       COr c d -> case (walk c, walk d) of-                   (Lit False, d') -> d'-                   (Lit True, _)   -> Lit True-                   (c', Lit False) -> c'-                   (_, Lit True)   -> Lit True-                   (c',d')         -> COr c' d'+        (Lit False, d') -> d'+        (Lit True, _) -> Lit True+        (c', Lit False) -> c'+        (_, Lit True) -> Lit True+        (c', d') -> COr c' d'       CAnd c d -> case (walk c, walk d) of-                    (Lit False, _) -> Lit False-                    (Lit True, d') -> d'-                    (_, Lit False) -> Lit False-                    (c', Lit True) -> c'-                    (c',d')        -> CAnd c' d'+        (Lit False, _) -> Lit False+        (Lit True, d') -> d'+        (_, Lit False) -> Lit False+        (c', Lit True) -> c'+        (c', d') -> CAnd c' d'     -- gather free vars     fv c = (c, fv' c)     fv' c = case c of-      Var v     -> [v]-      Lit _      -> []-      CNot c'    -> fv' c'-      COr c1 c2  -> fv' c1 ++ fv' c2+      Var v -> [v]+      Lit _ -> []+      CNot c' -> fv' c'+      COr c1 c2 -> fv' c1 ++ fv' c2       CAnd c1 c2 -> fv' c1 ++ fv' c2
src/Distribution/Types/ConfVar.hs view
@@ -1,23 +1,25 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-module Distribution.Types.ConfVar (-    ConfVar(..),-    ) where -import Prelude ()+module Distribution.Types.ConfVar+  ( ConfVar (..)+  ) where+ import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.Flag-import Distribution.Types.VersionRange import Distribution.Compiler import Distribution.System+import Distribution.Types.Flag+import Distribution.Types.VersionRange  -- | A @ConfVar@ represents the variable type used.-data ConfVar = OS OS-             | Arch Arch-             | PackageFlag FlagName-             | Impl CompilerFlavor VersionRange-    deriving (Eq, Show, Typeable, Data, Generic)+data ConfVar+  = OS OS+  | Arch Arch+  | PackageFlag FlagName+  | Impl CompilerFlavor VersionRange+  deriving (Eq, Show, Data, Generic)  instance Binary ConfVar instance Structured ConfVar
src/Distribution/Types/Dependency.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.Dependency-  ( Dependency(..)+  ( Dependency (..)   , mkDependency   , depPkgName   , depVerRange@@ -14,11 +15,11 @@ import Prelude ()  import Distribution.Types.VersionRange (isAnyVersionLight)-import Distribution.Version            (VersionRange, anyVersion, simplifyVersionRange)+import Distribution.Version (VersionRange, anyVersion, simplifyVersionRange)  import Distribution.CabalSpecVersion-import Distribution.Compat.CharParsing        (char, spaces)-import Distribution.Compat.Parsing            (between, option)+import Distribution.Compat.CharParsing (char, spaces)+import Distribution.Compat.Parsing (between, option) import Distribution.Parsec import Distribution.Pretty import Distribution.Types.LibraryName@@ -26,25 +27,21 @@ import Distribution.Types.UnqualComponentName  import qualified Distribution.Compat.NonEmptySet as NES-import qualified Text.PrettyPrint                as PP+import qualified Text.PrettyPrint as PP  -- | Describes a dependency on a source package (API) -- -- /Invariant:/ package name does not appear as 'LSubLibName' in -- set of library names.------ /Note:/ 'Dependency' is not an instance of 'Ord', and so it cannot be used--- in 'Set' or as the key to a 'Map'.  For these and similar use cases see--- 'DependencyMap'.----data Dependency = Dependency-                    PackageName-                    VersionRange-                    (NonEmptySet LibraryName)-                    -- ^ The set of libraries required from the package.-                    -- Only the selected libraries will be built.-                    -- It does not affect the cabal-install solver yet.-                  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data Dependency+  = -- | The set of libraries required from the package.+    -- Only the selected libraries will be built.+    -- It does not affect the cabal-install solver yet.+    Dependency+      PackageName+      VersionRange+      (NonEmptySet LibraryName)+  deriving (Generic, Read, Show, Eq, Ord, Data)  depPkgName :: Dependency -> PackageName depPkgName (Dependency pn _ _) = pn@@ -61,15 +58,15 @@ -- it is automatically converted to 'LMainLibName'. -- -- @since 3.4.0.0--- mkDependency :: PackageName -> VersionRange -> NonEmptySet LibraryName -> Dependency mkDependency pn vr lb = Dependency pn vr (NES.map conv lb)   where     pn' = packageNameToUnqualComponentName pn -    conv l@LMainLibName                 = l-    conv l@(LSubLibName ln) | ln == pn' = LMainLibName-                            | otherwise = l+    conv l@LMainLibName = l+    conv l@(LSubLibName ln)+      | ln == pn' = LMainLibName+      | otherwise = l  instance Binary Dependency instance Structured Dependency@@ -81,30 +78,20 @@ -- "pkg" -- -- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.insert (LSubLibName $ mkUnqualComponentName "sublib") mainLibSet--- "pkg:{pkg, sublib}"+-- "pkg:{pkg,sublib}" -- -- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.singleton (LSubLibName $ mkUnqualComponentName "sublib") -- "pkg:sublib" -- -- >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.insert (LSubLibName $ mkUnqualComponentName "sublib-b") $ NES.singleton (LSubLibName $ mkUnqualComponentName "sublib-a")--- "pkg:{sublib-a, sublib-b}"---+-- "pkg:{sublib-a,sublib-b}" instance Pretty Dependency where-    pretty (Dependency name ver sublibs) = withSubLibs (pretty name) <+> pver-      where-        -- TODO: change to isAnyVersion after #6736-        pver | isAnyVersionLight ver = PP.empty-             | otherwise             = pretty ver--        withSubLibs doc = case NES.toList sublibs of-            [LMainLibName]   -> doc-            [LSubLibName uq] -> doc <<>> PP.colon <<>> pretty uq-            _                -> doc <<>> PP.colon <<>> PP.braces prettySublibs--        prettySublibs = PP.hsep $ PP.punctuate PP.comma $ prettySublib <$> NES.toList sublibs--        prettySublib LMainLibName     = PP.text $ unPackageName name-        prettySublib (LSubLibName un) = PP.text $ unUnqualComponentName un+  pretty (Dependency name ver sublibs) = prettyLibraryNames name (NES.toNonEmpty sublibs) <+> pver+    where+      -- TODO: change to isAnyVersion after #6736+      pver+        | isAnyVersionLight ver = PP.empty+        | otherwise = pretty ver  -- | --@@ -137,36 +124,37 @@ -- -- >>> map (`simpleParsec'` "mylib:sub") [CabalSpecV2_4, CabalSpecV3_0] :: [Maybe Dependency] -- [Nothing,Just (Dependency (PackageName "mylib") (OrLaterVersion (mkVersion [0])) (fromNonEmpty (LSubLibName (UnqualComponentName "sub") :| [])))]--- instance Parsec Dependency where-    parsec = do-        name <- parsec--        libs <- option mainLibSet $ do-          _ <- char ':'-          versionGuardMultilibs-          NES.singleton <$> parseLib <|> parseMultipleLibs+  parsec = do+    name <- parsec -        spaces -- https://github.com/haskell/cabal/issues/5846+    libs <- option mainLibSet $ do+      _ <- char ':'+      versionGuardMultilibs+      NES.singleton <$> parseLib <|> parseMultipleLibs -        ver  <- parsec <|> pure anyVersion-        return $ mkDependency name ver libs-      where-        parseLib          = LSubLibName <$> parsec-        parseMultipleLibs = between-            (char '{' *> spaces)-            (spaces *> char '}')-            (NES.fromNonEmpty <$> parsecCommaNonEmpty parseLib)+    spaces -- https://github.com/haskell/cabal/issues/5846+    ver <- parsec <|> pure anyVersion+    return $ mkDependency name ver libs+    where+      parseLib = LSubLibName <$> parsec+      parseMultipleLibs =+        between+          (char '{' *> spaces)+          (spaces *> char '}')+          (NES.fromNonEmpty <$> parsecCommaNonEmpty parseLib)  versionGuardMultilibs :: CabalParsing m => m () versionGuardMultilibs = do   csv <- askCabalSpecVersion-  when (csv < CabalSpecV3_0) $ fail $ unwords-    [ "Sublibrary dependency syntax used."-    , "To use this syntax the package needs to specify at least 'cabal-version: 3.0'."-    , "Alternatively, if you are depending on an internal library, you can write"-    , "directly the library name as it were a package."-    ]+  when (csv < CabalSpecV3_0) $+    fail $+      unwords+        [ "Sublibrary dependency syntax used."+        , "To use this syntax the package needs to specify at least 'cabal-version: 3.0'."+        , "Alternatively, if you are depending on an internal library, you can write"+        , "directly the library name as it were a package."+        ]  -- | Library set with main library. --@@ -176,7 +164,6 @@  -- | Simplify the 'VersionRange' expression in a 'Dependency'. -- See 'simplifyVersionRange'.--- simplifyDependency :: Dependency -> Dependency simplifyDependency (Dependency name range comps) =   Dependency name (simplifyVersionRange range) comps
src/Distribution/Types/DependencyMap.hs view
@@ -1,9 +1,9 @@-module Distribution.Types.DependencyMap (-    DependencyMap,-    toDepMap,-    fromDepMap,-    constrainBy,-) where+module Distribution.Types.DependencyMap+  ( DependencyMap+  , toDepMap+  , fromDepMap+  , constrainBy+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -18,40 +18,42 @@  -- | A map of dependencies.  Newtyped since the default monoid instance is not --   appropriate.  The monoid instance uses 'intersectVersionRanges'.-newtype DependencyMap = DependencyMap { unDependencyMap :: Map PackageName (VersionRange, NonEmptySet LibraryName) }+newtype DependencyMap = DependencyMap {unDependencyMap :: Map PackageName (VersionRange, NonEmptySet LibraryName)}   deriving (Show, Read, Eq)  instance Monoid DependencyMap where-    mempty = DependencyMap Map.empty-    mappend = (<>)+  mempty = DependencyMap Map.empty+  mappend = (<>)  instance Semigroup DependencyMap where-    (DependencyMap a) <> (DependencyMap b) =-        DependencyMap (Map.unionWith intersectVersionRangesAndJoinComponents a b)+  (DependencyMap a) <> (DependencyMap b) =+    DependencyMap (Map.unionWith intersectVersionRangesAndJoinComponents a b) -intersectVersionRangesAndJoinComponents :: (VersionRange, NonEmptySet LibraryName)-                                        -> (VersionRange, NonEmptySet LibraryName)-                                        -> (VersionRange, NonEmptySet LibraryName)+intersectVersionRangesAndJoinComponents+  :: (VersionRange, NonEmptySet LibraryName)+  -> (VersionRange, NonEmptySet LibraryName)+  -> (VersionRange, NonEmptySet LibraryName) intersectVersionRangesAndJoinComponents (va, ca) (vb, cb) =   (intersectVersionRanges va vb, ca <> cb)  toDepMap :: [Dependency] -> DependencyMap toDepMap ds =-  DependencyMap $ Map.fromListWith intersectVersionRangesAndJoinComponents [ (p,(vr,cs)) | Dependency p vr cs <- ds ]+  DependencyMap $ Map.fromListWith intersectVersionRangesAndJoinComponents [(p, (vr, cs)) | Dependency p vr cs <- ds]  fromDepMap :: DependencyMap -> [Dependency]-fromDepMap m = [ Dependency p vr cs | (p,(vr,cs)) <- Map.toList (unDependencyMap m) ]+fromDepMap m = [Dependency p vr cs | (p, (vr, cs)) <- Map.toList (unDependencyMap m)]  -- Apply extra constraints to a dependency map. -- Combines dependencies where the result will only contain keys from the left -- (first) map.  If a key also exists in the right map, both constraints will -- be intersected. constrainBy-    :: DependencyMap-    -> [PackageVersionConstraint]-    -> DependencyMap-constrainBy = foldl' tightenConstraint where+  :: DependencyMap+  -> [PackageVersionConstraint]+  -> DependencyMap+constrainBy = foldl' tightenConstraint+  where     tightenConstraint (DependencyMap l) (PackageVersionConstraint pn vr) = DependencyMap $-        case Map.lookup pn l of-            Nothing        -> l-            Just (vr', cs) -> Map.insert pn (intersectVersionRanges vr' vr, cs) l+      case Map.lookup pn l of+        Nothing -> l+        Just (vr', cs) -> Map.insert pn (intersectVersionRanges vr' vr, cs) l
+ src/Distribution/Types/DependencySatisfaction.hs view
@@ -0,0 +1,14 @@+module Distribution.Types.DependencySatisfaction+  ( DependencySatisfaction (..)+  ) where++import Distribution.Types.MissingDependencyReason (MissingDependencyReason)++-- | Whether or not a dependency constraint is satisfied.+data DependencySatisfaction+  = -- | The dependency constraint is satisfied.+    Satisfied+  | -- | The dependency constraint is not satisfied.+    --+    -- Includes a reason for explanation.+    Unsatisfied MissingDependencyReason
src/Distribution/Types/ExeDependency.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.ExeDependency-  ( ExeDependency(..)+  ( ExeDependency (..)   , qualifiedExeName   ) where @@ -13,18 +14,18 @@ import Distribution.Types.ComponentName import Distribution.Types.PackageName import Distribution.Types.UnqualComponentName-import Distribution.Version                   (VersionRange, anyVersion, isAnyVersion)+import Distribution.Version (VersionRange, anyVersion, isAnyVersion)  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as PP  -- | Describes a dependency on an executable from a package----data ExeDependency = ExeDependency-                     PackageName-                     UnqualComponentName -- name of executable component of package-                     VersionRange-                     deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data ExeDependency+  = ExeDependency+      PackageName+      UnqualComponentName -- name of executable component of package+      VersionRange+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary ExeDependency instance Structured ExeDependency@@ -32,10 +33,11 @@  instance Pretty ExeDependency where   pretty (ExeDependency name exe ver) =-      pretty name <<>> PP.colon <<>> pretty exe PP.<+> pver+    pretty name <<>> PP.colon <<>> pretty exe PP.<+> pver     where-      pver | isAnyVersion ver = PP.empty-           | otherwise        = pretty ver+      pver+        | isAnyVersion ver = PP.empty+        | otherwise = pretty ver  -- | --@@ -58,14 +60,13 @@ -- -- >>> simpleParsec "happy :happy >= 1.19.12" :: Maybe ExeDependency -- Nothing--- instance Parsec ExeDependency where-    parsec = do-        name <- parsec-        _    <- P.char ':'-        exe  <- lexemeParsec-        ver  <- parsec <|> pure anyVersion-        return (ExeDependency name exe ver)+  parsec = do+    name <- parsec+    _ <- P.char ':'+    exe <- lexemeParsec+    ver <- parsec <|> pure anyVersion+    return (ExeDependency name exe ver)  qualifiedExeName :: ExeDependency -> ComponentName qualifiedExeName (ExeDependency _ ucn _) = CExeName ucn
src/Distribution/Types/Executable.hs view
@@ -1,56 +1,60 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.Executable (-    Executable(..),-    emptyExecutable,-    exeModules,-    exeModulesAutogen-) where+module Distribution.Types.Executable+  ( Executable (..)+  , emptyExecutable+  , exeModules+  , exeModulesAutogen+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () +import Distribution.ModuleName import Distribution.Types.BuildInfo-import Distribution.Types.UnqualComponentName import Distribution.Types.ExecutableScope-import Distribution.ModuleName+import Distribution.Types.UnqualComponentName+import Distribution.Utils.Path  import qualified Distribution.Types.BuildInfo.Lens as L -data Executable = Executable {-        exeName    :: UnqualComponentName,-        modulePath :: FilePath,-        exeScope   :: ExecutableScope,-        buildInfo  :: BuildInfo-    }-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data Executable = Executable+  { exeName :: UnqualComponentName+  , modulePath :: RelativePath Source File+  , exeScope :: ExecutableScope+  , buildInfo :: BuildInfo+  }+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance L.HasBuildInfo Executable where-    buildInfo f l = (\x -> l { buildInfo = x }) <$> f (buildInfo l)+  buildInfo f l = (\x -> l{buildInfo = x}) <$> f (buildInfo l)  instance Binary Executable instance Structured Executable instance NFData Executable where rnf = genericRnf  instance Monoid Executable where-  mempty = gmempty+  mempty =+    Executable+      { exeName = mempty+      , modulePath = unsafeMakeSymbolicPath ""+      , exeScope = mempty+      , buildInfo = mempty+      }   mappend = (<>)  instance Semigroup Executable where-  a <> b = Executable{-    exeName    = combine' exeName,-    modulePath = combine modulePath,-    exeScope   = combine exeScope,-    buildInfo  = combine buildInfo-  }-    where combine field = field a `mappend` field b-          combine' field = case ( unUnqualComponentName $ field a-                                , unUnqualComponentName $ field b) of-                      ("", _) -> field b-                      (_, "") -> field a-                      (x, y) -> error $ "Ambiguous values for executable field: '"-                                  ++ x ++ "' and '" ++ y ++ "'"+  a <> b =+    Executable+      { exeName = combineNames a b exeName "executable"+      , modulePath = unsafeMakeSymbolicPath $ combineNames a b (getSymbolicPath . modulePath) "modulePath"+      , exeScope = combine exeScope+      , buildInfo = combine buildInfo+      }+    where+      combine field = field a `mappend` field b  emptyExecutable :: Executable emptyExecutable = mempty
src/Distribution/Types/Executable/Lens.hs view
@@ -1,31 +1,34 @@-module Distribution.Types.Executable.Lens (-    Executable,-    module Distribution.Types.Executable.Lens,-    ) where+{-# LANGUAGE DataKinds #-} +module Distribution.Types.Executable.Lens+  ( Executable+  , module Distribution.Types.Executable.Lens+  ) where+ import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Types.BuildInfo           (BuildInfo)-import Distribution.Types.Executable          (Executable)-import Distribution.Types.ExecutableScope     (ExecutableScope)+import Distribution.Types.BuildInfo (BuildInfo)+import Distribution.Types.Executable (Executable)+import Distribution.Types.ExecutableScope (ExecutableScope) import Distribution.Types.UnqualComponentName (UnqualComponentName)+import Distribution.Utils.Path  import qualified Distribution.Types.Executable as T  exeName :: Lens' Executable UnqualComponentName-exeName f s = fmap (\x -> s { T.exeName = x }) (f (T.exeName s))+exeName f s = fmap (\x -> s{T.exeName = x}) (f (T.exeName s)) {-# INLINE exeName #-} -modulePath :: Lens' Executable String-modulePath f s = fmap (\x -> s { T.modulePath = x }) (f (T.modulePath s))+modulePath :: Lens' Executable (RelativePath Source File)+modulePath f s = fmap (\x -> s{T.modulePath = x}) (f (T.modulePath s)) {-# INLINE modulePath #-}  exeScope :: Lens' Executable ExecutableScope-exeScope f s = fmap (\x -> s { T.exeScope = x }) (f (T.exeScope s))+exeScope f s = fmap (\x -> s{T.exeScope = x}) (f (T.exeScope s)) {-# INLINE exeScope #-}  exeBuildInfo :: Lens' Executable BuildInfo-exeBuildInfo f s = fmap (\x -> s { T.buildInfo = x }) (f (T.buildInfo s))+exeBuildInfo f s = fmap (\x -> s{T.buildInfo = x}) (f (T.buildInfo s)) {-# INLINE exeBuildInfo #-}
src/Distribution/Types/ExecutableScope.hs view
@@ -2,31 +2,33 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.ExecutableScope (-    ExecutableScope(..),-) where+module Distribution.Types.ExecutableScope+  ( ExecutableScope (..)+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp -data ExecutableScope = ExecutablePublic-                     | ExecutablePrivate-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data ExecutableScope+  = ExecutablePublic+  | ExecutablePrivate+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Pretty ExecutableScope where-    pretty ExecutablePublic       = Disp.text "public"-    pretty ExecutablePrivate      = Disp.text "private"+  pretty ExecutablePublic = Disp.text "public"+  pretty ExecutablePrivate = Disp.text "private"  instance Parsec ExecutableScope where-    parsec = P.try pub <|> pri where-        pub = ExecutablePublic  <$ P.string "public"-        pri = ExecutablePrivate <$ P.string "private"+  parsec = P.try pub <|> pri+    where+      pub = ExecutablePublic <$ P.string "public"+      pri = ExecutablePrivate <$ P.string "private"  instance Binary ExecutableScope instance Structured ExecutableScope@@ -34,10 +36,10 @@  -- | 'Any' like semigroup, where 'ExecutablePrivate' is 'Any True' instance Semigroup ExecutableScope where-    ExecutablePublic    <> x = x-    x@ExecutablePrivate <> _ = x+  ExecutablePublic <> x = x+  x@ExecutablePrivate <> _ = x  -- | 'mempty' = 'ExecutablePublic' instance Monoid ExecutableScope where-    mempty = ExecutablePublic-    mappend = (<>)+  mempty = ExecutablePublic+  mappend = (<>)
src/Distribution/Types/ExposedModule.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.ExposedModule where  import Distribution.Compat.Prelude@@ -11,34 +11,34 @@ import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp -data ExposedModule-   = ExposedModule {-       exposedName      :: ModuleName,-       exposedReexport  :: Maybe OpenModule-     }-  deriving (Eq, Generic, Read, Show, Typeable)+data ExposedModule = ExposedModule+  { exposedName :: ModuleName+  , exposedReexport :: Maybe OpenModule+  }+  deriving (Eq, Generic, Read, Show)  instance Pretty ExposedModule where-    pretty (ExposedModule m reexport) =-        Disp.hsep [ pretty m-                  , case reexport of-                     Just m' -> Disp.hsep [Disp.text "from", pretty m']-                     Nothing -> Disp.empty-                  ]+  pretty (ExposedModule m reexport) =+    Disp.hsep+      [ pretty m+      , case reexport of+          Just m' -> Disp.hsep [Disp.text "from", pretty m']+          Nothing -> Disp.empty+      ]  instance Parsec ExposedModule where-    parsec = do-        m <- parsecMaybeQuoted parsec-        P.spaces+  parsec = do+    m <- parsecMaybeQuoted parsec+    P.spaces -        reexport <- P.optional $ do-            _ <- P.string "from"-            P.skipSpaces1-            parsec+    reexport <- P.optional $ do+      _ <- P.string "from"+      P.skipSpaces1+      parsec -        return (ExposedModule m reexport)+    return (ExposedModule m reexport)  instance Binary ExposedModule instance Structured ExposedModule
src/Distribution/Types/Flag.hs view
@@ -1,45 +1,49 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}-module Distribution.Types.Flag (-    -- * Package flag-    PackageFlag(..),-    emptyFlag,++module Distribution.Types.Flag+  ( -- * Package flag+    PackageFlag (..)+  , emptyFlag+     -- * Flag name-    FlagName,-    mkFlagName,-    unFlagName,+  , FlagName+  , mkFlagName+  , unFlagName+     -- * Flag assignment-    FlagAssignment,-    mkFlagAssignment,-    unFlagAssignment,-    lookupFlagAssignment,-    insertFlagAssignment,-    diffFlagAssignment,-    findDuplicateFlagAssignments,-    nullFlagAssignment,-    showFlagValue,-    dispFlagAssignment,-    showFlagAssignment,-    parsecFlagAssignment,-    parsecFlagAssignmentNonEmpty,+  , FlagAssignment+  , mkFlagAssignment+  , unFlagAssignment+  , lookupFlagAssignment+  , insertFlagAssignment+  , diffFlagAssignment+  , findDuplicateFlagAssignments+  , nullFlagAssignment+  , showFlagValue+  , dispFlagAssignment+  , showFlagAssignment+  , parsecFlagAssignment+  , parsecFlagAssignmentNonEmpty+     -- ** Legacy formats-    legacyShowFlagAssignment,-    legacyShowFlagAssignment',-    legacyParsecFlagAssignment,-    ) where+  , legacyShowFlagAssignment+  , legacyShowFlagAssignment'+  , legacyParsecFlagAssignment+  ) where -import Prelude () import Distribution.Compat.Prelude-import Distribution.Utils.ShortText import Distribution.Utils.Generic (lowercase)+import Distribution.Utils.ShortText+import Prelude ()  import Distribution.Parsec import Distribution.Pretty  import qualified Data.Map as Map-import qualified Text.PrettyPrint as Disp import qualified Distribution.Compat.CharParsing as P+import qualified Text.PrettyPrint as Disp  -- ----------------------------------------------------------------------------- -- The Flag' type@@ -47,12 +51,12 @@ -- | A flag can represent a feature to be included, or a way of linking --   a target against its dependencies, or in fact whatever you can think of. data PackageFlag = MkPackageFlag-    { flagName        :: FlagName-    , flagDescription :: String-    , flagDefault     :: Bool-    , flagManual      :: Bool-    }-    deriving (Show, Eq, Typeable, Data, Generic)+  { flagName :: FlagName+  , flagDescription :: String+  , flagDefault :: Bool+  , flagManual :: Bool+  }+  deriving (Show, Eq, Data, Generic)  instance Binary PackageFlag instance Structured PackageFlag@@ -60,11 +64,12 @@  -- | A 'PackageFlag' initialized with default parameters. emptyFlag :: FlagName -> PackageFlag-emptyFlag name = MkPackageFlag-    { flagName        = name+emptyFlag name =+  MkPackageFlag+    { flagName = name     , flagDescription = ""-    , flagDefault     = True-    , flagManual      = False+    , flagDefault = True+    , flagManual = False     }  -- | A 'FlagName' is the name of a user-defined configuration flag@@ -75,7 +80,7 @@ -- -- @since 2.0.0.2 newtype FlagName = FlagName ShortText-    deriving (Eq, Generic, Ord, Show, Read, Typeable, Data, NFData)+  deriving (Eq, Generic, Ord, Show, Read, Data, NFData)  -- | Construct a 'FlagName' from a 'String' --@@ -92,7 +97,7 @@ -- -- @since 2.0.0.2 instance IsString FlagName where-    fromString = mkFlagName+  fromString = mkFlagName  -- | Convert 'FlagName' to 'String' --@@ -104,16 +109,16 @@ instance Structured FlagName  instance Pretty FlagName where-    pretty = Disp.text . unFlagName+  pretty = Disp.text . unFlagName  instance Parsec FlagName where-    -- Note:  we don't check that FlagName doesn't have leading dash,-    -- cabal check will do that.-    parsec = mkFlagName . lowercase <$> parsec'-      where-        parsec' = (:) <$> lead <*> rest-        lead = P.satisfy (\c ->  isAlphaNum c || c == '_')-        rest = P.munch (\c -> isAlphaNum c ||  c == '_' || c == '-')+  -- Note:  we don't check that FlagName doesn't have leading dash,+  -- cabal check will do that.+  parsec = mkFlagName . lowercase <$> parsec'+    where+      parsec' = (:) <$> lead <*> rest+      lead = P.satisfy (\c -> isAlphaNum c || c == '_')+      rest = P.munch (\c -> isAlphaNum c || c == '_' || c == '-')  -- | A 'FlagAssignment' is a total or partial mapping of 'FlagName's to -- 'Bool' flag values. It represents the flags chosen by the user or@@ -121,26 +126,23 @@ -- becomes @[("foo", True), ("bar", False)]@ -- -- TODO: Why we record the multiplicity of the flag?----newtype FlagAssignment-  = FlagAssignment { getFlagAssignment :: Map.Map FlagName (Int, Bool) }-  deriving (Binary, Generic, NFData, Typeable)+newtype FlagAssignment = FlagAssignment {getFlagAssignment :: Map.Map FlagName (Int, Bool)}+  deriving (Binary, Generic, NFData)  instance Structured FlagAssignment  instance Eq FlagAssignment where-  (==) (FlagAssignment m1) (FlagAssignment m2)-    = fmap snd m1 == fmap snd m2+  (==) (FlagAssignment m1) (FlagAssignment m2) =+    fmap snd m1 == fmap snd m2  instance Ord FlagAssignment where-  compare (FlagAssignment m1) (FlagAssignment m2)-    = fmap snd m1 `compare` fmap snd m2+  compare (FlagAssignment m1) (FlagAssignment m2) =+    fmap snd m1 `compare` fmap snd m2  -- | Combines pairs of values contained in the 'FlagAssignment' Map. -- -- The last flag specified takes precedence, and we record the number -- of times we have seen the flag.--- combineFlagValues :: (Int, Bool) -> (Int, Bool) -> (Int, Bool) combineFlagValues (c1, _) (c2, b2) = (c1 + c2, b2) @@ -151,8 +153,8 @@ -- specified so that we have the option of warning the user about -- supplying duplicate flags. instance Semigroup FlagAssignment where-  (<>) (FlagAssignment m1) (FlagAssignment m2)-    = FlagAssignment (Map.unionWith combineFlagValues m1 m2)+  (<>) (FlagAssignment m1) (FlagAssignment m2) =+    FlagAssignment (Map.unionWith combineFlagValues m1 m2)  instance Monoid FlagAssignment where   mempty = FlagAssignment Map.empty@@ -166,8 +168,9 @@ -- @since 2.2.0 mkFlagAssignment :: [(FlagName, Bool)] -> FlagAssignment mkFlagAssignment =-  FlagAssignment .-  Map.fromListWith (flip combineFlagValues) . fmap (fmap (\b -> (1, b)))+  FlagAssignment+    . Map.fromListWith (flip combineFlagValues)+    . fmap (fmap (\b -> (1, b)))  -- | Deconstruct a 'FlagAssignment' into a list of flag/value pairs. --@@ -204,8 +207,9 @@ -- flag; rather than enforcing uniqueness at construction, it's -- verified later on via `D.C.Dependency.configuredPackageProblems` insertFlagAssignment flag val =-  FlagAssignment .-  Map.insertWith (flip combineFlagValues) flag (1, val) .  getFlagAssignment+  FlagAssignment+    . Map.insertWith (flip combineFlagValues) flag (1, val)+    . getFlagAssignment  -- | Remove all flag-assignments from the first 'FlagAssignment' that -- are contained in the second 'FlagAssignment'@@ -217,8 +221,9 @@ -- -- @since 2.2.0 diffFlagAssignment :: FlagAssignment -> FlagAssignment -> FlagAssignment-diffFlagAssignment fa1 fa2 = FlagAssignment-  (Map.difference (getFlagAssignment fa1) (getFlagAssignment fa2))+diffFlagAssignment fa1 fa2 =+  FlagAssignment+    (Map.difference (getFlagAssignment fa1) (getFlagAssignment fa2))  -- | Find the 'FlagName's that have been listed more than once. --@@ -229,20 +234,20 @@  -- | @since 2.2.0 instance Read FlagAssignment where-    readsPrec p s = [ (FlagAssignment x, rest) | (x,rest) <- readsPrec p s ]+  readsPrec p s = [(FlagAssignment x, rest) | (x, rest) <- readsPrec p s]  -- | @since 2.2.0 instance Show FlagAssignment where-    showsPrec p (FlagAssignment xs) = showsPrec p xs+  showsPrec p (FlagAssignment xs) = showsPrec p xs  -- | String representation of a flag-value pair. showFlagValue :: (FlagName, Bool) -> String-showFlagValue (f, True)   = '+' : unFlagName f-showFlagValue (f, False)  = '-' : unFlagName f+showFlagValue (f, True) = '+' : unFlagName f+showFlagValue (f, False) = '-' : unFlagName f  -- | @since 3.4.0.0 instance Pretty FlagAssignment where-    pretty = dispFlagAssignment+  pretty = dispFlagAssignment  -- | --@@ -273,33 +278,31 @@ -- Nothing -- -- @since 3.4.0.0--- instance Parsec FlagAssignment where-    parsec = parsecFlagAssignment+  parsec = parsecFlagAssignment  -- | Pretty-prints a flag assignment. dispFlagAssignment :: FlagAssignment -> Disp.Doc dispFlagAssignment = Disp.hsep . map (Disp.text . showFlagValue) . unFlagAssignment -- -- | Parses a flag assignment. parsecFlagAssignment :: CabalParsing m => m FlagAssignment parsecFlagAssignment = mkFlagAssignment <$> sepByEnding (onFlag <|> offFlag) P.skipSpaces1   where     onFlag = do-        _ <- P.char '+'-        f <- parsec-        return (f, True)+      _ <- P.char '+'+      f <- parsec+      return (f, True)     offFlag = do-        _ <- P.char '-'-        f <- parsec-        return (f, False)+      _ <- P.char '-'+      f <- parsec+      return (f, False)      sepByEnding :: CabalParsing m => m a -> m b -> m [a]-    sepByEnding p sep = afterSeparator where-        element        = (:) <$> p <*> afterElement-        afterElement   = sep *> afterSeparator <|> pure []+    sepByEnding p sep = afterSeparator+      where+        element = (:) <$> p <*> afterElement+        afterElement = sep *> afterSeparator <|> pure []         afterSeparator = element <|> pure []  -- | Parse a non-empty flag assignment@@ -311,18 +314,19 @@ parsecFlagAssignmentNonEmpty = mkFlagAssignment <$> sepByEnding1 (onFlag <|> offFlag) P.skipSpaces1   where     onFlag = do-        _ <- P.char '+'-        f <- parsec-        return (f, True)+      _ <- P.char '+'+      f <- parsec+      return (f, True)     offFlag = do-        _ <- P.char '-'-        f <- parsec-        return (f, False)+      _ <- P.char '-'+      f <- parsec+      return (f, False)      sepByEnding1 :: CabalParsing m => m a -> m b -> m [a]-    sepByEnding1 p sep = element where-        element        = (:) <$> p <*> afterElement-        afterElement   = sep *> afterSeparator <|> pure []+    sepByEnding1 p sep = element+      where+        element = (:) <$> p <*> afterElement+        afterElement = sep *> afterSeparator <|> pure []         afterSeparator = element <|> pure []  -- | Show flag assignment.@@ -340,7 +344,7 @@ -- @since 3.4.0.0 legacyShowFlagAssignment :: FlagAssignment -> String legacyShowFlagAssignment =-    prettyShow .  Disp.hsep . map Disp.text . legacyShowFlagAssignment'+  prettyShow . Disp.hsep . map Disp.text . legacyShowFlagAssignment'  -- | @since 3.4.0.0 legacyShowFlagAssignment' :: FlagAssignment -> [String]@@ -348,22 +352,23 @@  -- | @since 3.4.0.0 legacyShowFlagValue :: (FlagName, Bool) -> String-legacyShowFlagValue (f, True)   =       unFlagName f-legacyShowFlagValue (f, False)  = '-' : unFlagName f+legacyShowFlagValue (f, True) = unFlagName f+legacyShowFlagValue (f, False) = '-' : unFlagName f  -- | -- We need this as far as we support custom setups older than 2.2.0.0 -- -- @since 3.4.0.0 legacyParsecFlagAssignment :: CabalParsing m => m FlagAssignment-legacyParsecFlagAssignment = mkFlagAssignment <$>-                       P.sepBy (onFlag <|> offFlag) P.skipSpaces1+legacyParsecFlagAssignment =+  mkFlagAssignment+    <$> P.sepBy (onFlag <|> offFlag) P.skipSpaces1   where     onFlag = do-        _ <- P.optional (P.char '+')-        f <- parsec-        return (f, True)+      _ <- P.optional (P.char '+')+      f <- parsec+      return (f, True)     offFlag = do-        _ <- P.char '-'-        f <- parsec-        return (f, False)+      _ <- P.char '-'+      f <- parsec+      return (f, False)
src/Distribution/Types/ForeignLib.hs view
@@ -1,20 +1,20 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}--module Distribution.Types.ForeignLib(-    ForeignLib(..),-    emptyForeignLib,-    foreignLibModules,-    foreignLibIsShared,-    foreignLibVersion,+{-# LANGUAGE DeriveGeneric #-} -    LibVersionInfo,-    mkLibVersionInfo,-    libVersionInfoCRA,-    libVersionNumber,-    libVersionNumberShow,-    libVersionMajor-) where+module Distribution.Types.ForeignLib+  ( ForeignLib (..)+  , emptyForeignLib+  , foreignLibModules+  , foreignLibIsShared+  , foreignLibVersion+  , LibVersionInfo+  , mkLibVersionInfo+  , libVersionInfoCRA+  , libVersionNumber+  , libVersionNumberShow+  , libVersionMajor+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -27,79 +27,81 @@ import Distribution.Types.ForeignLibOption import Distribution.Types.ForeignLibType import Distribution.Types.UnqualComponentName+import Distribution.Utils.Path import Distribution.Version +import Data.Monoid import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp-import qualified Text.Read                       as Read+import qualified Text.PrettyPrint as Disp+import qualified Text.Read as Read  import qualified Distribution.Types.BuildInfo.Lens as L  -- | A foreign library stanza is like a library stanza, except that -- the built code is intended for consumption by a non-Haskell client.-data ForeignLib = ForeignLib {-      -- | Name of the foreign library-      foreignLibName       :: UnqualComponentName-      -- | What kind of foreign library is this (static or dynamic).-    , foreignLibType       :: ForeignLibType-      -- | What options apply to this foreign library (e.g., are we-      -- merging in all foreign dependencies.)-    , foreignLibOptions    :: [ForeignLibOption]-      -- | Build information for this foreign library.-    , foreignLibBuildInfo  :: BuildInfo-      -- | Libtool-style version-info data to compute library version.-      -- Refer to the libtool documentation on the-      -- current:revision:age versioning scheme.-    , foreignLibVersionInfo :: Maybe LibVersionInfo-      -- | Linux library version-    , foreignLibVersionLinux :: Maybe Version--      -- | (Windows-specific) module definition files-      ---      -- This is a list rather than a maybe field so that we can flatten-      -- the condition trees (for instance, when creating an sdist)-    , foreignLibModDefFile :: [FilePath]-    }-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data ForeignLib = ForeignLib+  { foreignLibName :: UnqualComponentName+  -- ^ Name of the foreign library+  , foreignLibType :: ForeignLibType+  -- ^ What kind of foreign library is this (static or dynamic).+  , foreignLibOptions :: [ForeignLibOption]+  -- ^ What options apply to this foreign library (e.g., are we+  -- merging in all foreign dependencies.)+  , foreignLibBuildInfo :: BuildInfo+  -- ^ Build information for this foreign library.+  , foreignLibVersionInfo :: Maybe LibVersionInfo+  -- ^ Libtool-style version-info data to compute library version.+  -- Refer to the libtool documentation on the+  -- current:revision:age versioning scheme.+  , foreignLibVersionLinux :: Maybe Version+  -- ^ Linux library version+  , foreignLibModDefFile :: [RelativePath Source File]+  -- ^ (Windows-specific) module definition files+  --+  -- This is a list rather than a maybe field so that we can flatten+  -- the condition trees (for instance, when creating an sdist)+  }+  deriving (Generic, Show, Read, Eq, Ord, Data) -data LibVersionInfo = LibVersionInfo Int Int Int deriving (Data, Eq, Generic, Typeable)+data LibVersionInfo = LibVersionInfo Int Int Int deriving (Data, Eq, Generic)  instance Ord LibVersionInfo where-    LibVersionInfo c r _ `compare` LibVersionInfo c' r' _ =-        case c `compare` c' of-            EQ -> r `compare` r'-            e  -> e+  LibVersionInfo c r _ `compare` LibVersionInfo c' r' _ =+    case c `compare` c' of+      EQ -> r `compare` r'+      e -> e  instance Show LibVersionInfo where-    showsPrec d (LibVersionInfo c r a) = showParen (d > 10)-        $ showString "mkLibVersionInfo "-        . showsPrec 11 (c,r,a)+  showsPrec d (LibVersionInfo c r a) =+    showParen (d > 10) $+      showString "mkLibVersionInfo "+        . showsPrec 11 (c, r, a)  instance Read LibVersionInfo where-    readPrec = Read.parens $ do-        Read.Ident "mkLibVersionInfo" <- Read.lexP-        t <- Read.step Read.readPrec-        return (mkLibVersionInfo t)+  readPrec = Read.parens $ do+    Read.Ident "mkLibVersionInfo" <- Read.lexP+    t <- Read.step Read.readPrec+    return (mkLibVersionInfo t)  instance Binary LibVersionInfo instance Structured LibVersionInfo instance NFData LibVersionInfo where rnf = genericRnf  instance Pretty LibVersionInfo where-    pretty (LibVersionInfo c r a)-      = Disp.hcat $ Disp.punctuate (Disp.char ':') $ map Disp.int [c,r,a]+  pretty (LibVersionInfo c r a) =+    Disp.hcat $ Disp.punctuate (Disp.char ':') $ map Disp.int [c, r, a]  instance Parsec LibVersionInfo where-    parsec = do-        c <- P.integral-        (r, a) <- P.option (0,0) $ do-            _ <- P.char ':'-            r <- P.integral-            a <- P.option 0 $ do-                _ <- P.char ':'-                P.integral-            return (r,a)-        return $ mkLibVersionInfo (c,r,a)+  parsec = do+    c <- P.integral+    (r, a) <- P.option (0, 0) $ do+      _ <- P.char ':'+      r <- P.integral+      a <- P.option 0 $ do+        _ <- P.char ':'+        P.integral+      return (r, a)+    return $ mkLibVersionInfo (c, r, a)  -- | Construct 'LibVersionInfo' from @(current, revision, age)@ -- numbers.@@ -109,64 +111,62 @@ -- -- All version components must be non-negative. mkLibVersionInfo :: (Int, Int, Int) -> LibVersionInfo-mkLibVersionInfo (c,r,a) = LibVersionInfo c r a+mkLibVersionInfo (c, r, a) = LibVersionInfo c r a  -- | From a given 'LibVersionInfo', extract the @(current, revision, -- age)@ numbers. libVersionInfoCRA :: LibVersionInfo -> (Int, Int, Int)-libVersionInfoCRA (LibVersionInfo c r a) = (c,r,a)+libVersionInfoCRA (LibVersionInfo c r a) = (c, r, a)  -- | Given a version-info field, produce a @major.minor.build@ version libVersionNumber :: LibVersionInfo -> (Int, Int, Int)-libVersionNumber (LibVersionInfo c r a) = (c-a , a , r)+libVersionNumber (LibVersionInfo c r a) = (c - a, a, r)  -- | Given a version-info field, return @"major.minor.build"@ as a -- 'String' libVersionNumberShow :: LibVersionInfo -> String libVersionNumberShow v =-    let (major, minor, build) = libVersionNumber v-    in show major ++ "." ++ show minor ++ "." ++ show build+  let (major, minor, build) = libVersionNumber v+   in show major ++ "." ++ show minor ++ "." ++ show build  -- | Return the @major@ version of a version-info field. libVersionMajor :: LibVersionInfo -> Int-libVersionMajor (LibVersionInfo c _ a) = c-a+libVersionMajor (LibVersionInfo c _ a) = c - a  instance L.HasBuildInfo ForeignLib where-    buildInfo f l = (\x -> l { foreignLibBuildInfo = x }) <$> f (foreignLibBuildInfo l)+  buildInfo f l = (\x -> l{foreignLibBuildInfo = x}) <$> f (foreignLibBuildInfo l)  instance Binary ForeignLib instance Structured ForeignLib instance NFData ForeignLib where rnf = genericRnf  instance Semigroup ForeignLib where-  a <> b = ForeignLib {-      foreignLibName         = combine'  foreignLibName-    , foreignLibType         = combine   foreignLibType-    , foreignLibOptions      = combine   foreignLibOptions-    , foreignLibBuildInfo    = combine   foreignLibBuildInfo-    , foreignLibVersionInfo  = combine'' foreignLibVersionInfo-    , foreignLibVersionLinux = combine'' foreignLibVersionLinux-    , foreignLibModDefFile   = combine   foreignLibModDefFile-    }-    where combine field = field a `mappend` field b-          combine' field = case ( unUnqualComponentName $ field a-                                , unUnqualComponentName $ field b) of-            ("", _) -> field b-            (_, "") -> field a-            (x, y) -> error $ "Ambiguous values for executable field: '"-                                  ++ x ++ "' and '" ++ y ++ "'"-          combine'' field = field b+  a <> b =+    ForeignLib+      { foreignLibName = combineNames a b foreignLibName "foreign library"+      , foreignLibType = combine foreignLibType+      , foreignLibOptions = combine foreignLibOptions+      , foreignLibBuildInfo = combine foreignLibBuildInfo+      , foreignLibVersionInfo = chooseLast foreignLibVersionInfo+      , foreignLibVersionLinux = chooseLast foreignLibVersionLinux+      , foreignLibModDefFile = combine foreignLibModDefFile+      }+    where+      combine field = field a `mappend` field b+      -- chooseLast: the second field overrides the first, unless it is Nothing+      chooseLast field = getLast (Last (field a) <> Last (field b))  instance Monoid ForeignLib where-  mempty = ForeignLib {-      foreignLibName         = mempty-    , foreignLibType         = ForeignLibTypeUnknown-    , foreignLibOptions      = []-    , foreignLibBuildInfo    = mempty-    , foreignLibVersionInfo  = Nothing-    , foreignLibVersionLinux = Nothing-    , foreignLibModDefFile   = []-    }+  mempty =+    ForeignLib+      { foreignLibName = mempty+      , foreignLibType = ForeignLibTypeUnknown+      , foreignLibOptions = []+      , foreignLibBuildInfo = mempty+      , foreignLibVersionInfo = Nothing+      , foreignLibVersionLinux = Nothing+      , foreignLibModDefFile = []+      }   mappend = (<>)  -- | An empty foreign library.@@ -189,11 +189,11 @@ foreignLibVersion :: ForeignLib -> OS -> [Int] foreignLibVersion flib Linux =   case foreignLibVersionLinux flib of-    Just v  -> versionNumbers v+    Just v -> versionNumbers v     Nothing ->       case foreignLibVersionInfo flib of         Just v' ->           let (major, minor, build) = libVersionNumber v'-          in [major, minor, build]+           in [major, minor, build]         Nothing -> [] foreignLibVersion _ _ = []
src/Distribution/Types/ForeignLib/Lens.hs view
@@ -1,45 +1,48 @@-module Distribution.Types.ForeignLib.Lens (-    ForeignLib,-    module Distribution.Types.ForeignLib.Lens,-    ) where+{-# LANGUAGE DataKinds #-} +module Distribution.Types.ForeignLib.Lens+  ( ForeignLib+  , module Distribution.Types.ForeignLib.Lens+  ) where+ import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Types.BuildInfo           (BuildInfo)-import Distribution.Types.ForeignLib          (ForeignLib, LibVersionInfo)-import Distribution.Types.ForeignLibOption    (ForeignLibOption)-import Distribution.Types.ForeignLibType      (ForeignLibType)+import Distribution.Types.BuildInfo (BuildInfo)+import Distribution.Types.ForeignLib (ForeignLib, LibVersionInfo)+import Distribution.Types.ForeignLibOption (ForeignLibOption)+import Distribution.Types.ForeignLibType (ForeignLibType) import Distribution.Types.UnqualComponentName (UnqualComponentName)-import Distribution.Version                   (Version)+import Distribution.Utils.Path+import Distribution.Version (Version)  import qualified Distribution.Types.ForeignLib as T  foreignLibName :: Lens' ForeignLib UnqualComponentName-foreignLibName f s = fmap (\x -> s { T.foreignLibName = x }) (f (T.foreignLibName s))+foreignLibName f s = fmap (\x -> s{T.foreignLibName = x}) (f (T.foreignLibName s)) {-# INLINE foreignLibName #-}  foreignLibType :: Lens' ForeignLib ForeignLibType-foreignLibType f s = fmap (\x -> s { T.foreignLibType = x }) (f (T.foreignLibType s))+foreignLibType f s = fmap (\x -> s{T.foreignLibType = x}) (f (T.foreignLibType s)) {-# INLINE foreignLibType #-}  foreignLibOptions :: Lens' ForeignLib [ForeignLibOption]-foreignLibOptions f s = fmap (\x -> s { T.foreignLibOptions = x }) (f (T.foreignLibOptions s))+foreignLibOptions f s = fmap (\x -> s{T.foreignLibOptions = x}) (f (T.foreignLibOptions s)) {-# INLINE foreignLibOptions #-}  foreignLibBuildInfo :: Lens' ForeignLib BuildInfo-foreignLibBuildInfo f s = fmap (\x -> s { T.foreignLibBuildInfo = x }) (f (T.foreignLibBuildInfo s))+foreignLibBuildInfo f s = fmap (\x -> s{T.foreignLibBuildInfo = x}) (f (T.foreignLibBuildInfo s)) {-# INLINE foreignLibBuildInfo #-}  foreignLibVersionInfo :: Lens' ForeignLib (Maybe LibVersionInfo)-foreignLibVersionInfo f s = fmap (\x -> s { T.foreignLibVersionInfo = x }) (f (T.foreignLibVersionInfo s))+foreignLibVersionInfo f s = fmap (\x -> s{T.foreignLibVersionInfo = x}) (f (T.foreignLibVersionInfo s)) {-# INLINE foreignLibVersionInfo #-}  foreignLibVersionLinux :: Lens' ForeignLib (Maybe Version)-foreignLibVersionLinux f s = fmap (\x -> s { T.foreignLibVersionLinux = x }) (f (T.foreignLibVersionLinux s))+foreignLibVersionLinux f s = fmap (\x -> s{T.foreignLibVersionLinux = x}) (f (T.foreignLibVersionLinux s)) {-# INLINE foreignLibVersionLinux #-} -foreignLibModDefFile :: Lens' ForeignLib [FilePath]-foreignLibModDefFile f s = fmap (\x -> s { T.foreignLibModDefFile = x }) (f (T.foreignLibModDefFile s))+foreignLibModDefFile :: Lens' ForeignLib [RelativePath Source File]+foreignLibModDefFile f s = fmap (\x -> s{T.foreignLibModDefFile = x}) (f (T.foreignLibModDefFile s)) {-# INLINE foreignLibModDefFile #-}
src/Distribution/Types/ForeignLibOption.hs view
@@ -2,27 +2,27 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.ForeignLibOption(-    ForeignLibOption(..)-) where+module Distribution.Types.ForeignLibOption+  ( ForeignLibOption (..)+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp -data ForeignLibOption =-     -- | Merge in all dependent libraries (i.e., use-     -- @ghc -shared -static@ rather than just record-     -- the dependencies, ala @ghc -shared -dynamic@).-     -- This option is compulsory on Windows and unsupported-     -- on other platforms.-     ForeignLibStandalone-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data ForeignLibOption+  = -- | Merge in all dependent libraries (i.e., use+    -- @ghc -shared -static@ rather than just record+    -- the dependencies, ala @ghc -shared -dynamic@).+    -- This option is compulsory on Windows and unsupported+    -- on other platforms.+    ForeignLibStandalone+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Pretty ForeignLibOption where   pretty ForeignLibStandalone = Disp.text "standalone"@@ -32,7 +32,7 @@     name <- P.munch1 (\c -> isAlphaNum c || c == '-')     case name of       "standalone" -> return ForeignLibStandalone-      _            -> fail "unrecognized foreign-library option"+      _ -> fail "unrecognized foreign-library option"  instance Binary ForeignLibOption instance Structured ForeignLibOption
src/Distribution/Types/ForeignLibType.hs view
@@ -2,37 +2,37 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.ForeignLibType(-    ForeignLibType(..),-    knownForeignLibTypes,-    foreignLibTypeIsShared,-) where+module Distribution.Types.ForeignLibType+  ( ForeignLibType (..)+  , knownForeignLibTypes+  , foreignLibTypeIsShared+  ) where -import Prelude () import Distribution.Compat.Prelude import Distribution.PackageDescription.Utils+import Prelude () -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp  -- | What kind of foreign library is to be built?-data ForeignLibType =-      -- | A native shared library (@.so@ on Linux, @.dylib@ on OSX, or-      -- @.dll@ on Windows).-      ForeignLibNativeShared-      -- | A native static library (not currently supported.)-    | ForeignLibNativeStatic-      -- TODO: Maybe this should record a string?-    | ForeignLibTypeUnknown-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data ForeignLibType+  = -- | A native shared library (@.so@ on Linux, @.dylib@ on OSX, or+    -- @.dll@ on Windows).+    ForeignLibNativeShared+  | -- | A native static library (not currently supported.)+    ForeignLibNativeStatic+  | -- TODO: Maybe this should record a string?+    ForeignLibTypeUnknown+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Pretty ForeignLibType where   pretty ForeignLibNativeShared = Disp.text "native-shared"   pretty ForeignLibNativeStatic = Disp.text "native-static"-  pretty ForeignLibTypeUnknown  = Disp.text "unknown"+  pretty ForeignLibTypeUnknown = Disp.text "unknown"  instance Parsec ForeignLibType where   parsec = do@@ -40,7 +40,7 @@     return $ case name of       "native-shared" -> ForeignLibNativeShared       "native-static" -> ForeignLibNativeStatic-      _               -> ForeignLibTypeUnknown+      _ -> ForeignLibTypeUnknown  instance Binary ForeignLibType instance Structured ForeignLibType@@ -56,14 +56,14 @@   mappend = (<>)  knownForeignLibTypes :: [ForeignLibType]-knownForeignLibTypes = [-      ForeignLibNativeShared-    , ForeignLibNativeStatic-    ]+knownForeignLibTypes =+  [ ForeignLibNativeShared+  , ForeignLibNativeStatic+  ]  foreignLibTypeIsShared :: ForeignLibType -> Bool foreignLibTypeIsShared t =-    case t of-      ForeignLibNativeShared -> True-      ForeignLibNativeStatic -> False-      ForeignLibTypeUnknown  -> cabalBug "Unknown foreign library type"+  case t of+    ForeignLibNativeShared -> True+    ForeignLibNativeStatic -> False+    ForeignLibTypeUnknown -> cabalBug "Unknown foreign library type"
src/Distribution/Types/GenericPackageDescription.hs view
@@ -3,62 +3,75 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} -module Distribution.Types.GenericPackageDescription (-    GenericPackageDescription(..),-    emptyGenericPackageDescription,-) where+module Distribution.Types.GenericPackageDescription+  ( GenericPackageDescription (..)+  , emptyGenericPackageDescription+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  -- lens-import Distribution.Compat.Lens                     as L-import qualified Distribution.Types.BuildInfo.Lens  as L+import Distribution.Compat.Lens as L+import qualified Distribution.Types.BuildInfo.Lens as L  import Distribution.Types.PackageDescription +import Distribution.Package import Distribution.Types.Benchmark import Distribution.Types.CondTree import Distribution.Types.ConfVar-import Distribution.Types.Dependency import Distribution.Types.Executable import Distribution.Types.Flag import Distribution.Types.ForeignLib import Distribution.Types.Library import Distribution.Types.TestSuite import Distribution.Types.UnqualComponentName-import Distribution.Package import Distribution.Version  -- --------------------------------------------------------------------------- -- The 'GenericPackageDescription' type -data GenericPackageDescription =-  GenericPackageDescription+data GenericPackageDescription = GenericPackageDescription   { packageDescription :: PackageDescription-  , gpdScannedVersion  :: Maybe Version-    -- ^ This is a version as specified in source.-    --   We populate this field in index reading for dummy GPDs,-    --   only when GPD reading failed, but scanning haven't.-    ---    --   Cabal-the-library never produces GPDs with Just as gpdScannedVersion.-    ---    --   Perfectly, PackageIndex should have sum type, so we don't need to-    --   have dummy GPDs.-  , genPackageFlags    :: [PackageFlag]-  , condLibrary        :: Maybe (CondTree ConfVar [Dependency] Library)-  , condSubLibraries   :: [( UnqualComponentName-                           , CondTree ConfVar [Dependency] Library )]-  , condForeignLibs    :: [( UnqualComponentName-                           , CondTree ConfVar [Dependency] ForeignLib )]-  , condExecutables    :: [( UnqualComponentName-                           , CondTree ConfVar [Dependency] Executable )]-  , condTestSuites     :: [( UnqualComponentName-                           , CondTree ConfVar [Dependency] TestSuite )]-  , condBenchmarks     :: [( UnqualComponentName-                           , CondTree ConfVar [Dependency] Benchmark )]+  , gpdScannedVersion :: Maybe Version+  -- ^ This is a version as specified in source.+  --   We populate this field in index reading for dummy GPDs,+  --   only when GPD reading failed, but scanning haven't.+  --+  --   Cabal-the-library never produces GPDs with Just as gpdScannedVersion.+  --+  --   Perfectly, PackageIndex should have sum type, so we don't need to+  --   have dummy GPDs.+  , genPackageFlags :: [PackageFlag]+  , condLibrary :: Maybe (CondTree ConfVar [Dependency] Library)+  , condSubLibraries+      :: [ ( UnqualComponentName+           , CondTree ConfVar [Dependency] Library+           )+         ]+  , condForeignLibs+      :: [ ( UnqualComponentName+           , CondTree ConfVar [Dependency] ForeignLib+           )+         ]+  , condExecutables+      :: [ ( UnqualComponentName+           , CondTree ConfVar [Dependency] Executable+           )+         ]+  , condTestSuites+      :: [ ( UnqualComponentName+           , CondTree ConfVar [Dependency] TestSuite+           )+         ]+  , condBenchmarks+      :: [ ( UnqualComponentName+           , CondTree ConfVar [Dependency] Benchmark+           )+         ]   }-    deriving (Show, Eq, Typeable, Data, Generic)+  deriving (Show, Eq, Data, Generic)  instance Package GenericPackageDescription where   packageId = packageId . packageDescription@@ -74,30 +87,34 @@ -- Traversal Instances  instance L.HasBuildInfos GenericPackageDescription where-    traverseBuildInfos f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) =-        GenericPackageDescription-            <$> L.traverseBuildInfos f p-            <*> pure v-            <*> pure a1-            <*> (traverse . traverseCondTreeBuildInfo) f x1-            <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x2-            <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x3-            <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x4-            <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x5-            <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x6+  traverseBuildInfos f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) =+    GenericPackageDescription+      <$> L.traverseBuildInfos f p+      <*> pure v+      <*> pure a1+      <*> (traverse . traverseCondTreeBuildInfo) f x1+      <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x2+      <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x3+      <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x4+      <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x5+      <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x6  -- We use this traversal to keep [Dependency] field in CondTree up to date. traverseCondTreeBuildInfo-    :: forall f comp v. (Applicative f, L.HasBuildInfo comp)-    => LensLike' f (CondTree v [Dependency] comp) L.BuildInfo-traverseCondTreeBuildInfo g = node where+  :: forall f comp v+   . (Applicative f, L.HasBuildInfo comp)+  => LensLike' f (CondTree v [Dependency] comp) L.BuildInfo+traverseCondTreeBuildInfo g = node+  where     mkCondNode :: comp -> [CondBranch v [Dependency] comp] -> CondTree v [Dependency] comp     mkCondNode comp = CondNode comp (view L.targetBuildDepends comp) -    node (CondNode comp _ branches) = mkCondNode+    node (CondNode comp _ branches) =+      mkCondNode         <$> L.buildInfo g comp         <*> traverse branch branches -    branch (CondBranch v x y) = CondBranch v+    branch (CondBranch v x y) =+      CondBranch v         <$> node x         <*> traverse node y
src/Distribution/Types/GenericPackageDescription/Lens.hs view
@@ -1,34 +1,36 @@ {-# LANGUAGE Rank2Types #-}-module Distribution.Types.GenericPackageDescription.Lens (-    GenericPackageDescription,-    PackageFlag,-    FlagName,-    ConfVar (..),-    module Distribution.Types.GenericPackageDescription.Lens,-    ) where -import Prelude()-import Distribution.Compat.Prelude+module Distribution.Types.GenericPackageDescription.Lens+  ( GenericPackageDescription+  , PackageFlag+  , FlagName+  , ConfVar (..)+  , module Distribution.Types.GenericPackageDescription.Lens+  ) where+ import Distribution.Compat.Lens+import Distribution.Compat.Prelude+import Prelude ()  import qualified Distribution.Types.GenericPackageDescription as T  -- We import types from their packages, so we can remove unused imports -- and have wider inter-module dependency graph++import Distribution.Compiler (CompilerFlavor)+import Distribution.System (Arch, OS)+import Distribution.Types.Benchmark (Benchmark) import Distribution.Types.CondTree (CondTree)+import Distribution.Types.ConfVar (ConfVar (..)) import Distribution.Types.Dependency (Dependency) import Distribution.Types.Executable (Executable)-import Distribution.Types.PackageDescription (PackageDescription)-import Distribution.Types.Benchmark (Benchmark)+import Distribution.Types.Flag (FlagName, PackageFlag (MkPackageFlag)) import Distribution.Types.ForeignLib (ForeignLib)-import Distribution.Types.GenericPackageDescription (GenericPackageDescription(GenericPackageDescription) )-import Distribution.Types.Flag (PackageFlag(MkPackageFlag), FlagName)-import Distribution.Types.ConfVar (ConfVar (..))+import Distribution.Types.GenericPackageDescription (GenericPackageDescription (GenericPackageDescription)) import Distribution.Types.Library (Library)+import Distribution.Types.PackageDescription (PackageDescription) import Distribution.Types.TestSuite (TestSuite) import Distribution.Types.UnqualComponentName (UnqualComponentName)-import Distribution.System (Arch, OS)-import Distribution.Compiler (CompilerFlavor) import Distribution.Version (Version, VersionRange)  -------------------------------------------------------------------------------@@ -36,59 +38,60 @@ -------------------------------------------------------------------------------  packageDescription :: Lens' GenericPackageDescription PackageDescription-packageDescription f s = fmap (\x -> s { T.packageDescription = x }) (f (T.packageDescription s))+packageDescription f s = fmap (\x -> s{T.packageDescription = x}) (f (T.packageDescription s)) {-# INLINE packageDescription #-}  gpdScannedVersion :: Lens' GenericPackageDescription (Maybe Version)-gpdScannedVersion f s = fmap (\x -> s { T.gpdScannedVersion = x }) (f (T.gpdScannedVersion s))+gpdScannedVersion f s = fmap (\x -> s{T.gpdScannedVersion = x}) (f (T.gpdScannedVersion s)) {-# INLINE gpdScannedVersion #-}  genPackageFlags :: Lens' GenericPackageDescription [PackageFlag]-genPackageFlags f s = fmap (\x -> s { T.genPackageFlags = x }) (f (T.genPackageFlags s))+genPackageFlags f s = fmap (\x -> s{T.genPackageFlags = x}) (f (T.genPackageFlags s)) {-# INLINE genPackageFlags #-}  condLibrary :: Lens' GenericPackageDescription (Maybe (CondTree ConfVar [Dependency] Library))-condLibrary f s = fmap (\x -> s { T.condLibrary = x }) (f (T.condLibrary s))+condLibrary f s = fmap (\x -> s{T.condLibrary = x}) (f (T.condLibrary s)) {-# INLINE condLibrary #-} -condSubLibraries :: Lens' GenericPackageDescription [(UnqualComponentName,(CondTree ConfVar [Dependency] Library))]-condSubLibraries f s = fmap (\x -> s { T.condSubLibraries = x }) (f (T.condSubLibraries s))+condSubLibraries :: Lens' GenericPackageDescription [(UnqualComponentName, (CondTree ConfVar [Dependency] Library))]+condSubLibraries f s = fmap (\x -> s{T.condSubLibraries = x}) (f (T.condSubLibraries s)) {-# INLINE condSubLibraries #-} -condForeignLibs :: Lens' GenericPackageDescription [(UnqualComponentName,(CondTree ConfVar [Dependency] ForeignLib))]-condForeignLibs f s = fmap (\x -> s { T.condForeignLibs = x }) (f (T.condForeignLibs s))+condForeignLibs :: Lens' GenericPackageDescription [(UnqualComponentName, (CondTree ConfVar [Dependency] ForeignLib))]+condForeignLibs f s = fmap (\x -> s{T.condForeignLibs = x}) (f (T.condForeignLibs s)) {-# INLINE condForeignLibs #-} -condExecutables :: Lens' GenericPackageDescription [(UnqualComponentName,(CondTree ConfVar [Dependency] Executable))]-condExecutables f s = fmap (\x -> s { T.condExecutables = x }) (f (T.condExecutables s))+condExecutables :: Lens' GenericPackageDescription [(UnqualComponentName, (CondTree ConfVar [Dependency] Executable))]+condExecutables f s = fmap (\x -> s{T.condExecutables = x}) (f (T.condExecutables s)) {-# INLINE condExecutables #-} -condTestSuites :: Lens' GenericPackageDescription [(UnqualComponentName,(CondTree ConfVar [Dependency] TestSuite))]-condTestSuites f s = fmap (\x -> s { T.condTestSuites = x }) (f (T.condTestSuites s))+condTestSuites :: Lens' GenericPackageDescription [(UnqualComponentName, (CondTree ConfVar [Dependency] TestSuite))]+condTestSuites f s = fmap (\x -> s{T.condTestSuites = x}) (f (T.condTestSuites s)) {-# INLINE condTestSuites #-} -condBenchmarks :: Lens' GenericPackageDescription [(UnqualComponentName,(CondTree ConfVar [Dependency] Benchmark))]-condBenchmarks f s = fmap (\x -> s { T.condBenchmarks = x }) (f (T.condBenchmarks s))+condBenchmarks :: Lens' GenericPackageDescription [(UnqualComponentName, (CondTree ConfVar [Dependency] Benchmark))]+condBenchmarks f s = fmap (\x -> s{T.condBenchmarks = x}) (f (T.condBenchmarks s)) {-# INLINE condBenchmarks #-}  allCondTrees   :: Applicative f-  => (forall a. CondTree ConfVar [Dependency] a-          -> f (CondTree ConfVar [Dependency] a))+  => ( forall a+        . CondTree ConfVar [Dependency] a+       -> f (CondTree ConfVar [Dependency] a)+     )   -> GenericPackageDescription   -> f GenericPackageDescription allCondTrees f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) =-    GenericPackageDescription-        <$> pure p-        <*> pure v-        <*> pure a1-        <*> traverse f x1-        <*> (traverse . _2) f x2-        <*> (traverse . _2) f x3-        <*> (traverse . _2) f x4-        <*> (traverse . _2) f x5-        <*> (traverse . _2) f x6-+  GenericPackageDescription+    <$> pure p+    <*> pure v+    <*> pure a1+    <*> traverse f x1+    <*> (traverse . _2) f x2+    <*> (traverse . _2) f x3+    <*> (traverse . _2) f x4+    <*> (traverse . _2) f x5+    <*> (traverse . _2) f x6  ------------------------------------------------------------------------------- -- Flag@@ -116,16 +119,16 @@  _OS :: Traversal' ConfVar OS _OS f (OS os) = OS <$> f os-_OS _ x       = pure x+_OS _ x = pure x  _Arch :: Traversal' ConfVar Arch _Arch f (Arch arch) = Arch <$> f arch-_Arch _ x           = pure x+_Arch _ x = pure x  _PackageFlag :: Traversal' ConfVar FlagName _PackageFlag f (PackageFlag flag) = PackageFlag <$> f flag-_PackageFlag _ x                  = pure x+_PackageFlag _ x = pure x  _Impl :: Traversal' ConfVar (CompilerFlavor, VersionRange) _Impl f (Impl cf vr) = uncurry Impl <$> f (cf, vr)-_Impl _ x            = pure x+_Impl _ x = pure x
src/Distribution/Types/HookedBuildInfo.hs view
@@ -1,9 +1,6 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric #-}--module Distribution.Types.HookedBuildInfo (-    HookedBuildInfo,-    emptyHookedBuildInfo,+module Distribution.Types.HookedBuildInfo+  ( HookedBuildInfo+  , emptyHookedBuildInfo   ) where  -- import Distribution.Compat.Prelude
src/Distribution/Types/IncludeRenaming.hs view
@@ -1,11 +1,11 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.IncludeRenaming (-    IncludeRenaming(..),-    defaultIncludeRenaming,-    isDefaultIncludeRenaming,-) where+module Distribution.Types.IncludeRenaming+  ( IncludeRenaming (..)+  , defaultIncludeRenaming+  , isDefaultIncludeRenaming+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -13,21 +13,20 @@ import Distribution.Types.ModuleRenaming  import qualified Distribution.Compat.CharParsing as P-import           Distribution.Parsec-import           Distribution.Pretty-import           Text.PrettyPrint           (text)-import qualified Text.PrettyPrint           as Disp+import Distribution.Parsec+import Distribution.Pretty+import Text.PrettyPrint (text)+import qualified Text.PrettyPrint as Disp  -- --------------------------------------------------------------------------- -- Module renaming  -- | A renaming on an include: (provides renaming, requires renaming)-data IncludeRenaming-    = IncludeRenaming {-        includeProvidesRn :: ModuleRenaming,-        includeRequiresRn :: ModuleRenaming-    }-    deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+data IncludeRenaming = IncludeRenaming+  { includeProvidesRn :: ModuleRenaming+  , includeRequiresRn :: ModuleRenaming+  }+  deriving (Show, Read, Eq, Ord, Data, Generic)  instance Binary IncludeRenaming instance Structured IncludeRenaming@@ -44,25 +43,26 @@ isDefaultIncludeRenaming (IncludeRenaming p r) = isDefaultRenaming p && isDefaultRenaming r  instance Pretty IncludeRenaming where-    pretty (IncludeRenaming prov_rn req_rn) =-        pretty prov_rn-          <+> (if isDefaultRenaming req_rn-                then Disp.empty-                else text "requires" <+> pretty req_rn)+  pretty (IncludeRenaming prov_rn req_rn) =+    pretty prov_rn+      <+> ( if isDefaultRenaming req_rn+              then Disp.empty+              else text "requires" <+> pretty req_rn+          )  instance Parsec IncludeRenaming where-    parsec = do-        prov_rn <- parsec-        req_rn <- P.option defaultRenaming $ P.try $ do-            P.spaces -- no need to be space-            _ <- P.string "requires"-            P.spaces-            parsec-        -- Requirements don't really care if they're mentioned-        -- or not (since you can't thin a requirement.)  But-        -- we have a little hack in Configure to combine-        -- the provisions and requirements together before passing-        -- them to GHC, and so the most neutral choice for a requirement-        -- is for the "with" field to be False, so we correctly-        -- thin provisions.-        return (IncludeRenaming prov_rn req_rn)+  parsec = do+    prov_rn <- parsec+    req_rn <- P.option defaultRenaming $ P.try $ do+      P.spaces -- no need to be space+      _ <- P.string "requires"+      P.spaces+      parsec+    -- Requirements don't really care if they're mentioned+    -- or not (since you can't thin a requirement.)  But+    -- we have a little hack in Configure to combine+    -- the provisions and requirements together before passing+    -- them to GHC, and so the most neutral choice for a requirement+    -- is for the "with" field to be False, so we correctly+    -- thin provisions.+    return (IncludeRenaming prov_rn req_rn)
src/Distribution/Types/InstalledPackageInfo.hs view
@@ -1,100 +1,100 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-{-# LANGUAGE TypeFamilies       #-}-{-# LANGUAGE OverloadedStrings  #-}-module Distribution.Types.InstalledPackageInfo (-    InstalledPackageInfo (..),-    emptyInstalledPackageInfo,-    mungedPackageId,-    mungedPackageName,-    AbiDependency (..),-    ExposedModule (..),-    ) where+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeFamilies #-} +module Distribution.Types.InstalledPackageInfo+  ( InstalledPackageInfo (..)+  , emptyInstalledPackageInfo+  , mungedPackageId+  , mungedPackageName+  , AbiDependency (..)+  , ExposedModule (..)+  ) where+ import Distribution.Compat.Prelude import Prelude ()  import Distribution.Backpack-import Distribution.Compat.Graph            (IsNode (..))+import Distribution.Compat.Graph (IsNode (..)) import Distribution.License import Distribution.ModuleName-import Distribution.Package                 hiding (installedUnitId)+import Distribution.Package hiding (installedUnitId) import Distribution.Types.AbiDependency import Distribution.Types.ExposedModule import Distribution.Types.LibraryName import Distribution.Types.LibraryVisibility import Distribution.Types.MungedPackageId import Distribution.Types.MungedPackageName-import Distribution.Version                 (nullVersion)-import Distribution.Utils.ShortText         (ShortText)+import Distribution.Utils.ShortText (ShortText)+import Distribution.Version (nullVersion)  import qualified Distribution.Package as Package-import qualified Distribution.SPDX    as SPDX+import qualified Distribution.SPDX as SPDX  -- ----------------------------------------------------------------------------- -- The InstalledPackageInfo type  -- For BC reasons, we continue to name this record an InstalledPackageInfo; -- but it would more accurately be called an InstalledUnitInfo with Backpack-data InstalledPackageInfo-   = InstalledPackageInfo {-        -- these parts (sourcePackageId, installedUnitId) are-        -- exactly the same as PackageDescription-        sourcePackageId   :: PackageId,-        sourceLibName     :: LibraryName,-        installedComponentId_ :: ComponentId,-        libVisibility     :: LibraryVisibility,-        installedUnitId   :: UnitId,-        -- INVARIANT: if this package is definite, OpenModule's-        -- OpenUnitId directly records UnitId.  If it is-        -- indefinite, OpenModule is always an OpenModuleVar-        -- with the same ModuleName as the key.-        instantiatedWith  :: [(ModuleName, OpenModule)],-        compatPackageKey  :: String,-        license           :: Either SPDX.License License,-        copyright         :: !ShortText,-        maintainer        :: !ShortText,-        author            :: !ShortText,-        stability         :: !ShortText,-        homepage          :: !ShortText,-        pkgUrl            :: !ShortText,-        synopsis          :: !ShortText,-        description       :: !ShortText,-        category          :: !ShortText,-        -- these parts are required by an installed package only:-        abiHash           :: AbiHash,-        indefinite        :: Bool,-        exposed           :: Bool,-        -- INVARIANT: if the package is definite, OpenModule's-        -- OpenUnitId directly records UnitId.-        exposedModules    :: [ExposedModule],-        hiddenModules     :: [ModuleName],-        trusted           :: Bool,-        importDirs        :: [FilePath],-        libraryDirs       :: [FilePath],-        libraryDirsStatic :: [FilePath],-        libraryDynDirs    :: [FilePath],  -- ^ overrides 'libraryDirs'-        dataDir           :: FilePath,-        hsLibraries       :: [String],-        extraLibraries    :: [String],-        extraLibrariesStatic :: [String],-        extraGHCiLibraries:: [String],    -- overrides extraLibraries for GHCi-        includeDirs       :: [FilePath],-        includes          :: [String],-        -- INVARIANT: if the package is definite, UnitId is NOT-        -- a ComponentId of an indefinite package-        depends           :: [UnitId],-        abiDepends        :: [AbiDependency],-        ccOptions         :: [String],-        cxxOptions        :: [String],-        ldOptions         :: [String],-        frameworkDirs     :: [FilePath],-        frameworks        :: [String],-        haddockInterfaces :: [FilePath],-        haddockHTMLs      :: [FilePath],-        pkgRoot           :: Maybe FilePath-    }-    deriving (Eq, Generic, Typeable, Read, Show)+data InstalledPackageInfo = InstalledPackageInfo+  { -- these parts (sourcePackageId, installedUnitId) are+    -- exactly the same as PackageDescription+    sourcePackageId :: PackageId+  , sourceLibName :: LibraryName+  , installedComponentId_ :: ComponentId+  , libVisibility :: LibraryVisibility+  , installedUnitId :: UnitId+  , -- INVARIANT: if this package is definite, OpenModule's+    -- OpenUnitId directly records UnitId.  If it is+    -- indefinite, OpenModule is always an OpenModuleVar+    -- with the same ModuleName as the key.+    instantiatedWith :: [(ModuleName, OpenModule)]+  , compatPackageKey :: String+  , license :: Either SPDX.License License+  , copyright :: !ShortText+  , maintainer :: !ShortText+  , author :: !ShortText+  , stability :: !ShortText+  , homepage :: !ShortText+  , pkgUrl :: !ShortText+  , synopsis :: !ShortText+  , description :: !ShortText+  , category :: !ShortText+  , -- these parts are required by an installed package only:+    abiHash :: AbiHash+  , indefinite :: Bool+  , exposed :: Bool+  , -- INVARIANT: if the package is definite, OpenModule's+    -- OpenUnitId directly records UnitId.+    exposedModules :: [ExposedModule]+  , hiddenModules :: [ModuleName]+  , trusted :: Bool+  , importDirs :: [FilePath]+  , libraryDirs :: [FilePath]+  , libraryDirsStatic :: [FilePath]+  , libraryDynDirs :: [FilePath]+  -- ^ overrides 'libraryDirs'+  , dataDir :: FilePath+  , hsLibraries :: [String]+  , extraLibraries :: [String]+  , extraLibrariesStatic :: [String]+  , extraGHCiLibraries :: [String] -- overrides extraLibraries for GHCi+  , includeDirs :: [FilePath]+  , includes :: [String]+  , -- INVARIANT: if the package is definite, UnitId is NOT+    -- a ComponentId of an indefinite package+    depends :: [UnitId]+  , abiDepends :: [AbiDependency]+  , ccOptions :: [String]+  , cxxOptions :: [String]+  , ldOptions :: [String]+  , frameworkDirs :: [FilePath]+  , frameworks :: [String]+  , haddockInterfaces :: [FilePath]+  , haddockHTMLs :: [FilePath]+  , pkgRoot :: Maybe FilePath+  }+  deriving (Eq, Generic, Read, Show)  instance Binary InstalledPackageInfo instance Structured InstalledPackageInfo@@ -102,25 +102,25 @@ instance NFData InstalledPackageInfo where rnf = genericRnf  instance Package.HasMungedPackageId InstalledPackageInfo where-   mungedId = mungedPackageId+  mungedId = mungedPackageId  instance Package.Package InstalledPackageInfo where-   packageId = sourcePackageId+  packageId = sourcePackageId  instance Package.HasUnitId InstalledPackageInfo where-   installedUnitId = installedUnitId+  installedUnitId = installedUnitId  instance Package.PackageInstalled InstalledPackageInfo where-   installedDepends = depends+  installedDepends = depends  instance IsNode InstalledPackageInfo where-    type Key InstalledPackageInfo = UnitId-    nodeKey       = installedUnitId-    nodeNeighbors = depends+  type Key InstalledPackageInfo = UnitId+  nodeKey = installedUnitId+  nodeNeighbors = depends  mungedPackageId :: InstalledPackageInfo -> MungedPackageId mungedPackageId ipi =-    MungedPackageId (mungedPackageName ipi) (packageVersion ipi)+  MungedPackageId (mungedPackageName ipi) (packageVersion ipi)  -- | Returns the munged package name, which we write into @name@ for -- compatibility with old versions of GHC.@@ -128,50 +128,50 @@ mungedPackageName ipi = MungedPackageName (packageName ipi) (sourceLibName ipi)  emptyInstalledPackageInfo :: InstalledPackageInfo-emptyInstalledPackageInfo-   = InstalledPackageInfo {-        sourcePackageId   = PackageIdentifier (mkPackageName "") nullVersion,-        sourceLibName     = LMainLibName,-        installedComponentId_ = mkComponentId "",-        installedUnitId   = mkUnitId "",-        instantiatedWith  = [],-        compatPackageKey  = "",-        license           = Left SPDX.NONE,-        copyright         = "",-        maintainer        = "",-        author            = "",-        stability         = "",-        homepage          = "",-        pkgUrl            = "",-        synopsis          = "",-        description       = "",-        category          = "",-        abiHash           = mkAbiHash "",-        indefinite        = False,-        exposed           = False,-        exposedModules    = [],-        hiddenModules     = [],-        trusted           = False,-        importDirs        = [],-        libraryDirs       = [],-        libraryDirsStatic = [],-        libraryDynDirs    = [],-        dataDir           = "",-        hsLibraries       = [],-        extraLibraries    = [],-        extraLibrariesStatic = [],-        extraGHCiLibraries= [],-        includeDirs       = [],-        includes          = [],-        depends           = [],-        abiDepends        = [],-        ccOptions         = [],-        cxxOptions        = [],-        ldOptions         = [],-        frameworkDirs     = [],-        frameworks        = [],-        haddockInterfaces = [],-        haddockHTMLs      = [],-        pkgRoot           = Nothing,-        libVisibility     = LibraryVisibilityPrivate+emptyInstalledPackageInfo =+  InstalledPackageInfo+    { sourcePackageId = PackageIdentifier (mkPackageName "") nullVersion+    , sourceLibName = LMainLibName+    , installedComponentId_ = mkComponentId ""+    , installedUnitId = mkUnitId ""+    , instantiatedWith = []+    , compatPackageKey = ""+    , license = Left SPDX.NONE+    , copyright = ""+    , maintainer = ""+    , author = ""+    , stability = ""+    , homepage = ""+    , pkgUrl = ""+    , synopsis = ""+    , description = ""+    , category = ""+    , abiHash = mkAbiHash ""+    , indefinite = False+    , exposed = False+    , exposedModules = []+    , hiddenModules = []+    , trusted = False+    , importDirs = []+    , libraryDirs = []+    , libraryDirsStatic = []+    , libraryDynDirs = []+    , dataDir = ""+    , hsLibraries = []+    , extraLibraries = []+    , extraLibrariesStatic = []+    , extraGHCiLibraries = []+    , includeDirs = []+    , includes = []+    , depends = []+    , abiDepends = []+    , ccOptions = []+    , cxxOptions = []+    , ldOptions = []+    , frameworkDirs = []+    , frameworks = []+    , haddockInterfaces = []+    , haddockHTMLs = []+    , pkgRoot = Nothing+    , libVisibility = LibraryVisibilityPrivate     }
src/Distribution/Types/InstalledPackageInfo/FieldGrammar.hs view
@@ -1,18 +1,19 @@-{-# LANGUAGE ConstraintKinds       #-}-{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings     #-}-{-# LANGUAGE RecordWildCards       #-}-module Distribution.Types.InstalledPackageInfo.FieldGrammar (-    ipiFieldGrammar,-    ) where+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-} +module Distribution.Types.InstalledPackageInfo.FieldGrammar+  ( ipiFieldGrammar+  ) where+ import Distribution.Compat.Prelude import Prelude ()  import Distribution.Backpack import Distribution.CabalSpecVersion-import Distribution.Compat.Lens               (Lens', (&), (.~))+import Distribution.Compat.Lens (Lens', (&), (.~)) import Distribution.Compat.Newtype import Distribution.FieldGrammar import Distribution.FieldGrammar.FieldDescrs@@ -27,16 +28,16 @@ import Distribution.Types.UnqualComponentName import Distribution.Version -import qualified Data.Char                       as Char-import qualified Data.Map                        as Map+import qualified Data.Char as Char+import qualified Data.Map as Map import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.SPDX               as SPDX-import qualified Text.PrettyPrint                as Disp+import qualified Distribution.SPDX as SPDX+import qualified Text.PrettyPrint as Disp  import Distribution.Types.InstalledPackageInfo  import qualified Distribution.Types.InstalledPackageInfo.Lens as L-import qualified Distribution.Types.PackageId.Lens            as L+import qualified Distribution.Types.PackageId.Lens as L  -- Note: GHC goes nuts and inlines everything, -- One can see e.g. in -ddump-simpl-stats:@@ -53,76 +54,80 @@ {-# NOINLINE (<@>) #-}  ipiFieldGrammar-    :: ( FieldGrammar c g, Applicative (g InstalledPackageInfo), Applicative (g Basic)-       , c (Identity AbiHash)-       , c (Identity LibraryVisibility)-       , c (Identity PackageName)-       , c (Identity UnitId)-       , c (Identity UnqualComponentName)-       , c (List FSep (Identity AbiDependency) AbiDependency)-       , c (List FSep (Identity UnitId) UnitId)-       , c (List FSep (MQuoted ModuleName) ModuleName)-       , c (List FSep FilePathNT String)-       , c (List FSep Token String)-       , c (MQuoted MungedPackageName)-       , c (MQuoted Version)-       , c CompatPackageKey-       , c ExposedModules-       , c InstWith-       , c SpecLicenseLenient-       )-    => g InstalledPackageInfo InstalledPackageInfo-ipiFieldGrammar = mkInstalledPackageInfo+  :: ( FieldGrammar c g+     , Applicative (g InstalledPackageInfo)+     , Applicative (g Basic)+     , c (Identity AbiHash)+     , c (Identity LibraryVisibility)+     , c (Identity PackageName)+     , c (Identity UnitId)+     , c (Identity UnqualComponentName)+     , c (List FSep (Identity AbiDependency) AbiDependency)+     , c (List FSep (Identity UnitId) UnitId)+     , c (List FSep (MQuoted ModuleName) ModuleName)+     , c (List FSep FilePathNT String)+     , c (List FSep Token String)+     , c (MQuoted MungedPackageName)+     , c (MQuoted Version)+     , c CompatPackageKey+     , c ExposedModules+     , c InstWith+     , c SpecLicenseLenient+     )+  => g InstalledPackageInfo InstalledPackageInfo+ipiFieldGrammar =+  mkInstalledPackageInfo     -- Deprecated fields-    <$> monoidalFieldAla    "hugs-options"         (alaList' FSep Token)         unitedList-        --- https://github.com/haskell/cabal/commit/40f3601e17024f07e0da8e64d3dd390177ce908b-        ^^^ deprecatedSince CabalSpecV1_22 "hugs isn't supported anymore"+    <$> monoidalFieldAla "hugs-options" (alaList' FSep Token) unitedList+      --- https://github.com/haskell/cabal/commit/40f3601e17024f07e0da8e64d3dd390177ce908b+      ^^^ deprecatedSince CabalSpecV1_22 "hugs isn't supported anymore"     -- Very basic fields: name, version, package-name, lib-name and visibility     <@> blurFieldGrammar basic basicFieldGrammar     -- Basic fields-    <@> optionalFieldDef    "id"                                                 L.installedUnitId (mkUnitId "")-    <@> optionalFieldDefAla "instantiated-with"    InstWith                      L.instantiatedWith []-    <@> optionalFieldDefAla "key"                  CompatPackageKey              L.compatPackageKey ""-    <@> optionalFieldDefAla "license"              SpecLicenseLenient            L.license (Left SPDX.NONE)-    <@> freeTextFieldDefST  "copyright"                                          L.copyright-    <@> freeTextFieldDefST  "maintainer"                                         L.maintainer-    <@> freeTextFieldDefST  "author"                                             L.author-    <@> freeTextFieldDefST  "stability"                                          L.stability-    <@> freeTextFieldDefST  "homepage"                                           L.homepage-    <@> freeTextFieldDefST  "package-url"                                        L.pkgUrl-    <@> freeTextFieldDefST  "synopsis"                                           L.synopsis-    <@> freeTextFieldDefST  "description"                                        L.description-    <@> freeTextFieldDefST  "category"                                           L.category+    <@> optionalFieldDef "id" L.installedUnitId (mkUnitId "")+    <@> optionalFieldDefAla "instantiated-with" InstWith L.instantiatedWith []+    <@> optionalFieldDefAla "key" CompatPackageKey L.compatPackageKey ""+    <@> optionalFieldDefAla "license" SpecLicenseLenient L.license (Left SPDX.NONE)+    <@> freeTextFieldDefST "copyright" L.copyright+    <@> freeTextFieldDefST "maintainer" L.maintainer+    <@> freeTextFieldDefST "author" L.author+    <@> freeTextFieldDefST "stability" L.stability+    <@> freeTextFieldDefST "homepage" L.homepage+    <@> freeTextFieldDefST "package-url" L.pkgUrl+    <@> freeTextFieldDefST "synopsis" L.synopsis+    <@> freeTextFieldDefST "description" L.description+    <@> freeTextFieldDefST "category" L.category     -- Installed fields-    <@> optionalFieldDef    "abi"                                                L.abiHash (mkAbiHash "")-    <@> booleanFieldDef     "indefinite"                                         L.indefinite False-    <@> booleanFieldDef     "exposed"                                            L.exposed False-    <@> monoidalFieldAla    "exposed-modules"      ExposedModules                L.exposedModules-    <@> monoidalFieldAla    "hidden-modules"       (alaList' FSep MQuoted)       L.hiddenModules-    <@> booleanFieldDef     "trusted"                                            L.trusted False-    <@> monoidalFieldAla    "import-dirs"          (alaList' FSep FilePathNT)    L.importDirs-    <@> monoidalFieldAla    "library-dirs"         (alaList' FSep FilePathNT)    L.libraryDirs-    <@> monoidalFieldAla    "library-dirs-static"  (alaList' FSep FilePathNT)    L.libraryDirsStatic-    <@> monoidalFieldAla    "dynamic-library-dirs" (alaList' FSep FilePathNT)    L.libraryDynDirs-    <@> optionalFieldDefAla "data-dir"             FilePathNT                    L.dataDir ""-    <@> monoidalFieldAla    "hs-libraries"         (alaList' FSep Token)         L.hsLibraries-    <@> monoidalFieldAla    "extra-libraries"      (alaList' FSep Token)         L.extraLibraries-    <@> monoidalFieldAla    "extra-libraries-static" (alaList' FSep Token)       L.extraLibrariesStatic-    <@> monoidalFieldAla    "extra-ghci-libraries" (alaList' FSep Token)         L.extraGHCiLibraries-    <@> monoidalFieldAla    "include-dirs"         (alaList' FSep FilePathNT)    L.includeDirs-    <@> monoidalFieldAla    "includes"             (alaList' FSep FilePathNT)    L.includes-    <@> monoidalFieldAla    "depends"              (alaList FSep)                L.depends-    <@> monoidalFieldAla    "abi-depends"          (alaList FSep)                L.abiDepends-    <@> monoidalFieldAla    "cc-options"           (alaList' FSep Token)         L.ccOptions-    <@> monoidalFieldAla    "cxx-options"          (alaList' FSep Token)         L.cxxOptions-    <@> monoidalFieldAla    "ld-options"           (alaList' FSep Token)         L.ldOptions-    <@> monoidalFieldAla    "framework-dirs"       (alaList' FSep FilePathNT)    L.frameworkDirs-    <@> monoidalFieldAla    "frameworks"           (alaList' FSep Token)         L.frameworks-    <@> monoidalFieldAla    "haddock-interfaces"   (alaList' FSep FilePathNT)    L.haddockInterfaces-    <@> monoidalFieldAla    "haddock-html"         (alaList' FSep FilePathNT)    L.haddockHTMLs-    <@> optionalFieldAla    "pkgroot"              FilePathNT                    L.pkgRoot+    <@> optionalFieldDef "abi" L.abiHash (mkAbiHash "")+    <@> booleanFieldDef "indefinite" L.indefinite False+    <@> booleanFieldDef "exposed" L.exposed False+    <@> monoidalFieldAla "exposed-modules" ExposedModules L.exposedModules+    <@> monoidalFieldAla "hidden-modules" (alaList' FSep MQuoted) L.hiddenModules+    <@> booleanFieldDef "trusted" L.trusted False+    <@> monoidalFieldAla "import-dirs" (alaList' FSep FilePathNT) L.importDirs+    <@> monoidalFieldAla "library-dirs" (alaList' FSep FilePathNT) L.libraryDirs+    <@> monoidalFieldAla "library-dirs-static" (alaList' FSep FilePathNT) L.libraryDirsStatic+    <@> monoidalFieldAla "dynamic-library-dirs" (alaList' FSep FilePathNT) L.libraryDynDirs+    <@> optionalFieldDefAla "data-dir" FilePathNT L.dataDir ""+    <@> monoidalFieldAla "hs-libraries" (alaList' FSep Token) L.hsLibraries+    <@> monoidalFieldAla "extra-libraries" (alaList' FSep Token) L.extraLibraries+    <@> monoidalFieldAla "extra-libraries-static" (alaList' FSep Token) L.extraLibrariesStatic+    <@> monoidalFieldAla "extra-ghci-libraries" (alaList' FSep Token) L.extraGHCiLibraries+    <@> monoidalFieldAla "include-dirs" (alaList' FSep FilePathNT) L.includeDirs+    <@> monoidalFieldAla "includes" (alaList' FSep FilePathNT) L.includes+    <@> monoidalFieldAla "depends" (alaList FSep) L.depends+    <@> monoidalFieldAla "abi-depends" (alaList FSep) L.abiDepends+    <@> monoidalFieldAla "cc-options" (alaList' FSep Token) L.ccOptions+    <@> monoidalFieldAla "cxx-options" (alaList' FSep Token) L.cxxOptions+    <@> monoidalFieldAla "ld-options" (alaList' FSep Token) L.ldOptions+    <@> monoidalFieldAla "framework-dirs" (alaList' FSep FilePathNT) L.frameworkDirs+    <@> monoidalFieldAla "frameworks" (alaList' FSep Token) L.frameworks+    <@> monoidalFieldAla "haddock-interfaces" (alaList' FSep FilePathNT) L.haddockInterfaces+    <@> monoidalFieldAla "haddock-html" (alaList' FSep FilePathNT) L.haddockHTMLs+    <@> optionalFieldAla "pkgroot" FilePathNT L.pkgRoot   where-    mkInstalledPackageInfo _ Basic {..} = InstalledPackageInfo+    mkInstalledPackageInfo _ Basic{..} =+      InstalledPackageInfo         -- _basicPkgName is not used         -- setMaybePackageId says it can be no-op.         (PackageIdentifier pn _basicVersion)@@ -149,7 +154,7 @@ -- /Should/ be irrelevant. combineLibraryName :: LibraryName -> LibraryName -> LibraryName combineLibraryName l@(LSubLibName _) _ = l-combineLibraryName _ l                 = l+combineLibraryName _ l = l  -- To maintain backwards-compatibility, we accept both comma/non-comma -- separated variants of this field.  You SHOULD use the comma syntax if you@@ -158,23 +163,26 @@  showExposedModules :: [ExposedModule] -> Disp.Doc showExposedModules xs-    | all isExposedModule xs = Disp.fsep (map pretty xs)-    | otherwise = Disp.fsep (Disp.punctuate Disp.comma (map pretty xs))-    where isExposedModule (ExposedModule _ Nothing) = True-          isExposedModule _ = False+  | all isExposedModule xs = Disp.fsep (map pretty xs)+  | otherwise = Disp.fsep (Disp.punctuate Disp.comma (map pretty xs))+  where+    isExposedModule (ExposedModule _ Nothing) = True+    isExposedModule _ = False  -- | Setter for the @package-name@ field.  It should be acceptable for this -- to be a no-op. setMaybePackageName :: Maybe PackageName -> InstalledPackageInfo -> InstalledPackageInfo-setMaybePackageName Nothing   ipi = ipi-setMaybePackageName (Just pn) ipi = ipi-    { sourcePackageId = (sourcePackageId ipi) {pkgName=pn}+setMaybePackageName Nothing ipi = ipi+setMaybePackageName (Just pn) ipi =+  ipi+    { sourcePackageId = (sourcePackageId ipi){pkgName = pn}     }  setMungedPackageName :: MungedPackageName -> InstalledPackageInfo -> InstalledPackageInfo-setMungedPackageName (MungedPackageName pn ln) ipi = ipi-    { sourcePackageId = (sourcePackageId ipi) {pkgName=pn}-    , sourceLibName   = ln+setMungedPackageName (MungedPackageName pn ln) ipi =+  ipi+    { sourcePackageId = (sourcePackageId ipi){pkgName = pn}+    , sourceLibName = ln     }  --- | Returns @Just@ if the @name@ field of the IPI record would not contain@@ -182,54 +190,55 @@ --- when it's redundant. maybePackageName :: InstalledPackageInfo -> Maybe PackageName maybePackageName ipi = case sourceLibName ipi of-    LMainLibName  -> Nothing-    LSubLibName _ -> Just (packageName ipi)+  LMainLibName -> Nothing+  LSubLibName _ -> Just (packageName ipi)  ------------------------------------------------------------------------------- -- Auxiliary types ------------------------------------------------------------------------------- -newtype ExposedModules = ExposedModules { getExposedModules :: [ExposedModule] }+newtype ExposedModules = ExposedModules {getExposedModules :: [ExposedModule]}  instance Newtype [ExposedModule] ExposedModules  instance Parsec ExposedModules where-    parsec = ExposedModules <$> parsecOptCommaList parsec+  parsec = ExposedModules <$> parsecOptCommaList parsec  instance Pretty ExposedModules where-    pretty = showExposedModules . getExposedModules+  pretty = showExposedModules . getExposedModules -newtype CompatPackageKey = CompatPackageKey { getCompatPackageKey :: String }+newtype CompatPackageKey = CompatPackageKey {getCompatPackageKey :: String}  instance Newtype String CompatPackageKey  instance Pretty CompatPackageKey where-    pretty = Disp.text . getCompatPackageKey+  pretty = Disp.text . getCompatPackageKey  instance Parsec CompatPackageKey where-    parsec = CompatPackageKey <$> P.munch1 uid_char where-        uid_char c = Char.isAlphaNum c || c `elem` ("-_.=[],:<>+" :: String)+  parsec = CompatPackageKey <$> P.munch1 uid_char+    where+      uid_char c = Char.isAlphaNum c || c `elem` ("-_.=[],:<>+" :: String) -newtype InstWith = InstWith { getInstWith :: [(ModuleName,OpenModule)] }+newtype InstWith = InstWith {getInstWith :: [(ModuleName, OpenModule)]} -instance Newtype  [(ModuleName, OpenModule)] InstWith+instance Newtype [(ModuleName, OpenModule)] InstWith  instance Pretty InstWith where-    pretty = dispOpenModuleSubst . Map.fromList . getInstWith+  pretty = dispOpenModuleSubst . Map.fromList . getInstWith  instance Parsec InstWith where-    parsec = InstWith . Map.toList <$> parsecOpenModuleSubst+  parsec = InstWith . Map.toList <$> parsecOpenModuleSubst  -- | SPDX License expression or legacy license. Lenient parser, accepts either.-newtype SpecLicenseLenient = SpecLicenseLenient { getSpecLicenseLenient :: Either SPDX.License License }+newtype SpecLicenseLenient = SpecLicenseLenient {getSpecLicenseLenient :: Either SPDX.License License}  instance Newtype (Either SPDX.License License) SpecLicenseLenient  instance Parsec SpecLicenseLenient where-    parsec = fmap SpecLicenseLenient $ Left <$> P.try parsec <|> Right <$> parsec+  parsec = fmap SpecLicenseLenient $ Left <$> P.try parsec <|> Right <$> parsec  instance Pretty SpecLicenseLenient where-    pretty = either pretty pretty . getSpecLicenseLenient+  pretty = either pretty pretty . getSpecLicenseLenient  ------------------------------------------------------------------------------- -- Basic fields@@ -239,24 +248,26 @@ -- in serialised textual representation -- to the actual 'InstalledPackageInfo' fields. data Basic = Basic-    { _basicName          :: MungedPackageName-    , _basicVersion       :: Version-    , _basicPkgName       :: Maybe PackageName-    , _basicLibName       :: LibraryName-    , _basicLibVisibility :: LibraryVisibility-    }+  { _basicName :: MungedPackageName+  , _basicVersion :: Version+  , _basicPkgName :: Maybe PackageName+  , _basicLibName :: LibraryName+  , _basicLibVisibility :: LibraryVisibility+  }  basic :: Lens' InstalledPackageInfo Basic basic f ipi = g <$> f b   where-    b = Basic+    b =+      Basic         (mungedPackageName ipi)         (packageVersion ipi)         (maybePackageName ipi)         (sourceLibName ipi)         (libVisibility ipi) -    g (Basic n v pn ln lv) = ipi+    g (Basic n v pn ln lv) =+      ipi         & setMungedPackageName n         & L.sourcePackageId . L.pkgVersion .~ v         & setMaybePackageName pn@@ -264,42 +275,46 @@         & L.libVisibility .~ lv  basicName :: Lens' Basic MungedPackageName-basicName f b = (\x -> b { _basicName = x }) <$> f (_basicName b)+basicName f b = (\x -> b{_basicName = x}) <$> f (_basicName b) {-# INLINE basicName #-}  basicVersion :: Lens' Basic Version-basicVersion f b = (\x -> b { _basicVersion = x }) <$> f (_basicVersion b)+basicVersion f b = (\x -> b{_basicVersion = x}) <$> f (_basicVersion b) {-# INLINE basicVersion #-}  basicPkgName :: Lens' Basic (Maybe PackageName)-basicPkgName f b = (\x -> b { _basicPkgName = x }) <$> f (_basicPkgName b)+basicPkgName f b = (\x -> b{_basicPkgName = x}) <$> f (_basicPkgName b) {-# INLINE basicPkgName #-}  basicLibName :: Lens' Basic (Maybe UnqualComponentName)-basicLibName f b = (\x -> b { _basicLibName = maybeToLibraryName x }) <$>-    f (libraryNameString (_basicLibName b))+basicLibName f b =+  (\x -> b{_basicLibName = maybeToLibraryName x})+    <$> f (libraryNameString (_basicLibName b)) {-# INLINE basicLibName #-}  basicLibVisibility :: Lens' Basic LibraryVisibility-basicLibVisibility f b = (\x -> b { _basicLibVisibility = x }) <$>-    f (_basicLibVisibility b)+basicLibVisibility f b =+  (\x -> b{_basicLibVisibility = x})+    <$> f (_basicLibVisibility b) {-# INLINE basicLibVisibility #-}  basicFieldGrammar-    :: ( FieldGrammar c g, Applicative (g Basic)-       , c (Identity LibraryVisibility)-       , c (Identity PackageName)-       , c (Identity UnqualComponentName)-       , c (MQuoted MungedPackageName)-       , c (MQuoted Version)-       )-    => g Basic Basic-basicFieldGrammar = mkBasic-    <$> optionalFieldDefAla "name"          MQuoted  basicName (mungedPackageName emptyInstalledPackageInfo)-    <*> optionalFieldDefAla "version"       MQuoted  basicVersion nullVersion-    <*> optionalField       "package-name"           basicPkgName-    <*> optionalField       "lib-name"               basicLibName-    <*> optionalFieldDef    "visibility"             basicLibVisibility LibraryVisibilityPrivate+  :: ( FieldGrammar c g+     , Applicative (g Basic)+     , c (Identity LibraryVisibility)+     , c (Identity PackageName)+     , c (Identity UnqualComponentName)+     , c (MQuoted MungedPackageName)+     , c (MQuoted Version)+     )+  => g Basic Basic+basicFieldGrammar =+  mkBasic+    <$> optionalFieldDefAla "name" MQuoted basicName (mungedPackageName emptyInstalledPackageInfo)+    <*> optionalFieldDefAla "version" MQuoted basicVersion nullVersion+    <*> optionalField "package-name" basicPkgName+    <*> optionalField "lib-name" basicLibName+    <*> optionalFieldDef "visibility" basicLibVisibility LibraryVisibilityPrivate   where     mkBasic n v pn ln lv = Basic n v pn ln' lv'       where@@ -310,10 +325,10 @@         -- This can be removed once we stop supporting GHC<8.8, at the         -- condition that we keep marking main libraries as public when         -- registering them.-        lv' = if-                let MungedPackageName _ mln = n in-                -- We need to check both because on ghc<8.2 ln' will always-                -- be LMainLibName-                ln' == LMainLibName && mln == LMainLibName-              then LibraryVisibilityPublic-              else lv+        lv' =+          if let MungedPackageName _ mln = n+              in -- We need to check both because on ghc<8.2 ln' will always+                 -- be LMainLibName+                 ln' == LMainLibName && mln == LMainLibName+            then LibraryVisibilityPublic+            else lv
src/Distribution/Types/InstalledPackageInfo/Lens.hs view
@@ -1,198 +1,196 @@-module Distribution.Types.InstalledPackageInfo.Lens (-    InstalledPackageInfo,-    module Distribution.Types.InstalledPackageInfo.Lens-    ) where+module Distribution.Types.InstalledPackageInfo.Lens+  ( InstalledPackageInfo+  , module Distribution.Types.InstalledPackageInfo.Lens+  ) where  import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Backpack                   (OpenModule)-import Distribution.License                    (License)-import Distribution.ModuleName                 (ModuleName)-import Distribution.Package                    (AbiHash, ComponentId, PackageIdentifier, UnitId)+import Distribution.Backpack (OpenModule)+import Distribution.License (License)+import Distribution.ModuleName (ModuleName)+import Distribution.Package (AbiHash, ComponentId, PackageIdentifier, UnitId) import Distribution.Types.InstalledPackageInfo (AbiDependency, ExposedModule, InstalledPackageInfo)-import Distribution.Types.LibraryName          (LibraryName)-import Distribution.Types.LibraryVisibility    (LibraryVisibility)-import Distribution.Utils.ShortText            (ShortText)-+import Distribution.Types.LibraryName (LibraryName)+import Distribution.Types.LibraryVisibility (LibraryVisibility)+import Distribution.Utils.ShortText (ShortText) -import qualified Distribution.SPDX                       as SPDX+import qualified Distribution.SPDX as SPDX import qualified Distribution.Types.InstalledPackageInfo as T  sourcePackageId :: Lens' InstalledPackageInfo PackageIdentifier-sourcePackageId f s = fmap (\x -> s { T.sourcePackageId = x }) (f (T.sourcePackageId s))+sourcePackageId f s = fmap (\x -> s{T.sourcePackageId = x}) (f (T.sourcePackageId s)) {-# INLINE sourcePackageId #-}  installedUnitId :: Lens' InstalledPackageInfo UnitId-installedUnitId f s = fmap (\x -> s { T.installedUnitId = x }) (f (T.installedUnitId s))+installedUnitId f s = fmap (\x -> s{T.installedUnitId = x}) (f (T.installedUnitId s)) {-# INLINE installedUnitId #-}  installedComponentId_ :: Lens' InstalledPackageInfo ComponentId-installedComponentId_ f s = fmap (\x -> s { T.installedComponentId_ = x }) (f (T.installedComponentId_ s))+installedComponentId_ f s = fmap (\x -> s{T.installedComponentId_ = x}) (f (T.installedComponentId_ s)) {-# INLINE installedComponentId_ #-} -instantiatedWith :: Lens' InstalledPackageInfo [(ModuleName,OpenModule)]-instantiatedWith f s = fmap (\x -> s { T.instantiatedWith = x }) (f (T.instantiatedWith s))+instantiatedWith :: Lens' InstalledPackageInfo [(ModuleName, OpenModule)]+instantiatedWith f s = fmap (\x -> s{T.instantiatedWith = x}) (f (T.instantiatedWith s)) {-# INLINE instantiatedWith #-}  sourceLibName :: Lens' InstalledPackageInfo LibraryName-sourceLibName f s = fmap (\x -> s { T.sourceLibName = x }) (f (T.sourceLibName s))+sourceLibName f s = fmap (\x -> s{T.sourceLibName = x}) (f (T.sourceLibName s)) {-# INLINE sourceLibName #-}  compatPackageKey :: Lens' InstalledPackageInfo String-compatPackageKey f s = fmap (\x -> s { T.compatPackageKey = x }) (f (T.compatPackageKey s))+compatPackageKey f s = fmap (\x -> s{T.compatPackageKey = x}) (f (T.compatPackageKey s)) {-# INLINE compatPackageKey #-}  license :: Lens' InstalledPackageInfo (Either SPDX.License License)-license f s = fmap (\x -> s { T.license = x }) (f (T.license s))+license f s = fmap (\x -> s{T.license = x}) (f (T.license s)) {-# INLINE license #-}  copyright :: Lens' InstalledPackageInfo ShortText-copyright f s = fmap (\x -> s { T.copyright = x }) (f (T.copyright s))+copyright f s = fmap (\x -> s{T.copyright = x}) (f (T.copyright s)) {-# INLINE copyright #-}  maintainer :: Lens' InstalledPackageInfo ShortText-maintainer f s = fmap (\x -> s { T.maintainer = x }) (f (T.maintainer s))+maintainer f s = fmap (\x -> s{T.maintainer = x}) (f (T.maintainer s)) {-# INLINE maintainer #-}  author :: Lens' InstalledPackageInfo ShortText-author f s = fmap (\x -> s { T.author = x }) (f (T.author s))+author f s = fmap (\x -> s{T.author = x}) (f (T.author s)) {-# INLINE author #-}  stability :: Lens' InstalledPackageInfo ShortText-stability f s = fmap (\x -> s { T.stability = x }) (f (T.stability s))+stability f s = fmap (\x -> s{T.stability = x}) (f (T.stability s)) {-# INLINE stability #-}  homepage :: Lens' InstalledPackageInfo ShortText-homepage f s = fmap (\x -> s { T.homepage = x }) (f (T.homepage s))+homepage f s = fmap (\x -> s{T.homepage = x}) (f (T.homepage s)) {-# INLINE homepage #-}  pkgUrl :: Lens' InstalledPackageInfo ShortText-pkgUrl f s = fmap (\x -> s { T.pkgUrl = x }) (f (T.pkgUrl s))+pkgUrl f s = fmap (\x -> s{T.pkgUrl = x}) (f (T.pkgUrl s)) {-# INLINE pkgUrl #-}  synopsis :: Lens' InstalledPackageInfo ShortText-synopsis f s = fmap (\x -> s { T.synopsis = x }) (f (T.synopsis s))+synopsis f s = fmap (\x -> s{T.synopsis = x}) (f (T.synopsis s)) {-# INLINE synopsis #-}  description :: Lens' InstalledPackageInfo ShortText-description f s = fmap (\x -> s { T.description = x }) (f (T.description s))+description f s = fmap (\x -> s{T.description = x}) (f (T.description s)) {-# INLINE description #-}  category :: Lens' InstalledPackageInfo ShortText-category f s = fmap (\x -> s { T.category = x }) (f (T.category s))+category f s = fmap (\x -> s{T.category = x}) (f (T.category s)) {-# INLINE category #-}  abiHash :: Lens' InstalledPackageInfo AbiHash-abiHash f s = fmap (\x -> s { T.abiHash = x }) (f (T.abiHash s))+abiHash f s = fmap (\x -> s{T.abiHash = x}) (f (T.abiHash s)) {-# INLINE abiHash #-}  indefinite :: Lens' InstalledPackageInfo Bool-indefinite f s = fmap (\x -> s { T.indefinite = x }) (f (T.indefinite s))+indefinite f s = fmap (\x -> s{T.indefinite = x}) (f (T.indefinite s)) {-# INLINE indefinite #-}  exposed :: Lens' InstalledPackageInfo Bool-exposed f s = fmap (\x -> s { T.exposed = x }) (f (T.exposed s))+exposed f s = fmap (\x -> s{T.exposed = x}) (f (T.exposed s)) {-# INLINE exposed #-}  exposedModules :: Lens' InstalledPackageInfo [ExposedModule]-exposedModules f s = fmap (\x -> s { T.exposedModules = x }) (f (T.exposedModules s))+exposedModules f s = fmap (\x -> s{T.exposedModules = x}) (f (T.exposedModules s)) {-# INLINE exposedModules #-}  hiddenModules :: Lens' InstalledPackageInfo [ModuleName]-hiddenModules f s = fmap (\x -> s { T.hiddenModules = x }) (f (T.hiddenModules s))+hiddenModules f s = fmap (\x -> s{T.hiddenModules = x}) (f (T.hiddenModules s)) {-# INLINE hiddenModules #-}  trusted :: Lens' InstalledPackageInfo Bool-trusted f s = fmap (\x -> s { T.trusted = x }) (f (T.trusted s))+trusted f s = fmap (\x -> s{T.trusted = x}) (f (T.trusted s)) {-# INLINE trusted #-}  importDirs :: Lens' InstalledPackageInfo [FilePath]-importDirs f s = fmap (\x -> s { T.importDirs = x }) (f (T.importDirs s))+importDirs f s = fmap (\x -> s{T.importDirs = x}) (f (T.importDirs s)) {-# INLINE importDirs #-}  libraryDirs :: Lens' InstalledPackageInfo [FilePath]-libraryDirs f s = fmap (\x -> s { T.libraryDirs = x }) (f (T.libraryDirs s))+libraryDirs f s = fmap (\x -> s{T.libraryDirs = x}) (f (T.libraryDirs s)) {-# INLINE libraryDirs #-}  libraryDirsStatic :: Lens' InstalledPackageInfo [FilePath]-libraryDirsStatic f s = fmap (\x -> s { T.libraryDirsStatic = x }) (f (T.libraryDirsStatic s))+libraryDirsStatic f s = fmap (\x -> s{T.libraryDirsStatic = x}) (f (T.libraryDirsStatic s)) {-# INLINE libraryDirsStatic #-}  libraryDynDirs :: Lens' InstalledPackageInfo [FilePath]-libraryDynDirs f s = fmap (\x -> s { T.libraryDynDirs = x }) (f (T.libraryDynDirs s))+libraryDynDirs f s = fmap (\x -> s{T.libraryDynDirs = x}) (f (T.libraryDynDirs s)) {-# INLINE libraryDynDirs #-}  dataDir :: Lens' InstalledPackageInfo FilePath-dataDir f s = fmap (\x -> s { T.dataDir = x }) (f (T.dataDir s))+dataDir f s = fmap (\x -> s{T.dataDir = x}) (f (T.dataDir s)) {-# INLINE dataDir #-}  hsLibraries :: Lens' InstalledPackageInfo [String]-hsLibraries f s = fmap (\x -> s { T.hsLibraries = x }) (f (T.hsLibraries s))+hsLibraries f s = fmap (\x -> s{T.hsLibraries = x}) (f (T.hsLibraries s)) {-# INLINE hsLibraries #-}  extraLibraries :: Lens' InstalledPackageInfo [String]-extraLibraries f s = fmap (\x -> s { T.extraLibraries = x }) (f (T.extraLibraries s))+extraLibraries f s = fmap (\x -> s{T.extraLibraries = x}) (f (T.extraLibraries s)) {-# INLINE extraLibraries #-}  extraLibrariesStatic :: Lens' InstalledPackageInfo [String]-extraLibrariesStatic f s = fmap (\x -> s { T.extraLibrariesStatic = x }) (f (T.extraLibrariesStatic s))+extraLibrariesStatic f s = fmap (\x -> s{T.extraLibrariesStatic = x}) (f (T.extraLibrariesStatic s)) {-# INLINE extraLibrariesStatic #-}  extraGHCiLibraries :: Lens' InstalledPackageInfo [String]-extraGHCiLibraries f s = fmap (\x -> s { T.extraGHCiLibraries = x }) (f (T.extraGHCiLibraries s))+extraGHCiLibraries f s = fmap (\x -> s{T.extraGHCiLibraries = x}) (f (T.extraGHCiLibraries s)) {-# INLINE extraGHCiLibraries #-}  includeDirs :: Lens' InstalledPackageInfo [FilePath]-includeDirs f s = fmap (\x -> s { T.includeDirs = x }) (f (T.includeDirs s))+includeDirs f s = fmap (\x -> s{T.includeDirs = x}) (f (T.includeDirs s)) {-# INLINE includeDirs #-}  includes :: Lens' InstalledPackageInfo [String]-includes f s = fmap (\x -> s { T.includes = x }) (f (T.includes s))+includes f s = fmap (\x -> s{T.includes = x}) (f (T.includes s)) {-# INLINE includes #-}  depends :: Lens' InstalledPackageInfo [UnitId]-depends f s = fmap (\x -> s { T.depends = x }) (f (T.depends s))+depends f s = fmap (\x -> s{T.depends = x}) (f (T.depends s)) {-# INLINE depends #-}  abiDepends :: Lens' InstalledPackageInfo [AbiDependency]-abiDepends f s = fmap (\x -> s { T.abiDepends = x }) (f (T.abiDepends s))+abiDepends f s = fmap (\x -> s{T.abiDepends = x}) (f (T.abiDepends s)) {-# INLINE abiDepends #-}  ccOptions :: Lens' InstalledPackageInfo [String]-ccOptions f s = fmap (\x -> s { T.ccOptions = x }) (f (T.ccOptions s))+ccOptions f s = fmap (\x -> s{T.ccOptions = x}) (f (T.ccOptions s)) {-# INLINE ccOptions #-}  cxxOptions :: Lens' InstalledPackageInfo [String]-cxxOptions f s = fmap (\x -> s { T.cxxOptions = x }) (f (T.cxxOptions s))+cxxOptions f s = fmap (\x -> s{T.cxxOptions = x}) (f (T.cxxOptions s)) {-# INLINE cxxOptions #-}  ldOptions :: Lens' InstalledPackageInfo [String]-ldOptions f s = fmap (\x -> s { T.ldOptions = x }) (f (T.ldOptions s))+ldOptions f s = fmap (\x -> s{T.ldOptions = x}) (f (T.ldOptions s)) {-# INLINE ldOptions #-}  frameworkDirs :: Lens' InstalledPackageInfo [FilePath]-frameworkDirs f s = fmap (\x -> s { T.frameworkDirs = x }) (f (T.frameworkDirs s))+frameworkDirs f s = fmap (\x -> s{T.frameworkDirs = x}) (f (T.frameworkDirs s)) {-# INLINE frameworkDirs #-}  frameworks :: Lens' InstalledPackageInfo [String]-frameworks f s = fmap (\x -> s { T.frameworks = x }) (f (T.frameworks s))+frameworks f s = fmap (\x -> s{T.frameworks = x}) (f (T.frameworks s)) {-# INLINE frameworks #-}  haddockInterfaces :: Lens' InstalledPackageInfo [FilePath]-haddockInterfaces f s = fmap (\x -> s { T.haddockInterfaces = x }) (f (T.haddockInterfaces s))+haddockInterfaces f s = fmap (\x -> s{T.haddockInterfaces = x}) (f (T.haddockInterfaces s)) {-# INLINE haddockInterfaces #-}  haddockHTMLs :: Lens' InstalledPackageInfo [FilePath]-haddockHTMLs f s = fmap (\x -> s { T.haddockHTMLs = x }) (f (T.haddockHTMLs s))+haddockHTMLs f s = fmap (\x -> s{T.haddockHTMLs = x}) (f (T.haddockHTMLs s)) {-# INLINE haddockHTMLs #-}  pkgRoot :: Lens' InstalledPackageInfo (Maybe FilePath)-pkgRoot f s = fmap (\x -> s { T.pkgRoot = x }) (f (T.pkgRoot s))+pkgRoot f s = fmap (\x -> s{T.pkgRoot = x}) (f (T.pkgRoot s)) {-# INLINE pkgRoot #-}  libVisibility :: Lens' InstalledPackageInfo LibraryVisibility-libVisibility f s = fmap (\x -> s { T.libVisibility = x }) (f (T.libVisibility s))+libVisibility f s = fmap (\x -> s{T.libVisibility = x}) (f (T.libVisibility s)) {-# INLINE libVisibility #-}-
src/Distribution/Types/LegacyExeDependency.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.LegacyExeDependency-  ( LegacyExeDependency(..)+  ( LegacyExeDependency (..)   ) where  import Distribution.Compat.Prelude@@ -12,7 +13,7 @@ import Distribution.Version (VersionRange, anyVersion)  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp  -- | Describes a legacy `build-tools`-style dependency on an executable --@@ -21,27 +22,28 @@ -- executable (UnqualComponentName). Thus the name is stringly typed. -- -- @since 2.0.0.2-data LegacyExeDependency = LegacyExeDependency-                           String-                           VersionRange-                         deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data LegacyExeDependency+  = LegacyExeDependency+      String+      VersionRange+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary LegacyExeDependency instance Structured LegacyExeDependency instance NFData LegacyExeDependency where rnf = genericRnf  instance Pretty LegacyExeDependency where-    pretty (LegacyExeDependency name ver) =-        Disp.text name <+> pretty ver+  pretty (LegacyExeDependency name ver) =+    Disp.text name <+> pretty ver  instance Parsec LegacyExeDependency where-    parsec = do-        name <- parsecMaybeQuoted nameP-        P.spaces-        verRange <- parsecMaybeQuoted parsec <|> pure anyVersion-        pure $ LegacyExeDependency name verRange-      where-        nameP = intercalate "-" <$> toList <$> P.sepByNonEmpty component (P.char '-')-        component = do-            cs <- P.munch1 (\c -> isAlphaNum c || c == '+' || c == '_')-            if all isDigit cs then fail "invalid component" else return cs+  parsec = do+    name <- parsecMaybeQuoted nameP+    P.spaces+    verRange <- parsecMaybeQuoted parsec <|> pure anyVersion+    pure $ LegacyExeDependency name verRange+    where+      nameP = intercalate "-" <$> toList <$> P.sepByNonEmpty component (P.char '-')+      component = do+        cs <- P.munch1 (\c -> isAlphaNum c || c == '+' || c == '_')+        if all isDigit cs then fail "invalid component" else return cs
src/Distribution/Types/Lens.hs view
@@ -1,16 +1,16 @@-module Distribution.Types.Lens (-    module Distribution.Types.Benchmark.Lens,-    module Distribution.Types.BuildInfo.Lens,-    module Distribution.Types.Executable.Lens,-    module Distribution.Types.ForeignLib.Lens,-    module Distribution.Types.GenericPackageDescription.Lens,-    module Distribution.Types.Library.Lens,-    module Distribution.Types.PackageDescription.Lens,-    module Distribution.Types.PackageId.Lens,-    module Distribution.Types.SetupBuildInfo.Lens,-    module Distribution.Types.SourceRepo.Lens,-    module Distribution.Types.TestSuite.Lens,-    ) where+module Distribution.Types.Lens+  ( module Distribution.Types.Benchmark.Lens+  , module Distribution.Types.BuildInfo.Lens+  , module Distribution.Types.Executable.Lens+  , module Distribution.Types.ForeignLib.Lens+  , module Distribution.Types.GenericPackageDescription.Lens+  , module Distribution.Types.Library.Lens+  , module Distribution.Types.PackageDescription.Lens+  , module Distribution.Types.PackageId.Lens+  , module Distribution.Types.SetupBuildInfo.Lens+  , module Distribution.Types.SourceRepo.Lens+  , module Distribution.Types.TestSuite.Lens+  ) where  import Distribution.Types.Benchmark.Lens import Distribution.Types.BuildInfo.Lens
src/Distribution/Types/Library.hs view
@@ -1,51 +1,55 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.Library (-    Library(..),-    emptyLibrary,-    explicitLibModules,-    libModulesAutogen,-) where+module Distribution.Types.Library+  ( Library (..)+  , emptyLibrary+  , explicitLibModules+  , libModulesAutogen+  ) where  import Distribution.Compat.Prelude import Prelude ()  import Distribution.ModuleName import Distribution.Types.BuildInfo+import Distribution.Types.LibraryName import Distribution.Types.LibraryVisibility import Distribution.Types.ModuleReexport-import Distribution.Types.LibraryName  import qualified Distribution.Types.BuildInfo.Lens as L  data Library = Library-    { libName           :: LibraryName-    , exposedModules    :: [ModuleName]-    , reexportedModules :: [ModuleReexport]-    , signatures        :: [ModuleName]       -- ^ What sigs need implementations?-    , libExposed        :: Bool               -- ^ Is the lib to be exposed by default? (i.e. whether its modules available in GHCi for example)-    , libVisibility     :: LibraryVisibility  -- ^ Whether this multilib can be used as a dependency for other packages.-    , libBuildInfo      :: BuildInfo-    }-    deriving (Generic, Show, Eq, Ord, Read, Typeable, Data)+  { libName :: LibraryName+  , exposedModules :: [ModuleName]+  , reexportedModules :: [ModuleReexport]+  , signatures :: [ModuleName]+  -- ^ What sigs need implementations?+  , libExposed :: Bool+  -- ^ Is the lib to be exposed by default? (i.e. whether its modules available in GHCi for example)+  , libVisibility :: LibraryVisibility+  -- ^ Whether this multilib can be used as a dependency for other packages.+  , libBuildInfo :: BuildInfo+  }+  deriving (Generic, Show, Eq, Ord, Read, Data)  instance L.HasBuildInfo Library where-    buildInfo f l = (\x -> l { libBuildInfo = x }) <$> f (libBuildInfo l)+  buildInfo f l = (\x -> l{libBuildInfo = x}) <$> f (libBuildInfo l)  instance Binary Library instance Structured Library instance NFData Library where rnf = genericRnf  emptyLibrary :: Library-emptyLibrary = Library-    { libName           = LMainLibName-    , exposedModules    = mempty+emptyLibrary =+  Library+    { libName = LMainLibName+    , exposedModules = mempty     , reexportedModules = mempty-    , signatures        = mempty-    , libExposed        = True-    , libVisibility     = mempty-    , libBuildInfo      = mempty+    , signatures = mempty+    , libExposed = True+    , libVisibility = mempty+    , libBuildInfo = mempty     }  -- | This instance is not good.@@ -55,22 +59,23 @@ -- -- More concretely, 'addBuildableCondition' will make `libVisibility = False` -- libraries when `buildable: false`. This may cause problems.--- instance Monoid Library where-    mempty = emptyLibrary-    mappend = (<>)+  mempty = emptyLibrary+  mappend = (<>)  instance Semigroup Library where-  a <> b = Library-    { libName           = combineLibraryName (libName a) (libName b)-    , exposedModules    = combine exposedModules-    , reexportedModules = combine reexportedModules-    , signatures        = combine signatures-    , libExposed        = libExposed a && libExposed b -- so False propagates-    , libVisibility     = combine libVisibility-    , libBuildInfo      = combine libBuildInfo-    }-    where combine field = field a `mappend` field b+  a <> b =+    Library+      { libName = combineLibraryName (libName a) (libName b)+      , exposedModules = combine exposedModules+      , reexportedModules = combine reexportedModules+      , signatures = combine signatures+      , libExposed = libExposed a && libExposed b -- so False propagates+      , libVisibility = combine libVisibility+      , libBuildInfo = combine libBuildInfo+      }+    where+      combine field = field a `mappend` field b  -- | Get all the module names from the library (exposed and internal modules) -- which are explicitly listed in the package description which would@@ -78,9 +83,10 @@ -- do not need to be compiled.)  This may not include all modules for which -- GHC generated interface files (i.e., implicit modules.) explicitLibModules :: Library -> [ModuleName]-explicitLibModules lib = exposedModules lib-              ++ otherModules (libBuildInfo lib)-              ++ signatures lib+explicitLibModules lib =+  exposedModules lib+    ++ otherModules (libBuildInfo lib)+    ++ signatures lib  -- | Get all the auto generated module names from the library, exposed or not. -- This are a subset of 'libModules'.@@ -93,4 +99,4 @@ -- /Should/ be irrelevant. combineLibraryName :: LibraryName -> LibraryName -> LibraryName combineLibraryName l@(LSubLibName _) _ = l-combineLibraryName _ l                 = l+combineLibraryName _ l = l
src/Distribution/Types/Library/Lens.hs view
@@ -1,45 +1,45 @@-module Distribution.Types.Library.Lens (-    Library,-    module Distribution.Types.Library.Lens,-    ) where+module Distribution.Types.Library.Lens+  ( Library+  , module Distribution.Types.Library.Lens+  ) where  import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.ModuleName              (ModuleName)-import Distribution.Types.BuildInfo         (BuildInfo)-import Distribution.Types.Library           (Library)-import Distribution.Types.LibraryName       (LibraryName)+import Distribution.ModuleName (ModuleName)+import Distribution.Types.BuildInfo (BuildInfo)+import Distribution.Types.Library (Library)+import Distribution.Types.LibraryName (LibraryName) import Distribution.Types.LibraryVisibility (LibraryVisibility)-import Distribution.Types.ModuleReexport    (ModuleReexport)+import Distribution.Types.ModuleReexport (ModuleReexport)  import qualified Distribution.Types.Library as T  libName :: Lens' Library LibraryName-libName f s = fmap (\x -> s { T.libName = x }) (f (T.libName s))+libName f s = fmap (\x -> s{T.libName = x}) (f (T.libName s)) {-# INLINE libName #-}  exposedModules :: Lens' Library [ModuleName]-exposedModules f s = fmap (\x -> s { T.exposedModules = x }) (f (T.exposedModules s))+exposedModules f s = fmap (\x -> s{T.exposedModules = x}) (f (T.exposedModules s)) {-# INLINE exposedModules #-}  reexportedModules :: Lens' Library [ModuleReexport]-reexportedModules f s = fmap (\x -> s { T.reexportedModules = x }) (f (T.reexportedModules s))+reexportedModules f s = fmap (\x -> s{T.reexportedModules = x}) (f (T.reexportedModules s)) {-# INLINE reexportedModules #-}  signatures :: Lens' Library [ModuleName]-signatures f s = fmap (\x -> s { T.signatures = x }) (f (T.signatures s))+signatures f s = fmap (\x -> s{T.signatures = x}) (f (T.signatures s)) {-# INLINE signatures #-}  libExposed :: Lens' Library Bool-libExposed f s = fmap (\x -> s { T.libExposed = x }) (f (T.libExposed s))+libExposed f s = fmap (\x -> s{T.libExposed = x}) (f (T.libExposed s)) {-# INLINE libExposed #-}  libVisibility :: Lens' Library LibraryVisibility-libVisibility f s = fmap (\x -> s { T.libVisibility = x }) (f (T.libVisibility s))+libVisibility f s = fmap (\x -> s{T.libVisibility = x}) (f (T.libVisibility s)) {-# INLINE libVisibility #-}  libBuildInfo :: Lens' Library BuildInfo-libBuildInfo f s = fmap (\x -> s { T.libBuildInfo = x }) (f (T.libBuildInfo s))+libBuildInfo f s = fmap (\x -> s{T.libBuildInfo = x}) (f (T.libBuildInfo s)) {-# INLINE libBuildInfo #-}
src/Distribution/Types/LibraryName.hs view
@@ -1,31 +1,35 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.LibraryName (-  LibraryName(..),-  defaultLibName,-  maybeToLibraryName,-  showLibraryName,-  libraryNameStanza,-  libraryNameString,-  -- * Pretty & Parse-  prettyLibraryNameComponent,-  parsecLibraryNameComponent,+module Distribution.Types.LibraryName+  ( LibraryName (..)+  , defaultLibName+  , maybeToLibraryName+  , showLibraryName+  , libraryNameStanza+  , libraryNameString++    -- * Pretty & Parse+  , prettyLibraryNames+  , prettyLibraryNameComponent+  , parsecLibraryNameComponent   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.UnqualComponentName-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty+import Distribution.Types.UnqualComponentName +import qualified Data.List.NonEmpty as NEL import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp -data LibraryName = LMainLibName-                 | LSubLibName UnqualComponentName-                 deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)+data LibraryName+  = LMainLibName+  | LSubLibName UnqualComponentName+  deriving (Eq, Generic, Ord, Read, Show, Data)  instance Binary LibraryName instance Structured LibraryName@@ -37,28 +41,44 @@ -- as there's other way to represent 'LibraryName', namely as bare -- 'UnqualComponentName'. prettyLibraryNameComponent :: LibraryName -> Disp.Doc-prettyLibraryNameComponent LMainLibName      = Disp.text "lib"+prettyLibraryNameComponent LMainLibName = Disp.text "lib" prettyLibraryNameComponent (LSubLibName str) = Disp.text "lib:" <<>> pretty str +-- | Pretty print a 'LibraryName' after a package name.+--+-- Produces output like @foo@, @foo:bar@, or @foo:{bar,baz}@+prettyLibraryNames :: Pretty a => a -> NonEmpty LibraryName -> Disp.Doc+prettyLibraryNames package libraries =+  let doc = pretty package++      prettyComponent LMainLibName = pretty package+      prettyComponent (LSubLibName component) = Disp.text $ unUnqualComponentName component++      prettyComponents = commaSep $ prettyComponent <$> NEL.toList libraries+   in case libraries of+        LMainLibName :| [] -> doc+        LSubLibName component :| [] -> doc <<>> Disp.colon <<>> pretty component+        _ -> doc <<>> Disp.colon <<>> Disp.braces prettyComponents+ parsecLibraryNameComponent :: CabalParsing m => m LibraryName parsecLibraryNameComponent = do-    _ <- P.string "lib"-    parseComposite <|> parseSingle+  _ <- P.string "lib"+  parseComposite <|> parseSingle   where     parseSingle = return LMainLibName     parseComposite = do-        _ <- P.char ':'-        LSubLibName <$> parsec+      _ <- P.char ':'+      LSubLibName <$> parsec  defaultLibName :: LibraryName defaultLibName = LMainLibName  showLibraryName :: LibraryName -> String-showLibraryName LMainLibName       = "library"+showLibraryName LMainLibName = "library" showLibraryName (LSubLibName name) = "library '" ++ prettyShow name ++ "'"  libraryNameStanza :: LibraryName -> String-libraryNameStanza LMainLibName       = "library"+libraryNameStanza LMainLibName = "library" libraryNameStanza (LSubLibName name) = "library " ++ prettyShow name  libraryNameString :: LibraryName -> Maybe UnqualComponentName@@ -70,4 +90,3 @@ maybeToLibraryName :: Maybe UnqualComponentName -> LibraryName maybeToLibraryName Nothing = LMainLibName maybeToLibraryName (Just n) = LSubLibName n-
src/Distribution/Types/LibraryVisibility.hs view
@@ -1,10 +1,10 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-{-# LANGUAGE OverloadedStrings  #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.LibraryVisibility(-    LibraryVisibility(..),-) where+module Distribution.Types.LibraryVisibility+  ( LibraryVisibility (..)+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -13,39 +13,38 @@ import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp  -- | Multi-lib visibility -- -- @since 3.0.0.0--- data LibraryVisibility-      -- | Can be used as a dependency for other packages-    = LibraryVisibilityPublic-      -- | Internal library, default-    | LibraryVisibilityPrivate-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+  = -- | Can be used as a dependency for other packages+    LibraryVisibilityPublic+  | -- | Internal library, default+    LibraryVisibilityPrivate+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Pretty LibraryVisibility where-    pretty LibraryVisibilityPublic  = Disp.text "public"-    pretty LibraryVisibilityPrivate = Disp.text "private"+  pretty LibraryVisibilityPublic = Disp.text "public"+  pretty LibraryVisibilityPrivate = Disp.text "private"  instance Parsec LibraryVisibility where   parsec = do     name <- P.munch1 isAlpha     case name of-      "public"  -> return LibraryVisibilityPublic+      "public" -> return LibraryVisibilityPublic       "private" -> return LibraryVisibilityPrivate-      _         -> fail $ "Unknown visibility: " ++ name+      _ -> fail $ "Unknown visibility: " ++ name  instance Binary LibraryVisibility instance Structured LibraryVisibility instance NFData LibraryVisibility where rnf = genericRnf  instance Semigroup LibraryVisibility where-    LibraryVisibilityPrivate <> LibraryVisibilityPrivate = LibraryVisibilityPrivate-    _                        <> _                        = LibraryVisibilityPublic+  LibraryVisibilityPrivate <> LibraryVisibilityPrivate = LibraryVisibilityPrivate+  _ <> _ = LibraryVisibilityPublic  instance Monoid LibraryVisibility where-    mempty  = LibraryVisibilityPrivate-    mappend = (<>)+  mempty = LibraryVisibilityPrivate+  mappend = (<>)
+ src/Distribution/Types/MissingDependency.hs view
@@ -0,0 +1,34 @@+module Distribution.Types.MissingDependency+  ( MissingDependency (..)+  ) where++import Distribution.Compat.Prelude+import Distribution.Pretty+import Distribution.Types.Dependency+  ( Dependency+  , simplifyDependency+  )+import Distribution.Types.LibraryName+  ( prettyLibraryNames+  )+import Distribution.Types.MissingDependencyReason+  ( MissingDependencyReason (..)+  )++import qualified Text.PrettyPrint as PP++-- | A missing dependency and information on why it's missing.+data MissingDependency = MissingDependency Dependency MissingDependencyReason+  deriving (Show)++instance Pretty MissingDependency where+  pretty (MissingDependency dependency reason) =+    let prettyReason =+          case reason of+            MissingLibrary libraries ->+              PP.text "missing" <+> prettyLibraryNames PP.empty libraries+            MissingPackage -> PP.text "missing"+            MissingComponent name -> PP.text "missing component" <+> pretty name+            WrongVersion versions ->+              PP.text "installed:" <+> commaSpaceSep versions+     in pretty (simplifyDependency dependency) <+> PP.parens prettyReason
+ src/Distribution/Types/MissingDependencyReason.hs view
@@ -0,0 +1,25 @@+module Distribution.Types.MissingDependencyReason+  ( MissingDependencyReason (..)+  ) where++import Data.List.NonEmpty (NonEmpty)+import Distribution.Types.LibraryName (LibraryName)+import Distribution.Types.PackageName (PackageName)+import Distribution.Types.Version (Version)++-- | A reason for a dependency failing to solve.+--+-- This helps pinpoint dependencies that are installed with an incorrect+-- version vs. dependencies that are not installed at all.+data MissingDependencyReason+  = -- | One or more libraries is missing.+    MissingLibrary (NonEmpty LibraryName)+  | -- | A package is not installed.+    MissingPackage+  | -- | A package is installed, but the versions don't match.+    --+    -- Contains the available versions.+    WrongVersion [Version]+  | -- | A component is not installed.+    MissingComponent PackageName+  deriving (Show)
src/Distribution/Types/Mixin.hs view
@@ -1,11 +1,11 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.Mixin (-    Mixin(..),-    mkMixin,-    normaliseMixin,-) where+module Distribution.Types.Mixin+  ( Mixin (..)+  , mkMixin+  , normaliseMixin+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -19,18 +19,19 @@ import Distribution.Types.UnqualComponentName  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as PP+import qualified Text.PrettyPrint as PP  -- | -- -- /Invariant:/ if 'mixinLibraryName' is 'LSubLibName', it's not -- the same as 'mixinPackageName'. In other words, -- the same invariant as 'Dependency' has.----data Mixin = Mixin { mixinPackageName :: PackageName-                   , mixinLibraryName :: LibraryName-                   , mixinIncludeRenaming :: IncludeRenaming }-    deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+data Mixin = Mixin+  { mixinPackageName :: PackageName+  , mixinLibraryName :: LibraryName+  , mixinIncludeRenaming :: IncludeRenaming+  }+  deriving (Show, Read, Eq, Ord, Data, Generic)  instance Binary Mixin instance Structured Mixin@@ -38,8 +39,8 @@ instance NFData Mixin where rnf = genericRnf  instance Pretty Mixin where-    pretty (Mixin pn LMainLibName incl)     = pretty pn <+> pretty incl-    pretty (Mixin pn (LSubLibName ln) incl) = pretty pn <<>> PP.colon <<>> pretty ln <+> pretty incl+  pretty (Mixin pn LMainLibName incl) = pretty pn <+> pretty incl+  pretty (Mixin pn (LSubLibName ln) incl) = pretty pn <<>> PP.colon <<>> pretty ln <+> pretty incl  -- | --@@ -56,36 +57,36 @@ -- -- >>> map (`simpleParsec'` "mylib:sub") [CabalSpecV3_0, CabalSpecV3_4] :: [Maybe Mixin] -- [Nothing,Just (Mixin {mixinPackageName = PackageName "mylib", mixinLibraryName = LSubLibName (UnqualComponentName "sub"), mixinIncludeRenaming = IncludeRenaming {includeProvidesRn = DefaultRenaming, includeRequiresRn = DefaultRenaming}})]--- instance Parsec Mixin where-    parsec = do-        pn <- parsec-        ln <- P.option LMainLibName $ do-            _ <- P.char ':'-            versionGuardMultilibs-            LSubLibName <$> parsec-        P.spaces-        incl <- parsec-        return (mkMixin pn ln incl)-      where+  parsec = do+    pn <- parsec+    ln <- P.option LMainLibName $ do+      _ <- P.char ':'+      versionGuardMultilibs+      LSubLibName <$> parsec+    P.spaces+    incl <- parsec+    return (mkMixin pn ln incl)  versionGuardMultilibs :: CabalParsing m => m () versionGuardMultilibs = do   csv <- askCabalSpecVersion-  when (csv < CabalSpecV3_4) $ fail $ unwords-    [ "Sublibrary mixin syntax used."-    , "To use this syntax the package needs to specify at least 'cabal-version: 3.4'."-    ]+  when (csv < CabalSpecV3_4) $+    fail $+      unwords+        [ "Sublibrary mixin syntax used."+        , "To use this syntax the package needs to specify at least 'cabal-version: 3.4'."+        ]  -- | Smart constructor of 'Mixin', enforces invariant. -- -- @since 3.4.0.0 mkMixin :: PackageName -> LibraryName -> IncludeRenaming -> Mixin mkMixin pn (LSubLibName uqn) incl-    | packageNameToUnqualComponentName pn == uqn-    = Mixin pn LMainLibName incl-mkMixin pn ln incl-    = Mixin pn ln incl+  | packageNameToUnqualComponentName pn == uqn =+      Mixin pn LMainLibName incl+mkMixin pn ln incl =+  Mixin pn ln incl  -- | Restore invariant normaliseMixin :: Mixin -> Mixin
src/Distribution/Types/Module.hs view
@@ -1,20 +1,19 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}  module Distribution.Types.Module-  ( Module(..)+  ( Module (..)   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint as Disp-import Distribution.Pretty+import Distribution.ModuleName import Distribution.Parsec+import Distribution.Pretty import Distribution.Types.UnitId-import Distribution.ModuleName+import qualified Text.PrettyPrint as Disp  -- | A module identity uniquely identifies a Haskell module by -- qualifying a 'ModuleName' with the 'UnitId' which defined@@ -24,23 +23,23 @@ -- There are a few cases where Cabal needs to know about -- module identities, e.g., when writing out reexported modules in -- the 'InstalledPackageInfo'.-data Module =-      Module DefUnitId ModuleName-    deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data Module+  = Module DefUnitId ModuleName+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary Module instance Structured Module  instance Pretty Module where-    pretty (Module uid mod_name) =-        pretty uid <<>> Disp.text ":" <<>> pretty mod_name+  pretty (Module uid mod_name) =+    pretty uid <<>> Disp.text ":" <<>> pretty mod_name  instance Parsec Module where-    parsec = do-        uid <- parsec-        _ <- P.char ':'-        mod_name <- parsec-        return (Module uid mod_name)+  parsec = do+    uid <- parsec+    _ <- P.char ':'+    mod_name <- parsec+    return (Module uid mod_name)  instance NFData Module where-    rnf (Module uid mod_name) = rnf uid `seq` rnf mod_name+  rnf (Module uid mod_name) = rnf uid `seq` rnf mod_name
src/Distribution/Types/ModuleReexport.hs view
@@ -1,9 +1,9 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.ModuleReexport (-    ModuleReexport(..)-) where+module Distribution.Types.ModuleReexport+  ( ModuleReexport (..)+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -14,37 +14,37 @@ import Distribution.Types.PackageName  import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp  -- ----------------------------------------------------------------------------- -- Module re-exports -data ModuleReexport = ModuleReexport {-       moduleReexportOriginalPackage :: Maybe PackageName,-       moduleReexportOriginalName    :: ModuleName,-       moduleReexportName            :: ModuleName-    }-    deriving (Eq, Ord, Generic, Read, Show, Typeable, Data)+data ModuleReexport = ModuleReexport+  { moduleReexportOriginalPackage :: Maybe PackageName+  , moduleReexportOriginalName :: ModuleName+  , moduleReexportName :: ModuleName+  }+  deriving (Eq, Ord, Generic, Read, Show, Data)  instance Binary ModuleReexport instance Structured ModuleReexport instance NFData ModuleReexport where rnf = genericRnf  instance Pretty ModuleReexport where-    pretty (ModuleReexport mpkgname origname newname) =-          maybe Disp.empty (\pkgname -> pretty pkgname <<>> Disp.char ':') mpkgname-       <<>> pretty origname+  pretty (ModuleReexport mpkgname origname newname) =+    maybe Disp.empty (\pkgname -> pretty pkgname <<>> Disp.char ':') mpkgname+      <<>> pretty origname       <+> if newname == origname-            then Disp.empty-            else Disp.text "as" <+> pretty newname+        then Disp.empty+        else Disp.text "as" <+> pretty newname  instance Parsec ModuleReexport where-    parsec = do-        mpkgname <- P.optional (P.try $ parsec <* P.char ':')-        origname <- parsec-        newname  <- P.option origname $ P.try $ do-            P.spaces-            _ <- P.string "as"-            P.spaces-            parsec-        return (ModuleReexport mpkgname origname newname)+  parsec = do+    mpkgname <- P.optional (P.try $ parsec <* P.char ':')+    origname <- parsec+    newname <- P.option origname $ P.try $ do+      P.spaces+      _ <- P.string "as"+      P.spaces+      parsec+    return (ModuleReexport mpkgname origname newname)
src/Distribution/Types/ModuleRenaming.hs view
@@ -1,13 +1,13 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-{-# LANGUAGE RankNTypes         #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE RankNTypes #-} -module Distribution.Types.ModuleRenaming (-    ModuleRenaming(..),-    interpModuleRenaming,-    defaultRenaming,-    isDefaultRenaming,-) where+module Distribution.Types.ModuleRenaming+  ( ModuleRenaming (..)+  , interpModuleRenaming+  , defaultRenaming+  , isDefaultRenaming+  ) where  import Distribution.CabalSpecVersion import Distribution.Compat.Prelude hiding (empty)@@ -17,10 +17,10 @@ import Distribution.Parsec import Distribution.Pretty -import qualified Data.Map                   as Map-import qualified Data.Set                   as Set+import qualified Data.Map as Map+import qualified Data.Set as Set import qualified Distribution.Compat.CharParsing as P-import           Text.PrettyPrint           (hsep, parens, punctuate, text, comma)+import Text.PrettyPrint (comma, hsep, parens, punctuate, text)  -- | Renaming applied to the modules provided by a package. -- The boolean indicates whether or not to also include all of the@@ -30,18 +30,17 @@ -- If a renaming is omitted you get the 'DefaultRenaming'. -- -- (NB: This is a list not a map so that we can preserve order.)--- data ModuleRenaming-        -- | A module renaming/thinning; e.g., @(A as B, C as C)@-        -- brings @B@ and @C@ into scope.-        = ModuleRenaming [(ModuleName, ModuleName)]-        -- | The default renaming, bringing all exported modules-        -- into scope.-        | DefaultRenaming-        -- | Hiding renaming, e.g., @hiding (A, B)@, bringing all-        -- exported modules into scope except the hidden ones.-        | HidingRenaming [ModuleName]-    deriving (Show, Read, Eq, Ord, Typeable, Data, Generic)+  = -- | A module renaming/thinning; e.g., @(A as B, C as C)@+    -- brings @B@ and @C@ into scope.+    ModuleRenaming [(ModuleName, ModuleName)]+  | -- | The default renaming, bringing all exported modules+    -- into scope.+    DefaultRenaming+  | -- | Hiding renaming, e.g., @hiding (A, B)@, bringing all+    -- exported modules into scope except the hidden ones.+    HidingRenaming [ModuleName]+  deriving (Show, Read, Eq, Ord, Data, Generic)  -- | Interpret a 'ModuleRenaming' as a partial map from 'ModuleName' -- to 'ModuleName'.  For efficiency, you should partially apply it@@ -49,11 +48,11 @@ interpModuleRenaming :: ModuleRenaming -> ModuleName -> Maybe ModuleName interpModuleRenaming DefaultRenaming = Just interpModuleRenaming (ModuleRenaming rns) =-    let m = Map.fromList rns-    in \k -> Map.lookup k m+  let m = Map.fromList rns+   in \k -> Map.lookup k m interpModuleRenaming (HidingRenaming hs) =-    let s = Set.fromList hs-    in \k -> if k `Set.member` s then Nothing else Just k+  let s = Set.fromList hs+   in \k -> if k `Set.member` s then Nothing else Just k  -- | The default renaming, if something is specified in @build-depends@ -- only.@@ -66,10 +65,8 @@ isDefaultRenaming DefaultRenaming = True isDefaultRenaming _ = False ---instance Binary ModuleRenaming where-instance Structured ModuleRenaming where+instance Binary ModuleRenaming+instance Structured ModuleRenaming  instance NFData ModuleRenaming where rnf = genericRnf @@ -77,58 +74,62 @@ -- to allow "hiding (A, B)" or other modifier words. instance Pretty ModuleRenaming where   pretty DefaultRenaming = mempty-  pretty (HidingRenaming hides)-        = text "hiding" <+> parens (hsep (punctuate comma (map pretty hides)))-  pretty (ModuleRenaming rns)-        = parens . hsep $ punctuate comma (map dispEntry rns)-    where dispEntry (orig, new)-            | orig == new = pretty orig-            | otherwise = pretty orig <+> text "as" <+> pretty new+  pretty (HidingRenaming hides) =+    text "hiding" <+> parens (hsep (punctuate comma (map pretty hides)))+  pretty (ModuleRenaming rns) =+    parens . hsep $ punctuate comma (map dispEntry rns)+    where+      dispEntry (orig, new)+        | orig == new = pretty orig+        | otherwise = pretty orig <+> text "as" <+> pretty new  instance Parsec ModuleRenaming where-    parsec = do-        csv <- askCabalSpecVersion-        if csv >= CabalSpecV3_0-        then moduleRenamingParsec parensLax    lexemeParsec-        else moduleRenamingParsec parensStrict parsec-      where-        -- For cabal spec versions < 3.0 white spaces were not skipped-        -- after the '(' and ')' tokens in the mixin field. This-        -- parser checks the cabal file version and does the correct-        -- skipping of spaces.-        parensLax    p = P.between (P.char '(' >> P.spaces)   (P.char ')' >> P.spaces)   p-        parensStrict p = P.between (P.char '(' >> warnSpaces) (P.char ')') p+  parsec = do+    csv <- askCabalSpecVersion+    if csv >= CabalSpecV3_0+      then moduleRenamingParsec parensLax lexemeParsec+      else moduleRenamingParsec parensStrict parsec+    where+      -- For cabal spec versions < 3.0 white spaces were not skipped+      -- after the '(' and ')' tokens in the mixin field. This+      -- parser checks the cabal file version and does the correct+      -- skipping of spaces.+      parensLax p = P.between (P.char '(' >> P.spaces) (P.char ')' >> P.spaces) p+      parensStrict p = P.between (P.char '(' >> warnSpaces) (P.char ')') p -        warnSpaces = P.optional $-            P.space *> fail "space after parenthesis, use cabal-version: 3.0 or higher"+      warnSpaces =+        P.optional $+          P.space *> fail "space after parenthesis, use cabal-version: 3.0 or higher"  moduleRenamingParsec-    :: CabalParsing m-    => (forall a. m a -> m a)  -- ^ between parens-    -> m ModuleName            -- ^ module name parser-    -> m ModuleRenaming+  :: CabalParsing m+  => (forall a. m a -> m a)+  -- ^ between parens+  -> m ModuleName+  -- ^ module name parser+  -> m ModuleRenaming moduleRenamingParsec bp mn =-    -- NB: try not necessary as the first token is obvious-    P.choice [ parseRename, parseHiding, return DefaultRenaming ]+  -- NB: try not necessary as the first token is obvious+  P.choice [parseRename, parseHiding, return DefaultRenaming]   where     cma = P.char ',' >> P.spaces     parseRename = do-        rns <- bp parseList-        P.spaces-        return (ModuleRenaming rns)+      rns <- bp parseList+      P.spaces+      return (ModuleRenaming rns)     parseHiding = do-        _ <- P.string "hiding"-        P.spaces -- space isn't strictly required as next is an open paren-        hides <- bp (P.sepBy mn cma)-        return (HidingRenaming hides)+      _ <- P.string "hiding"+      P.spaces -- space isn't strictly required as next is an open paren+      hides <- bp (P.sepBy mn cma)+      return (HidingRenaming hides)     parseList =-        P.sepBy parseEntry cma+      P.sepBy parseEntry cma     parseEntry = do-        orig <- parsec+      orig <- parsec+      P.spaces+      P.option (orig, orig) $ do+        _ <- P.string "as"+        P.skipSpaces1 -- require space after "as"+        new <- parsec         P.spaces-        P.option (orig, orig) $ do-            _ <- P.string "as"-            P.skipSpaces1 -- require space after "as"-            new <- parsec-            P.spaces-            return (orig, new)+        return (orig, new)
src/Distribution/Types/MungedPackageId.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.MungedPackageId-  ( MungedPackageId(..)+  ( MungedPackageId (..)   , computeCompatPackageId   ) where @@ -13,22 +14,21 @@ import Distribution.Types.LibraryName import Distribution.Types.MungedPackageName import Distribution.Types.PackageId-import Distribution.Version                 (Version, nullVersion)+import Distribution.Version (Version, nullVersion)  import qualified Text.PrettyPrint as Disp  -- | A simple pair of a 'MungedPackageName' and 'Version'. 'MungedPackageName' is to -- 'MungedPackageId' as 'PackageName' is to 'PackageId'. See 'MungedPackageName' for more -- info.-data MungedPackageId-    = MungedPackageId {-        -- | The combined package and component name. see documentation for-        -- 'MungedPackageName'.-        mungedName    :: MungedPackageName,-        -- | The version of this package / component, eg 1.2-        mungedVersion :: Version-     }-     deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data MungedPackageId = MungedPackageId+  { mungedName :: MungedPackageName+  -- ^ The combined package and component name. see documentation for+  -- 'MungedPackageName'.+  , mungedVersion :: Version+  -- ^ The version of this package / component, eg 1.2+  }+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary MungedPackageId instance Structured MungedPackageId@@ -40,11 +40,10 @@ -- -- >>> prettyShow $ MungedPackageId (MungedPackageName "servant" (LSubLibName "lackey")) (mkVersion [0,1,2]) -- "z-servant-z-lackey-0.1.2"--- instance Pretty MungedPackageId where-    pretty (MungedPackageId n v)-        | v == nullVersion = pretty n -- if no version, don't show version.-        | otherwise        = pretty n <<>> Disp.char '-' <<>> pretty v+  pretty (MungedPackageId n v)+    | v == nullVersion = pretty n -- if no version, don't show version.+    | otherwise = pretty n <<>> Disp.char '-' <<>> pretty v  -- | --@@ -65,18 +64,17 @@ -- -- >>> simpleParsec "foo-bar.4-2" :: Maybe MungedPackageId -- Nothing--- instance Parsec MungedPackageId where-    parsec = do-        PackageIdentifier pn v <- parsec-        return $ MungedPackageId (decodeCompatPackageName pn) v+  parsec = do+    PackageIdentifier pn v <- parsec+    return $ MungedPackageId (decodeCompatPackageName pn) v  instance NFData MungedPackageId where-    rnf (MungedPackageId name version) = rnf name `seq` rnf version+  rnf (MungedPackageId name version) = rnf name `seq` rnf version  computeCompatPackageId :: PackageId -> LibraryName -> MungedPackageId computeCompatPackageId (PackageIdentifier pn vr) ln =-    MungedPackageId (MungedPackageName pn ln) vr+  MungedPackageId (MungedPackageName pn ln) vr  -- $setup -- >>> :seti -XOverloadedStrings
src/Distribution/Types/MungedPackageName.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.MungedPackageName   ( MungedPackageName (..)   , decodeCompatPackageName@@ -29,9 +30,8 @@ -- In @3.0.0.0@ representation was changed from opaque (string) to semantic representation. -- -- @since 2.0.0.2--- data MungedPackageName = MungedPackageName !PackageName !LibraryName-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary MungedPackageName instance Structured MungedPackageName@@ -71,12 +71,11 @@ -- -- >>> prettyShow $ MungedPackageName "servant" (LSubLibName "lackey") -- "z-servant-z-lackey"--- instance Pretty MungedPackageName where-    -- First handle the cases where we can just use the original 'PackageName'.-    -- This is for the PRIMARY library, and it is non-Backpack, or the-    -- indefinite package for us.-    pretty = Disp.text . encodeCompatPackageName'+  -- First handle the cases where we can just use the original 'PackageName'.+  -- This is for the PRIMARY library, and it is non-Backpack, or the+  -- indefinite package for us.+  pretty = Disp.text . encodeCompatPackageName'  -- | --@@ -88,9 +87,8 @@ -- -- >>> simpleParsec "z-servant-zz" :: Maybe MungedPackageName -- Just (MungedPackageName (PackageName "z-servant-zz") LMainLibName)--- instance Parsec MungedPackageName where-    parsec = decodeCompatPackageName' <$> parsecUnqualComponentName+  parsec = decodeCompatPackageName' <$> parsecUnqualComponentName  ------------------------------------------------------------------------------- -- ZDashCode conversions@@ -100,7 +98,6 @@ -- -- >>> decodeCompatPackageName "z-servant-z-lackey" -- MungedPackageName (PackageName "servant") (LSubLibName (UnqualComponentName "lackey"))--- decodeCompatPackageName :: PackageName -> MungedPackageName decodeCompatPackageName = decodeCompatPackageName' . unPackageName @@ -111,44 +108,48 @@ -- -- This is used in @cabal-install@ in the Solver. -- May become obsolete as solver moves to per-component solving.--- encodeCompatPackageName :: MungedPackageName -> PackageName encodeCompatPackageName = mkPackageName . encodeCompatPackageName'  decodeCompatPackageName' :: String -> MungedPackageName decodeCompatPackageName' m =-    case m of-        'z':'-':rest | Right [pn, cn] <- explicitEitherParsec parseZDashCode rest-            -> MungedPackageName (mkPackageName pn) (LSubLibName (mkUnqualComponentName cn))-        s   -> MungedPackageName (mkPackageName s) LMainLibName+  case m of+    'z' : '-' : rest+      | Right [pn, cn] <- explicitEitherParsec parseZDashCode rest ->+          MungedPackageName (mkPackageName pn) (LSubLibName (mkUnqualComponentName cn))+    s -> MungedPackageName (mkPackageName s) LMainLibName  encodeCompatPackageName' :: MungedPackageName -> String-encodeCompatPackageName' (MungedPackageName pn LMainLibName)      = unPackageName pn+encodeCompatPackageName' (MungedPackageName pn LMainLibName) = unPackageName pn encodeCompatPackageName' (MungedPackageName pn (LSubLibName uqn)) =-     "z-" ++ zdashcode (unPackageName pn) ++-    "-z-" ++ zdashcode (unUnqualComponentName uqn)+  "z-"+    ++ zdashcode (unPackageName pn)+    ++ "-z-"+    ++ zdashcode (unUnqualComponentName uqn)  zdashcode :: String -> String zdashcode s = go s (Nothing :: Maybe Int) []-    where go [] _ r = reverse r-          go ('-':z) (Just n) r | n > 0 = go z (Just 0) ('-':'z':r)-          go ('-':z) _        r = go z (Just 0) ('-':r)-          go ('z':z) (Just n) r = go z (Just (n+1)) ('z':r)-          go (c:z)   _        r = go z Nothing (c:r)+  where+    go [] _ r = reverse r+    go ('-' : z) (Just n) r | n > 0 = go z (Just 0) ('-' : 'z' : r)+    go ('-' : z) _ r = go z (Just 0) ('-' : r)+    go ('z' : z) (Just n) r = go z (Just (n + 1)) ('z' : r)+    go (c : z) _ r = go z Nothing (c : r)  parseZDashCode :: CabalParsing m => m [String] parseZDashCode = do-    ns <- toList <$> P.sepByNonEmpty (some (P.satisfy (/= '-'))) (P.char '-')-    return (go ns)+  ns <- toList <$> P.sepByNonEmpty (some (P.satisfy (/= '-'))) (P.char '-')+  return (go ns)   where-    go ns = case break (=="z") ns of-                (_, []) -> [paste ns]-                (as, "z":bs) -> paste as : go bs-                _ -> error "parseZDashCode: go"+    go ns = case break (== "z") ns of+      (_, []) -> [paste ns]+      (as, "z" : bs) -> paste as : go bs+      _ -> error "parseZDashCode: go"     unZ :: String -> String     unZ "" = error "parseZDashCode: unZ"-    unZ r@('z':zs) | all (=='z') zs = zs-                   | otherwise      = r+    unZ r@('z' : zs)+      | all (== 'z') zs = zs+      | otherwise = r     unZ r = r     paste :: [String] -> String     paste = intercalate "-" . map unZ
src/Distribution/Types/PackageDescription.hs view
@@ -1,9 +1,11 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-}  -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Types.PackageDescription -- Copyright   :  Isaac Jones 2003-2005@@ -25,70 +27,70 @@ -- It was done this way initially to avoid breaking too much stuff when the -- feature was introduced. It could probably do with being rationalised at some -- point to make it simpler.--module Distribution.Types.PackageDescription (-    PackageDescription(..),-    license,-    license',-    buildType,-    emptyPackageDescription,-    hasPublicLib,-    hasLibs,-    allLibraries,-    withLib,-    hasExes,-    withExe,-    hasTests,-    withTest,-    hasBenchmarks,-    withBenchmark,-    hasForeignLibs,-    withForeignLib,-    allBuildInfo,-    enabledBuildInfos,-    allBuildDepends,-    enabledBuildDepends,-    updatePackageDescription,-    pkgComponents,-    pkgBuildableComponents,-    enabledComponents,-    lookupComponent,-    getComponent,+module Distribution.Types.PackageDescription+  ( PackageDescription (..)+  , license+  , license'+  , buildType+  , emptyPackageDescription+  , hasPublicLib+  , hasLibs+  , allLibraries+  , withLib+  , hasExes+  , withExe+  , hasTests+  , withTest+  , hasBenchmarks+  , withBenchmark+  , hasForeignLibs+  , withForeignLib+  , allBuildInfo+  , enabledBuildInfos+  , allBuildDepends+  , enabledBuildDepends+  , updatePackageDescription+  , pkgComponents+  , pkgBuildableComponents+  , enabledComponents+  , lookupComponent+  , getComponent   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Control.Monad ((<=<))  -- lens-import qualified Distribution.Types.BuildInfo.Lens  as L-import Distribution.Types.Library-import Distribution.Types.TestSuite-import Distribution.Types.Executable+ import Distribution.Types.Benchmark+import qualified Distribution.Types.BuildInfo.Lens as L+import Distribution.Types.Executable import Distribution.Types.ForeignLib+import Distribution.Types.Library+import Distribution.Types.TestSuite +import Distribution.Types.BuildInfo+import Distribution.Types.BuildType import Distribution.Types.Component+import Distribution.Types.ComponentName import Distribution.Types.ComponentRequestedSpec import Distribution.Types.Dependency+import Distribution.Types.HookedBuildInfo import Distribution.Types.PackageId-import Distribution.Types.ComponentName import Distribution.Types.PackageName-import Distribution.Types.UnqualComponentName import Distribution.Types.SetupBuildInfo-import Distribution.Types.BuildInfo-import Distribution.Types.BuildType import Distribution.Types.SourceRepo-import Distribution.Types.HookedBuildInfo+import Distribution.Types.UnqualComponentName  import Distribution.CabalSpecVersion import Distribution.Compiler import Distribution.License import Distribution.Package-import Distribution.Version import Distribution.Utils.Path import Distribution.Utils.ShortText+import Distribution.Version  import qualified Distribution.SPDX as SPDX @@ -100,53 +102,56 @@ -- which is needed for all packages, such as the package name and version, and -- information which is needed for the simple build system only, such as -- the compiler options and library name.----data PackageDescription-    =  PackageDescription {-        -- the following are required by all packages:--        -- | The version of the Cabal spec that this package description uses.-        specVersion    :: CabalSpecVersion,-        package        :: PackageIdentifier,-        licenseRaw     :: Either SPDX.License License,-        licenseFiles   :: [SymbolicPath PackageDir LicenseFile],-        copyright      :: !ShortText,-        maintainer     :: !ShortText,-        author         :: !ShortText,-        stability      :: !ShortText,-        testedWith     :: [(CompilerFlavor,VersionRange)],-        homepage       :: !ShortText,-        pkgUrl         :: !ShortText,-        bugReports     :: !ShortText,-        sourceRepos    :: [SourceRepo],-        synopsis       :: !ShortText, -- ^A one-line summary of this package-        description    :: !ShortText, -- ^A more verbose description of this package-        category       :: !ShortText,-        customFieldsPD :: [(String,String)], -- ^Custom fields starting-                                             -- with x-, stored in a-                                             -- simple assoc-list.+data PackageDescription = PackageDescription+  { -- the following are required by all packages: -        -- | The original @build-type@ value as parsed from the-        -- @.cabal@ file without defaulting. See also 'buildType'.-        ---        -- @since 2.2-        buildTypeRaw   :: Maybe BuildType,-        setupBuildInfo :: Maybe SetupBuildInfo,-        -- components-        library        :: Maybe Library,-        subLibraries   :: [Library],-        executables    :: [Executable],-        foreignLibs    :: [ForeignLib],-        testSuites     :: [TestSuite],-        benchmarks     :: [Benchmark],-        -- files-        dataFiles      :: [FilePath],-        dataDir        :: FilePath,-        extraSrcFiles  :: [FilePath],-        extraTmpFiles  :: [FilePath],-        extraDocFiles  :: [FilePath]-    }-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+    specVersion :: CabalSpecVersion+  -- ^ The version of the Cabal spec that this package description uses.+  , package :: PackageIdentifier+  , licenseRaw :: Either SPDX.License License+  , licenseFiles :: [RelativePath Pkg File]+  , copyright :: !ShortText+  , maintainer :: !ShortText+  , author :: !ShortText+  , stability :: !ShortText+  , testedWith :: [(CompilerFlavor, VersionRange)]+  , homepage :: !ShortText+  , pkgUrl :: !ShortText+  , bugReports :: !ShortText+  , sourceRepos :: [SourceRepo]+  , synopsis :: !ShortText+  -- ^ A one-line summary of this package+  , description :: !ShortText+  -- ^ A more verbose description of this package+  , category :: !ShortText+  , customFieldsPD :: [(String, String)]+  -- ^ Custom fields starting+  --  with x-, stored in a+  --  simple assoc-list.+  , buildTypeRaw :: Maybe BuildType+  -- ^ The original @build-type@ value as parsed from the+  -- @.cabal@ file without defaulting. See also 'buildType'.+  --+  -- @since 2.2+  , setupBuildInfo :: Maybe SetupBuildInfo+  , -- components+    library :: Maybe Library+  , subLibraries :: [Library]+  , executables :: [Executable]+  , foreignLibs :: [ForeignLib]+  , testSuites :: [TestSuite]+  , benchmarks :: [Benchmark]+  , -- files+    dataFiles :: [RelativePath DataDir File]+  -- ^ data file globs, relative to data directory+  , dataDir :: SymbolicPath Pkg (Dir DataDir)+  -- ^ data directory (may be absolute, or relative to package)+  , extraSrcFiles :: [RelativePath Pkg File]+  , extraTmpFiles :: [RelativePath Pkg File]+  , extraDocFiles :: [RelativePath Pkg File]+  , extraFiles :: [RelativePath Pkg File]+  }+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary PackageDescription instance Structured PackageDescription@@ -185,49 +190,54 @@ -- @since 2.2 buildType :: PackageDescription -> BuildType buildType pkg-  | specVersion pkg >= CabalSpecV2_2-    = fromMaybe newDefault (buildTypeRaw pkg)+  | specVersion pkg >= CabalSpecV2_2 =+      fromMaybe newDefault (buildTypeRaw pkg)   | otherwise -- cabal-version < 2.1-    = fromMaybe Custom (buildTypeRaw pkg)+    =+      fromMaybe Custom (buildTypeRaw pkg)   where-    newDefault | isNothing (setupBuildInfo pkg) = Simple-               | otherwise                      = Custom+    newDefault+      | isNothing (setupBuildInfo pkg) = Simple+      | otherwise = Custom  emptyPackageDescription :: PackageDescription-emptyPackageDescription-    =  PackageDescription {-                      package      = PackageIdentifier (mkPackageName "")-                                                       nullVersion,-                      licenseRaw   = Right UnspecifiedLicense, -- TODO:-                      licenseFiles = [],-                      specVersion  = CabalSpecV1_0,-                      buildTypeRaw = Nothing,-                      copyright    = mempty,-                      maintainer   = mempty,-                      author       = mempty,-                      stability    = mempty,-                      testedWith   = [],-                      homepage     = mempty,-                      pkgUrl       = mempty,-                      bugReports   = mempty,-                      sourceRepos  = [],-                      synopsis     = mempty,-                      description  = mempty,-                      category     = mempty,-                      customFieldsPD = [],-                      setupBuildInfo = Nothing,-                      library      = Nothing,-                      subLibraries = [],-                      foreignLibs  = [],-                      executables  = [],-                      testSuites   = [],-                      benchmarks   = [],-                      dataFiles    = [],-                      dataDir      = ".",-                      extraSrcFiles = [],-                      extraTmpFiles = [],-                      extraDocFiles = []-                     }+emptyPackageDescription =+  PackageDescription+    { package =+        PackageIdentifier+          (mkPackageName "")+          nullVersion+    , licenseRaw = Right UnspecifiedLicense -- TODO:+    , licenseFiles = []+    , specVersion = CabalSpecV1_0+    , buildTypeRaw = Nothing+    , copyright = mempty+    , maintainer = mempty+    , author = mempty+    , stability = mempty+    , testedWith = []+    , homepage = mempty+    , pkgUrl = mempty+    , bugReports = mempty+    , sourceRepos = []+    , synopsis = mempty+    , description = mempty+    , category = mempty+    , customFieldsPD = []+    , setupBuildInfo = Nothing+    , library = Nothing+    , subLibraries = []+    , foreignLibs = []+    , executables = []+    , testSuites = []+    , benchmarks = []+    , dataFiles = []+    , dataDir = sameDirectory+    , extraSrcFiles = []+    , extraTmpFiles = []+    , extraDocFiles = []+    , extraFiles = []+    }  -- --------------------------------------------------------------------------- -- The Library type@@ -235,9 +245,9 @@ -- | Does this package have a buildable PUBLIC library? hasPublicLib :: PackageDescription -> Bool hasPublicLib p =-    case library p of-        Just lib -> buildable (libBuildInfo lib)-        Nothing  -> False+  case library p of+    Just lib -> buildable (libBuildInfo lib)+    Nothing -> False  -- | Does this package have any libraries? hasLibs :: PackageDescription -> Bool@@ -254,12 +264,12 @@ -- for more information. withLib :: PackageDescription -> (Library -> IO ()) -> IO () withLib pkg_descr f =-   sequence_ [f lib | lib <- allLibraries pkg_descr, buildable (libBuildInfo lib)]+  sequence_ [f lib | lib <- allLibraries pkg_descr, buildable (libBuildInfo lib)]  -- --------------------------------------------------------------------------- -- The Executable type --- |does this package have any executables?+-- | does this package have any executables? hasExes :: PackageDescription -> Bool hasExes p = any (buildable . buildInfo) (executables p) @@ -283,10 +293,9 @@ -- You probably want 'withTestLBI' if you have a 'LocalBuildInfo', see the note in -- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components" -- for more information.- withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO () withTest pkg_descr f =-    sequence_ [ f test | test <- testSuites pkg_descr, buildable (testBuildInfo test) ]+  sequence_ [f test | test <- testSuites pkg_descr, buildable (testBuildInfo test)]  -- --------------------------------------------------------------------------- -- The Benchmark type@@ -299,10 +308,9 @@ -- You probably want 'withBenchLBI' if you have a 'LocalBuildInfo', see the note in -- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components" -- for more information.- withBenchmark :: PackageDescription -> (Benchmark -> IO ()) -> IO () withBenchmark pkg_descr f =-    sequence_ [f bench | bench <- benchmarks pkg_descr, buildable (benchmarkBuildInfo bench)]+  sequence_ [f bench | bench <- benchmarks pkg_descr, buildable (benchmarkBuildInfo bench)]  -- --------------------------------------------------------------------------- -- The ForeignLib type@@ -315,10 +323,11 @@ -- description. withForeignLib :: PackageDescription -> (ForeignLib -> IO ()) -> IO () withForeignLib pkg_descr f =-  sequence_ [ f flib-            | flib <- foreignLibs pkg_descr-            , buildable (foreignLibBuildInfo flib)-            ]+  sequence_+    [ f flib+    | flib <- foreignLibs pkg_descr+    , buildable (foreignLibBuildInfo flib)+    ]  -- --------------------------------------------------------------------------- -- The BuildInfo type@@ -328,27 +337,30 @@ -- -- Useful for implementing package checks. allBuildInfo :: PackageDescription -> [BuildInfo]-allBuildInfo pkg_descr = [ bi | lib <- allLibraries pkg_descr-                               , let bi = libBuildInfo lib ]-                       ++ [ bi | flib <- foreignLibs pkg_descr-                               , let bi = foreignLibBuildInfo flib ]-                       ++ [ bi | exe <- executables pkg_descr-                               , let bi = buildInfo exe ]-                       ++ [ bi | tst <- testSuites pkg_descr-                               , let bi = testBuildInfo tst ]-                       ++ [ bi | tst <- benchmarks pkg_descr-                               , let bi = benchmarkBuildInfo tst ]+allBuildInfo pkg_descr =+  [ bi | lib <- allLibraries pkg_descr, let bi = libBuildInfo lib+  ]+    ++ [ bi | flib <- foreignLibs pkg_descr, let bi = foreignLibBuildInfo flib+       ]+    ++ [ bi | exe <- executables pkg_descr, let bi = buildInfo exe+       ]+    ++ [ bi | tst <- testSuites pkg_descr, let bi = testBuildInfo tst+       ]+    ++ [ bi | tst <- benchmarks pkg_descr, let bi = benchmarkBuildInfo tst+       ]  -- | Return all of the 'BuildInfo's of enabled components, i.e., all of -- the ones that would be built if you run @./Setup build@. enabledBuildInfos :: PackageDescription -> ComponentRequestedSpec -> [BuildInfo] enabledBuildInfos pkg enabled =-    [ componentBuildInfo comp-    | comp <- enabledComponents pkg enabled ]-+  [ componentBuildInfo comp+  | comp <- enabledComponents pkg enabled+  ]  -- ------------------------------------------------------------+ -- * Utils+ -- ------------------------------------------------------------  -- | Get the combined build-depends entries of all components.@@ -360,42 +372,50 @@ enabledBuildDepends :: PackageDescription -> ComponentRequestedSpec -> [Dependency] enabledBuildDepends spec pd = targetBuildDepends =<< enabledBuildInfos spec pd - updatePackageDescription :: HookedBuildInfo -> PackageDescription -> PackageDescription-updatePackageDescription (mb_lib_bi, exe_bi) p-    = p{ executables = updateExecutables exe_bi    (executables p)-       , library     = updateLibrary     mb_lib_bi (library     p) }-    where-      updateLibrary :: Maybe BuildInfo -> Maybe Library -> Maybe Library-      updateLibrary (Just bi) (Just lib) = Just (lib{libBuildInfo = bi `mappend` libBuildInfo lib})-      updateLibrary Nothing   mb_lib     = mb_lib-      updateLibrary (Just _)  Nothing    = Nothing+updatePackageDescription (mb_lib_bi, exe_bi) p =+  p+    { executables = updateExecutables exe_bi (executables p)+    , library = updateLibrary mb_lib_bi (library p)+    }+  where+    updateLibrary :: Maybe BuildInfo -> Maybe Library -> Maybe Library+    updateLibrary (Just bi) (Just lib) = Just (lib{libBuildInfo = bi `mappend` libBuildInfo lib})+    updateLibrary Nothing mb_lib = mb_lib+    updateLibrary (Just _) Nothing = Nothing -      updateExecutables :: [(UnqualComponentName, BuildInfo)] -- ^[(exeName, new buildinfo)]-        -> [Executable]                                       -- ^list of executables to update-        -> [Executable]                                       -- ^list with exeNames updated-      updateExecutables exe_bi' executables' = foldr updateExecutable executables' exe_bi'+    updateExecutables+      :: [(UnqualComponentName, BuildInfo)]+      -- \^[(exeName, new buildinfo)]+      -> [Executable]+      -- \^list of executables to update+      -> [Executable]+    -- \^list with exeNames updated+    updateExecutables exe_bi' executables' = foldr updateExecutable executables' exe_bi' -      updateExecutable :: (UnqualComponentName, BuildInfo) -- ^(exeName, new buildinfo)-                       -> [Executable]                     -- ^list of executables to update-                       -> [Executable]                     -- ^list with exeName updated-      updateExecutable _                 []         = []-      updateExecutable exe_bi'@(name,bi) (exe:exes)-        | exeName exe == name = exe{buildInfo = bi `mappend` buildInfo exe} : exes-        | otherwise           = exe : updateExecutable exe_bi' exes+    updateExecutable+      :: (UnqualComponentName, BuildInfo)+      -- \^(exeName, new buildinfo)+      -> [Executable]+      -- \^list of executables to update+      -> [Executable]+    -- \^list with exeName updated+    updateExecutable _ [] = []+    updateExecutable exe_bi'@(name, bi) (exe : exes)+      | exeName exe == name = exe{buildInfo = bi `mappend` buildInfo exe} : exes+      | otherwise = exe : updateExecutable exe_bi' exes  -- ----------------------------------------------------------------------------- -- Source-representation of buildable components  -- | All the components in the package.--- pkgComponents :: PackageDescription -> [Component] pkgComponents pkg =-    [ CLib  lib | lib <- allLibraries pkg ]- ++ [ CFLib flib | flib <- foreignLibs pkg ]- ++ [ CExe  exe | exe <- executables pkg ]- ++ [ CTest tst | tst <- testSuites  pkg ]- ++ [ CBench bm | bm  <- benchmarks  pkg ]+  [CLib lib | lib <- allLibraries pkg]+    ++ [CFLib flib | flib <- foreignLibs pkg]+    ++ [CExe exe | exe <- executables pkg]+    ++ [CTest tst | tst <- testSuites pkg]+    ++ [CBench bm | bm <- benchmarks pkg]  -- | A list of all components in the package that are buildable, -- i.e., were not marked with @buildable: False@.  This does NOT@@ -403,55 +423,88 @@ -- see 'enabledComponents' instead. -- -- @since 2.0.0.2--- pkgBuildableComponents :: PackageDescription -> [Component] pkgBuildableComponents = filter componentBuildable . pkgComponents  -- | A list of all components in the package that are enabled. -- -- @since 2.0.0.2--- enabledComponents :: PackageDescription -> ComponentRequestedSpec -> [Component] enabledComponents pkg enabled = filter (componentEnabled enabled) $ pkgBuildableComponents pkg  lookupComponent :: PackageDescription -> ComponentName -> Maybe Component lookupComponent pkg (CLibName name) =-    fmap CLib $ find ((name ==) . libName) (allLibraries pkg)+  fmap CLib $ find ((name ==) . libName) (allLibraries pkg) lookupComponent pkg (CFLibName name) =-    fmap CFLib $ find ((name ==) . foreignLibName) (foreignLibs pkg)+  fmap CFLib $ find ((name ==) . foreignLibName) (foreignLibs pkg) lookupComponent pkg (CExeName name) =-    fmap CExe $ find ((name ==) . exeName) (executables pkg)+  fmap CExe $ find ((name ==) . exeName) (executables pkg) lookupComponent pkg (CTestName name) =-    fmap CTest $ find ((name ==) . testName) (testSuites pkg)+  fmap CTest $ find ((name ==) . testName) (testSuites pkg) lookupComponent pkg (CBenchName name) =-    fmap CBench $ find ((name ==) . benchmarkName) (benchmarks pkg)+  fmap CBench $ find ((name ==) . benchmarkName) (benchmarks pkg)  getComponent :: PackageDescription -> ComponentName -> Component getComponent pkg cname =-    case lookupComponent pkg cname of-      Just cpnt -> cpnt-      Nothing   -> missingComponent+  case lookupComponent pkg cname of+    Just cpnt -> cpnt+    Nothing -> missingComponent   where     missingComponent =-      error $ "internal error: the package description contains no "-           ++ "component corresponding to " ++ show cname+      error $+        "internal error: the package description contains no "+          ++ "component corresponding to "+          ++ show cname  -- ----------------------------------------------------------------------------- -- Traversal Instances  instance L.HasBuildInfos PackageDescription where-  traverseBuildInfos f (PackageDescription a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19-                                   x1 x2 x3 x4 x5 x6-                                   a20 a21 a22 a23 a24) =-    PackageDescription a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19+  traverseBuildInfos+    f+    ( PackageDescription+        a1+        a2+        a3+        a4+        a5+        a6+        a7+        a8+        a9+        a10+        a11+        a12+        a13+        a14+        a15+        a16+        a17+        a18+        a19+        x1+        x2+        x3+        x4+        x5+        x6+        a20+        a21+        a22+        a23+        a24+        a25+      ) =+      PackageDescription a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19         <$> (traverse . L.buildInfo) f x1 -- library         <*> (traverse . L.buildInfo) f x2 -- sub libraries         <*> (traverse . L.buildInfo) f x3 -- executables         <*> (traverse . L.buildInfo) f x4 -- foreign libs         <*> (traverse . L.buildInfo) f x5 -- test suites         <*> (traverse . L.buildInfo) f x6 -- benchmarks-        <*> pure a20                      -- data files-        <*> pure a21                      -- data dir-        <*> pure a22                      -- extra src files-        <*> pure a23                      -- extra temp files-        <*> pure a24                      -- extra doc files+        <*> pure a20 -- data files+        <*> pure a21 -- data dir+        <*> pure a22 -- extra src files+        <*> pure a23 -- extra temp files+        <*> pure a24 -- extra doc files+        <*> pure a25 -- extra files
src/Distribution/Types/PackageDescription/Lens.hs view
@@ -1,193 +1,198 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE RankNTypes        #-}-module Distribution.Types.PackageDescription.Lens (-    PackageDescription,-    module Distribution.Types.PackageDescription.Lens,-    ) where+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE RankNTypes #-} +module Distribution.Types.PackageDescription.Lens+  ( PackageDescription+  , module Distribution.Types.PackageDescription.Lens+  ) where+ import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.CabalSpecVersion         (CabalSpecVersion)-import Distribution.Compiler                 (CompilerFlavor)-import Distribution.License                  (License)-import Distribution.ModuleName               (ModuleName)-import Distribution.Types.Benchmark          (Benchmark, benchmarkModules)-import Distribution.Types.Benchmark.Lens     (benchmarkBuildInfo, benchmarkName)-import Distribution.Types.BuildInfo          (BuildInfo)-import Distribution.Types.BuildType          (BuildType)-import Distribution.Types.ComponentName      (ComponentName (..))-import Distribution.Types.Executable         (Executable, exeModules)-import Distribution.Types.Executable.Lens    (exeBuildInfo, exeName)-import Distribution.Types.ForeignLib         (ForeignLib, foreignLibModules)-import Distribution.Types.ForeignLib.Lens    (foreignLibBuildInfo, foreignLibName)-import Distribution.Types.Library            (Library, explicitLibModules)-import Distribution.Types.Library.Lens       (libBuildInfo, libName)+import Distribution.CabalSpecVersion (CabalSpecVersion)+import Distribution.Compiler (CompilerFlavor)+import Distribution.License (License)+import Distribution.ModuleName (ModuleName)+import Distribution.Types.Benchmark (Benchmark, benchmarkModules)+import Distribution.Types.Benchmark.Lens (benchmarkBuildInfo, benchmarkName)+import Distribution.Types.BuildInfo (BuildInfo)+import Distribution.Types.BuildType (BuildType)+import Distribution.Types.ComponentName (ComponentName (..))+import Distribution.Types.Executable (Executable, exeModules)+import Distribution.Types.Executable.Lens (exeBuildInfo, exeName)+import Distribution.Types.ForeignLib (ForeignLib, foreignLibModules)+import Distribution.Types.ForeignLib.Lens (foreignLibBuildInfo, foreignLibName)+import Distribution.Types.Library (Library, explicitLibModules)+import Distribution.Types.Library.Lens (libBuildInfo, libName) import Distribution.Types.PackageDescription (PackageDescription)-import Distribution.Types.PackageId          (PackageIdentifier)-import Distribution.Types.SetupBuildInfo     (SetupBuildInfo)-import Distribution.Types.SourceRepo         (SourceRepo)-import Distribution.Types.TestSuite          (TestSuite, testModules)-import Distribution.Types.TestSuite.Lens     (testBuildInfo, testName)-import Distribution.Utils.Path               (LicenseFile, PackageDir, SymbolicPath)-import Distribution.Utils.ShortText          (ShortText)-import Distribution.Version                  (VersionRange)+import Distribution.Types.PackageId (PackageIdentifier)+import Distribution.Types.SetupBuildInfo (SetupBuildInfo)+import Distribution.Types.SourceRepo (SourceRepo)+import Distribution.Types.TestSuite (TestSuite, testModules)+import Distribution.Types.TestSuite.Lens (testBuildInfo, testName)+import Distribution.Utils.Path+import Distribution.Utils.ShortText (ShortText)+import Distribution.Version (VersionRange) -import qualified Distribution.SPDX                     as SPDX+import qualified Distribution.SPDX as SPDX import qualified Distribution.Types.PackageDescription as T  package :: Lens' PackageDescription PackageIdentifier-package f s = fmap (\x -> s { T.package = x }) (f (T.package s))+package f s = fmap (\x -> s{T.package = x}) (f (T.package s)) {-# INLINE package #-}  licenseRaw :: Lens' PackageDescription (Either SPDX.License License)-licenseRaw f s = fmap (\x -> s { T.licenseRaw = x }) (f (T.licenseRaw s))+licenseRaw f s = fmap (\x -> s{T.licenseRaw = x}) (f (T.licenseRaw s)) {-# INLINE licenseRaw #-} -licenseFiles :: Lens' PackageDescription [SymbolicPath PackageDir LicenseFile]-licenseFiles f s = fmap (\x -> s { T.licenseFiles = x }) (f (T.licenseFiles s))+licenseFiles :: Lens' PackageDescription [RelativePath Pkg File]+licenseFiles f s = fmap (\x -> s{T.licenseFiles = x}) (f (T.licenseFiles s)) {-# INLINE licenseFiles #-}  copyright :: Lens' PackageDescription ShortText-copyright f s = fmap (\x -> s { T.copyright = x }) (f (T.copyright s))+copyright f s = fmap (\x -> s{T.copyright = x}) (f (T.copyright s)) {-# INLINE copyright #-}  maintainer :: Lens' PackageDescription ShortText-maintainer f s = fmap (\x -> s { T.maintainer = x }) (f (T.maintainer s))+maintainer f s = fmap (\x -> s{T.maintainer = x}) (f (T.maintainer s)) {-# INLINE maintainer #-}  author :: Lens' PackageDescription ShortText-author f s = fmap (\x -> s { T.author = x }) (f (T.author s))+author f s = fmap (\x -> s{T.author = x}) (f (T.author s)) {-# INLINE author #-}  stability :: Lens' PackageDescription ShortText-stability f s = fmap (\x -> s { T.stability = x }) (f (T.stability s))+stability f s = fmap (\x -> s{T.stability = x}) (f (T.stability s)) {-# INLINE stability #-} -testedWith :: Lens' PackageDescription [(CompilerFlavor,VersionRange)]-testedWith f s = fmap (\x -> s { T.testedWith = x }) (f (T.testedWith s))+testedWith :: Lens' PackageDescription [(CompilerFlavor, VersionRange)]+testedWith f s = fmap (\x -> s{T.testedWith = x}) (f (T.testedWith s)) {-# INLINE testedWith #-}  homepage :: Lens' PackageDescription ShortText-homepage f s = fmap (\x -> s { T.homepage = x }) (f (T.homepage s))+homepage f s = fmap (\x -> s{T.homepage = x}) (f (T.homepage s)) {-# INLINE homepage #-}  pkgUrl :: Lens' PackageDescription ShortText-pkgUrl f s = fmap (\x -> s { T.pkgUrl = x }) (f (T.pkgUrl s))+pkgUrl f s = fmap (\x -> s{T.pkgUrl = x}) (f (T.pkgUrl s)) {-# INLINE pkgUrl #-}  bugReports :: Lens' PackageDescription ShortText-bugReports f s = fmap (\x -> s { T.bugReports = x }) (f (T.bugReports s))+bugReports f s = fmap (\x -> s{T.bugReports = x}) (f (T.bugReports s)) {-# INLINE bugReports #-}  sourceRepos :: Lens' PackageDescription [SourceRepo]-sourceRepos f s = fmap (\x -> s { T.sourceRepos = x }) (f (T.sourceRepos s))+sourceRepos f s = fmap (\x -> s{T.sourceRepos = x}) (f (T.sourceRepos s)) {-# INLINE sourceRepos #-}  synopsis :: Lens' PackageDescription ShortText-synopsis f s = fmap (\x -> s { T.synopsis = x }) (f (T.synopsis s))+synopsis f s = fmap (\x -> s{T.synopsis = x}) (f (T.synopsis s)) {-# INLINE synopsis #-}  description :: Lens' PackageDescription ShortText-description f s = fmap (\x -> s { T.description = x }) (f (T.description s))+description f s = fmap (\x -> s{T.description = x}) (f (T.description s)) {-# INLINE description #-}  category :: Lens' PackageDescription ShortText-category f s = fmap (\x -> s { T.category = x }) (f (T.category s))+category f s = fmap (\x -> s{T.category = x}) (f (T.category s)) {-# INLINE category #-} -customFieldsPD :: Lens' PackageDescription [(String,String)]-customFieldsPD f s = fmap (\x -> s { T.customFieldsPD = x }) (f (T.customFieldsPD s))+customFieldsPD :: Lens' PackageDescription [(String, String)]+customFieldsPD f s = fmap (\x -> s{T.customFieldsPD = x}) (f (T.customFieldsPD s)) {-# INLINE customFieldsPD #-}  specVersion :: Lens' PackageDescription CabalSpecVersion-specVersion f s = fmap (\x -> s { T.specVersion = x }) (f (T.specVersion s))+specVersion f s = fmap (\x -> s{T.specVersion = x}) (f (T.specVersion s)) {-# INLINE specVersion #-}  buildTypeRaw :: Lens' PackageDescription (Maybe BuildType)-buildTypeRaw f s = fmap (\x -> s { T.buildTypeRaw = x }) (f (T.buildTypeRaw s))+buildTypeRaw f s = fmap (\x -> s{T.buildTypeRaw = x}) (f (T.buildTypeRaw s)) {-# INLINE buildTypeRaw #-}  setupBuildInfo :: Lens' PackageDescription (Maybe SetupBuildInfo)-setupBuildInfo f s = fmap (\x -> s { T.setupBuildInfo = x }) (f (T.setupBuildInfo s))+setupBuildInfo f s = fmap (\x -> s{T.setupBuildInfo = x}) (f (T.setupBuildInfo s)) {-# INLINE setupBuildInfo #-}  library :: Lens' PackageDescription (Maybe Library)-library f s = fmap (\x -> s { T.library = x }) (f (T.library s))+library f s = fmap (\x -> s{T.library = x}) (f (T.library s)) {-# INLINE library #-}  subLibraries :: Lens' PackageDescription [Library]-subLibraries f s = fmap (\x -> s { T.subLibraries = x }) (f (T.subLibraries s))+subLibraries f s = fmap (\x -> s{T.subLibraries = x}) (f (T.subLibraries s)) {-# INLINE subLibraries #-}  executables :: Lens' PackageDescription [Executable]-executables f s = fmap (\x -> s { T.executables = x }) (f (T.executables s))+executables f s = fmap (\x -> s{T.executables = x}) (f (T.executables s)) {-# INLINE executables #-}  foreignLibs :: Lens' PackageDescription [ForeignLib]-foreignLibs f s = fmap (\x -> s { T.foreignLibs = x }) (f (T.foreignLibs s))+foreignLibs f s = fmap (\x -> s{T.foreignLibs = x}) (f (T.foreignLibs s)) {-# INLINE foreignLibs #-}  testSuites :: Lens' PackageDescription [TestSuite]-testSuites f s = fmap (\x -> s { T.testSuites = x }) (f (T.testSuites s))+testSuites f s = fmap (\x -> s{T.testSuites = x}) (f (T.testSuites s)) {-# INLINE testSuites #-}  benchmarks :: Lens' PackageDescription [Benchmark]-benchmarks f s = fmap (\x -> s { T.benchmarks = x }) (f (T.benchmarks s))+benchmarks f s = fmap (\x -> s{T.benchmarks = x}) (f (T.benchmarks s)) {-# INLINE benchmarks #-} -dataFiles :: Lens' PackageDescription [FilePath]-dataFiles f s = fmap (\x -> s { T.dataFiles = x }) (f (T.dataFiles s))+dataFiles :: Lens' PackageDescription [RelativePath DataDir File]+dataFiles f s = fmap (\x -> s{T.dataFiles = x}) (f (T.dataFiles s)) {-# INLINE dataFiles #-} -dataDir :: Lens' PackageDescription FilePath-dataDir f s = fmap (\x -> s { T.dataDir = x }) (f (T.dataDir s))+dataDir :: Lens' PackageDescription (SymbolicPath Pkg (Dir DataDir))+dataDir f s = fmap (\x -> s{T.dataDir = x}) (f (T.dataDir s)) {-# INLINE dataDir #-} -extraSrcFiles :: Lens' PackageDescription [String]-extraSrcFiles f s = fmap (\x -> s { T.extraSrcFiles = x }) (f (T.extraSrcFiles s))+extraSrcFiles :: Lens' PackageDescription [RelativePath Pkg File]+extraSrcFiles f s = fmap (\x -> s{T.extraSrcFiles = x}) (f (T.extraSrcFiles s)) {-# INLINE extraSrcFiles #-} -extraTmpFiles :: Lens' PackageDescription [String]-extraTmpFiles f s = fmap (\x -> s { T.extraTmpFiles = x }) (f (T.extraTmpFiles s))+extraTmpFiles :: Lens' PackageDescription [RelativePath Pkg File]+extraTmpFiles f s = fmap (\x -> s{T.extraTmpFiles = x}) (f (T.extraTmpFiles s)) {-# INLINE extraTmpFiles #-} -extraDocFiles :: Lens' PackageDescription [String]-extraDocFiles f s = fmap (\x -> s { T.extraDocFiles = x }) (f (T.extraDocFiles s))+extraDocFiles :: Lens' PackageDescription [RelativePath Pkg File]+extraDocFiles f s = fmap (\x -> s{T.extraDocFiles = x}) (f (T.extraDocFiles s)) {-# INLINE extraDocFiles #-} +extraFiles :: Lens' PackageDescription [RelativePath Pkg File]+extraFiles f s = fmap (\x -> s{T.extraFiles = x}) (f (T.extraFiles s))+{-# INLINE extraFiles #-}+ -- | @since 3.0.0.0 allLibraries :: Traversal' PackageDescription Library allLibraries f pd = mk <$> traverse f (T.library pd) <*> traverse f (T.subLibraries pd)   where-    mk l ls = pd { T.library = l, T.subLibraries = ls }+    mk l ls = pd{T.library = l, T.subLibraries = ls}  -- | @since 2.4 componentModules :: Monoid r => ComponentName -> Getting r PackageDescription [ModuleName] componentModules cname = case cname of-    CLibName    name ->-      componentModules' name allLibraries             libName            explicitLibModules-    CFLibName   name ->-      componentModules' name (foreignLibs . traverse) foreignLibName     foreignLibModules-    CExeName    name ->-      componentModules' name (executables . traverse) exeName            exeModules-    CTestName   name ->-      componentModules' name (testSuites  . traverse) testName           testModules-    CBenchName  name ->-      componentModules' name (benchmarks  . traverse) benchmarkName      benchmarkModules+  CLibName name ->+    componentModules' name allLibraries libName explicitLibModules+  CFLibName name ->+    componentModules' name (foreignLibs . traverse) foreignLibName foreignLibModules+  CExeName name ->+    componentModules' name (executables . traverse) exeName exeModules+  CTestName name ->+    componentModules' name (testSuites . traverse) testName testModules+  CBenchName name ->+    componentModules' name (benchmarks . traverse) benchmarkName benchmarkModules   where     componentModules'-        :: (Eq name, Monoid r)-        => name-        -> Traversal' PackageDescription a-        -> Lens' a name-        -> (a -> [ModuleName])-        -> Getting r PackageDescription [ModuleName]+      :: (Eq name, Monoid r)+      => name+      -> Traversal' PackageDescription a+      -> Lens' a name+      -> (a -> [ModuleName])+      -> Getting r PackageDescription [ModuleName]     componentModules' name pdL nameL modules =-        pdL-      . filtered ((== name) . view nameL)-      . getting modules+      pdL+        . filtered ((== name) . view nameL)+        . getting modules      filtered :: (a -> Bool) -> Traversal' a a     filtered p f s = if p s then f s else pure s@@ -195,27 +200,28 @@ -- | @since 2.4 componentBuildInfo :: ComponentName -> Traversal' PackageDescription BuildInfo componentBuildInfo cname = case cname of-    CLibName    name ->-      componentBuildInfo' name allLibraries             libName            libBuildInfo-    CFLibName   name ->-      componentBuildInfo' name (foreignLibs . traverse) foreignLibName     foreignLibBuildInfo-    CExeName    name ->-      componentBuildInfo' name (executables . traverse) exeName            exeBuildInfo-    CTestName   name ->-      componentBuildInfo' name (testSuites  . traverse) testName           testBuildInfo-    CBenchName  name ->-      componentBuildInfo' name (benchmarks  . traverse) benchmarkName      benchmarkBuildInfo+  CLibName name ->+    componentBuildInfo' name allLibraries libName libBuildInfo+  CFLibName name ->+    componentBuildInfo' name (foreignLibs . traverse) foreignLibName foreignLibBuildInfo+  CExeName name ->+    componentBuildInfo' name (executables . traverse) exeName exeBuildInfo+  CTestName name ->+    componentBuildInfo' name (testSuites . traverse) testName testBuildInfo+  CBenchName name ->+    componentBuildInfo' name (benchmarks . traverse) benchmarkName benchmarkBuildInfo   where-    componentBuildInfo' :: Eq name-                        => name-                        -> Traversal' PackageDescription a-                        -> Lens' a name-                        -> Traversal' a BuildInfo-                        -> Traversal' PackageDescription BuildInfo+    componentBuildInfo'+      :: Eq name+      => name+      -> Traversal' PackageDescription a+      -> Lens' a name+      -> Traversal' a BuildInfo+      -> Traversal' PackageDescription BuildInfo     componentBuildInfo' name pdL nameL biL =-        pdL-      . filtered ((== name) . view nameL)-      . biL+      pdL+        . filtered ((== name) . view nameL)+        . biL      filtered :: (a -> Bool) -> Traversal' a a     filtered p f s = if p s then f s else pure s
src/Distribution/Types/PackageId.hs view
@@ -1,32 +1,34 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.PackageId-  ( PackageIdentifier(..)+  ( PackageIdentifier (..)   , PackageId   ) where  import Distribution.Compat.Prelude import Prelude () -import Distribution.Parsec            (Parsec (..), simpleParsec)+import Distribution.Parsec (Parsec (..), simpleParsec) import Distribution.Pretty import Distribution.Types.PackageName-import Distribution.Version           (Version, nullVersion)+import Distribution.Version (Version, nullVersion) -import qualified Data.List.NonEmpty              as NE+import qualified Data.List.NonEmpty as NE import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp+import qualified Text.PrettyPrint as Disp  -- | Type alias so we can use the shorter name PackageId. type PackageId = PackageIdentifier  -- | The name and version of a package.-data PackageIdentifier-    = PackageIdentifier {-        pkgName    :: PackageName, -- ^The name of this package, eg. foo-        pkgVersion :: Version -- ^the version of this package, eg 1.2-     }-     deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data PackageIdentifier = PackageIdentifier+  { pkgName :: PackageName+  -- ^ The name of this package, eg. foo+  , pkgVersion :: Version+  -- ^ the version of this package, eg 1.2+  }+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary PackageIdentifier instance Structured PackageIdentifier@@ -34,7 +36,7 @@ instance Pretty PackageIdentifier where   pretty (PackageIdentifier n v)     | v == nullVersion = pretty n -- if no version, don't show version.-    | otherwise        = pretty n <<>> Disp.char '-' <<>> pretty v+    | otherwise = pretty n <<>> Disp.char '-' <<>> pretty v  -- | --@@ -57,18 +59,17 @@ -- -- >>> simpleParsec "1.2.3" :: Maybe PackageIdentifier -- Nothing--- instance Parsec PackageIdentifier where   parsec = do-      xs' <- P.sepByNonEmpty component (P.char '-')-      (v, xs) <- case simpleParsec (NE.last xs') of-          Nothing -> return (nullVersion, toList xs') -- all components are version-          Just v  -> return (v, NE.init xs')-      if not (null xs) && all (\c ->  all (/= '.') c && not (all isDigit c)) xs-      then return $ PackageIdentifier (mkPackageName (intercalate  "-" xs)) v+    xs' <- P.sepByNonEmpty component (P.char '-')+    (v, xs) <- case simpleParsec (NE.last xs') of+      Nothing -> return (nullVersion, toList xs') -- all components are version+      Just v -> return (v, NE.init xs')+    if not (null xs) && all (\c -> all (/= '.') c && not (all isDigit c)) xs+      then return $ PackageIdentifier (mkPackageName (intercalate "-" xs)) v       else fail "all digits or a dot in a portion of package name"     where-      component = P.munch1 (\c ->  isAlphaNum c || c == '.')+      component = P.munch1 (\c -> isAlphaNum c || c == '.')  instance NFData PackageIdentifier where-    rnf (PackageIdentifier name version) = rnf name `seq` rnf version+  rnf (PackageIdentifier name version) = rnf name `seq` rnf version
src/Distribution/Types/PackageId/Lens.hs view
@@ -1,22 +1,22 @@-module Distribution.Types.PackageId.Lens (-    PackageIdentifier,-    module Distribution.Types.PackageId.Lens,-    ) where+module Distribution.Types.PackageId.Lens+  ( PackageIdentifier+  , module Distribution.Types.PackageId.Lens+  ) where  import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Types.PackageId   (PackageIdentifier)+import Distribution.Types.PackageId (PackageIdentifier) import Distribution.Types.PackageName (PackageName)-import Distribution.Version           (Version)+import Distribution.Version (Version)  import qualified Distribution.Types.PackageId as T  pkgName :: Lens' PackageIdentifier PackageName-pkgName f s = fmap (\x -> s { T.pkgName = x }) (f (T.pkgName s))+pkgName f s = fmap (\x -> s{T.pkgName = x}) (f (T.pkgName s)) {-# INLINE pkgName #-}  pkgVersion :: Lens' PackageIdentifier Version-pkgVersion f s = fmap (\x -> s { T.pkgVersion = x }) (f (T.pkgVersion s))+pkgVersion f s = fmap (\x -> s{T.pkgVersion = x}) (f (T.pkgVersion s)) {-# INLINE pkgVersion #-}
src/Distribution/Types/PackageName.hs view
@@ -1,19 +1,21 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.PackageName   ( PackageName-  , unPackageName, mkPackageName-  , unPackageNameST, mkPackageNameST+  , unPackageName+  , mkPackageName+  , unPackageNameST+  , mkPackageNameST   ) where -import Prelude () import Distribution.Compat.Prelude import Distribution.Utils.ShortText+import Prelude () -import qualified Text.PrettyPrint as Disp-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty+import qualified Text.PrettyPrint as Disp  -- | A package name. --@@ -24,7 +26,7 @@ -- -- @since 2.0.0.2 newtype PackageName = PackageName ShortText-    deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+  deriving (Generic, Read, Show, Eq, Ord, Data)  -- | Convert 'PackageName' to 'String' unPackageName :: PackageName -> String@@ -70,4 +72,4 @@   parsec = mkPackageName <$> parsecUnqualComponentName  instance NFData PackageName where-    rnf (PackageName pkg) = rnf pkg+  rnf (PackageName pkg) = rnf pkg
src/Distribution/Types/PackageVersionConstraint.hs view
@@ -1,11 +1,12 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-module Distribution.Types.PackageVersionConstraint (-    PackageVersionConstraint(..),-    thisPackageVersionConstraint,-    simplifyPackageVersionConstraint,-) where+{-# LANGUAGE DeriveGeneric #-} +module Distribution.Types.PackageVersionConstraint+  ( PackageVersionConstraint (..)+  , thisPackageVersionConstraint+  , simplifyPackageVersionConstraint+  ) where+ import Distribution.Compat.Prelude import Prelude () @@ -15,7 +16,7 @@ import Distribution.Types.PackageName import Distribution.Types.Version import Distribution.Types.VersionRange.Internal-import Distribution.Version                     (simplifyVersionRange)+import Distribution.Version (simplifyVersionRange)  import qualified Distribution.Compat.CharParsing as P @@ -25,7 +26,7 @@ -- There are a few places in the codebase where 'Dependency' was used where -- 'PackageVersionConstraint' is not used instead (#5570). data PackageVersionConstraint = PackageVersionConstraint PackageName VersionRange-                  deriving (Generic, Read, Show, Eq, Typeable, Data)+  deriving (Generic, Read, Show, Eq, Data)  instance Binary PackageVersionConstraint instance Structured PackageVersionConstraint@@ -38,7 +39,7 @@   -- pretty (PackageVersionConstraint name (ThisVersion ver)) =   --     pretty (PackageIdentifier name ver)   pretty (PackageVersionConstraint name ver) =-      pretty name <+> pretty ver+    pretty name <+> pretty ver  -- | --@@ -50,25 +51,23 @@ -- -- >>> simpleParsec "foo-2.0" :: Maybe PackageVersionConstraint -- Just (PackageVersionConstraint (PackageName "foo") (ThisVersion (mkVersion [2,0])))--- instance Parsec PackageVersionConstraint where   parsec = do-      PackageIdentifier name ver <- parsec-      if ver == nullVersion+    PackageIdentifier name ver <- parsec+    if ver == nullVersion       then do-          P.spaces-          vr <- parsec <|> return anyVersion-          P.spaces-          return (PackageVersionConstraint name vr)-      else-          pure (PackageVersionConstraint name (thisVersion ver))+        P.spaces+        vr <- parsec <|> return anyVersion+        P.spaces+        return (PackageVersionConstraint name vr)+      else pure (PackageVersionConstraint name (thisVersion ver))  -- | @since 3.4.0.0 thisPackageVersionConstraint :: PackageIdentifier -> PackageVersionConstraint thisPackageVersionConstraint (PackageIdentifier pn vr) =-    PackageVersionConstraint pn (thisVersion vr)+  PackageVersionConstraint pn (thisVersion vr)  -- | @since 3.4.0.0 simplifyPackageVersionConstraint :: PackageVersionConstraint -> PackageVersionConstraint simplifyPackageVersionConstraint (PackageVersionConstraint pn vr) =-    PackageVersionConstraint pn (simplifyVersionRange vr)+  PackageVersionConstraint pn (simplifyVersionRange vr)
src/Distribution/Types/PkgconfigDependency.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.PkgconfigDependency-  ( PkgconfigDependency(..)+  ( PkgconfigDependency (..)   ) where  import Distribution.Compat.Prelude@@ -18,22 +19,23 @@ -- | Describes a dependency on a pkg-config library -- -- @since 2.0.0.2-data PkgconfigDependency = PkgconfigDependency-                           PkgconfigName-                           PkgconfigVersionRange-                         deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+data PkgconfigDependency+  = PkgconfigDependency+      PkgconfigName+      PkgconfigVersionRange+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary PkgconfigDependency instance Structured PkgconfigDependency instance NFData PkgconfigDependency where rnf = genericRnf  instance Pretty PkgconfigDependency where-    pretty (PkgconfigDependency name PcAnyVersion) = pretty name-    pretty (PkgconfigDependency name ver)          = pretty name <+> pretty ver+  pretty (PkgconfigDependency name PcAnyVersion) = pretty name+  pretty (PkgconfigDependency name ver) = pretty name <+> pretty ver  instance Parsec PkgconfigDependency where-    parsec = do-        name <- parsec-        P.spaces-        verRange <- parsec <|> pure anyPkgconfigVersion-        pure $ PkgconfigDependency name verRange+  parsec = do+    name <- parsec+    P.spaces+    verRange <- parsec <|> pure anyPkgconfigVersion+    pure $ PkgconfigDependency name verRange
src/Distribution/Types/PkgconfigName.hs view
@@ -1,16 +1,18 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+ module Distribution.Types.PkgconfigName-  ( PkgconfigName, unPkgconfigName, mkPkgconfigName+  ( PkgconfigName+  , unPkgconfigName+  , mkPkgconfigName   ) where -import Prelude () import Distribution.Compat.Prelude import Distribution.Utils.ShortText+import Prelude () -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty  import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp@@ -21,7 +23,7 @@ -- -- @since 2.0.0.2 newtype PkgconfigName = PkgconfigName ShortText-    deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+  deriving (Generic, Read, Show, Eq, Ord, Data)  -- | Convert 'PkgconfigName' to 'String' --@@ -44,7 +46,7 @@ -- -- @since 2.0.0.2 instance IsString PkgconfigName where-    fromString = mkPkgconfigName+  fromString = mkPkgconfigName  instance Binary PkgconfigName instance Structured PkgconfigName@@ -56,13 +58,14 @@   pretty = Disp.text . unPkgconfigName  instance Parsec PkgconfigName where-    parsec = mkPkgconfigName <$> P.munch1 isNameChar where-        -- https://gitlab.haskell.org/ghc/ghc/issues/17752-        isNameChar '-' = True-        isNameChar '_' = True-        isNameChar '.' = True-        isNameChar '+' = True-        isNameChar c   = isAlphaNum c+  parsec = mkPkgconfigName <$> P.munch1 isNameChar+    where+      -- https://gitlab.haskell.org/ghc/ghc/issues/17752+      isNameChar '-' = True+      isNameChar '_' = True+      isNameChar '.' = True+      isNameChar '+' = True+      isNameChar c = isAlphaNum c  instance NFData PkgconfigName where-    rnf (PkgconfigName pkg) = rnf pkg+  rnf (PkgconfigName pkg) = rnf pkg
src/Distribution/Types/PkgconfigVersion.hs view
@@ -1,10 +1,11 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}+ -- @since 3.0-module Distribution.Types.PkgconfigVersion (-    PkgconfigVersion (..),-    rpmvercmp,-    ) where+module Distribution.Types.PkgconfigVersion+  ( PkgconfigVersion (..)+  , rpmvercmp+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -13,10 +14,10 @@ import Distribution.Pretty import Distribution.Utils.Generic (isAsciiAlphaNum) -import qualified Data.ByteString                 as BS-import qualified Data.ByteString.Char8           as BS8+import qualified Data.ByteString as BS+import qualified Data.ByteString.Char8 as BS8 import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as PP+import qualified Text.PrettyPrint as PP  -- | @pkg-config@ versions. --@@ -25,20 +26,20 @@ -- -- @since 3.0 newtype PkgconfigVersion = PkgconfigVersion BS.ByteString-  deriving (Generic, Read, Show, Typeable, Data)+  deriving (Generic, Read, Show, Data)  instance Eq PkgconfigVersion where-    PkgconfigVersion a == PkgconfigVersion b = rpmvercmp a b == EQ+  PkgconfigVersion a == PkgconfigVersion b = rpmvercmp a b == EQ  instance Ord PkgconfigVersion where-    PkgconfigVersion a `compare` PkgconfigVersion b = rpmvercmp a b+  PkgconfigVersion a `compare` PkgconfigVersion b = rpmvercmp a b  instance Binary PkgconfigVersion instance Structured PkgconfigVersion instance NFData PkgconfigVersion where rnf = genericRnf  instance Pretty PkgconfigVersion where-    pretty (PkgconfigVersion bs) = PP.text (BS8.unpack bs)+  pretty (PkgconfigVersion bs) = PP.text (BS8.unpack bs)  -- | --@@ -47,10 +48,10 @@ -- -- >>> simpleParsec "0.3.5+ds" :: Maybe PkgconfigVersion -- Nothing--- instance Parsec PkgconfigVersion where-    parsec = PkgconfigVersion . BS8.pack <$> P.munch1 predicate where-        predicate c = isAsciiAlphaNum c || c == '.' || c == '-'+  parsec = PkgconfigVersion . BS8.pack <$> P.munch1 predicate+    where+      predicate c = isAsciiAlphaNum c || c == '.' || c == '-'  ------------------------------------------------------------------------------- -- rpmvercmp - pure Haskell implementation@@ -66,36 +67,36 @@     -- if there is _any_ trailing "garbage", it seems to affect result     -- https://github.com/haskell/cabal/issues/6805     go0 [] [] = EQ-    go0 [] _  = LT-    go0 _  [] = GT+    go0 [] _ = LT+    go0 _ [] = GT     go0 xs ys = go1 (dropNonAlnum8 xs) (dropNonAlnum8 ys)      go1 :: [Word8] -> [Word8] -> Ordering     go1 [] [] = EQ-    go1 [] _  = LT-    go1 _  [] = GT-    go1 xs@(x:_) ys+    go1 [] _ = LT+    go1 _ [] = GT+    go1 xs@(x : _) ys       | isDigit8 x =           let (xs1, xs2) = span isDigit8 xs               (ys1, ys2) = span isDigit8 ys-            -- numeric segments are always newer than alpha segments-          in if null ys1-             then GT-             else compareInt xs1 ys1 <> go0 xs2 ys2-+           in -- numeric segments are always newer than alpha segments+              if null ys1+                then GT+                else compareInt xs1 ys1 <> go0 xs2 ys2       -- isAlpha       | otherwise =           let (xs1, xs2) = span isAlpha8 xs               (ys1, ys2) = span isAlpha8 ys-          in if null ys1-             then LT-             else compareStr xs1 ys1 <> go0 xs2 ys2+           in if null ys1+                then LT+                else compareStr xs1 ys1 <> go0 xs2 ys2  -- compare as numbers compareInt :: [Word8] -> [Word8] -> Ordering compareInt xs ys =-    -- whichever number has more digits wins-    compare (length xs') (length ys') <>+  -- whichever number has more digits wins+  compare (length xs') (length ys')+    <>     -- equal length: use per character compare, "strcmp"     compare xs' ys'   where@@ -115,4 +116,3 @@  isAlpha8 :: Word8 -> Bool isAlpha8 w = (0x41 <= w && w <= 0x5A) || (0x61 <= w && w <= 0x7A)-
src/Distribution/Types/PkgconfigVersionRange.hs view
@@ -1,14 +1,16 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-module Distribution.Types.PkgconfigVersionRange (-    PkgconfigVersionRange (..),-    anyPkgconfigVersion,-    isAnyPkgconfigVersion,-    withinPkgconfigVersionRange,+{-# LANGUAGE DeriveGeneric #-}++module Distribution.Types.PkgconfigVersionRange+  ( PkgconfigVersionRange (..)+  , anyPkgconfigVersion+  , isAnyPkgconfigVersion+  , withinPkgconfigVersionRange+     -- * Internal-    versionToPkgconfigVersion,-    versionRangeToPkgconfigVersionRange,-    ) where+  , versionToPkgconfigVersion+  , versionRangeToPkgconfigVersionRange+  ) where  import Distribution.Compat.Prelude import Prelude ()@@ -21,83 +23,84 @@ import Distribution.Types.VersionInterval import Distribution.Types.VersionRange -import qualified Data.ByteString.Char8           as BS8+import qualified Data.ByteString.Char8 as BS8 import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as PP+import qualified Text.PrettyPrint as PP  -- | @since 3.0 data PkgconfigVersionRange   = PcAnyVersion-  | PcThisVersion            PkgconfigVersion -- = version-  | PcLaterVersion           PkgconfigVersion -- > version  (NB. not >=)-  | PcEarlierVersion         PkgconfigVersion -- < version-  | PcOrLaterVersion         PkgconfigVersion -- >= version-  | PcOrEarlierVersion       PkgconfigVersion -- =< version-  | PcUnionVersionRanges     PkgconfigVersionRange PkgconfigVersionRange+  | PcThisVersion PkgconfigVersion -- = version+  | PcLaterVersion PkgconfigVersion -- > version  (NB. not >=)+  | PcEarlierVersion PkgconfigVersion -- < version+  | PcOrLaterVersion PkgconfigVersion -- >= version+  | PcOrEarlierVersion PkgconfigVersion -- =< version+  | PcUnionVersionRanges PkgconfigVersionRange PkgconfigVersionRange   | PcIntersectVersionRanges PkgconfigVersionRange PkgconfigVersionRange-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)+  deriving (Generic, Read, Show, Eq, Ord, Data)  instance Binary PkgconfigVersionRange instance Structured PkgconfigVersionRange instance NFData PkgconfigVersionRange where rnf = genericRnf  instance Pretty PkgconfigVersionRange where-    pretty = pp 0  where-        pp :: Int -> PkgconfigVersionRange -> PP.Doc-        pp _ PcAnyVersion           = PP.text "-any"-        pp _ (PcThisVersion v)      = PP.text "==" <<>> pretty v-        pp _ (PcLaterVersion v)     = PP.text ">" <<>> pretty v-        pp _ (PcEarlierVersion v)   = PP.text "<" <<>> pretty v-        pp _ (PcOrLaterVersion v)   = PP.text ">=" <<>> pretty v-        pp _ (PcOrEarlierVersion v) = PP.text "<=" <<>> pretty v--        pp d (PcUnionVersionRanges v u) = parens (d >= 1) $-            pp 1 v PP.<+> PP.text "||" PP.<+> pp 0 u-        pp d (PcIntersectVersionRanges v u) = parens (d >= 2) $-            pp 2 v PP.<+> PP.text "&&" PP.<+> pp 1 u+  pretty = pp 0+    where+      pp :: Int -> PkgconfigVersionRange -> PP.Doc+      pp _ PcAnyVersion = PP.text "-any"+      pp _ (PcThisVersion v) = PP.text "==" <<>> pretty v+      pp _ (PcLaterVersion v) = PP.text ">" <<>> pretty v+      pp _ (PcEarlierVersion v) = PP.text "<" <<>> pretty v+      pp _ (PcOrLaterVersion v) = PP.text ">=" <<>> pretty v+      pp _ (PcOrEarlierVersion v) = PP.text "<=" <<>> pretty v+      pp d (PcUnionVersionRanges v u) =+        parens (d >= 1) $+          pp 1 v PP.<+> PP.text "||" PP.<+> pp 0 u+      pp d (PcIntersectVersionRanges v u) =+        parens (d >= 2) $+          pp 2 v PP.<+> PP.text "&&" PP.<+> pp 1 u -        parens True  = PP.parens-        parens False = id+      parens True = PP.parens+      parens False = id  instance Parsec PkgconfigVersionRange where-    -- note: the wildcard is used in some places, e.g-    -- http://hackage.haskell.org/package/bindings-libzip-0.10.1/bindings-libzip.cabal-    ---    -- however, in the presence of alphanumerics etc. lax version parser,-    -- wildcard is ill-specified+  -- note: the wildcard is used in some places, e.g+  -- http://hackage.haskell.org/package/bindings-libzip-0.10.1/bindings-libzip.cabal+  --+  -- however, in the presence of alphanumerics etc. lax version parser,+  -- wildcard is ill-specified -    parsec = do-        csv <- askCabalSpecVersion-        if csv >= CabalSpecV3_0-        then pkgconfigParser-        else versionRangeToPkgconfigVersionRange <$> versionRangeParser P.integral csv+  parsec = do+    csv <- askCabalSpecVersion+    if csv >= CabalSpecV3_0+      then pkgconfigParser+      else versionRangeToPkgconfigVersionRange <$> versionRangeParser P.integral csv  -- "modern" parser of @pkg-config@ package versions. pkgconfigParser :: CabalParsing m => m PkgconfigVersionRange-pkgconfigParser = P.spaces >> expr where+pkgconfigParser = P.spaces >> expr+  where     -- every parser here eats trailing space     expr = do-        ts <- term `P.sepByNonEmpty` (P.string "||" >> P.spaces)-        return $ foldr1 PcUnionVersionRanges ts+      ts <- term `P.sepByNonEmpty` (P.string "||" >> P.spaces)+      return $ foldr1 PcUnionVersionRanges ts      term = do-        fs <- factor `P.sepByNonEmpty` (P.string "&&" >> P.spaces)-        return $ foldr1 PcIntersectVersionRanges fs+      fs <- factor `P.sepByNonEmpty` (P.string "&&" >> P.spaces)+      return $ foldr1 PcIntersectVersionRanges fs      factor = parens expr <|> prim      prim = do-        op <- P.munch1 isOpChar P.<?> "operator"-        case op of-            "-"  -> anyPkgconfigVersion <$ (P.string "any" *> P.spaces)--            "==" -> afterOp PcThisVersion-            ">"  -> afterOp PcLaterVersion-            "<"  -> afterOp PcEarlierVersion-            ">=" -> afterOp PcOrLaterVersion-            "<=" -> afterOp PcOrEarlierVersion--            _ -> P.unexpected $ "Unknown version operator " ++ show op+      op <- P.munch1 isOpChar P.<?> "operator"+      case op of+        "-" -> anyPkgconfigVersion <$ (P.string "any" *> P.spaces)+        "==" -> afterOp PcThisVersion+        ">" -> afterOp PcLaterVersion+        "<" -> afterOp PcEarlierVersion+        ">=" -> afterOp PcOrLaterVersion+        "<=" -> afterOp PcOrEarlierVersion+        _ -> P.unexpected $ "Unknown version operator " ++ show op      -- https://gitlab.haskell.org/ghc/ghc/issues/17752     isOpChar '<' = True@@ -105,15 +108,16 @@     isOpChar '>' = True     isOpChar '^' = True     isOpChar '-' = True-    isOpChar _   = False+    isOpChar _ = False      afterOp f = do-        P.spaces-        v <- parsec-        P.spaces-        return (f v)+      P.spaces+      v <- parsec+      P.spaces+      return (f v) -    parens = P.between+    parens =+      P.between         ((P.char '(' P.<?> "opening paren") >> P.spaces)         (P.char ')' >> P.spaces) @@ -125,14 +129,15 @@ isAnyPkgconfigVersion = (== PcAnyVersion)  withinPkgconfigVersionRange :: PkgconfigVersion -> PkgconfigVersionRange -> Bool-withinPkgconfigVersionRange v = go where-    go PcAnyVersion                   = True-    go (PcThisVersion u)              = v == u-    go (PcLaterVersion u)             = v > u-    go (PcEarlierVersion u)           = v < u-    go (PcOrLaterVersion u)           = v >= u-    go (PcOrEarlierVersion u)         = v <= u-    go (PcUnionVersionRanges a b)     = go a || go b+withinPkgconfigVersionRange v = go+  where+    go PcAnyVersion = True+    go (PcThisVersion u) = v == u+    go (PcLaterVersion u) = v > u+    go (PcEarlierVersion u) = v < u+    go (PcOrLaterVersion u) = v >= u+    go (PcOrEarlierVersion u) = v <= u+    go (PcUnionVersionRanges a b) = go a || go b     go (PcIntersectVersionRanges a b) = go a && go b  -------------------------------------------------------------------------------@@ -144,14 +149,14 @@  versionRangeToPkgconfigVersionRange :: VersionRange -> PkgconfigVersionRange versionRangeToPkgconfigVersionRange vr-    | isAnyVersion vr-    = PcAnyVersion-    | otherwise-    = case asVersionIntervals vr of-        []     -> PcEarlierVersion (PkgconfigVersion (BS8.pack "0"))-        (i:is) -> foldl (\r j -> PcUnionVersionRanges r (conv j)) (conv i) is+  | isAnyVersion vr =+      PcAnyVersion+  | otherwise =+      case asVersionIntervals vr of+        [] -> PcEarlierVersion (PkgconfigVersion (BS8.pack "0"))+        (i : is) -> foldl (\r j -> PcUnionVersionRanges r (conv j)) (conv i) is   where-    conv (VersionInterval (LowerBound v b) NoUpperBound)     = convL v b+    conv (VersionInterval (LowerBound v b) NoUpperBound) = convL v b     conv (VersionInterval (LowerBound v b) (UpperBound u c)) = PcIntersectVersionRanges (convL v b) (convU u c)      convL v ExclusiveBound = PcLaterVersion (versionToPkgconfigVersion v)
src/Distribution/Types/SetupBuildInfo.hs view
@@ -1,12 +1,12 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.SetupBuildInfo (-    SetupBuildInfo(..)-) where+module Distribution.Types.SetupBuildInfo+  ( SetupBuildInfo (..)+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Types.Dependency @@ -18,24 +18,25 @@ -- options authors can specify to just Haskell package dependencies.  data SetupBuildInfo = SetupBuildInfo-    { setupDepends        :: [Dependency]-    , defaultSetupDepends :: Bool-        -- ^ Is this a default 'custom-setup' section added by the cabal-install-        -- code (as opposed to user-provided)? This field is only used-        -- internally, and doesn't correspond to anything in the .cabal-        -- file. See #3199.-    }-    deriving (Generic, Show, Eq, Ord, Read, Typeable, Data)+  { setupDepends :: [Dependency]+  , defaultSetupDepends :: Bool+  -- ^ Is this a default 'custom-setup' section added by the cabal-install+  -- code (as opposed to user-provided)? This field is only used+  -- internally, and doesn't correspond to anything in the .cabal+  -- file. See #3199.+  }+  deriving (Generic, Show, Eq, Ord, Read, Data)  instance Binary SetupBuildInfo instance Structured SetupBuildInfo instance NFData SetupBuildInfo where rnf = genericRnf  instance Monoid SetupBuildInfo where-    mempty  = SetupBuildInfo [] False-    mappend = (<>)+  mempty = SetupBuildInfo [] False+  mappend = (<>)  instance Semigroup SetupBuildInfo where-    a <> b = SetupBuildInfo-        (setupDepends a <> setupDepends b)-        (defaultSetupDepends a || defaultSetupDepends b)+  a <> b =+    SetupBuildInfo+      (setupDepends a <> setupDepends b)+      (defaultSetupDepends a || defaultSetupDepends b)
src/Distribution/Types/SetupBuildInfo/Lens.hs view
@@ -1,21 +1,21 @@-module Distribution.Types.SetupBuildInfo.Lens (-    SetupBuildInfo,-    module Distribution.Types.SetupBuildInfo.Lens,-    ) where+module Distribution.Types.SetupBuildInfo.Lens+  ( SetupBuildInfo+  , module Distribution.Types.SetupBuildInfo.Lens+  ) where  import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Types.Dependency     (Dependency)+import Distribution.Types.Dependency (Dependency) import Distribution.Types.SetupBuildInfo (SetupBuildInfo)  import qualified Distribution.Types.SetupBuildInfo as T  setupDepends :: Lens' SetupBuildInfo [Dependency]-setupDepends f s = fmap (\x -> s { T.setupDepends = x }) (f (T.setupDepends s))+setupDepends f s = fmap (\x -> s{T.setupDepends = x}) (f (T.setupDepends s)) {-# INLINE setupDepends #-}  defaultSetupDepends :: Lens' SetupBuildInfo Bool-defaultSetupDepends f s = fmap (\x -> s { T.defaultSetupDepends = x }) (f (T.defaultSetupDepends s))+defaultSetupDepends f s = fmap (\x -> s{T.defaultSetupDepends = x}) (f (T.defaultSetupDepends s)) {-# INLINE defaultSetupDepends #-}
src/Distribution/Types/SourceRepo.hs view
@@ -1,31 +1,33 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.SourceRepo (-    SourceRepo(..),-    RepoKind(..),-    RepoType(..),-    KnownRepoType (..),-    knownRepoTypes,-    emptySourceRepo,-    classifyRepoType,-    classifyRepoKind,+module Distribution.Types.SourceRepo+  ( SourceRepo (..)+  , RepoKind (..)+  , RepoType (..)+  , KnownRepoType (..)+  , knownRepoTypes+  , emptySourceRepo+  , classifyRepoType+  , classifyRepoKind   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Utils.Generic (lowercase) -import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty +import qualified Data.Map.Strict as M import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp-import qualified Data.Map.Strict as M  -- ------------------------------------------------------------+ -- * Source repos+ -- ------------------------------------------------------------  -- | Information about the source revision control system for a package.@@ -43,57 +45,50 @@ -- The required information is the 'RepoType' which tells us if it's using -- 'Darcs', 'Git' for example. The 'repoLocation' and other details are -- interpreted according to the repo type.----data SourceRepo = SourceRepo {-  -- | The kind of repo. This field is required.-  repoKind     :: RepoKind,--  -- | The type of the source repository system for this repo, eg 'Darcs' or+data SourceRepo = SourceRepo+  { repoKind :: RepoKind+  -- ^ The kind of repo. This field is required.+  , repoType :: Maybe RepoType+  -- ^ The type of the source repository system for this repo, eg 'Darcs' or   -- 'Git'. This field is required.-  repoType     :: Maybe RepoType,--  -- | The location of the repository. For most 'RepoType's this is a URL.+  , repoLocation :: Maybe String+  -- ^ The location of the repository. For most 'RepoType's this is a URL.   -- This field is required.-  repoLocation :: Maybe String,--  -- | 'CVS' can put multiple \"modules\" on one server and requires a+  , repoModule :: Maybe String+  -- ^ 'CVS' can put multiple \"modules\" on one server and requires a   -- module name in addition to the location to identify a particular repo.   -- Logically this is part of the location but unfortunately has to be   -- specified separately. This field is required for the 'CVS' 'RepoType' and   -- should not be given otherwise.-  repoModule   :: Maybe String,--  -- | The name or identifier of the branch, if any. Many source control+  , repoBranch :: Maybe String+  -- ^ The name or identifier of the branch, if any. Many source control   -- systems have the notion of multiple branches in a repo that exist in the   -- same location. For example 'Git' and 'CVS' use this while systems like   -- 'Darcs' use different locations for different branches. This field is   -- optional but should be used if necessary to identify the sources,   -- especially for the 'RepoThis' repo kind.-  repoBranch   :: Maybe String,--  -- | The tag identify a particular state of the repository. This should be+  , repoTag :: Maybe String+  -- ^ The tag identify a particular state of the repository. This should be   -- given for the 'RepoThis' repo kind and not for 'RepoHead' kind.-  ---  repoTag      :: Maybe String,--  -- | Some repositories contain multiple projects in different subdirectories+  , repoSubdir :: Maybe FilePath+  -- ^ Some repositories contain multiple projects in different subdirectories   -- This field specifies the subdirectory where this packages sources can be   -- found, eg the subdirectory containing the @.cabal@ file. It is interpreted   -- relative to the root of the repository. This field is optional. If not   -- given the default is \".\" ie no subdirectory.-  repoSubdir   :: Maybe FilePath-}-  deriving (Eq, Ord, Generic, Read, Show, Typeable, Data)+  }+  deriving (Eq, Ord, Generic, Read, Show, Data)  emptySourceRepo :: RepoKind -> SourceRepo-emptySourceRepo kind = SourceRepo-    { repoKind     = kind-    , repoType     = Nothing+emptySourceRepo kind =+  SourceRepo+    { repoKind = kind+    , repoType = Nothing     , repoLocation = Nothing-    , repoModule   = Nothing-    , repoBranch   = Nothing-    , repoTag      = Nothing-    , repoSubdir   = Nothing+    , repoModule = Nothing+    , repoBranch = Nothing+    , repoTag = Nothing+    , repoSubdir = Nothing     }  instance Binary SourceRepo@@ -101,20 +96,17 @@ instance NFData SourceRepo where rnf = genericRnf  -- | What this repo info is for, what it represents.----data RepoKind =-    -- | The repository for the \"head\" or development version of the project.+data RepoKind+  = -- | The repository for the \"head\" or development version of the project.     -- This repo is where we should track the latest development activity or     -- the usual repo people should get to contribute patches.     RepoHead--    -- | The repository containing the sources for this exact package version+  | -- | The repository containing the sources for this exact package version     -- or release. For this kind of repo a tag should be given to give enough     -- information to re-create the exact sources.-  | RepoThis-+    RepoThis   | RepoKindUnknown String-  deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)+  deriving (Eq, Generic, Ord, Read, Show, Data)  instance Binary RepoKind instance Structured RepoKind@@ -123,11 +115,18 @@ -- | An enumeration of common source control systems. The fields used in the -- 'SourceRepo' depend on the type of repo. The tools and methods used to -- obtain and track the repo depend on the repo type.----data KnownRepoType = Darcs | Git | SVN | CVS-                   | Mercurial | GnuArch | Bazaar | Monotone-                   | Pijul -- ^ @since 3.4.0.0-  deriving (Eq, Generic, Ord, Read, Show, Typeable, Data, Enum, Bounded)+data KnownRepoType+  = Darcs+  | Git+  | SVN+  | CVS+  | Mercurial+  | GnuArch+  | Bazaar+  | Monotone+  | -- | @since 3.4.0.0+    Pijul+  deriving (Eq, Generic, Ord, Read, Show, Data, Enum, Bounded)  instance Binary KnownRepoType instance Structured KnownRepoType@@ -144,9 +143,10 @@ instance Pretty KnownRepoType where   pretty = Disp.text . lowercase . show -data RepoType = KnownRepoType KnownRepoType-              | OtherRepoType String-  deriving (Eq, Generic, Ord, Read, Show, Typeable, Data)+data RepoType+  = KnownRepoType KnownRepoType+  | OtherRepoType String+  deriving (Eq, Generic, Ord, Read, Show, Data)  instance Binary RepoType instance Structured RepoType@@ -156,14 +156,14 @@ knownRepoTypes = [minBound .. maxBound]  repoTypeAliases :: KnownRepoType -> [String]-repoTypeAliases Bazaar    = ["bzr"]+repoTypeAliases Bazaar = ["bzr"] repoTypeAliases Mercurial = ["hg"]-repoTypeAliases GnuArch   = ["arch"]-repoTypeAliases _         = []+repoTypeAliases GnuArch = ["arch"]+repoTypeAliases _ = []  instance Pretty RepoKind where-  pretty RepoHead                = Disp.text "head"-  pretty RepoThis                = Disp.text "this"+  pretty RepoHead = Disp.text "head"+  pretty RepoThis = Disp.text "this"   pretty (RepoKindUnknown other) = Disp.text other  instance Parsec RepoKind where@@ -173,7 +173,7 @@ classifyRepoKind name = case lowercase name of   "head" -> RepoHead   "this" -> RepoThis-  _      -> RepoKindUnknown name+  _ -> RepoKindUnknown name  instance Parsec RepoType where   parsec = classifyRepoType <$> P.munch1 isIdent@@ -193,8 +193,8 @@ knownRepoTypeMap =   M.fromList     [ (name, repoType')-      | repoType' <- knownRepoTypes-      , name <- prettyShow repoType' : repoTypeAliases repoType'+    | repoType' <- knownRepoTypes+    , name <- prettyShow repoType' : repoTypeAliases repoType'     ]  isIdent :: Char -> Bool
src/Distribution/Types/SourceRepo/Lens.hs view
@@ -1,39 +1,39 @@-module Distribution.Types.SourceRepo.Lens (-    T.SourceRepo,-    module Distribution.Types.SourceRepo.Lens,-    ) where+module Distribution.Types.SourceRepo.Lens+  ( T.SourceRepo+  , module Distribution.Types.SourceRepo.Lens+  ) where -import Prelude()-import Distribution.Compat.Prelude import Distribution.Compat.Lens+import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.SourceRepo (SourceRepo, RepoKind, RepoType)+import Distribution.Types.SourceRepo (RepoKind, RepoType, SourceRepo) import qualified Distribution.Types.SourceRepo as T  repoKind :: Lens' SourceRepo RepoKind-repoKind f s = fmap (\x -> s { T.repoKind = x }) (f (T.repoKind s))+repoKind f s = fmap (\x -> s{T.repoKind = x}) (f (T.repoKind s)) {-# INLINE repoKind #-}  repoType :: Lens' SourceRepo (Maybe RepoType)-repoType f s = fmap (\x -> s { T.repoType = x }) (f (T.repoType s))+repoType f s = fmap (\x -> s{T.repoType = x}) (f (T.repoType s)) {-# INLINE repoType #-}  repoLocation :: Lens' SourceRepo (Maybe String)-repoLocation f s = fmap (\x -> s { T.repoLocation = x }) (f (T.repoLocation s))+repoLocation f s = fmap (\x -> s{T.repoLocation = x}) (f (T.repoLocation s)) {-# INLINE repoLocation #-}  repoModule :: Lens' SourceRepo (Maybe String)-repoModule f s = fmap (\x -> s { T.repoModule = x }) (f (T.repoModule s))+repoModule f s = fmap (\x -> s{T.repoModule = x}) (f (T.repoModule s)) {-# INLINE repoModule #-}  repoBranch :: Lens' SourceRepo (Maybe String)-repoBranch f s = fmap (\x -> s { T.repoBranch = x }) (f (T.repoBranch s))+repoBranch f s = fmap (\x -> s{T.repoBranch = x}) (f (T.repoBranch s)) {-# INLINE repoBranch #-}  repoTag :: Lens' SourceRepo (Maybe String)-repoTag f s = fmap (\x -> s { T.repoTag = x }) (f (T.repoTag s))+repoTag f s = fmap (\x -> s{T.repoTag = x}) (f (T.repoTag s)) {-# INLINE repoTag #-}  repoSubdir :: Lens' SourceRepo (Maybe FilePath)-repoSubdir f s = fmap (\x -> s { T.repoSubdir = x }) (f (T.repoSubdir s))+repoSubdir f s = fmap (\x -> s{T.repoSubdir = x}) (f (T.repoSubdir s)) {-# INLINE repoSubdir #-}
src/Distribution/Types/TestSuite.hs view
@@ -1,20 +1,20 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.TestSuite (-    TestSuite(..),-    emptyTestSuite,-    testType,-    testModules,-    testModulesAutogen-) where+module Distribution.Types.TestSuite+  ( TestSuite (..)+  , emptyTestSuite+  , testType+  , testModules+  , testModulesAutogen+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Types.BuildInfo-import Distribution.Types.TestType import Distribution.Types.TestSuiteInterface+import Distribution.Types.TestType import Distribution.Types.UnqualComponentName  import Distribution.ModuleName@@ -22,17 +22,16 @@ import qualified Distribution.Types.BuildInfo.Lens as L  -- | A \"test-suite\" stanza in a cabal file.----data TestSuite = TestSuite {-        testName      :: UnqualComponentName,-        testInterface :: TestSuiteInterface,-        testBuildInfo :: BuildInfo,-        testCodeGenerators :: [String]-    }-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data TestSuite = TestSuite+  { testName :: UnqualComponentName+  , testInterface :: TestSuiteInterface+  , testBuildInfo :: BuildInfo+  , testCodeGenerators :: [String]+  }+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance L.HasBuildInfo TestSuite where-    buildInfo f l = (\x -> l { testBuildInfo = x }) <$> f (testBuildInfo l)+  buildInfo f l = (\x -> l{testBuildInfo = x}) <$> f (testBuildInfo l)  instance Binary TestSuite instance Structured TestSuite@@ -40,45 +39,43 @@ instance NFData TestSuite where rnf = genericRnf  instance Monoid TestSuite where-    mempty = TestSuite {-        testName      = mempty,-        testInterface = mempty,-        testBuildInfo = mempty,-        testCodeGenerators = mempty-    }-    mappend = (<>)+  mempty =+    TestSuite+      { testName = mempty+      , testInterface = mempty+      , testBuildInfo = mempty+      , testCodeGenerators = mempty+      }+  mappend = (<>)  instance Semigroup TestSuite where-    a <> b = TestSuite {-        testName      = combine' testName,-        testInterface = combine  testInterface,-        testBuildInfo = combine  testBuildInfo,-        testCodeGenerators = combine testCodeGenerators-    }-        where combine  field = field a `mappend` field b-              combine' field = case ( unUnqualComponentName $ field a-                                    , unUnqualComponentName $ field b) of-                        ("", _) -> field b-                        (_, "") -> field a-                        (x, y) -> error $ "Ambiguous values for test field: '"-                            ++ x ++ "' and '" ++ y ++ "'"+  a <> b =+    TestSuite+      { testName = combineNames a b testName "test"+      , testInterface = combine testInterface+      , testBuildInfo = combine testBuildInfo+      , testCodeGenerators = combine testCodeGenerators+      }+    where+      combine field = field a `mappend` field b  emptyTestSuite :: TestSuite emptyTestSuite = mempty - testType :: TestSuite -> TestType testType test = case testInterface test of-  TestSuiteExeV10 ver _         -> TestTypeExe ver-  TestSuiteLibV09 ver _         -> TestTypeLib ver+  TestSuiteExeV10 ver _ -> TestTypeExe ver+  TestSuiteLibV09 ver _ -> TestTypeLib ver   TestSuiteUnsupported testtype -> testtype  -- | Get all the module names from a test suite. testModules :: TestSuite -> [ModuleName]-testModules test = (case testInterface test of-                     TestSuiteLibV09 _ m -> [m]-                     _                   -> [])-                ++ otherModules (testBuildInfo test)+testModules test =+  ( case testInterface test of+      TestSuiteLibV09 _ m -> [m]+      _ -> []+  )+    ++ otherModules (testBuildInfo test)  -- | Get all the auto generated module names from a test suite. -- This are a subset of 'testModules'.
src/Distribution/Types/TestSuite/Lens.hs view
@@ -1,27 +1,27 @@-module Distribution.Types.TestSuite.Lens (-    TestSuite,-    module Distribution.Types.TestSuite.Lens,-    ) where+module Distribution.Types.TestSuite.Lens+  ( TestSuite+  , module Distribution.Types.TestSuite.Lens+  ) where  import Distribution.Compat.Lens import Distribution.Compat.Prelude import Prelude () -import Distribution.Types.BuildInfo           (BuildInfo)-import Distribution.Types.TestSuite           (TestSuite)-import Distribution.Types.TestSuiteInterface  (TestSuiteInterface)+import Distribution.Types.BuildInfo (BuildInfo)+import Distribution.Types.TestSuite (TestSuite)+import Distribution.Types.TestSuiteInterface (TestSuiteInterface) import Distribution.Types.UnqualComponentName (UnqualComponentName)  import qualified Distribution.Types.TestSuite as T  testName :: Lens' TestSuite UnqualComponentName-testName f s = fmap (\x -> s { T.testName = x }) (f (T.testName s))+testName f s = fmap (\x -> s{T.testName = x}) (f (T.testName s)) {-# INLINE testName #-}  testInterface :: Lens' TestSuite TestSuiteInterface-testInterface f s = fmap (\x -> s { T.testInterface = x }) (f (T.testInterface s))+testInterface f s = fmap (\x -> s{T.testInterface = x}) (f (T.testInterface s)) {-# INLINE testInterface #-}  testBuildInfo :: Lens' TestSuite BuildInfo-testBuildInfo f s = fmap (\x -> s { T.testBuildInfo = x }) (f (T.testBuildInfo s))+testBuildInfo f s = fmap (\x -> s{T.testBuildInfo = x}) (f (T.testBuildInfo s)) {-# INLINE testBuildInfo #-}
src/Distribution/Types/TestSuiteInterface.hs view
@@ -1,41 +1,36 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} -module Distribution.Types.TestSuiteInterface (-    TestSuiteInterface(..),-) where+module Distribution.Types.TestSuiteInterface+  ( TestSuiteInterface (..)+  ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude () -import Distribution.Types.TestType import Distribution.ModuleName+import Distribution.Types.TestType+import Distribution.Utils.Path import Distribution.Version  -- | The test suite interfaces that are currently defined. -- -- More interfaces may be defined in future, either new revisions or totally -- new interfaces.----data TestSuiteInterface =--     -- | Test interface \"exitcode-stdio-1.0\". The test-suite takes the form-     -- of an executable. It returns a zero exit code for success, non-zero for-     -- failure. The stdout and stderr channels may be logged. Test tooling may-     -- pass command line arguments and/or connect the stdin channel to the test.-     ---     TestSuiteExeV10 Version FilePath--     -- | Test interface \"detailed-0.9\". The test-suite takes the form of a-     -- library containing a designated module that exports \"tests :: [Test]\".-     ---   | TestSuiteLibV09 Version ModuleName--     -- | A test suite that does not conform to one of the above interfaces for-     -- the given reason (e.g. unknown test type).-     ---   | TestSuiteUnsupported TestType-   deriving (Eq, Ord, Generic, Read, Show, Typeable, Data)+data TestSuiteInterface+  = -- | Test interface \"exitcode-stdio-1.0\". The test-suite takes the form+    -- of an executable. It returns a zero exit code for success, non-zero for+    -- failure. The stdout and stderr channels may be logged. Test tooling may+    -- pass command line arguments and/or connect the stdin channel to the test.+    TestSuiteExeV10 Version (RelativePath Source File)+  | -- | Test interface \"detailed-0.9\". The test-suite takes the form of a+    -- library containing a designated module that exports \"tests :: [Test]\".+    TestSuiteLibV09 Version ModuleName+  | -- | A test suite that does not conform to one of the above interfaces for+    -- the given reason (e.g. unknown test type).+    TestSuiteUnsupported TestType+  deriving (Eq, Ord, Generic, Read, Show, Data)  instance Binary TestSuiteInterface instance Structured TestSuiteInterface@@ -43,9 +38,9 @@ instance NFData TestSuiteInterface where rnf = genericRnf  instance Monoid TestSuiteInterface where-    mempty  =  TestSuiteUnsupported (TestTypeUnknown mempty nullVersion)-    mappend = (<>)+  mempty = TestSuiteUnsupported (TestTypeUnknown mempty nullVersion)+  mappend = (<>)  instance Semigroup TestSuiteInterface where-    a <> (TestSuiteUnsupported _) = a-    _ <> b                        = b+  a <> (TestSuiteUnsupported _) = a+  _ <> b = b
src/Distribution/Types/TestType.hs view
@@ -1,13 +1,13 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-{-# LANGUAGE OverloadedStrings  #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE OverloadedStrings #-} -module Distribution.Types.TestType (-    TestType(..),-    knownTestTypes,-    testTypeExe,-    testTypeLib,-) where+module Distribution.Types.TestType+  ( TestType (..)+  , knownTestTypes+  , testTypeExe+  , testTypeLib+  ) where  import Distribution.Compat.Prelude import Distribution.Version@@ -15,14 +15,17 @@  import Distribution.Parsec import Distribution.Pretty-import Text.PrettyPrint    (char, text)+import Text.PrettyPrint (char, text)  -- | The \"test-type\" field in the test suite stanza.----data TestType = TestTypeExe Version     -- ^ \"type: exitcode-stdio-x.y\"-              | TestTypeLib Version     -- ^ \"type: detailed-x.y\"-              | TestTypeUnknown String Version -- ^ Some unknown test type e.g. \"type: foo\"-    deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+data TestType+  = -- | \"type: exitcode-stdio-x.y\"+    TestTypeExe Version+  | -- | \"type: detailed-x.y\"+    TestTypeLib Version+  | -- | Some unknown test type e.g. \"type: foo\"+    TestTypeUnknown String Version+  deriving (Generic, Show, Read, Eq, Ord, Data)  instance Binary TestType instance Structured TestType@@ -30,23 +33,24 @@ instance NFData TestType where rnf = genericRnf  knownTestTypes :: [TestType]-knownTestTypes = [ testTypeExe-                 , testTypeLib-                 ]+knownTestTypes =+  [ testTypeExe+  , testTypeLib+  ]  testTypeExe :: TestType-testTypeExe = TestTypeExe (mkVersion [1,0])+testTypeExe = TestTypeExe (mkVersion [1, 0])  testTypeLib :: TestType-testTypeLib = TestTypeLib (mkVersion [0,9])+testTypeLib = TestTypeLib (mkVersion [0, 9])  instance Pretty TestType where-  pretty (TestTypeExe ver)          = text "exitcode-stdio-" <<>> pretty ver-  pretty (TestTypeLib ver)          = text "detailed-"       <<>> pretty ver+  pretty (TestTypeExe ver) = text "exitcode-stdio-" <<>> pretty ver+  pretty (TestTypeLib ver) = text "detailed-" <<>> pretty ver   pretty (TestTypeUnknown name ver) = text name <<>> char '-' <<>> pretty ver  instance Parsec TestType where   parsec = parsecStandard $ \ver name -> case name of-      "exitcode-stdio" -> TestTypeExe ver-      "detailed"       -> TestTypeLib ver-      _                -> TestTypeUnknown name ver+    "exitcode-stdio" -> TestTypeExe ver+    "detailed" -> TestTypeLib ver+    _ -> TestTypeUnknown name ver
src/Distribution/Types/UnitId.hs view
@@ -1,10 +1,12 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}  module Distribution.Types.UnitId-  ( UnitId, unUnitId, mkUnitId+  ( UnitId+  , unUnitId+  , mkUnitId   , DefUnitId   , unsafeMkDefUnitId   , unDefUnitId@@ -13,13 +15,13 @@   , getHSLibraryName   ) where -import Prelude () import Distribution.Compat.Prelude import Distribution.Utils.ShortText+import Prelude ()  import qualified Distribution.Compat.CharParsing as P-import Distribution.Pretty import Distribution.Parsec+import Distribution.Pretty import Distribution.Types.ComponentId import Distribution.Types.PackageId @@ -61,34 +63,31 @@ -- representation of a UnitId to pass, e.g., as a @-package-id@ -- flag, use the 'display' function, which will work on all -- versions of Cabal.--- newtype UnitId = UnitId ShortText-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data, NFData)+  deriving (Generic, Read, Show, Eq, Ord, Data, NFData)  instance Binary UnitId instance Structured UnitId  -- | The textual format for 'UnitId' coincides with the format -- GHC accepts for @-package-id@.--- instance Pretty UnitId where-    pretty = text . unUnitId+  pretty = text . unUnitId  -- | The textual format for 'UnitId' coincides with the format -- GHC accepts for @-package-id@.--- instance Parsec UnitId where-    parsec = mkUnitId <$> P.munch1 isUnitChar where-        -- https://gitlab.haskell.org/ghc/ghc/issues/17752-        isUnitChar '-' = True-        isUnitChar '_' = True-        isUnitChar '.' = True-        isUnitChar '+' = True-        isUnitChar c   = isAlphaNum c+  parsec = mkUnitId <$> P.munch1 isUnitChar+    where+      -- https://gitlab.haskell.org/ghc/ghc/issues/17752+      isUnitChar '-' = True+      isUnitChar '_' = True+      isUnitChar '.' = True+      isUnitChar '+' = True+      isUnitChar c = isAlphaNum c  -- | If you need backwards compatibility, consider using 'display' -- instead, which is supported by all versions of Cabal.--- unUnitId :: UnitId -> String unUnitId (UnitId s) = fromShortText s @@ -99,7 +98,7 @@ -- -- @since 2.0.0.2 instance IsString UnitId where-    fromString = mkUnitId+  fromString = mkUnitId  -- | Create a unit identity with no associated hash directly -- from a 'ComponentId'.@@ -118,8 +117,8 @@ -- | A 'UnitId' for a definite package.  The 'DefUnitId' invariant says -- that a 'UnitId' identified this way is definite; i.e., it has no -- unfilled holes.-newtype DefUnitId = DefUnitId { unDefUnitId :: UnitId }-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data, Binary, NFData, Pretty)+newtype DefUnitId = DefUnitId {unDefUnitId :: UnitId}+  deriving (Generic, Read, Show, Eq, Ord, Data, Binary, NFData, Pretty)  instance Structured DefUnitId 
src/Distribution/Types/UnqualComponentName.hs view
@@ -1,14 +1,19 @@-{-# LANGUAGE DeriveDataTypeable         #-}-{-# LANGUAGE DeriveGeneric              #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+ module Distribution.Types.UnqualComponentName-  ( UnqualComponentName, unUnqualComponentName, unUnqualComponentNameST, mkUnqualComponentName-  , packageNameToUnqualComponentName, unqualComponentNameToPackageName+  ( UnqualComponentName+  , unUnqualComponentName+  , unUnqualComponentNameST+  , mkUnqualComponentName+  , packageNameToUnqualComponentName+  , unqualComponentNameToPackageName+  , combineNames   ) where  import Distribution.Compat.Prelude import Distribution.Utils.ShortText-import Prelude ()  import Distribution.Parsec import Distribution.Pretty@@ -22,8 +27,16 @@ -- -- @since 2.0.0.2 newtype UnqualComponentName = UnqualComponentName ShortText-  deriving (Generic, Read, Show, Eq, Ord, Typeable, Data,-            Semigroup, Monoid) -- TODO: bad enabler of bad monoids+  deriving+    ( Generic+    , Read+    , Show+    , Eq+    , Ord+    , Data+    , Semigroup+    , Monoid -- TODO: bad enabler of bad monoids+    )  -- | Convert 'UnqualComponentName' to 'String' --@@ -91,3 +104,34 @@ -- @since 2.0.0.2 unqualComponentNameToPackageName :: UnqualComponentName -> PackageName unqualComponentNameToPackageName = mkPackageNameST . unUnqualComponentNameST++-- | Combine names in targets if one name is empty or both names are equal+-- (partial function).+-- Useful in 'Semigroup' and similar instances.+combineNames+  :: (Monoid b, Eq b, Show b)+  => a+  -> a+  -> (a -> b)+  -> String+  -> b+combineNames a b tacc tt+  -- One empty or the same.+  | nb == mempty+      || na == nb =+      na+  | na == mempty =+      nb+  -- Both non-empty, different.+  | otherwise =+      error $+        "Ambiguous values for "+          ++ tt+          ++ " field: '"+          ++ show na+          ++ "' and '"+          ++ show nb+          ++ "'"+  where+    (na, nb) = (tacc a, tacc b)+{-# INLINEABLE combineNames #-}
src/Distribution/Types/Version.hs view
@@ -1,31 +1,32 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}-module Distribution.Types.Version (-    -- * Package versions-    Version,-    mkVersion,-    mkVersion',-    versionNumbers,-    nullVersion,-    alterVersion,-    version0,+{-# LANGUAGE DeriveGeneric #-} +module Distribution.Types.Version+  ( -- * Package versions+    Version+  , mkVersion+  , mkVersion'+  , versionNumbers+  , nullVersion+  , alterVersion+  , version0+     -- * Internal-    validVersion,-    versionDigitParser,-    ) where+  , validVersion+  , versionDigitParser+  ) where -import Data.Bits                   (shiftL, shiftR, (.&.), (.|.))+import Data.Bits (shiftL, shiftR, (.&.), (.|.)) import Distribution.Compat.Prelude import Prelude ()  import Distribution.Parsec import Distribution.Pretty -import qualified Data.Version                    as Base+import qualified Data.Version as Base import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint                as Disp-import qualified Text.Read                       as Read+import qualified Text.PrettyPrint as Disp+import qualified Text.Read as Read  -- | A 'Version' represents the version of a software entity. --@@ -38,68 +39,73 @@ -- 'Binary' instance using a different (and more compact) encoding. -- -- @since 2.0.0.2-data Version = PV0 {-# UNPACK #-} !Word64-             | PV1 !Int [Int]-             -- NOTE: If a version fits into the packed Word64-             -- representation (i.e. at most four version components-             -- which all fall into the [0..0xfffe] range), then PV0-             -- MUST be used. This is essential for the 'Eq' instance-             -- to work.-             deriving (Data,Eq,Generic,Typeable)+data Version+  = PV0 {-# UNPACK #-} !Word64+  | PV1 !Int [Int]+  -- NOTE: If a version fits into the packed Word64+  -- representation (i.e. at most four version components+  -- which all fall into the [0..0xfffe] range), then PV0+  -- MUST be used. This is essential for the 'Eq' instance+  -- to work.+  deriving (Data, Eq, Generic)  instance Ord Version where-    compare (PV0 x)    (PV0 y)    = compare x y-    compare (PV1 x xs) (PV1 y ys) = case compare x y of-        EQ -> compare xs ys-        c  -> c-    compare (PV0 w)    (PV1 y ys) = case compare x y of-        EQ -> compare [x2,x3,x4] ys-        c  -> c-      where-        x  = fromIntegral ((w `shiftR` 48) .&. 0xffff) - 1-        x2 = fromIntegral ((w `shiftR` 32) .&. 0xffff) - 1-        x3 = fromIntegral ((w `shiftR` 16) .&. 0xffff) - 1-        x4 = fromIntegral               (w .&. 0xffff) - 1-    compare (PV1 x xs) (PV0 w)    = case compare x y of-        EQ -> compare xs [y2,y3,y4]-        c  -> c-      where-        y  = fromIntegral ((w `shiftR` 48) .&. 0xffff) - 1-        y2 = fromIntegral ((w `shiftR` 32) .&. 0xffff) - 1-        y3 = fromIntegral ((w `shiftR` 16) .&. 0xffff) - 1-        y4 = fromIntegral               (w .&. 0xffff) - 1+  compare (PV0 x) (PV0 y) = compare x y+  compare (PV1 x xs) (PV1 y ys) = case compare x y of+    EQ -> compare xs ys+    c -> c+  compare (PV0 w) (PV1 y ys) = case compare x y of+    EQ -> compare [x2, x3, x4] ys+    c -> c+    where+      x = fromIntegral ((w `shiftR` 48) .&. 0xffff) - 1+      x2 = fromIntegral ((w `shiftR` 32) .&. 0xffff) - 1+      x3 = fromIntegral ((w `shiftR` 16) .&. 0xffff) - 1+      x4 = fromIntegral (w .&. 0xffff) - 1+  compare (PV1 x xs) (PV0 w) = case compare x y of+    EQ -> compare xs [y2, y3, y4]+    c -> c+    where+      y = fromIntegral ((w `shiftR` 48) .&. 0xffff) - 1+      y2 = fromIntegral ((w `shiftR` 32) .&. 0xffff) - 1+      y3 = fromIntegral ((w `shiftR` 16) .&. 0xffff) - 1+      y4 = fromIntegral (w .&. 0xffff) - 1  instance Show Version where-    showsPrec d v = showParen (d > 10)-        $ showString "mkVersion "+  showsPrec d v =+    showParen (d > 10) $+      showString "mkVersion "         . showsPrec 11 (versionNumbers v)  instance Read Version where-    readPrec = Read.parens $ do-        Read.Ident "mkVersion" <- Read.lexP-        v <- Read.step Read.readPrec-        return (mkVersion v)+  readPrec = Read.parens $ do+    Read.Ident "mkVersion" <- Read.lexP+    v <- Read.step Read.readPrec+    return (mkVersion v)  instance Binary Version instance Structured Version  instance NFData Version where-    rnf (PV0 _) = ()-    rnf (PV1 _ ns) = rnf ns+  rnf (PV0 _) = ()+  rnf (PV1 _ ns) = rnf ns  instance Pretty Version where-  pretty ver-    = Disp.hcat (Disp.punctuate (Disp.char '.')-                                (map Disp.int $ versionNumbers ver))+  pretty ver =+    Disp.hcat+      ( Disp.punctuate+          (Disp.char '.')+          (map Disp.int $ versionNumbers ver)+      )  instance Parsec Version where-    parsec = mkVersion <$> toList <$> P.sepByNonEmpty versionDigitParser (P.char '.') <* tags-      where-        tags = do-            ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum)-            case ts of-                []      -> pure ()-                (_ : _) -> parsecWarning PWTVersionTag "version with tags"+  parsec = mkVersion <$> toList <$> P.sepByNonEmpty versionDigitParser (P.char '.') <* tags+    where+      tags = do+        ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum)+        case ts of+          [] -> pure ()+          (_ : _) -> parsecWarning PWTVersionTag "version with tags"  -- | An integral without leading zeroes. --@@ -108,15 +114,15 @@ versionDigitParser = (some d >>= toNumber) P.<?> "version digit (integral without leading zeroes)"   where     toNumber :: CabalParsing m => [Int] -> m Int-    toNumber [0]   = return 0-    toNumber (0:_) = P.unexpected "Version digit with leading zero"+    toNumber [0] = return 0+    toNumber (0 : _) = P.unexpected "Version digit with leading zero"     toNumber xs-        -- 10^9 = 1000000000-        -- 2^30 = 1073741824-        ---        -- GHC Int is at least 32 bits, so 2^31-1 is the 'maxBound'.-        | length xs > 9 = P.unexpected "At most 9 numbers are allowed per version number part"-        | otherwise     = return $ foldl' (\a b -> a * 10 + b) 0 xs+      -- 10^9 = 1000000000+      -- 2^30 = 1073741824+      --+      -- GHC Int is at least 32 bits, so 2^31-1 is the 'maxBound'.+      | length xs > 9 = P.unexpected "At most 9 numbers are allowed per version number part"+      | otherwise = return $ foldl' (\a b -> a * 10 + b) 0 xs      d :: P.CharParsing m => m Int     d = f <$> P.satisfyRange '0' '9'@@ -134,42 +140,56 @@ mkVersion :: [Int] -> Version -- TODO: add validity check; disallow 'mkVersion []' (we have -- 'nullVersion' for that)-mkVersion []                    = nullVersion-mkVersion (v1:[])-  | inWord16VerRep1 v1          = PV0 (mkWord64VerRep1 v1)-  | otherwise                   = PV1 v1 []+mkVersion [] = nullVersion+mkVersion (v1 : [])+  | inWord16VerRep1 v1 = PV0 (mkWord64VerRep1 v1)+  | otherwise = PV1 v1 []   where-    inWord16VerRep1 x1 = inWord16 (x1 .|. (x1+1))-    mkWord64VerRep1 y1 = mkWord64VerRep (y1+1) 0 0 0--mkVersion (v1:vs@(v2:[]))-  | inWord16VerRep2 v1 v2       = PV0 (mkWord64VerRep2 v1 v2)-  | otherwise                   = PV1 v1 vs+    inWord16VerRep1 x1 = inWord16 (x1 .|. (x1 + 1))+    mkWord64VerRep1 y1 = mkWord64VerRep (y1 + 1) 0 0 0+mkVersion (v1 : vs@(v2 : []))+  | inWord16VerRep2 v1 v2 = PV0 (mkWord64VerRep2 v1 v2)+  | otherwise = PV1 v1 vs   where-    inWord16VerRep2 x1 x2 = inWord16 (x1 .|. (x1+1)-                                  .|. x2 .|. (x2+1))-    mkWord64VerRep2 y1 y2 = mkWord64VerRep (y1+1) (y2+1) 0 0--mkVersion (v1:vs@(v2:v3:[]))-  | inWord16VerRep3 v1 v2 v3    = PV0 (mkWord64VerRep3 v1 v2 v3)-  | otherwise                   = PV1 v1 vs+    inWord16VerRep2 x1 x2 =+      inWord16+        ( x1+            .|. (x1 + 1)+            .|. x2+            .|. (x2 + 1)+        )+    mkWord64VerRep2 y1 y2 = mkWord64VerRep (y1 + 1) (y2 + 1) 0 0+mkVersion (v1 : vs@(v2 : v3 : []))+  | inWord16VerRep3 v1 v2 v3 = PV0 (mkWord64VerRep3 v1 v2 v3)+  | otherwise = PV1 v1 vs   where-    inWord16VerRep3 x1 x2 x3 = inWord16 (x1 .|. (x1+1)-                                     .|. x2 .|. (x2+1)-                                     .|. x3 .|. (x3+1))-    mkWord64VerRep3 y1 y2 y3 = mkWord64VerRep (y1+1) (y2+1) (y3+1) 0--mkVersion (v1:vs@(v2:v3:v4:[]))+    inWord16VerRep3 x1 x2 x3 =+      inWord16+        ( x1+            .|. (x1 + 1)+            .|. x2+            .|. (x2 + 1)+            .|. x3+            .|. (x3 + 1)+        )+    mkWord64VerRep3 y1 y2 y3 = mkWord64VerRep (y1 + 1) (y2 + 1) (y3 + 1) 0+mkVersion (v1 : vs@(v2 : v3 : v4 : []))   | inWord16VerRep4 v1 v2 v3 v4 = PV0 (mkWord64VerRep4 v1 v2 v3 v4)-  | otherwise                   = PV1 v1 vs+  | otherwise = PV1 v1 vs   where-    inWord16VerRep4 x1 x2 x3 x4 = inWord16 (x1 .|. (x1+1)-                                        .|. x2 .|. (x2+1)-                                        .|. x3 .|. (x3+1)-                                        .|. x4 .|. (x4+1))-    mkWord64VerRep4 y1 y2 y3 y4 = mkWord64VerRep (y1+1) (y2+1) (y3+1) (y4+1)--mkVersion (v1:vs)               = PV1 v1 vs+    inWord16VerRep4 x1 x2 x3 x4 =+      inWord16+        ( x1+            .|. (x1 + 1)+            .|. x2+            .|. (x2 + 1)+            .|. x3+            .|. (x3 + 1)+            .|. x4+            .|. (x4 + 1)+        )+    mkWord64VerRep4 y1 y2 y3 y4 = mkWord64VerRep (y1 + 1) (y2 + 1) (y3 + 1) (y4 + 1)+mkVersion (v1 : vs) = PV1 v1 vs  -- | Version 0. A lower bound of 'Version'. --@@ -180,10 +200,10 @@ {-# INLINE mkWord64VerRep #-} mkWord64VerRep :: Int -> Int -> Int -> Int -> Word64 mkWord64VerRep v1 v2 v3 v4 =-      (fromIntegral v1 `shiftL` 48)-  .|. (fromIntegral v2 `shiftL` 32)-  .|. (fromIntegral v3 `shiftL` 16)-  .|.  fromIntegral v4+  (fromIntegral v1 `shiftL` 48)+    .|. (fromIntegral v2 `shiftL` 32)+    .|. (fromIntegral v3 `shiftL` 16)+    .|. fromIntegral v4  {-# INLINE inWord16 #-} inWord16 :: Int -> Bool@@ -204,20 +224,19 @@ -- -- @since 2.0.0.2 versionNumbers :: Version -> [Int]-versionNumbers (PV1 n ns) = n:ns+versionNumbers (PV1 n ns) = n : ns versionNumbers (PV0 w)-  | v1 < 0    = []-  | v2 < 0    = [v1]-  | v3 < 0    = [v1,v2]-  | v4 < 0    = [v1,v2,v3]-  | otherwise = [v1,v2,v3,v4]+  | v1 < 0 = []+  | v2 < 0 = [v1]+  | v3 < 0 = [v1, v2]+  | v4 < 0 = [v1, v2, v3]+  | otherwise = [v1, v2, v3, v4]   where     v1 = fromIntegral ((w `shiftR` 48) .&. 0xffff) - 1     v2 = fromIntegral ((w `shiftR` 32) .&. 0xffff) - 1     v3 = fromIntegral ((w `shiftR` 16) .&. 0xffff) - 1     v4 = fromIntegral (w .&. 0xffff) - 1 - -- | Constant representing the special /null/ 'Version' -- -- The 'nullVersion' compares (via 'Ord') as less than every proper@@ -239,4 +258,4 @@  -- internal helper validVersion :: Version -> Bool-validVersion v = v /= nullVersion && all (>=0) (versionNumbers v)+validVersion v = v /= nullVersion && all (>= 0) (versionNumbers v)
src/Distribution/Types/VersionInterval.hs view
@@ -1,5 +1,4 @@-{-# LANGUAGE BangPatterns       #-}-{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE BangPatterns #-}  -- | This module implements a view of a 'VersionRange' as a finite -- list of separated version intervals.@@ -8,37 +7,37 @@ -- preserve the caret operator @^>=x.y@.  This constraint a priori -- specifies the same interval as @==x.y.*@, but indicates that newer -- versions could be acceptable (@allow-newer: ^@).----module Distribution.Types.VersionInterval (-    -- * Version intervals-    VersionIntervals,-    unVersionIntervals,+module Distribution.Types.VersionInterval+  ( -- * Version intervals+    VersionIntervals+  , unVersionIntervals+  , mkVersionIntervals      -- * Conversions-    toVersionIntervals,-    fromVersionIntervals,+  , toVersionIntervals+  , fromVersionIntervals      -- ** Normalisation-    normaliseVersionRange2,+  , normaliseVersionRange2      -- * Relaxation-    relaxLastInterval,-    relaxHeadInterval,+  , relaxLastInterval+  , relaxHeadInterval      -- * Version intervals view-    asVersionIntervals,-    VersionInterval (..),-    LowerBound(..),-    UpperBound(..),-    Bound(..),+  , asVersionIntervals+  , VersionInterval (..)+  , LowerBound (..)+  , UpperBound (..)+  , Bound (..)      -- * Invariants-    invariantVersionIntervals,-    ) where+  , invariantVersionIntervals+  ) where -import Control.Applicative         (liftA2)-import Control.Exception           (assert)-import Distribution.Compat.Prelude hiding (Applicative(..))+import Control.Applicative (liftA2)+import Control.Exception (assert)+import Distribution.Compat.Prelude hiding (Applicative (..)) import Prelude ()  import Distribution.Types.Version@@ -64,20 +63,24 @@ -- or containment. It also makes it easier to identify \'simple\' version -- predicates for translation into foreign packaging systems that do not -- support complex version range expressions.--- newtype VersionIntervals = VersionIntervals [VersionInterval]-  deriving (Eq, Show, Typeable)+  deriving (Eq, Show)  -- | Inspect the list of version intervals.--- unVersionIntervals :: VersionIntervals -> [VersionInterval] unVersionIntervals (VersionIntervals is) = is -data VersionInterval = VersionInterval !LowerBound !UpperBound    deriving (Eq, Show)-data LowerBound      = LowerBound !Version !Bound                 deriving (Eq, Show)-data UpperBound      = NoUpperBound | UpperBound !Version !Bound  deriving (Eq, Show)-data Bound           = ExclusiveBound | InclusiveBound            deriving (Eq, Show)+-- | Directly construct a 'VersionIntervals' from a list of intervals.+mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals+mkVersionIntervals intervals+  | invariantVersionIntervals (VersionIntervals intervals) = Just . VersionIntervals $ intervals+  | otherwise = Nothing +data VersionInterval = VersionInterval !LowerBound !UpperBound deriving (Eq, Show)+data LowerBound = LowerBound !Version !Bound deriving (Eq, Show)+data UpperBound = NoUpperBound | UpperBound !Version !Bound deriving (Eq, Show)+data Bound = ExclusiveBound | InclusiveBound deriving (Eq, Show)+ zeroLowerBound :: LowerBound zeroLowerBound = LowerBound version0 InclusiveBound @@ -89,29 +92,27 @@ -------------------------------------------------------------------------------  stage1 :: VersionRange -> [VersionInterval]-stage1 = cataVersionRange alg where-    -- version range leafs transform into singleton intervals-    alg (ThisVersionF v)                = [VersionInterval (LowerBound v InclusiveBound) (UpperBound v InclusiveBound)]-    alg (LaterVersionF v)               = [VersionInterval (LowerBound v ExclusiveBound) NoUpperBound]-    alg (OrLaterVersionF v)             = [VersionInterval (LowerBound v InclusiveBound) NoUpperBound]+stage1 = cataVersionRange alg+  where+    -- version range leaves transform into singleton intervals+    alg (ThisVersionF v) = [VersionInterval (LowerBound v InclusiveBound) (UpperBound v InclusiveBound)]+    alg (LaterVersionF v) = [VersionInterval (LowerBound v ExclusiveBound) NoUpperBound]+    alg (OrLaterVersionF v) = [VersionInterval (LowerBound v InclusiveBound) NoUpperBound]     alg (EarlierVersionF v)-        | isVersion0 v                  = []-        | otherwise                     = [VersionInterval zeroLowerBound                (UpperBound v ExclusiveBound)]-    alg (OrEarlierVersionF v)           = [VersionInterval zeroLowerBound                (UpperBound v InclusiveBound)]--    -- ^>= version-range's upper bound should be MajorBound-    alg (MajorBoundVersionF v)          = [VersionInterval (LowerBound v InclusiveBound) (UpperBound (majorUpperBound v) ExclusiveBound)]-+      | isVersion0 v = []+      | otherwise = [VersionInterval zeroLowerBound (UpperBound v ExclusiveBound)]+    alg (OrEarlierVersionF v) = [VersionInterval zeroLowerBound (UpperBound v InclusiveBound)]+    -- \^>= version-range's upper bound should be MajorBound+    alg (MajorBoundVersionF v) = [VersionInterval (LowerBound v InclusiveBound) (UpperBound (majorUpperBound v) ExclusiveBound)]     -- union: just merge the version intervals-    alg (UnionVersionRangesF v1 v2)     = v1 ++ v2-+    alg (UnionVersionRangesF v1 v2) = v1 ++ v2     -- intersection: pairwise intersect. Strip empty intervals. Sort to restore the invariant.     alg (IntersectVersionRangesF v1 v2) = mapMaybe nonEmptyInterval $ liftA2 intersectInterval (stage2and3 v1) (stage2and3 v2)  -- | Check that interval is non-empty nonEmptyInterval :: VersionInterval -> Maybe VersionInterval nonEmptyInterval i | nonEmptyVI i = Just i-nonEmptyInterval _                = Nothing+nonEmptyInterval _ = Nothing  ------------------------------------------------------------------------------- -- Stage2@@ -122,7 +123,7 @@  lowerboundCmp :: VersionInterval -> VersionInterval -> Ordering lowerboundCmp (VersionInterval (LowerBound v vb) _) (VersionInterval (LowerBound u ub) _) =-    compare v u `mappend` compareBound vb ub+  compare v u `mappend` compareBound vb ub   where     compareBound :: Bound -> Bound -> Ordering     compareBound InclusiveBound InclusiveBound = EQ@@ -136,7 +137,6 @@  -- | Post-processing takes a list of ordered version intervals, -- but possibly overlapping, and creates 'VersionIntervals'.--- postprocess :: [VersionInterval] -> VersionIntervals postprocess = checkInvariant . VersionIntervals . stage2and3 @@ -144,15 +144,15 @@ stage2and3 = stage3 . stage2  stage3 :: [VersionInterval] -> [VersionInterval]-stage3 []                                     = []-stage3 (VersionInterval lb ub : rest)         = stage3go lb ub rest+stage3 [] = []+stage3 (VersionInterval lb ub : rest) = stage3go lb ub rest  stage3go :: LowerBound -> UpperBound -> [VersionInterval] -> [VersionInterval]-stage3go !lb NoUpperBound _                                 = [VersionInterval lb NoUpperBound]-stage3go !lb !ub          []                                = [VersionInterval lb ub]-stage3go !lb !ub          (VersionInterval lb' ub' : rest')-    | doesNotTouch ub lb'                                   = VersionInterval lb ub : stage3go lb' ub' rest'-    | otherwise                                             = stage3go lb (unionUpper ub ub') rest'+stage3go !lb NoUpperBound _ = [VersionInterval lb NoUpperBound]+stage3go !lb !ub [] = [VersionInterval lb ub]+stage3go !lb !ub (VersionInterval lb' ub' : rest')+  | doesNotTouch ub lb' = VersionInterval lb ub : stage3go lb' ub' rest'+  | otherwise = stage3go lb (unionUpper ub ub') rest'  ------------------------------------------------------------------------------- -- Intersections@@ -160,41 +160,41 @@  intersectInterval :: VersionInterval -> VersionInterval -> VersionInterval intersectInterval (VersionInterval lv uv) (VersionInterval lu uu) =-    VersionInterval (intersectLower lv lu) (intersectUpper uv uu)+  VersionInterval (intersectLower lv lu) (intersectUpper uv uu)  intersectLower :: LowerBound -> LowerBound -> LowerBound intersectLower (LowerBound v vb) (LowerBound u ub) = case compare v u of-    EQ -> LowerBound v (intersectBound vb ub)-    LT -> LowerBound u ub-    GT -> LowerBound v vb+  EQ -> LowerBound v (intersectBound vb ub)+  LT -> LowerBound u ub+  GT -> LowerBound v vb  intersectUpper :: UpperBound -> UpperBound -> UpperBound-intersectUpper NoUpperBound      b                 = b-intersectUpper b                 NoUpperBound      = b+intersectUpper NoUpperBound b = b+intersectUpper b NoUpperBound = b intersectUpper (UpperBound v vb) (UpperBound u ub) = case compare v u of-    EQ -> UpperBound v (intersectBound vb ub)-    LT -> UpperBound v vb-    GT -> UpperBound u ub+  EQ -> UpperBound v (intersectBound vb ub)+  LT -> UpperBound v vb+  GT -> UpperBound u ub  intersectBound :: Bound -> Bound -> Bound intersectBound InclusiveBound InclusiveBound = InclusiveBound-intersectBound _              _              = ExclusiveBound+intersectBound _ _ = ExclusiveBound  ------------------------------------------------------------------------------- -- Unions -------------------------------------------------------------------------------  unionUpper :: UpperBound -> UpperBound -> UpperBound-unionUpper NoUpperBound      _                 = NoUpperBound-unionUpper _                 NoUpperBound      = NoUpperBound+unionUpper NoUpperBound _ = NoUpperBound+unionUpper _ NoUpperBound = NoUpperBound unionUpper (UpperBound v vb) (UpperBound u ub) = case compare v u of-    EQ -> UpperBound v (unionBound vb ub)-    LT -> UpperBound u ub-    GT -> UpperBound v vb+  EQ -> UpperBound v (unionBound vb ub)+  LT -> UpperBound u ub+  GT -> UpperBound v vb  unionBound :: Bound -> Bound -> Bound unionBound ExclusiveBound ExclusiveBound = ExclusiveBound-unionBound _              _              = InclusiveBound+unionBound _ _ = InclusiveBound  ------------------------------------------------------------------------------- -- VersionRange@@ -221,7 +221,6 @@ -- >       ,UpperBound v' InclusiveBound)] <- asVersionIntervals vr -- >    , v == v'   = Just v -- >    | otherwise = Nothing--- asVersionIntervals :: VersionRange -> [VersionInterval] asVersionIntervals = unVersionIntervals . toVersionIntervals @@ -235,11 +234,10 @@ --   ---|      or  ---)     but not  ---]     or  ---)     or  ---] --       |---         (---              (---         [---         [--- -- @--- doesNotTouch :: UpperBound -> LowerBound -> Bool-doesNotTouch NoUpperBound      _                 = False+doesNotTouch NoUpperBound _ = False doesNotTouch (UpperBound u ub) (LowerBound l lb) =-    (u < l) || (u == l && ub == ExclusiveBound && lb == ExclusiveBound)+  (u < l) || (u == l && ub == ExclusiveBound && lb == ExclusiveBound)  ------------------------------------------------------------------------------- -- Invariants@@ -249,19 +247,18 @@ -- -- * all intervals are valid (lower bound is less then upper bound, i.e. non-empty) -- * intervals doesn't touch each other (distinct)--- invariantVersionIntervals :: VersionIntervals -> Bool invariantVersionIntervals (VersionIntervals intervals) =-    all validInterval intervals &&-    all doesNotTouch' adjacentIntervals+  all validInterval intervals+    && all doesNotTouch' adjacentIntervals   where     doesNotTouch' :: (VersionInterval, VersionInterval) -> Bool     doesNotTouch' (VersionInterval _ u, VersionInterval l' _) = doesNotTouch u l'      adjacentIntervals :: [(VersionInterval, VersionInterval)]     adjacentIntervals = case intervals of-      []     -> []-      (_:tl) -> zip intervals tl+      [] -> []+      (_ : tl) -> zip intervals tl  checkInvariant :: VersionIntervals -> VersionIntervals checkInvariant is = assert (invariantVersionIntervals is) is@@ -271,13 +268,13 @@ validInterval i@(VersionInterval l u) = validLower l && validUpper u && nonEmptyVI i   where     validLower (LowerBound v _) = validVersion v-    validUpper NoUpperBound      = True-    validUpper (UpperBound v _)  = validVersion v+    validUpper NoUpperBound = True+    validUpper (UpperBound v _) = validVersion v  -- Check an interval is non-empty -- nonEmptyVI :: VersionInterval -> Bool-nonEmptyVI (VersionInterval _                 NoUpperBound)      = True+nonEmptyVI (VersionInterval _ NoUpperBound) = True nonEmptyVI (VersionInterval (LowerBound l lb) (UpperBound u ub)) =   (l < u) || (l == u && lb == InclusiveBound && ub == InclusiveBound) @@ -286,39 +283,35 @@ -------------------------------------------------------------------------------  -- | Convert a 'VersionRange' to a sequence of version intervals.--- toVersionIntervals :: VersionRange -> VersionIntervals toVersionIntervals = postprocess . stage1  -- | Convert a 'VersionIntervals' value back into a 'VersionRange' expression -- representing the version intervals.--- fromVersionIntervals :: VersionIntervals -> VersionRange-fromVersionIntervals (VersionIntervals [])     = noVersion-fromVersionIntervals (VersionIntervals (x:xs)) = foldr1 unionVersionRanges (fmap intervalToVersionRange (x:|xs))+fromVersionIntervals (VersionIntervals []) = noVersion+fromVersionIntervals (VersionIntervals (x : xs)) = foldr1 unionVersionRanges (fmap intervalToVersionRange (x :| xs))  intervalToVersionRange :: VersionInterval -> VersionRange intervalToVersionRange (VersionInterval (LowerBound v vb) upper') = case upper' of-    NoUpperBound-        -> lowerBound--    UpperBound u ub-        | vb == InclusiveBound-        , ub == InclusiveBound-        , v == u-        -> thisVersion v--    UpperBound u ub -> withLowerBound (makeUpperBound u ub)+  NoUpperBound ->+    lowerBound+  UpperBound u ub+    | vb == InclusiveBound+    , ub == InclusiveBound+    , v == u ->+        thisVersion v+  UpperBound u ub -> withLowerBound (makeUpperBound u ub)   where     lowerBound :: VersionRange     lowerBound = case vb of-        InclusiveBound -> orLaterVersion v-        ExclusiveBound -> laterVersion v+      InclusiveBound -> orLaterVersion v+      ExclusiveBound -> laterVersion v      withLowerBound :: VersionRange -> VersionRange     withLowerBound vr-        | isVersion0 v, vb == InclusiveBound = vr-        | otherwise                          = intersectVersionRanges lowerBound vr+      | isVersion0 v, vb == InclusiveBound = vr+      | otherwise = intersectVersionRanges lowerBound vr      makeUpperBound :: Version -> Bound -> VersionRange     makeUpperBound u InclusiveBound = orEarlierVersion u@@ -329,7 +322,6 @@ -------------------------------------------------------------------------------  -- | Since @Cabal-3.6@ this function.. TODO--- normaliseVersionRange2 :: VersionRange -> VersionRange normaliseVersionRange2 = fromVersionIntervals . toVersionIntervals @@ -340,12 +332,12 @@ relaxLastInterval :: VersionIntervals -> VersionIntervals relaxLastInterval (VersionIntervals xs) = VersionIntervals (relaxLastInterval' xs)   where-    relaxLastInterval' []                    = []+    relaxLastInterval' [] = []     relaxLastInterval' [VersionInterval l _] = [VersionInterval l NoUpperBound]-    relaxLastInterval' (i:is)                = i : relaxLastInterval' is+    relaxLastInterval' (i : is) = i : relaxLastInterval' is  relaxHeadInterval :: VersionIntervals -> VersionIntervals relaxHeadInterval (VersionIntervals xs) = VersionIntervals (relaxHeadInterval' xs)   where-    relaxHeadInterval' []                         = []+    relaxHeadInterval' [] = []     relaxHeadInterval' (VersionInterval _ u : is) = VersionInterval zeroLowerBound u : is
src/Distribution/Types/VersionInterval/Legacy.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE DeriveDataTypeable #-}- -- | This module implements a view of a 'VersionRange' as a finite -- list of separated version intervals and provides the Boolean -- algebra operations union, intersection, and complement.@@ -9,32 +7,31 @@ -- The current module "Distribution.Types.VersionInterval" (refurbished since -- @Cabal >= 3.6@) makes some effort to preserve the caret operator, -- but so far does not expose the Boolean algebra structure.----module Distribution.Types.VersionInterval.Legacy (-    -- * Version intervals-    VersionIntervals,-    toVersionIntervals,-    fromVersionIntervals,-    withinIntervals,-    versionIntervals,-    mkVersionIntervals,-    unionVersionIntervals,-    intersectVersionIntervals,-    invertVersionIntervals,-    relaxLastInterval,-    relaxHeadInterval,+module Distribution.Types.VersionInterval.Legacy+  ( -- * Version intervals+    VersionIntervals+  , toVersionIntervals+  , fromVersionIntervals+  , withinIntervals+  , versionIntervals+  , mkVersionIntervals+  , unionVersionIntervals+  , intersectVersionIntervals+  , invertVersionIntervals+  , relaxLastInterval+  , relaxHeadInterval      -- * Version intervals view-    asVersionIntervals,-    VersionInterval,-    LowerBound(..),-    UpperBound(..),-    Bound(..),-    ) where+  , asVersionIntervals+  , VersionInterval+  , LowerBound (..)+  , UpperBound (..)+  , Bound (..)+  ) where -import Prelude ()-import Distribution.Compat.Prelude import Control.Exception (assert)+import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Types.Version import Distribution.Types.VersionRange.Internal@@ -72,11 +69,9 @@ -- >       ,UpperBound v' InclusiveBound)] <- asVersionIntervals vr -- >    , v == v'   = Just v -- >    | otherwise = Nothing--- asVersionIntervals :: VersionRange -> [VersionInterval] asVersionIntervals = versionIntervals . toVersionIntervals - ------------------------------------------------------------------------------- -- VersionInterval -------------------------------------------------------------------------------@@ -98,12 +93,10 @@ -- or containment. It also makes it easier to identify \'simple\' version -- predicates for translation into foreign packaging systems that do not -- support complex version range expressions.--- newtype VersionIntervals = VersionIntervals [VersionInterval]-  deriving (Eq, Show, Typeable)+  deriving (Eq, Show)  -- | Inspect the list of version intervals.--- versionIntervals :: VersionIntervals -> [VersionInterval] versionIntervals (VersionIntervals is) = is @@ -115,21 +108,25 @@ -- 4. \( [lb,ub] \) meaning \( lb ≤ \_ < ub \). -- -- The upper bound can also be missing, meaning "\( ..,∞) \)".--- type VersionInterval = (LowerBound, UpperBound)  data LowerBound-  = LowerBound Version !Bound  -- ^ Either exclusive @(v,..@ or inclusive @[v,..@.+  = -- | Either exclusive @(v,..@ or inclusive @[v,..@.+    LowerBound Version !Bound   deriving (Eq, Show)  data UpperBound-  = NoUpperBound               -- ^ @..,∞)@-  | UpperBound Version !Bound  -- ^ Either exclusive @..,v)@ or inclusive @..,v]@.+  = -- | @..,∞)@+    NoUpperBound+  | -- | Either exclusive @..,v)@ or inclusive @..,v]@.+    UpperBound Version !Bound   deriving (Eq, Show)  data Bound-  = ExclusiveBound   -- ^ @(v,..@ if used as lower bound, @..,v)@ if used as upper bound.-  | InclusiveBound   -- ^ @[v,..@ if used as lower bound, @..,v]@ if used as upper bound.+  = -- | @(v,..@ if used as lower bound, @..,v)@ if used as upper bound.+    ExclusiveBound+  | -- | @[v,..@ if used as lower bound, @..,v]@ if used as upper bound.+    InclusiveBound   deriving (Eq, Show)  -- | @[0,..@.@@ -140,7 +137,6 @@ isVersion0 = (==) version0  -- | @lb1 <= lb2@ holds iff interval @lb1..@ is contained in interval @lb2..@.--- instance Ord LowerBound where   LowerBound ver bound <= LowerBound ver' bound' = case compare ver ver' of     LT -> True@@ -148,9 +144,8 @@     GT -> False  -- | @ub1 <= ub2@ holds iff interval @0..ub1@ is contained in interval @0..ub2@.--- instance Ord UpperBound where-  _            <= NoUpperBound   = True+  _ <= NoUpperBound = True   NoUpperBound <= UpperBound _ _ = False   UpperBound ver bound <= UpperBound ver' bound' = case compare ver ver' of     LT -> True@@ -160,54 +155,49 @@ -- | Check that the sequence is ordered, -- adjacent intervals are separated (do not overlap), -- an no interval is empty (which would be a redundant entry).--- invariant :: VersionIntervals -> Bool-invariant (VersionIntervals intervals) = all validInterval intervals-                                      && all doesNotTouch' adjacentIntervals+invariant (VersionIntervals intervals) =+  all validInterval intervals+    && all doesNotTouch' adjacentIntervals   where     doesNotTouch' :: (VersionInterval, VersionInterval) -> Bool-    doesNotTouch' ((_,u), (l',_)) = doesNotTouch u l'+    doesNotTouch' ((_, u), (l', _)) = doesNotTouch u l'      -- adjacentIntervals = zip intervals (tail intervals)     adjacentIntervals :: [(VersionInterval, VersionInterval)]     adjacentIntervals = case intervals of-      []     -> []-      (_:tl) -> zip intervals tl+      [] -> []+      (_ : tl) -> zip intervals tl  -- | The partial identity function, erroring out on illformed 'VersionIntervals'.--- checkInvariant :: VersionIntervals -> VersionIntervals checkInvariant is = assert (invariant is) is  -- | Directly construct a 'VersionIntervals' from a list of intervals.--- mkVersionIntervals :: [VersionInterval] -> VersionIntervals mkVersionIntervals intervals-    | invariant (VersionIntervals intervals) = VersionIntervals intervals-    | otherwise-        = checkInvariant+  | invariant (VersionIntervals intervals) = VersionIntervals intervals+  | otherwise =+      checkInvariant         . foldl' (flip insertInterval) (VersionIntervals [])         . filter validInterval         $ intervals  -- | Add an interval to the sequence, fusing with existing intervals if necessary.--- insertInterval :: VersionInterval -> VersionIntervals -> VersionIntervals insertInterval i is = unionVersionIntervals (VersionIntervals [i]) is  -- | A valid interval is non-empty.--- validInterval :: (LowerBound, UpperBound) -> Bool validInterval i@(l, u) = validLower l && validUpper u && nonEmptyVI i   where     validLower (LowerBound v _) = validVersion v-    validUpper NoUpperBound     = True+    validUpper NoUpperBound = True     validUpper (UpperBound v _) = validVersion v  -- | Check that an interval is non-empty.--- nonEmptyVI :: VersionInterval -> Bool-nonEmptyVI (_,               NoUpperBound   ) = True+nonEmptyVI (_, NoUpperBound) = True nonEmptyVI (LowerBound l lb, UpperBound u ub) =   (l < u) || (l == u && lb == InclusiveBound && ub == InclusiveBound) @@ -222,8 +212,8 @@ doesNotTouch :: UpperBound -> LowerBound -> Bool doesNotTouch NoUpperBound _ = False doesNotTouch (UpperBound u ub) (LowerBound l lb) =-      u <  l-  || (u == l && ub == ExclusiveBound && lb == ExclusiveBound)+  u < l+    || (u == l && ub == ExclusiveBound && lb == ExclusiveBound)  -- | Check an upper bound does not intersect a lower bound: --@@ -233,12 +223,11 @@ --       |---         (---         (---         [---              [--- -- -- @--- doesNotIntersect :: UpperBound -> LowerBound -> Bool doesNotIntersect NoUpperBound _ = False doesNotIntersect (UpperBound u ub) (LowerBound l lb) =-      u <  l-  || (u == l && not (ub == InclusiveBound && lb == InclusiveBound))+  u < l+    || (u == l && not (ub == InclusiveBound && lb == InclusiveBound))  -- | Test if a version falls within the version intervals. --@@ -247,39 +236,39 @@ -- -- > withinIntervals v (toVersionIntervals vr) = withinRange v vr -- > withinIntervals v ivs = withinRange v (fromVersionIntervals ivs)--- withinIntervals :: Version -> VersionIntervals -> Bool withinIntervals v (VersionIntervals intervals) = any withinInterval intervals   where-    withinInterval (lowerBound, upperBound)    = withinLower lowerBound-                                              && withinUpper upperBound-    withinLower (LowerBound v' ExclusiveBound) = v' <  v+    withinInterval (lowerBound, upperBound) =+      withinLower lowerBound+        && withinUpper upperBound+    withinLower (LowerBound v' ExclusiveBound) = v' < v     withinLower (LowerBound v' InclusiveBound) = v' <= v -    withinUpper NoUpperBound                   = True-    withinUpper (UpperBound v' ExclusiveBound) = v' >  v+    withinUpper NoUpperBound = True+    withinUpper (UpperBound v' ExclusiveBound) = v' > v     withinUpper (UpperBound v' InclusiveBound) = v' >= v  -- | Convert a 'VersionRange' to a sequence of version intervals.--- toVersionIntervals :: VersionRange -> VersionIntervals-toVersionIntervals = cataVersionRange alg where+toVersionIntervals = cataVersionRange alg+  where     -- @== v@-    alg (ThisVersionF v)                = chkIvl (LowerBound v InclusiveBound, UpperBound v InclusiveBound)+    alg (ThisVersionF v) = chkIvl (LowerBound v InclusiveBound, UpperBound v InclusiveBound)     -- @>  v@-    alg (LaterVersionF v)               = chkIvl (LowerBound v ExclusiveBound, NoUpperBound)+    alg (LaterVersionF v) = chkIvl (LowerBound v ExclusiveBound, NoUpperBound)     -- @>= v@-    alg (OrLaterVersionF v)             = chkIvl (LowerBound v InclusiveBound, NoUpperBound)+    alg (OrLaterVersionF v) = chkIvl (LowerBound v InclusiveBound, NoUpperBound)     -- @<  v@     alg (EarlierVersionF v)-        | isVersion0 v                  = VersionIntervals []-        | otherwise                     = chkIvl (minLowerBound,               UpperBound v ExclusiveBound)+      | isVersion0 v = VersionIntervals []+      | otherwise = chkIvl (minLowerBound, UpperBound v ExclusiveBound)     -- @<= v@-    alg (OrEarlierVersionF v)           = chkIvl (minLowerBound,               UpperBound v InclusiveBound)+    alg (OrEarlierVersionF v) = chkIvl (minLowerBound, UpperBound v InclusiveBound)     -- @^>= v@-    alg (MajorBoundVersionF v)          = chkIvl (LowerBound v InclusiveBound, UpperBound (majorUpperBound v) ExclusiveBound)+    alg (MajorBoundVersionF v) = chkIvl (LowerBound v InclusiveBound, UpperBound (majorUpperBound v) ExclusiveBound)     -- @r || r'@-    alg (UnionVersionRangesF v1 v2)     = unionVersionIntervals v1 v2+    alg (UnionVersionRangesF v1 v2) = unionVersionIntervals v1 v2     -- @r && r'@     alg (IntersectVersionRangesF v1 v2) = intersectVersionIntervals v1 v2 @@ -287,55 +276,52 @@  -- | Convert a 'VersionIntervals' value back into a 'VersionRange' expression -- representing the version intervals.--- fromVersionIntervals :: VersionIntervals -> VersionRange fromVersionIntervals (VersionIntervals []) = noVersion fromVersionIntervals (VersionIntervals intervals) =-    Prelude.foldr1 unionVersionRanges [ interval l u | (l, u) <- intervals ]-+  Prelude.foldr1 unionVersionRanges [interval l u | (l, u) <- intervals]   where-    interval (LowerBound v  InclusiveBound)-             (UpperBound v' InclusiveBound) | v == v'-                 = thisVersion v+    interval+      (LowerBound v InclusiveBound)+      (UpperBound v' InclusiveBound)+        | v == v' =+            thisVersion v     interval l u = lowerBound l `intersectVersionRanges'` upperBound u      lowerBound (LowerBound v InclusiveBound)-                              | isVersion0 v = Nothing-                              | otherwise    = Just (orLaterVersion v)+      | isVersion0 v = Nothing+      | otherwise = Just (orLaterVersion v)     lowerBound (LowerBound v ExclusiveBound) = Just (laterVersion v) -    upperBound NoUpperBound                  = Nothing+    upperBound NoUpperBound = Nothing     upperBound (UpperBound v InclusiveBound) = Just (orEarlierVersion v)     upperBound (UpperBound v ExclusiveBound) = Just (earlierVersion v) -    intersectVersionRanges' Nothing Nothing      = anyVersion-    intersectVersionRanges' (Just vr) Nothing    = vr-    intersectVersionRanges' Nothing (Just vr)    = vr+    intersectVersionRanges' Nothing Nothing = anyVersion+    intersectVersionRanges' (Just vr) Nothing = vr+    intersectVersionRanges' Nothing (Just vr) = vr     intersectVersionRanges' (Just vr) (Just vr') = intersectVersionRanges vr vr'  -- | Union two interval sequences, fusing intervals where necessary. -- Computed \( O(n+m) \) time, resulting in sequence of length \( ≤ n+m \).----unionVersionIntervals :: VersionIntervals -> VersionIntervals-                      -> VersionIntervals+unionVersionIntervals+  :: VersionIntervals+  -> VersionIntervals+  -> VersionIntervals unionVersionIntervals (VersionIntervals is0) (VersionIntervals is'0) =   checkInvariant (VersionIntervals (union is0 is'0))   where-    union is []  = is+    union is [] = is     union [] is' = is'-    union (i:is) (i':is') = case unionInterval i i' of-+    union (i : is) (i' : is') = case unionInterval i i' of       -- @i < i'@ and separated: keep @i@.-      Left  Nothing    -> i  : union      is  (i' :is')-+      Left Nothing -> i : union is (i' : is')       -- @i'' = i ∪ i'@ and @i@ ends first: drop @i@, replace @i'@ by @i''@.-      Left  (Just i'') ->      union      is  (i'':is')-+      Left (Just i'') -> union is (i'' : is')       -- @i' < i@ and separated: keep @i'@.-      Right Nothing    -> i' : union (i  :is)      is'-+      Right Nothing -> i' : union (i : is) is'       -- @i'' = i ∪ i'@ and @i'@ ends first: drop @i'@, replace @i@ by @i''@.-      Right (Just i'') ->      union (i'':is)      is'+      Right (Just i'') -> union (i'' : is) is'  -- | Given two version intervals @i1@ and @i2@, return one of the following: --@@ -346,24 +332,23 @@ -- -- Herein, @i < i'@ means that the whole of the interval @i@ is strictly left of the whole of @i'@, -- and @ub(i)@ returns the right boundary of interval @i@ which could be inclusive or exclusive.----unionInterval :: VersionInterval -> VersionInterval-              -> Either (Maybe VersionInterval) (Maybe VersionInterval)-unionInterval (lower , upper ) (lower', upper')-+unionInterval+  :: VersionInterval+  -> VersionInterval+  -> Either (Maybe VersionInterval) (Maybe VersionInterval)+unionInterval (lower, upper) (lower', upper')   -- Non-intersecting intervals with the left interval ending first   | upper `doesNotTouch` lower' = Left Nothing-   -- Non-intersecting intervals with the right interval first   | upper' `doesNotTouch` lower = Right Nothing-   -- Complete or partial overlap, with the left interval ending first-  | upper <= upper' = lowerBound `seq`-                      Left (Just (lowerBound, upper'))-+  | upper <= upper' =+      lowerBound `seq`+        Left (Just (lowerBound, upper'))   -- Complete or partial overlap, with the left interval ending first-  | otherwise = lowerBound `seq`-                Right (Just (lowerBound, upper))+  | otherwise =+      lowerBound `seq`+        Right (Just (lowerBound, upper))   where     lowerBound = min lower lower' @@ -374,27 +359,24 @@ -- (rather than the naive \( O(nm) \). -- -- The length of \( is \cap is' \) is \( ≤ \min(n,m) \).----intersectVersionIntervals :: VersionIntervals -> VersionIntervals-                          -> VersionIntervals+intersectVersionIntervals+  :: VersionIntervals+  -> VersionIntervals+  -> VersionIntervals intersectVersionIntervals (VersionIntervals is0) (VersionIntervals is'0) =   checkInvariant (VersionIntervals (intersect is0 is'0))   where-    intersect _  [] = []-    intersect [] _  = []-    intersect (i:is) (i':is') = case intersectInterval i i' of-+    intersect _ [] = []+    intersect [] _ = []+    intersect (i : is) (i' : is') = case intersectInterval i i' of       -- @i < i'@: throw out @i@-      Left  Nothing    ->       intersect is (i':is')-+      Left Nothing -> intersect is (i' : is')       -- @i'' = i /\ i'@ and @i@ ends first: replace @i@ by @i''@.-      Left  (Just i'') -> i'' : intersect is (i':is')-+      Left (Just i'') -> i'' : intersect is (i' : is')       -- @i' < i@: throw out @i'@-      Right Nothing    ->       intersect (i:is) is'-+      Right Nothing -> intersect (i : is) is'       -- @i'' = i /\ i'@ and @i'@ ends first: replace @i'@ by @i''@.-      Right (Just i'') -> i'' : intersect (i:is) is'+      Right (Just i'') -> i'' : intersect (i : is) is'  -- | Given two version intervals @i1@ and @i2@, return one of the following: --@@ -405,69 +387,72 @@ -- -- Herein, @i < i'@ means that the whole of the interval @i@ is strictly left of the whole of @i'@, -- and @ub(i)@ returns the right boundary of interval @i@ which could be inclusive or exclusive.----intersectInterval :: VersionInterval -> VersionInterval-                  -> Either (Maybe VersionInterval) (Maybe VersionInterval)-intersectInterval (lower , upper ) (lower', upper')-+intersectInterval+  :: VersionInterval+  -> VersionInterval+  -> Either (Maybe VersionInterval) (Maybe VersionInterval)+intersectInterval (lower, upper) (lower', upper')   -- Non-intersecting intervals with the left interval ending first   | upper `doesNotIntersect` lower' = Left Nothing-   -- Non-intersecting intervals with the right interval first   | upper' `doesNotIntersect` lower = Right Nothing-   -- Complete or partial overlap, with the left interval ending first-  | upper <= upper' = lowerBound `seq`-                      Left (Just (lowerBound, upper))-+  | upper <= upper' =+      lowerBound `seq`+        Left (Just (lowerBound, upper))   -- Complete or partial overlap, with the right interval ending first-  | otherwise = lowerBound `seq`-                Right (Just (lowerBound, upper'))+  | otherwise =+      lowerBound `seq`+        Right (Just (lowerBound, upper'))   where     lowerBound = max lower lower'  -- | Compute the complement. -- \( O(n) \).-invertVersionIntervals :: VersionIntervals-                       -> VersionIntervals+invertVersionIntervals+  :: VersionIntervals+  -> VersionIntervals invertVersionIntervals (VersionIntervals xs) =-    case xs of-      -- Empty interval set-      [] -> VersionIntervals [(noLowerBound, NoUpperBound)]-      -- Interval with no lower bound-      ((lb, ub) : more) | lb == noLowerBound ->-        VersionIntervals $ invertVersionIntervals' ub more-      -- Interval with a lower bound-      ((lb, ub) : more) ->-          VersionIntervals $ (noLowerBound, invertLowerBound lb)+  case xs of+    -- Empty interval set+    [] -> VersionIntervals [(noLowerBound, NoUpperBound)]+    -- Interval with no lower bound+    ((lb, ub) : more)+      | lb == noLowerBound ->+          VersionIntervals $ invertVersionIntervals' ub more+    -- Interval with a lower bound+    ((lb, ub) : more) ->+      VersionIntervals $+        (noLowerBound, invertLowerBound lb)           : invertVersionIntervals' ub more-    where-      -- Invert subsequent version intervals given the upper bound of-      -- the intervals already inverted.-      invertVersionIntervals' :: UpperBound-                              -> [(LowerBound, UpperBound)]-                              -> [(LowerBound, UpperBound)]-      invertVersionIntervals' NoUpperBound [] = []-      invertVersionIntervals' ub0 [] = [(invertUpperBound ub0, NoUpperBound)]-      invertVersionIntervals' ub0 [(lb, NoUpperBound)] =-          [(invertUpperBound ub0, invertLowerBound lb)]-      invertVersionIntervals' ub0 ((lb, ub1) : more) =-          (invertUpperBound ub0, invertLowerBound lb)-            : invertVersionIntervals' ub1 more+  where+    -- Invert subsequent version intervals given the upper bound of+    -- the intervals already inverted.+    invertVersionIntervals'+      :: UpperBound+      -> [(LowerBound, UpperBound)]+      -> [(LowerBound, UpperBound)]+    invertVersionIntervals' NoUpperBound [] = []+    invertVersionIntervals' ub0 [] = [(invertUpperBound ub0, NoUpperBound)]+    invertVersionIntervals' ub0 [(lb, NoUpperBound)] =+      [(invertUpperBound ub0, invertLowerBound lb)]+    invertVersionIntervals' ub0 ((lb, ub1) : more) =+      (invertUpperBound ub0, invertLowerBound lb)+        : invertVersionIntervals' ub1 more -      invertLowerBound :: LowerBound -> UpperBound-      invertLowerBound (LowerBound v b) = UpperBound v (invertBound b)+    invertLowerBound :: LowerBound -> UpperBound+    invertLowerBound (LowerBound v b) = UpperBound v (invertBound b) -      invertUpperBound :: UpperBound -> LowerBound-      invertUpperBound (UpperBound v b) = LowerBound v (invertBound b)-      invertUpperBound NoUpperBound = error "NoUpperBound: unexpected"+    invertUpperBound :: UpperBound -> LowerBound+    invertUpperBound (UpperBound v b) = LowerBound v (invertBound b)+    invertUpperBound NoUpperBound = error "NoUpperBound: unexpected" -      invertBound :: Bound -> Bound-      invertBound ExclusiveBound = InclusiveBound-      invertBound InclusiveBound = ExclusiveBound+    invertBound :: Bound -> Bound+    invertBound ExclusiveBound = InclusiveBound+    invertBound InclusiveBound = ExclusiveBound -      noLowerBound :: LowerBound-      noLowerBound = LowerBound (mkVersion [0]) InclusiveBound+    noLowerBound :: LowerBound+    noLowerBound = LowerBound (mkVersion [0]) InclusiveBound  -- | Remove the last upper bound, enlarging the range. -- But empty ranges stay empty.@@ -475,9 +460,9 @@ relaxLastInterval :: VersionIntervals -> VersionIntervals relaxLastInterval (VersionIntervals xs) = VersionIntervals (relaxLastInterval' xs)   where-    relaxLastInterval' []      = []-    relaxLastInterval' [(l,_)] = [(l, NoUpperBound)]-    relaxLastInterval' (i:is)  = i : relaxLastInterval' is+    relaxLastInterval' [] = []+    relaxLastInterval' [(l, _)] = [(l, NoUpperBound)]+    relaxLastInterval' (i : is) = i : relaxLastInterval' is  -- | Remove the first lower bound (i.e, make it \( [0 \). -- Empty ranges stay empty.@@ -485,5 +470,5 @@ relaxHeadInterval :: VersionIntervals -> VersionIntervals relaxHeadInterval (VersionIntervals xs) = VersionIntervals (relaxHeadInterval' xs)   where-    relaxHeadInterval' []         = []-    relaxHeadInterval' ((_,u):is) = (minLowerBound,u) : is+    relaxHeadInterval' [] = []+    relaxHeadInterval' ((_, u) : is) = (minLowerBound, u) : is
src/Distribution/Types/VersionRange.hs view
@@ -1,43 +1,67 @@-module Distribution.Types.VersionRange (-    -- * Version ranges-    VersionRange,+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE ViewPatterns #-} +module Distribution.Types.VersionRange+  ( -- * Version Range+    VersionRange++    -- ** Predicates+    -- $predicate-examples++    -- *** Lower Bound+  , hasLowerBound+  , hasGTLowerBound++    -- *** Upper Bound+  , hasUpperBound+  , hasLEUpperBound+  , hasTrailingZeroUpperBound++    -- *** Any Version+  , isAnyVersion+  , isAnyVersionLight+     -- ** Constructing-    anyVersion, noVersion,-    thisVersion, notThisVersion,-    laterVersion, earlierVersion,-    orLaterVersion, orEarlierVersion,-    unionVersionRanges, intersectVersionRanges,-    withinVersion,-    majorBoundVersion,+  , anyVersion+  , noVersion+  , thisVersion+  , notThisVersion+  , laterVersion+  , earlierVersion+  , orLaterVersion+  , orEarlierVersion+  , unionVersionRanges+  , intersectVersionRanges+  , withinVersion+  , majorBoundVersion +    -- ** Modification+  , normaliseVersionRange+  , stripParensVersionRange+     -- ** Inspection-    ---    -- See "Distribution.Version" for more utilities.-    withinRange,-    foldVersionRange,-    normaliseVersionRange,-    stripParensVersionRange,-    hasUpperBound,-    hasLowerBound,+  , withinRange+  , foldVersionRange -    -- ** Cata & ana-    VersionRangeF (..),-    cataVersionRange,-    anaVersionRange,-    hyloVersionRange,-    projectVersionRange,-    embedVersionRange,+    -- ** Parser+  , versionRangeParser -    -- ** Utilities-    isAnyVersion,-    isAnyVersionLight,-    wildcardUpperBound,-    majorUpperBound,-    isWildcardRange,-    versionRangeParser,-    ) where+    -- * Version F-Algebra+  , VersionRangeF (..)+  , projectVersionRange+  , embedVersionRange+  , cataVersionRange+  , anaVersionRange+  , hyloVersionRange +    -- * Version Utilities++  -- See "Distribution.Version" for more utilities.+  , wildcardUpperBound+  , majorUpperBound+  , isWildcardRange+  ) where+ import Distribution.Compat.Prelude import Distribution.Types.Version import Distribution.Types.VersionInterval@@ -51,30 +75,38 @@ -- in terms of the other basic syntax. -- -- For a semantic view use 'asVersionIntervals'.----foldVersionRange :: a                         -- ^ @\"-any\"@ version-                 -> (Version -> a)            -- ^ @\"== v\"@-                 -> (Version -> a)            -- ^ @\"> v\"@-                 -> (Version -> a)            -- ^ @\"< v\"@-                 -> (a -> a -> a)             -- ^ @\"_ || _\"@ union-                 -> (a -> a -> a)             -- ^ @\"_ && _\"@ intersection-                 -> VersionRange -> a+foldVersionRange+  :: a+  -- ^ @\"-any\"@ version+  -> (Version -> a)+  -- ^ @\"== v\"@+  -> (Version -> a)+  -- ^ @\"> v\"@+  -> (Version -> a)+  -- ^ @\"< v\"@+  -> (a -> a -> a)+  -- ^ @\"_ || _\"@ union+  -> (a -> a -> a)+  -- ^ @\"_ && _\"@ intersection+  -> VersionRange+  -> a foldVersionRange _any this later earlier union intersect = fold   where     fold = cataVersionRange alg -    alg (ThisVersionF v)                = this v-    alg (LaterVersionF v)               = later v-    alg (OrLaterVersionF v)             = union (this v) (later v)-    alg (EarlierVersionF v)             = earlier v-    alg (OrEarlierVersionF v)           = union (this v) (earlier v)-    alg (MajorBoundVersionF v)          = fold (majorBound v)-    alg (UnionVersionRangesF v1 v2)     = union v1 v2+    alg (ThisVersionF v) = this v+    alg (LaterVersionF v) = later v+    alg (OrLaterVersionF v) = union (this v) (later v)+    alg (EarlierVersionF v) = earlier v+    alg (OrEarlierVersionF v) = union (this v) (earlier v)+    alg (MajorBoundVersionF v) = fold (majorBound v)+    alg (UnionVersionRangesF v1 v2) = union v1 v2     alg (IntersectVersionRangesF v1 v2) = intersect v1 v2 -    majorBound v = intersectVersionRanges-                     (orLaterVersion v)-                     (earlierVersion (majorUpperBound v))+    majorBound v =+      intersectVersionRanges+        (orLaterVersion v)+        (earlierVersion (majorUpperBound v))  -- | Normalise 'VersionRange'. --@@ -83,17 +115,19 @@ normaliseVersionRange = hyloVersionRange embed projectVersionRange   where     -- == v || > v, > v || == v  ==>  >= v-    embed (UnionVersionRangesF (ThisVersion v) (LaterVersion v')) | v == v' =-        orLaterVersion v-    embed (UnionVersionRangesF (LaterVersion v) (ThisVersion v')) | v == v' =-        orLaterVersion v-+    embed (UnionVersionRangesF (ThisVersion v) (LaterVersion v'))+      | v == v' =+          orLaterVersion v+    embed (UnionVersionRangesF (LaterVersion v) (ThisVersion v'))+      | v == v' =+          orLaterVersion v     -- == v || < v, < v || == v  ==>  <= v-    embed (UnionVersionRangesF (ThisVersion v) (EarlierVersion v')) | v == v' =-        orEarlierVersion v-    embed (UnionVersionRangesF (EarlierVersion v) (ThisVersion v')) | v == v' =-        orEarlierVersion v-+    embed (UnionVersionRangesF (ThisVersion v) (EarlierVersion v'))+      | v == v' =+          orEarlierVersion v+    embed (UnionVersionRangesF (EarlierVersion v) (ThisVersion v'))+      | v == v' =+          orEarlierVersion v     -- otherwise embed normally     embed vr = embedVersionRange vr @@ -108,15 +142,15 @@ -- | Does this version fall within the given range? -- -- This is the evaluation function for the 'VersionRange' type.--- withinRange :: Version -> VersionRange -> Bool-withinRange v = foldVersionRange-                   True-                   (\v'  -> v == v')-                   (\v'  -> v >  v')-                   (\v'  -> v <  v')-                   (||)-                   (&&)+withinRange v =+  foldVersionRange+    True+    (\v' -> v == v')+    (\v' -> v > v')+    (\v' -> v < v')+    (||)+    (&&)  -- | Does this 'VersionRange' place any restriction on the 'Version' or is it -- in fact equivalent to 'AnyVersion'.@@ -125,11 +159,10 @@ -- the following is @True@ (for all @v@). -- -- > isAnyVersion (EarlierVersion v `UnionVersionRanges` orLaterVersion v)--- isAnyVersion :: VersionRange -> Bool isAnyVersion vr = case asVersionIntervals vr of-    [VersionInterval (LowerBound v InclusiveBound) NoUpperBound] -> v == version0-    _                                                            -> False+  [VersionInterval (LowerBound v InclusiveBound) NoUpperBound] -> v == version0+  _ -> False  -- A fast and non-precise version of 'isAnyVersion', -- returns 'True' only for @>= 0@ 'VersionRange's.@@ -141,29 +174,34 @@ -- isAnyVersionLight :: VersionRange -> Bool isAnyVersionLight (OrLaterVersion v) = v == version0-isAnyVersionLight _vr                = False+isAnyVersionLight _vr = False  ---------------------------- -- Wildcard range utilities -- - isWildcardRange :: Version -> Version -> Bool isWildcardRange ver1 ver2 = check (versionNumbers ver1) (versionNumbers ver2)-  where check (n:[]) (m:[]) | n+1 == m = True-        check (n:ns) (m:ms) | n   == m = check ns ms-        check _      _                 = False+  where+    check (n : []) (m : []) | n + 1 == m = True+    check (n : ns) (m : ms) | n == m = check ns ms+    check _ _ = False  -- | Does the version range have an upper bound? -- -- @since 1.24.0.0+--+-- >>> forM ["< 1", ">= 0 && < 1", ">= 0 || < 1", "^>= 4.20.0.0"] (fmap hasUpperBound . simpleParsec)+-- Just [True,True,False,True] hasUpperBound :: VersionRange -> Bool-hasUpperBound = foldVersionRange-                False-                (const True)-                (const False)-                (const True)-                (&&) (||)+hasUpperBound =+  foldVersionRange+    False+    (const True)+    (const False)+    (const True)+    (&&)+    (||)  -- | Does the version range have an explicit lower bound? --@@ -171,10 +209,62 @@ -- the implicit >=0 lower bound. -- -- @since 1.24.0.0+--+-- >>> forM ["< 1", ">= 0 && < 1", ">= 0 || < 1", "^>= 4.20.0.0"] (fmap hasLowerBound . simpleParsec)+-- Just [False,True,False,True] hasLowerBound :: VersionRange -> Bool-hasLowerBound = foldVersionRange-                False-                (const True)-                (const True)-                (const False)-                (&&) (||)+hasLowerBound =+  foldVersionRange+    False+    (const True)+    (const True)+    (const False)+    (&&)+    (||)++-- | Is the upper bound version range (less than or equal (LE, <=)?+--+-- >>> forM ["< 1", "<= 1", ">= 0 && < 1", ">= 0 || < 1", ">= 0 && <= 1", ">= 0 || <= 1", "^>= 4.20.0.0"] (fmap hasLEUpperBound . simpleParsec)+-- Just [False,True,False,False,True,True,False]+hasLEUpperBound :: VersionRange -> Bool+hasLEUpperBound = queryVersionRange (\case LEUpperBound -> True; _ -> False) hasLEUpperBound++-- | Is the lower bound version range greater than (GT, >)?+--+-- >>> forM ["< 1", ">= 0 && < 1", ">= 0 || < 1", "> 0 && < 1", "> 0 || < 1", "^>= 4.20.0.0"] (fmap hasGTLowerBound . simpleParsec)+-- Just [False,False,False,True,True,False]+hasGTLowerBound :: VersionRange -> Bool+hasGTLowerBound = queryVersionRange (\case GTLowerBound -> True; _ -> False) hasGTLowerBound++-- | Does the upper bound version range have a trailing zero?+--+-- >>> forM ["< 1", "< 1.1", "< 1.0", "< 1.1.0", "^>= 4.20.0.0"] (fmap hasTrailingZeroUpperBound . simpleParsec)+-- Just [False,False,True,True,False]+hasTrailingZeroUpperBound :: VersionRange -> Bool+hasTrailingZeroUpperBound = queryVersionRange (\case TZUpperBound -> True; _ -> False) hasTrailingZeroUpperBound++queryVersionRange :: (VersionRangeF VersionRange -> Bool) -> (VersionRange -> Bool) -> VersionRange -> Bool+queryVersionRange pf p (projectVersionRange -> v) =+  let f = queryVersionRange pf p+   in pf v || case v of+        IntersectVersionRangesF x y -> f x || f y+        UnionVersionRangesF x y -> f x || f y+        _ -> False++-- $setup+-- >>> import Distribution.Parsec+-- >>> import Data.Traversable++-- $predicate-examples+--+-- The parsed 'VersionRange' of each version constraint used in the examples for+-- 'hasUpperBound' and 'hasLowerBound' are:+--+-- >>> simpleParsec "< 1" :: Maybe VersionRange+-- Just (EarlierVersion (mkVersion [1]))+-- >>> simpleParsec ">= 0 && < 1" :: Maybe VersionRange+-- Just (IntersectVersionRanges (OrLaterVersion (mkVersion [0])) (EarlierVersion (mkVersion [1])))+-- >>> simpleParsec ">= 0 || < 1" :: Maybe VersionRange+-- Just (UnionVersionRanges (OrLaterVersion (mkVersion [0])) (EarlierVersion (mkVersion [1])))+-- >>> simpleParsec "^>= 4.20.0.0" :: Maybe VersionRange+-- Just (MajorBoundVersion (mkVersion [4,20,0,0]))
src/Distribution/Types/VersionRange/Internal.hs view
@@ -1,35 +1,37 @@-{-# LANGUAGE DeriveDataTypeable  #-}-{-# LANGUAGE DeriveFoldable      #-}-{-# LANGUAGE DeriveFunctor       #-}-{-# LANGUAGE DeriveGeneric       #-}-{-# LANGUAGE DeriveTraversable   #-}-{-# LANGUAGE FlexibleContexts    #-}-{-# LANGUAGE OverloadedStrings   #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ViewPatterns #-}  -- | The only purpose of this module is to prevent the export of -- 'VersionRange' constructors from -- "Distribution.Types.VersionRange". To avoid creating orphan -- instances, a lot of related code had to be moved here too.- module Distribution.Types.VersionRange.Internal-  ( VersionRange(..)-  , anyVersion, noVersion-  , thisVersion, notThisVersion-  , laterVersion, earlierVersion-  , orLaterVersion, orEarlierVersion-  , unionVersionRanges, intersectVersionRanges+  ( VersionRange (..)+  , anyVersion+  , noVersion+  , thisVersion+  , notThisVersion+  , laterVersion+  , earlierVersion+  , orLaterVersion+  , orEarlierVersion+  , unionVersionRanges+  , intersectVersionRanges   , withinVersion   , majorBoundVersion--  , VersionRangeF(..)+  , VersionRangeF (.., LEUpperBound, GTLowerBound, TZUpperBound)   , projectVersionRange   , embedVersionRange   , cataVersionRange   , anaVersionRange   , hyloVersionRange   , versionRangeParser-   , majorUpperBound   , wildcardUpperBound   ) where@@ -41,22 +43,22 @@ import Distribution.CabalSpecVersion import Distribution.Parsec import Distribution.Pretty-import Distribution.Utils.Generic    (unsnoc)+import Distribution.Utils.Generic (unsnoc)  import qualified Distribution.Compat.CharParsing as P-import qualified Distribution.Compat.DList       as DList-import qualified Text.PrettyPrint                as Disp+import qualified Distribution.Compat.DList as DList+import qualified Text.PrettyPrint as Disp  data VersionRange-  = ThisVersion            Version -- = version-  | LaterVersion           Version -- > version  (NB. not >=)-  | OrLaterVersion         Version -- >= version-  | EarlierVersion         Version -- < version-  | OrEarlierVersion       Version -- <= version-  | MajorBoundVersion      Version -- @^>= ver@ (same as >= ver && < MAJ(ver)+1)-  | UnionVersionRanges     VersionRange VersionRange+  = ThisVersion Version -- = version+  | LaterVersion Version -- > version  (NB. not >=)+  | OrLaterVersion Version -- >= version+  | EarlierVersion Version -- < version+  | OrEarlierVersion Version -- <= version+  | MajorBoundVersion Version -- @^>= ver@ (same as >= ver && < MAJ(ver)+1)+  | UnionVersionRanges VersionRange VersionRange   | IntersectVersionRanges VersionRange VersionRange-  deriving ( Data, Eq, Ord, Generic, Read, Show, Typeable )+  deriving (Data, Eq, Ord, Generic, Read, Show)  instance Binary VersionRange instance Structured VersionRange@@ -66,7 +68,6 @@ -- versions. -- -- > withinRange v anyVersion = True--- anyVersion :: VersionRange anyVersion = OrLaterVersion (mkVersion [0]) @@ -76,49 +77,42 @@ -- for example @< 0@. -- -- > withinRange v noVersion = False--- noVersion :: VersionRange noVersion = EarlierVersion (mkVersion [0])  -- | The version range @== v@. -- -- > withinRange v' (thisVersion v) = v' == v--- thisVersion :: Version -> VersionRange thisVersion = ThisVersion  -- | The version range @/= v@. -- -- > withinRange v' (notThisVersion v) = v' /= v--- notThisVersion :: Version -> VersionRange notThisVersion v = UnionVersionRanges (EarlierVersion v) (LaterVersion v)  -- | The version range @> v@. -- -- > withinRange v' (laterVersion v) = v' > v--- laterVersion :: Version -> VersionRange laterVersion = LaterVersion  -- | The version range @>= v@. -- -- > withinRange v' (orLaterVersion v) = v' >= v--- orLaterVersion :: Version -> VersionRange orLaterVersion = OrLaterVersion  -- | The version range @< v@. -- -- > withinRange v' (earlierVersion v) = v' < v--- earlierVersion :: Version -> VersionRange earlierVersion = EarlierVersion  -- | The version range @<= v@. -- -- > withinRange v' (orEarlierVersion v) = v' <= v--- orEarlierVersion :: Version -> VersionRange orEarlierVersion = OrEarlierVersion @@ -126,7 +120,6 @@ -- -- >   withinRange v' (unionVersionRanges vr1 vr2) -- > = withinRange v' vr1 || withinRange v' vr2--- unionVersionRanges :: VersionRange -> VersionRange -> VersionRange unionVersionRanges = UnionVersionRanges @@ -134,7 +127,6 @@ -- -- >   withinRange v' (intersectVersionRanges vr1 vr2) -- > = withinRange v' vr1 && withinRange v' vr2--- intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange intersectVersionRanges = IntersectVersionRanges @@ -146,9 +138,9 @@ -- > withinRange v' (withinVersion v) = v' >= v && v' < upper v -- >   where -- >     upper (Version lower t) = Version (init lower ++ [last lower + 1]) t--- withinVersion :: Version -> VersionRange-withinVersion v = intersectVersionRanges+withinVersion v =+  intersectVersionRanges     (orLaterVersion v)     (earlierVersion (wildcardUpperBound v)) @@ -163,33 +155,64 @@ majorBoundVersion :: Version -> VersionRange majorBoundVersion = MajorBoundVersion - -- | F-Algebra of 'VersionRange'. See 'cataVersionRange'. -- -- @since 2.2 data VersionRangeF a-  = ThisVersionF            Version -- ^ @== version@.-  | LaterVersionF           Version -- ^ @>  version@.   NB: not @>=@-  | OrLaterVersionF         Version -- ^ @>= version@.-  | EarlierVersionF         Version -- ^ @<  version@.-  | OrEarlierVersionF       Version -- ^ @<= version@.-  | MajorBoundVersionF      Version -- ^ @^>= version@, same as @>= version && < MAJ(version)+1@.-  | UnionVersionRangesF     a a     -- ^ @||@.-  | IntersectVersionRangesF a a     -- ^ @&&@.-  deriving ( Data, Eq, Generic, Read, Show, Typeable-           , Functor, Foldable, Traversable )+  = -- | @== version@.+    ThisVersionF Version+  | -- | @>  version@.   NB: not @>=@+    LaterVersionF Version+  | -- | @>= version@.+    OrLaterVersionF Version+  | -- | @<  version@.+    EarlierVersionF Version+  | -- | @<= version@.+    OrEarlierVersionF Version+  | -- | @^>= version@, same as @>= version && < MAJ(version)+1@.+    MajorBoundVersionF Version+  | -- | @||@.+    UnionVersionRangesF a a+  | -- | @&&@.+    IntersectVersionRangesF a a+  deriving+    ( Data+    , Eq+    , Generic+    , Read+    , Show+    , Functor+    , Foldable+    , Traversable+    ) +pattern LEUpperBound, GTLowerBound, TZUpperBound :: VersionRangeF a+pattern LEUpperBound <- OrEarlierVersionF _+pattern GTLowerBound <- LaterVersionF _+pattern TZUpperBound <- (upperTrailingZero -> True)++upperTrailingZero :: VersionRangeF a -> Bool+upperTrailingZero (OrEarlierVersionF x) = trailingZero x+upperTrailingZero (EarlierVersionF x) = trailingZero x+upperTrailingZero _ = False++trailingZero :: Version -> Bool+trailingZero (versionNumbers -> vs)+  | [0] <- vs = False+  | 0 : _ <- reverse vs = True+  | otherwise = False+ -- | Generic destructor for 'VersionRange'. -- -- @since 2.2 projectVersionRange :: VersionRange -> VersionRangeF VersionRange-projectVersionRange (ThisVersion v)              = ThisVersionF v-projectVersionRange (LaterVersion v)             = LaterVersionF v-projectVersionRange (OrLaterVersion v)           = OrLaterVersionF v-projectVersionRange (EarlierVersion v)           = EarlierVersionF v-projectVersionRange (OrEarlierVersion v)         = OrEarlierVersionF v-projectVersionRange (MajorBoundVersion v)        = MajorBoundVersionF v-projectVersionRange (UnionVersionRanges a b)     = UnionVersionRangesF a b+projectVersionRange (ThisVersion v) = ThisVersionF v+projectVersionRange (LaterVersion v) = LaterVersionF v+projectVersionRange (OrLaterVersion v) = OrLaterVersionF v+projectVersionRange (EarlierVersion v) = EarlierVersionF v+projectVersionRange (OrEarlierVersion v) = OrEarlierVersionF v+projectVersionRange (MajorBoundVersion v) = MajorBoundVersionF v+projectVersionRange (UnionVersionRanges a b) = UnionVersionRangesF a b projectVersionRange (IntersectVersionRanges a b) = IntersectVersionRangesF a b  -- | Fold 'VersionRange'.@@ -202,13 +225,13 @@ -- -- @since 2.2 embedVersionRange :: VersionRangeF VersionRange -> VersionRange-embedVersionRange (ThisVersionF v)              = ThisVersion v-embedVersionRange (LaterVersionF v)             = LaterVersion v-embedVersionRange (OrLaterVersionF v)           = OrLaterVersion v-embedVersionRange (EarlierVersionF v)           = EarlierVersion v-embedVersionRange (OrEarlierVersionF v)         = OrEarlierVersion v-embedVersionRange (MajorBoundVersionF v)        = MajorBoundVersion v-embedVersionRange (UnionVersionRangesF a b)     = UnionVersionRanges a b+embedVersionRange (ThisVersionF v) = ThisVersion v+embedVersionRange (LaterVersionF v) = LaterVersion v+embedVersionRange (OrLaterVersionF v) = OrLaterVersion v+embedVersionRange (EarlierVersionF v) = EarlierVersion v+embedVersionRange (OrEarlierVersionF v) = OrEarlierVersion v+embedVersionRange (MajorBoundVersionF v) = MajorBoundVersion v+embedVersionRange (UnionVersionRangesF a b) = UnionVersionRanges a b embedVersionRange (IntersectVersionRangesF a b) = IntersectVersionRanges a b  -- | Unfold 'VersionRange'.@@ -220,9 +243,11 @@ -- | Refold 'VersionRange'. -- -- @since 2.2-hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange)-                 -> (VersionRange -> VersionRangeF VersionRange)-                 -> VersionRange -> VersionRange+hyloVersionRange+  :: (VersionRangeF VersionRange -> VersionRange)+  -> (VersionRange -> VersionRangeF VersionRange)+  -> VersionRange+  -> VersionRange hyloVersionRange f g = h where h = f . fmap h . g  -------------------------------------------------------------------------------@@ -242,43 +267,46 @@ -- -- >>> fmap (prettyVersioned CabalSpecV1_6) (simpleParsec' CabalSpecV1_6 "-any" :: Maybe VersionRange) -- Just >=0--- instance Pretty VersionRange where-    pretty = prettyVersioned cabalSpecLatest+  pretty = prettyVersioned cabalSpecLatest -    prettyVersioned csv-        | csv > CabalSpecV1_6 = prettyVersionRange-        | otherwise           = prettyVersionRange16+  prettyVersioned csv+    | csv > CabalSpecV1_6 = prettyVersionRange+    | otherwise = prettyVersionRange16  prettyVersionRange :: VersionRange -> Disp.Doc prettyVersionRange vr = cataVersionRange alg vr 0   where     alg :: VersionRangeF (Int -> Disp.Doc) -> Int -> Disp.Doc-    alg (ThisVersionF v)                _ = Disp.text "=="  <<>> pretty v-    alg (LaterVersionF v)               _ = Disp.text ">"   <<>> pretty v-    alg (OrLaterVersionF v)             _ = Disp.text ">="  <<>> pretty v-    alg (EarlierVersionF v)             _ = Disp.text "<"   <<>> pretty v-    alg (OrEarlierVersionF v)           _ = Disp.text "<="  <<>> pretty v-    alg (MajorBoundVersionF v)          _ = Disp.text "^>=" <<>> pretty v-    alg (UnionVersionRangesF r1 r2)     d = parens (d > 0)-        $ r1 1 <+> Disp.text "||" <+> r2 0-    alg (IntersectVersionRangesF r1 r2) d = parens (d > 1)-        $ r1 2 <+> Disp.text "&&" <+> r2 1+    alg (ThisVersionF v) _ = Disp.text "==" <<>> pretty v+    alg (LaterVersionF v) _ = Disp.text ">" <<>> pretty v+    alg (OrLaterVersionF v) _ = Disp.text ">=" <<>> pretty v+    alg (EarlierVersionF v) _ = Disp.text "<" <<>> pretty v+    alg (OrEarlierVersionF v) _ = Disp.text "<=" <<>> pretty v+    alg (MajorBoundVersionF v) _ = Disp.text "^>=" <<>> pretty v+    alg (UnionVersionRangesF r1 r2) d =+      parens (d > 0) $+        r1 1 <+> Disp.text "||" <+> r2 0+    alg (IntersectVersionRangesF r1 r2) d =+      parens (d > 1) $+        r1 2 <+> Disp.text "&&" <+> r2 1 -    parens True  = Disp.parens+    parens True = Disp.parens     parens False = id  -- | Don't use && and || operators. If possible. prettyVersionRange16 :: VersionRange -> Disp.Doc prettyVersionRange16 (IntersectVersionRanges (OrLaterVersion v) (EarlierVersion u))-    | u == wildcardUpperBound v-    = Disp.text "==" <<>> dispWild v+  | u == wildcardUpperBound v =+      Disp.text "==" <<>> dispWild v   where     dispWild ver =-        Disp.hcat (Disp.punctuate (Disp.char '.')-                    (map Disp.int $ versionNumbers ver))+      Disp.hcat+        ( Disp.punctuate+            (Disp.char '.')+            (map Disp.int $ versionNumbers ver)+        )         <<>> Disp.text ".*"- prettyVersionRange16 vr = prettyVersionRange vr  -- |@@ -318,9 +346,8 @@ -- -- >>> map (`simpleParsecW'` "== 1.2.*") [CabalSpecV1_4, CabalSpecV1_6] :: [Maybe VersionRange] -- [Nothing,Just (IntersectVersionRanges (OrLaterVersion (mkVersion [1,2])) (EarlierVersion (mkVersion [1,3])))]--- instance Parsec VersionRange where-    parsec = askCabalSpecVersion >>= versionRangeParser versionDigitParser+  parsec = askCabalSpecVersion >>= versionRangeParser versionDigitParser  -- | 'VersionRange' parser parametrised by version digit parser. --@@ -331,180 +358,197 @@ -- @since 3.0 versionRangeParser :: forall m. CabalParsing m => m Int -> CabalSpecVersion -> m VersionRange versionRangeParser digitParser csv = expr-      where-        expr   = do P.spaces-                    t <- term-                    P.spaces-                    (do _  <- P.string "||"-                        checkOp-                        P.spaces-                        e <- expr-                        return (unionVersionRanges t e)-                     <|>-                     return t)-        term   = do f <- factor-                    P.spaces-                    (do _  <- P.string "&&"-                        checkOp-                        P.spaces-                        t <- term-                        return (intersectVersionRanges f t)-                     <|>-                     return f)-        factor = parens expr <|> prim--        prim = do-            op <- P.munch1 isOpChar P.<?> "operator"-            case op of-                "-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion'--                "==" -> do-                    P.spaces-                    (do (wild, v) <- verOrWild-                        checkWild wild-                        pure $ (if wild then withinVersion else thisVersion) v-                     <|>-                     (verSet' thisVersion =<< verSet))--                "^>=" -> do-                    P.spaces-                    (do (wild, v) <- verOrWild-                        when wild $ P.unexpected $-                            "wild-card version after ^>= operator"-                        majorBoundVersion' v-                     <|>-                     (verSet' majorBoundVersion =<< verSet))--                _ -> do-                    P.spaces-                    (wild, v) <- verOrWild-                    when wild $ P.unexpected $-                        "wild-card version after non-== operator: " ++ show op-                    case op of-                        ">="  -> pure $ orLaterVersion v-                        "<"   -> pure $ earlierVersion v-                        "<="  -> pure $ orEarlierVersion v-                        ">"   -> pure $ laterVersion v-                        _ -> fail $ "Unknown version operator " ++ show op+  where+    expr = do+      P.spaces+      t <- term+      P.spaces+      ( do+          _ <- P.string "||"+          checkOp+          P.spaces+          e <- expr+          return (unionVersionRanges t e)+          <|> return t+        )+    term = do+      f <- factor+      P.spaces+      ( do+          _ <- P.string "&&"+          checkOp+          P.spaces+          t <- term+          return (intersectVersionRanges f t)+          <|> return f+        )+    factor = parens expr <|> prim -        -- Cannot be warning-        -- On 2020-03-16 there was around 27400 files on Hackage failing to parse due this-        -- For example https://hackage.haskell.org/package/haxr-3000.0.0/haxr.cabal-        ---        checkOp = when (csv < CabalSpecV1_8) $-            parsecWarning PWTVersionOperator $ unwords-                [ "version operators used."-                , "To use version operators the package needs to specify at least 'cabal-version: >= 1.8'."-                ]+    prim = do+      op <- P.munch1 isOpChar P.<?> "operator"+      case op of+        "-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion'+        "==" -> do+          P.spaces+          ( do+              (wild, v) <- verOrWild+              checkWild wild+              pure $ (if wild then withinVersion else thisVersion) v+              <|> (verSet' thisVersion =<< verSet)+            )+        "^>=" -> do+          P.spaces+          ( do+              (wild, v) <- verOrWild+              when wild $+                P.unexpected $+                  "wild-card version after ^>= operator"+              majorBoundVersion' v+              <|> (verSet' majorBoundVersion =<< verSet)+            )+        _ -> do+          P.spaces+          (wild, v) <- verOrWild+          when wild $+            P.unexpected $+              "wild-card version after non-== operator: " ++ show op+          case op of+            ">=" -> pure $ orLaterVersion v+            "<" -> pure $ earlierVersion v+            "<=" -> pure $ orEarlierVersion v+            ">" -> pure $ laterVersion v+            _ -> fail $ "Unknown version operator " ++ show op -        -- Cannot be warning-        -- On 2020-03-16 there was 46 files on Hackage failing to parse due this-        -- For example https://hackage.haskell.org/package/derive-0.1.2/derive.cabal-        ---        checkWild False = pure ()-        checkWild True  = when (csv < CabalSpecV1_6) $-            parsecWarning PWTVersionWildcard $ unwords-                [ "Wildcard syntax used."-                , "To use version wildcards the package needs to specify at least 'cabal-version: >= 1.6'."-                ]+    -- Cannot be warning+    -- On 2020-03-16 there was around 27400 files on Hackage failing to parse due this+    -- For example https://hackage.haskell.org/package/haxr-3000.0.0/haxr.cabal+    --+    checkOp =+      when (csv < CabalSpecV1_8) $+        parsecWarning PWTVersionOperator $+          unwords+            [ "version operators used."+            , "To use version operators the package needs to specify at least 'cabal-version: >= 1.8'."+            ] -        -- https://gitlab.haskell.org/ghc/ghc/issues/17752-        isOpChar '<' = True-        isOpChar '=' = True-        isOpChar '>' = True-        isOpChar '^' = True-        isOpChar '-' = csv < CabalSpecV3_4-        -- https://github.com/haskell/cabal/issues/6589-        -- Unfortunately we have must not consume the dash,-        -- as otherwise following parts may not be parsed.-        ---        -- i.e. we cannot fail here with good error.-        isOpChar _   = False+    -- Cannot be warning+    -- On 2020-03-16 there was 46 files on Hackage failing to parse due this+    -- For example https://hackage.haskell.org/package/derive-0.1.2/derive.cabal+    --+    checkWild False = pure ()+    checkWild True =+      when (csv < CabalSpecV1_6) $+        parsecWarning PWTVersionWildcard $+          unwords+            [ "Wildcard syntax used."+            , "To use version wildcards the package needs to specify at least 'cabal-version: >= 1.6'."+            ] -        -- -none version range is available since 1.22-        noVersion' =-            if csv >= CabalSpecV1_22-            then pure noVersion-            else fail $ unwords-                [ "-none version range used."-                , "To use this syntax the package needs to specify at least 'cabal-version: 1.22'."-                , "Alternatively, if broader compatibility is important then use"-                , "<0 or other empty range."-                ]+    -- https://gitlab.haskell.org/ghc/ghc/issues/17752+    isOpChar '<' = True+    isOpChar '=' = True+    isOpChar '>' = True+    isOpChar '^' = True+    isOpChar '-' = csv < CabalSpecV3_4+    -- https://github.com/haskell/cabal/issues/6589+    -- Unfortunately we have must not consume the dash,+    -- as otherwise following parts may not be parsed.+    --+    -- i.e. we cannot fail here with good error.+    isOpChar _ = False -        -- ^>= is available since 2.0-        majorBoundVersion' v =-            if csv >= CabalSpecV2_0-            then pure $ majorBoundVersion v-            else fail $ unwords-                [ "major bounded version syntax (caret, ^>=) used."-                , "To use this syntax the package need to specify at least 'cabal-version: 2.0'."-                , "Alternatively, if broader compatibility is important then use:"-                , prettyShow $ eliminateMajorBoundSyntax $ majorBoundVersion v-                ]-          where-            eliminateMajorBoundSyntax = hyloVersionRange embed projectVersionRange-            embed (MajorBoundVersionF u) = intersectVersionRanges-                (orLaterVersion u) (earlierVersion (majorUpperBound u))-            embed vr = embedVersionRange vr+    -- -none version range is available since 1.22+    noVersion' =+      if csv >= CabalSpecV1_22+        then pure noVersion+        else+          fail $+            unwords+              [ "-none version range used."+              , "To use this syntax the package needs to specify at least 'cabal-version: 1.22'."+              , "Alternatively, if broader compatibility is important then use"+              , "<0 or other empty range."+              ] -        -- version set notation (e.g. "== { 0.0.1.0, 0.0.2.0, 0.1.0.0 }")-        verSet' op vs =-            if csv >= CabalSpecV3_0-            then pure $ foldr1 unionVersionRanges (fmap op vs)-            else fail $ unwords-                [ "version set syntax used."-                , "To use this syntax the package needs to specify at least 'cabal-version: 3.0'."-                , "Alternatively, if broader compatibility is important then use"-                , "a series of single version constraints joined with the || operator:"-                , prettyShow (foldr1 unionVersionRanges (fmap op vs))-                ]+    -- \^>= is available since 2.0+    majorBoundVersion' v =+      if csv >= CabalSpecV2_0+        then pure $ majorBoundVersion v+        else+          fail $+            unwords+              [ "major bounded version syntax (caret, ^>=) used."+              , "To use this syntax the package need to specify at least 'cabal-version: 2.0'."+              , "Alternatively, if broader compatibility is important then use:"+              , prettyShow $ eliminateMajorBoundSyntax $ majorBoundVersion v+              ]+      where+        eliminateMajorBoundSyntax = hyloVersionRange embed projectVersionRange+        embed (MajorBoundVersionF u) =+          intersectVersionRanges+            (orLaterVersion u)+            (earlierVersion (majorUpperBound u))+        embed vr = embedVersionRange vr -        verSet :: CabalParsing m => m (NonEmpty Version)-        verSet = do-            _ <- P.char '{'-            P.spaces-            vs <- P.sepByNonEmpty (verPlain <* P.spaces) (P.char ',' *> P.spaces)-            _ <- P.char '}'-            pure vs+    -- version set notation (e.g. "== { 0.0.1.0, 0.0.2.0, 0.1.0.0 }")+    verSet' op vs =+      if csv >= CabalSpecV3_0+        then pure $ foldr1 unionVersionRanges (fmap op vs)+        else+          fail $+            unwords+              [ "version set syntax used."+              , "To use this syntax the package needs to specify at least 'cabal-version: 3.0'."+              , "Alternatively, if broader compatibility is important then use"+              , "a series of single version constraints joined with the || operator:"+              , prettyShow (foldr1 unionVersionRanges (fmap op vs))+              ] -        -- a plain version without tags or wildcards-        verPlain :: CabalParsing m => m Version-        verPlain = mkVersion <$> toList <$> P.sepByNonEmpty digitParser (P.char '.')+    verSet :: CabalParsing m => m (NonEmpty Version)+    verSet = do+      _ <- P.char '{'+      P.spaces+      vs <- P.sepByNonEmpty (verPlain <* P.spaces) (P.char ',' *> P.spaces)+      _ <- P.char '}'+      pure vs -        -- either wildcard or normal version-        verOrWild :: CabalParsing m => m (Bool, Version)-        verOrWild = do-            x <- digitParser-            verLoop (DList.singleton x)+    -- a plain version without tags or wildcards+    verPlain :: CabalParsing m => m Version+    verPlain = mkVersion <$> toList <$> P.sepByNonEmpty digitParser (P.char '.') -        -- trailing: wildcard (.y.*) or normal version (optional tags) (.y.z-tag)-        verLoop :: CabalParsing m => DList.DList Int -> m (Bool, Version)-        verLoop acc = verLoop' acc-                  <|> (tags *> pure (False, mkVersion (DList.toList acc)))+    -- either wildcard or normal version+    verOrWild :: CabalParsing m => m (Bool, Version)+    verOrWild = do+      x <- digitParser+      verLoop (DList.singleton x) -        verLoop' :: CabalParsing m => DList.DList Int -> m (Bool, Version)-        verLoop' acc = do-            _ <- P.char '.'-            let digit = digitParser >>= verLoop . DList.snoc acc-            let wild  = (True, mkVersion (DList.toList acc)) <$ P.char '*'-            digit <|> wild+    -- trailing: wildcard (.y.*) or normal version (optional tags) (.y.z-tag)+    verLoop :: CabalParsing m => DList.DList Int -> m (Bool, Version)+    verLoop acc =+      verLoop' acc+        <|> (tags *> pure (False, mkVersion (DList.toList acc))) -        parens p = P.between-            ((P.char '(' P.<?> "opening paren") >> P.spaces)-            (P.char ')' >> P.spaces)-            $ do-                a <- p-                P.spaces-                return a+    verLoop' :: CabalParsing m => DList.DList Int -> m (Bool, Version)+    verLoop' acc = do+      _ <- P.char '.'+      let digit = digitParser >>= verLoop . DList.snoc acc+      let wild = (True, mkVersion (DList.toList acc)) <$ P.char '*'+      digit <|> wild -        tags :: CabalParsing m => m ()-        tags = do-            ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum)-            case ts of-                []      -> pure ()-                (_ : _) -> parsecWarning PWTVersionTag "version with tags"+    parens p = P.between+      ((P.char '(' P.<?> "opening paren") >> P.spaces)+      (P.char ')' >> P.spaces)+      $ do+        a <- p+        P.spaces+        return a +    tags :: CabalParsing m => m ()+    tags = do+      ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum)+      case ts of+        [] -> pure ()+        (_ : _) -> parsecWarning PWTVersionTag "version with tags"  ---------------------------- -- Wildcard range utilities@@ -518,9 +562,9 @@ -- @since 2.2 majorUpperBound :: Version -> Version majorUpperBound = alterVersion $ \numbers -> case numbers of-    []        -> [0,1] -- should not happen-    [m1]      -> [m1,1] -- e.g. version '1'-    (m1:m2:_) -> [m1,m2+1]+  [] -> [0, 1] -- should not happen+  [m1] -> [m1, 1] -- e.g. version '1'+  (m1 : m2 : _) -> [m1, m2 + 1]  -- | Increment the last version number. --@@ -531,6 +575,6 @@ -- @since 2.2 wildcardUpperBound :: Version -> Version wildcardUpperBound = alterVersion $-    \lowerBound -> case unsnoc lowerBound of-        Nothing      -> []-        Just (xs, x) -> xs ++ [x + 1]+  \lowerBound -> case unsnoc lowerBound of+    Nothing -> []+    Just (xs, x) -> xs ++ [x + 1]
src/Distribution/Utils/Base62.hs view
@@ -1,11 +1,10 @@- -- | Implementation of base-62 encoding, which we use when computing hashes -- for fully instantiated unit ids. module Distribution.Utils.Base62 (hashToBase62) where -import GHC.Fingerprint ( Fingerprint(..), fingerprintString )-import Numeric ( showIntAtBase )-import Data.Char ( chr )+import Data.Char (chr)+import GHC.Fingerprint (Fingerprint (..), fingerprintString)+import Numeric (showIntAtBase)  -- | Hash a string using GHC's fingerprinting algorithm (a 128-bit -- MD5 hash) and then encode the resulting hash in base 62.@@ -14,9 +13,8 @@   where     showIntAtBase62 x = showIntAtBase 62 representBase62 x ""     representBase62 x-        | x < 10 = chr (48 + x)-        | x < 36 = chr (65 + x - 10)-        | x < 62 = chr (97 + x - 36)-        | otherwise = '@'+      | x < 10 = chr (48 + x)+      | x < 36 = chr (65 + x - 10)+      | x < 62 = chr (97 + x - 36)+      | otherwise = '@'     showFingerprint (Fingerprint a b) = showIntAtBase62 a ++ showIntAtBase62 b-
src/Distribution/Utils/Generic.hs view
@@ -1,11 +1,8 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE ScopedTypeVariables #-} ------------------------------------------------------------------------------ -- | -- Module      :  Distribution.Utils.Generic -- Copyright   :  Isaac Jones, Simon Marlow 2003-2004@@ -20,169 +17,203 @@ -- lib like @cabal-install@. It has a very simple set of logging actions. It -- has low level functions for running programs, a bunch of wrappers for -- various directory and file functions that do extra logging.--module Distribution.Utils.Generic (-        -- * reading and writing files safely-        withFileContents,-        writeFileAtomic,--        -- * Unicode--        -- ** Conversions-        fromUTF8BS,-        fromUTF8LBS,+module Distribution.Utils.Generic+  ( -- * reading and writing files safely+    withFileContents+  , writeFileAtomic -        toUTF8BS,-        toUTF8LBS,+    -- * Unicode -        validateUTF8,+    -- ** Conversions+  , fromUTF8BS+  , fromUTF8LBS+  , toUTF8BS+  , toUTF8LBS+  , validateUTF8 -        -- ** File I/O-        readUTF8File,-        withUTF8FileContents,-        writeUTF8File,+    -- ** File I/O+  , readUTF8File+  , withUTF8FileContents+  , writeUTF8File -        -- ** BOM-        ignoreBOM,+    -- ** BOM+  , ignoreBOM -        -- ** Misc-        normaliseLineEndings,+    -- ** Misc+  , normaliseLineEndings -        -- * generic utils-        dropWhileEndLE,-        takeWhileEndLE,-        equating,-        comparing,-        isInfixOf,-        intercalate,-        lowercase,-        isAscii,-        isAsciiAlpha,-        isAsciiAlphaNum,-        listUnion,-        listUnionRight,-        ordNub,-        ordNubBy,-        ordNubRight,-        safeHead,-        safeTail,-        safeLast,-        safeInit,-        unintersperse,-        wrapText,-        wrapLine,-        unfoldrM,-        spanMaybe,-        breakMaybe,-        unsnoc,-        unsnocNE,+    -- * generic utils+  , dropWhileEndLE+  , takeWhileEndLE+  , equating+  , comparing+  , isInfixOf+  , intercalate+  , lowercase+  , isAscii+  , isAsciiAlpha+  , isAsciiAlphaNum+  , listUnion+  , listUnionRight+  , ordNub+  , sortNub+  , ordNubBy+  , ordNubRight+  , safeHead+  , safeTail+  , safeLast+  , safeInit+  , unintersperse+  , wrapText+  , wrapLine+  , unfoldrM+  , spanMaybe+  , breakMaybe+  , unsnoc+  , unsnocNE -        -- * Triples-        fstOf3,-        sndOf3,-        trdOf3,+    -- * Triples+  , fstOf3+  , sndOf3+  , trdOf3 -        -- * FilePath stuff-        isAbsoluteOnAnyPlatform,-        isRelativeOnAnyPlatform,+    -- * FilePath stuff+  , isAbsoluteOnAnyPlatform+  , isRelativeOnAnyPlatform   ) where -import Prelude () import Distribution.Compat.Prelude+import Prelude ()  import Distribution.Utils.String -import Data.Bits ((.&.), (.|.), shiftL)-import Data.List-    ( isInfixOf )-import qualified Data.Set as Set+import Data.Bits (shiftL, (.&.), (.|.)) import qualified Data.ByteString as SBS import qualified Data.ByteString.Lazy as LBS+import Data.List+  ( isInfixOf+  )+import qualified Data.Set as Set +import qualified Control.Exception as Exception import System.Directory-    ( removeFile, renameFile )+  ( copyFile+  , getTemporaryDirectory+  , removeFile+  , renameFile+  ) import System.FilePath-    ( (<.>), splitFileName )+  ( takeFileName+  , (<.>)+  ) import System.IO-    ( withFile, withBinaryFile-    , openBinaryTempFileWithDefaultPermissions-    , IOMode(ReadMode), hGetContents, hClose )-import qualified Control.Exception as Exception+  ( IOMode (ReadMode)+  , hClose+  , hGetContents+  , openBinaryTempFileWithDefaultPermissions+  , withBinaryFile+  , withFile+  )  -- ----------------------------------------------------------------------------- -- Helper functions  -- | Wraps text to the default line width. Existing newlines are preserved. wrapText :: String -> String-wrapText = unlines-         . map (intercalate "\n"-              . map unwords-              . wrapLine 79-              . words)-         . lines+wrapText =+  unlines+    . map+      ( intercalate "\n"+          . map unwords+          . wrapLine 79+          . words+      )+    . lines  -- | Wraps a list of words to a list of lines of words of a particular width. wrapLine :: Int -> [String] -> [[String]] wrapLine width = wrap 0 []-  where wrap :: Int -> [String] -> [String] -> [[String]]-        wrap 0   []   (w:ws)-          | length w + 1 > width-          = wrap (length w) [w] ws-        wrap col line (w:ws)-          | col + length w + 1 > width-          = reverse line : wrap 0 [] (w:ws)-        wrap col line (w:ws)-          = let col' = col + length w + 1-             in wrap col' (w:line) ws-        wrap _ []   [] = []-        wrap _ line [] = [reverse line]+  where+    wrap :: Int -> [String] -> [String] -> [[String]]+    wrap 0 [] (w : ws)+      | length w + 1 > width =+          wrap (length w) [w] ws+    wrap col line (w : ws)+      | col + length w + 1 > width =+          reverse line : wrap 0 [] (w : ws)+    wrap col line (w : ws) =+      let col' = col + length w + 1+       in wrap col' (w : line) ws+    wrap _ [] [] = []+    wrap _ line [] = [reverse line]  ----------------------------------- -- Safely reading and writing files  -- | Gets the contents of a file, but guarantee that it gets closed. ----- The file is read lazily but if it is not fully consumed by the action then--- the remaining input is truncated and the file is closed.---+-- The file is read lazily; if it is not fully consumed by the action then an+-- exception is thrown. withFileContents :: FilePath -> (String -> IO a) -> IO a withFileContents name action =-  withFile name ReadMode-           (\hnd -> hGetContents hnd >>= action)+  withFile+    name+    ReadMode+    (\hnd -> hGetContents hnd >>= action)  -- | Writes a file atomically. -- -- The file is either written successfully or an IO exception is raised and -- the original file is left unchanged. ----- On windows it is not possible to delete a file that is open by a process.--- This case will give an IO exception but the atomic property is not affected.+-- On Unix: --+-- - If the temp directory (@$TMPDIR@) is in a filesystem different than the+--   destination path, the renaming will be emulated via 'copyFile' then+--   'deleteFile'.+--+-- On Windows:+--+-- - This operation is not guaranteed to be atomic, see 'renameFile'.+--+-- - It is not possible to delete a file that is open by a process. This case+--   will give an IO exception but the atomic property is not affected.+--+-- - If the temp directory (@TMP@/@TEMP@/..., see haddocks on+--   'getTemporaryDirectory') is in a different drive than the destination path,+--   the write will be emulated via 'copyFile', then 'deleteFile'. writeFileAtomic :: FilePath -> LBS.ByteString -> IO () writeFileAtomic targetPath content = do-  let (targetDir, targetFile) = splitFileName targetPath+  let targetFile = takeFileName targetPath+  tmpDir <- getTemporaryDirectory   Exception.bracketOnError-    (openBinaryTempFileWithDefaultPermissions targetDir $ targetFile <.> "tmp")+    (openBinaryTempFileWithDefaultPermissions tmpDir $ targetFile <.> "tmp")     (\(tmpPath, handle) -> hClose handle >> removeFile tmpPath)-    (\(tmpPath, handle) -> do+    ( \(tmpPath, handle) -> do         LBS.hPut handle content         hClose handle-        renameFile tmpPath targetPath)+        Exception.catch+          (renameFile tmpPath targetPath)+          ( \(_ :: Exception.SomeException) -> do+              copyFile tmpPath targetPath+              removeFile tmpPath+          )+    )  -- ------------------------------------------------------------+ -- * Unicode stuff+ -- ------------------------------------------------------------  -- | Decode 'String' from UTF8-encoded 'BS.ByteString' -- -- Invalid data in the UTF8 stream (this includes code-points @U+D800@ -- through @U+DFFF@) will be decoded as the replacement character (@U+FFFD@).--- fromUTF8BS :: SBS.ByteString -> String fromUTF8BS = decodeStringUtf8 . SBS.unpack  -- | Variant of 'fromUTF8BS' for lazy 'BS.ByteString's--- fromUTF8LBS :: LBS.ByteString -> String fromUTF8LBS = decodeStringUtf8 . LBS.unpack @@ -190,93 +221,92 @@ -- -- Code-points in the @U+D800@-@U+DFFF@ range will be encoded -- as the replacement character (i.e. @U+FFFD@).--- toUTF8BS :: String -> SBS.ByteString toUTF8BS = SBS.pack . encodeStringUtf8  -- | Variant of 'toUTF8BS' for lazy 'BS.ByteString's--- toUTF8LBS :: String -> LBS.ByteString toUTF8LBS = LBS.pack . encodeStringUtf8  -- | Check that strict 'ByteString' is valid UTF8. Returns 'Just offset' if it's not. validateUTF8 :: SBS.ByteString -> Maybe Int-validateUTF8 = go 0 where+validateUTF8 = go 0+  where     go off bs = case SBS.uncons bs of-        Nothing -> Nothing-        Just (c, bs')-            | c <= 0x7F -> go (off + 1) bs'-            | c <= 0xBF -> Just off-            | c <= 0xDF -> twoBytes off c bs'-            | c <= 0xEF -> moreBytes off 3 0x800     bs' (fromIntegral $ c .&. 0xF)-            | c <= 0xF7 -> moreBytes off 4 0x10000   bs' (fromIntegral $ c .&. 0x7)-            | c <= 0xFB -> moreBytes off 5 0x200000  bs' (fromIntegral $ c .&. 0x3)-            | c <= 0xFD -> moreBytes off 6 0x4000000 bs' (fromIntegral $ c .&. 0x1)-            | otherwise -> Just off+      Nothing -> Nothing+      Just (c, bs')+        | c <= 0x7F -> go (off + 1) bs'+        | c <= 0xBF -> Just off+        | c <= 0xDF -> twoBytes off c bs'+        | c <= 0xEF -> moreBytes off 3 0x800 bs' (fromIntegral $ c .&. 0xF)+        | c <= 0xF7 -> moreBytes off 4 0x10000 bs' (fromIntegral $ c .&. 0x7)+        | c <= 0xFB -> moreBytes off 5 0x200000 bs' (fromIntegral $ c .&. 0x3)+        | c <= 0xFD -> moreBytes off 6 0x4000000 bs' (fromIntegral $ c .&. 0x1)+        | otherwise -> Just off      twoBytes off c0 bs = case SBS.uncons bs of-        Nothing        -> Just off-        Just (c1, bs')-            | c1 .&. 0xC0 == 0x80 ->-                if d >= (0x80 :: Int)-                then go (off + 2) bs'-                else Just off-            | otherwise -> Just off-          where-            d = (fromIntegral (c0 .&. 0x1F) `shiftL` 6) .|. fromIntegral (c1 .&. 0x3F)+      Nothing -> Just off+      Just (c1, bs')+        | c1 .&. 0xC0 == 0x80 ->+            if d >= (0x80 :: Int)+              then go (off + 2) bs'+              else Just off+        | otherwise -> Just off+        where+          d = (fromIntegral (c0 .&. 0x1F) `shiftL` 6) .|. fromIntegral (c1 .&. 0x3F)      moreBytes :: Int -> Int -> Int -> SBS.ByteString -> Int -> Maybe Int     moreBytes off 1 overlong cs' acc-      | overlong <= acc, acc <= 0x10FFFF, acc < 0xD800 || 0xDFFF < acc-      = go (off + 1) cs'--      | otherwise-      = Just off-+      | overlong <= acc+      , acc <= 0x10FFFF+      , acc < 0xD800 || 0xDFFF < acc =+          go (off + 1) cs'+      | otherwise =+          Just off     moreBytes off byteCount overlong bs acc = case SBS.uncons bs of-        Just (cn, bs') | cn .&. 0xC0 == 0x80 ->-            moreBytes (off + 1) (byteCount-1) overlong bs' ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)-        _ -> Just off-+      Just (cn, bs')+        | cn .&. 0xC0 == 0x80 ->+            moreBytes (off + 1) (byteCount - 1) overlong bs' ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)+      _ -> Just off  -- | Ignore a Unicode byte order mark (BOM) at the beginning of the input--- ignoreBOM :: String -> String-ignoreBOM ('\xFEFF':string) = string-ignoreBOM string            = string+ignoreBOM ('\xFEFF' : string) = string+ignoreBOM string = string  -- | Reads a UTF8 encoded text file as a Unicode String -- -- Reads lazily using ordinary 'readFile'.--- readUTF8File :: FilePath -> IO String readUTF8File f = (ignoreBOM . fromUTF8LBS) <$> LBS.readFile f  -- | Reads a UTF8 encoded text file as a Unicode String -- -- Same behaviour as 'withFileContents'.--- withUTF8FileContents :: FilePath -> (String -> IO a) -> IO a withUTF8FileContents name action =-  withBinaryFile name ReadMode+  withBinaryFile+    name+    ReadMode     (\hnd -> LBS.hGetContents hnd >>= action . ignoreBOM . fromUTF8LBS)  -- | Writes a Unicode String as a UTF8 encoded text file. -- -- Uses 'writeFileAtomic', so provides the same guarantees.--- writeUTF8File :: FilePath -> String -> IO () writeUTF8File path = writeFileAtomic path . toUTF8LBS  -- | Fix different systems silly line ending conventions normaliseLineEndings :: String -> String normaliseLineEndings [] = []-normaliseLineEndings ('\r':'\n':s) = '\n' : normaliseLineEndings s -- windows-normaliseLineEndings ('\r':s)      = '\n' : normaliseLineEndings s -- old OS X-normaliseLineEndings (  c :s)      =   c  : normaliseLineEndings s+normaliseLineEndings ('\r' : '\n' : s) = '\n' : normaliseLineEndings s -- windows+normaliseLineEndings ('\r' : s) = '\n' : normaliseLineEndings s -- old OS X+normaliseLineEndings (c : s) = c : normaliseLineEndings s  -- ------------------------------------------------------------+ -- * Common utils+ -- ------------------------------------------------------------  -- | @dropWhileEndLE p@ is equivalent to @reverse . dropWhile p . reverse@, but@@ -300,9 +330,8 @@ -- >>> take 3 $ dropWhileEndLE (<3) [5, 4, 3, 2, 1, undefined] -- *** Exception: Prelude.undefined -- ...--- dropWhileEndLE :: (a -> Bool) -> [a] -> [a]-dropWhileEndLE p = foldr (\x r -> if null r && p x then [] else x:r) []+dropWhileEndLE p = foldr (\x r -> if null r && p x then [] else x : r) []  -- | @takeWhileEndLE p@ is equivalent to @reverse . takeWhile p . reverse@, but -- is usually faster (as well as being easier to read).@@ -310,7 +339,7 @@ takeWhileEndLE p = fst . foldr go ([], False)   where     go x (rest, done)-      | not done && p x = (x:rest, False)+      | not done && p x = (x : rest, False)       | otherwise = (rest, True)  -- | Like 'Data.List.nub', but has @O(n log n)@ complexity instead of@@ -325,16 +354,17 @@ ordNubBy f l = go Set.empty l   where     go !_ [] = []-    go !s (x:xs)+    go !s (x : xs)       | y `Set.member` s = go s xs-      | otherwise        = let !s' = Set.insert y s-                            in x : go s' xs+      | otherwise =+          let !s' = Set.insert y s+           in x : go s' xs       where         y = f x  -- | Like "Data.List.union", but has @O(n log n)@ complexity instead of -- @O(n^2)@.-listUnion :: (Ord a) => [a] -> [a] -> [a]+listUnion :: Ord a => [a] -> [a] -> [a] listUnion a b = a ++ ordNub (filter (`Set.notMember` aSet) b)   where     aSet = Set.fromList a@@ -348,13 +378,18 @@ -- -- >>> ordNubRight [1,2,1] :: [Int] -- [2,1]----ordNubRight :: (Ord a) => [a] -> [a]+ordNubRight :: Ord a => [a] -> [a] ordNubRight = fst . foldr go ([], Set.empty)   where-    go x p@(l, s) = if x `Set.member` s then p-                                        else (x:l, Set.insert x s)+    go x p@(l, s) =+      if x `Set.member` s+        then p+        else (x : l, Set.insert x s) +-- | Sort and nub a list+sortNub :: Ord a => [a] -> [a]+sortNub = Set.toList . Set.fromList+ -- | A right-biased version of 'listUnion'. -- -- Example:@@ -364,8 +399,7 @@ -- -- >>> listUnionRight [1,2,3,4,3] [2,1,1] -- [4,3,2,1,1]----listUnionRight :: (Ord a) => [a] -> [a] -> [a]+listUnionRight :: Ord a => [a] -> [a] -> [a] listUnionRight a b = ordNubRight (filter (`Set.notMember` bSet) a) ++ b   where     bSet = Set.fromList b@@ -374,30 +408,30 @@ -- -- @since 3.2.0.0 safeHead :: [a] -> Maybe a-safeHead []    = Nothing-safeHead (x:_) = Just x+safeHead [] = Nothing+safeHead (x : _) = Just x  -- | A total variant of 'tail'. -- -- @since 3.2.0.0 safeTail :: [a] -> [a]-safeTail []     = []-safeTail (_:xs) = xs+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)+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 [_]    = []-safeInit (x:xs) = x : safeInit xs+safeInit [] = []+safeInit [_] = []+safeInit (x : xs) = x : safeInit xs  equating :: Eq a => (b -> a) -> b -> b -> Bool equating p x y = p x == p y@@ -415,7 +449,8 @@  -- | Ascii letters. isAsciiAlpha :: Char -> Bool-isAsciiAlpha c = ('a' <= c && c <= 'z')+isAsciiAlpha c =+  ('a' <= c && c <= 'z')     || ('A' <= c && c <= 'Z')  -- | Ascii letters and digits.@@ -425,17 +460,17 @@ -- -- >>> isAsciiAlphaNum 'ä' -- False--- isAsciiAlphaNum :: Char -> Bool isAsciiAlphaNum c = isAscii c && isAlphaNum c  unintersperse :: Char -> String -> [String]-unintersperse mark = unfoldr unintersperse1 where-  unintersperse1 str-    | null str = Nothing-    | otherwise =-        let (this, rest) = break (== mark) str in-        Just (this, safeTail rest)+unintersperse mark = unfoldr unintersperse1+  where+    unintersperse1 str+      | null str = Nothing+      | otherwise =+          let (this, rest) = break (== mark) str+           in Just (this, safeTail rest)  -- | Like 'break', but with 'Maybe' predicate --@@ -446,13 +481,13 @@ -- (["foo","bar"],Nothing) -- -- @since 2.2--- breakMaybe :: (a -> Maybe b) -> [a] -> ([a], Maybe (b, [a]))-breakMaybe f = go id where-    go !acc []     = (acc [], Nothing)-    go !acc (x:xs) = case f x of-        Nothing -> go (acc . (x:)) xs-        Just b  -> (acc [], Just (b, xs))+breakMaybe f = go id+  where+    go !acc [] = (acc [], Nothing)+    go !acc (x : xs) = case f x of+      Nothing -> go (acc . (x :)) xs+      Just b -> (acc [], Just (b, xs))  -- | Like 'span' but with 'Maybe' predicate --@@ -463,12 +498,11 @@ -- ([1,2],["foo"]) -- -- @since 2.2----spanMaybe :: (a -> Maybe b) -> [a] -> ([b],[a])-spanMaybe _ xs@[] =  ([], xs)-spanMaybe p xs@(x:xs') = case p x of-    Just y  -> let (ys, zs) = spanMaybe p xs' in (y : ys, zs)-    Nothing -> ([], xs)+spanMaybe :: (a -> Maybe b) -> [a] -> ([b], [a])+spanMaybe _ xs@[] = ([], xs)+spanMaybe p xs@(x : xs') = case p x of+  Just y -> let (ys, zs) = spanMaybe p xs' in (y : ys, zs)+  Nothing -> ([], xs)  -- | 'unfoldr' with monadic action. --@@ -476,14 +510,14 @@ -- [3,4,5,6,7] -- -- @since 2.2--- unfoldrM :: Monad m => (b -> m (Maybe (a, b))) -> b -> m [a]-unfoldrM f = go where+unfoldrM f = go+  where     go b = do-        m <- f b-        case m of-            Nothing      -> return []-            Just (a, b') -> liftM (a :) (go b')+      m <- f b+      case m of+        Nothing -> return []+        Just (a, b') -> liftM (a :) (go b')  -- | The opposite of 'snoc', which is the reverse of 'cons' --@@ -496,10 +530,9 @@ -- Nothing -- -- @since 3.2.0.0--- unsnoc :: [a] -> Maybe ([a], a)-unsnoc []     = Nothing-unsnoc (x:xs) = Just (unsnocNE (x :| xs))+unsnoc [] = Nothing+unsnoc (x : xs) = Just (unsnocNE (x :| xs))  -- | Like 'unsnoc', but for 'NonEmpty' so without the 'Maybe' --@@ -512,30 +545,32 @@ -- ([],1) -- -- @since 3.2.0.0--- unsnocNE :: NonEmpty a -> ([a], a)-unsnocNE (x:|xs) = go x xs where-    go y []     = ([], y)-    go y (z:zs) = let ~(ws, w) = go z zs in (y : ws, w)+unsnocNE (x :| xs) = go x xs+  where+    go y [] = ([], y)+    go y (z : zs) = let ~(ws, w) = go z zs in (y : ws, w)  ------------------------------------------------------------------------------- -- Triples -------------------------------------------------------------------------------  -- | @since 3.4.0.0-fstOf3 :: (a,b,c) -> a-fstOf3 (a,_,_) = a+fstOf3 :: (a, b, c) -> a+fstOf3 (a, _, _) = a  -- | @since 3.4.0.0-sndOf3 :: (a,b,c) -> b-sndOf3 (_,b,_) = b+sndOf3 :: (a, b, c) -> b+sndOf3 (_, b, _) = b  -- | @since 3.4.0.0-trdOf3 :: (a,b,c) -> c-trdOf3 (_,_,c) = c+trdOf3 :: (a, b, c) -> c+trdOf3 (_, _, c) = c  -- ------------------------------------------------------------+ -- * FilePath stuff+ -- ------------------------------------------------------------  -- | 'isAbsoluteOnAnyPlatform' and 'isRelativeOnAnyPlatform' are like@@ -559,12 +594,12 @@ -- the platform independent heuristics. isAbsoluteOnAnyPlatform :: FilePath -> Bool -- C:\\directory-isAbsoluteOnAnyPlatform (drive:':':'\\':_) = isAlpha drive-isAbsoluteOnAnyPlatform (drive:':':'/':_)  = isAlpha drive+isAbsoluteOnAnyPlatform (drive : ':' : '\\' : _) = isAlpha drive+isAbsoluteOnAnyPlatform (drive : ':' : '/' : _) = isAlpha drive -- UNC-isAbsoluteOnAnyPlatform ('\\':'\\':_) = True+isAbsoluteOnAnyPlatform ('\\' : '\\' : _) = True -- Posix root-isAbsoluteOnAnyPlatform ('/':_) = True+isAbsoluteOnAnyPlatform ('/' : _) = True isAbsoluteOnAnyPlatform _ = False  -- | @isRelativeOnAnyPlatform = not . 'isAbsoluteOnAnyPlatform'@
src/Distribution/Utils/MD5.hs view
@@ -1,24 +1,26 @@-module Distribution.Utils.MD5 (-    MD5,-    showMD5,-    md5,+module Distribution.Utils.MD5+  ( MD5+  , showMD5+  , md5+     -- * Helpers-    md5FromInteger,+  , md5FromInteger+     -- * Binary-    binaryPutMD5,-    binaryGetMD5,-    ) where+  , binaryPutMD5+  , binaryGetMD5+  ) where -import Data.Binary      (Get, Put)-import Data.Binary.Get  (getWord64le)-import Data.Binary.Put  (putWord64le)-import Data.Bits        (complement, shiftR, (.&.))-import Foreign.Ptr      (castPtr)-import GHC.Fingerprint  (Fingerprint (..), fingerprintData)-import Numeric          (showHex)+import Data.Binary (Get, Put)+import Data.Binary.Get (getWord64le)+import Data.Binary.Put (putWord64le)+import Data.Bits (complement, shiftR, (.&.))+import Foreign.Ptr (castPtr)+import GHC.Fingerprint (Fingerprint (..), fingerprintData)+import Numeric (showHex) import System.IO.Unsafe (unsafeDupablePerformIO) -import qualified Data.ByteString        as BS+import qualified Data.ByteString as BS import qualified Data.ByteString.Unsafe as BS  type MD5 = Fingerprint@@ -33,7 +35,8 @@ -- -- @since  3.2.0.0 showMD5 :: MD5 -> String-showMD5 (Fingerprint a b) = pad a' ++ pad b' where+showMD5 (Fingerprint a b) = pad a' ++ pad b'+  where     a' = showHex a ""     b' = showHex b ""     pad s = replicate (16 - length s) '0' ++ s@@ -41,20 +44,20 @@ -- | @since  3.2.0.0 md5 :: BS.ByteString -> MD5 md5 bs = unsafeDupablePerformIO $ BS.unsafeUseAsCStringLen bs $ \(ptr, len) ->-    fingerprintData (castPtr ptr) len+  fingerprintData (castPtr ptr) len  -- | @since  3.2.0.0 binaryPutMD5 :: MD5 -> Put binaryPutMD5 (Fingerprint a b) = do-    putWord64le a-    putWord64le b+  putWord64le a+  putWord64le b  -- | @since  3.2.0.0 binaryGetMD5 :: Get MD5 binaryGetMD5 = do-    a <- getWord64le-    b <- getWord64le-    return (Fingerprint a b)+  a <- getWord64le+  b <- getWord64le+  return (Fingerprint a b)  -- | --@@ -73,7 +76,8 @@ -- -- @since 3.4.0.0 md5FromInteger :: Integer -> MD5-md5FromInteger i = Fingerprint hi lo where+md5FromInteger i = Fingerprint hi lo+  where     mask = complement 0-    lo   = mask .&. fromInteger i-    hi   = mask .&. fromInteger (i `shiftR` 64)+    lo = mask .&. fromInteger i+    hi = mask .&. fromInteger (i `shiftR` 64)
src/Distribution/Utils/Path.hs view
@@ -1,103 +1,533 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE StandaloneDeriving #-}-module Distribution.Utils.Path (-    -- * Symbolic path-    SymbolicPath,-    getSymbolicPath,-    sameDirectory,-    unsafeMakeSymbolicPath,-    -- * Path ends-    PackageDir,-    SourceDir,-    LicenseFile,-    IsDir,-) where+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE RoleAnnotations #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-} -import Prelude ()+module Distribution.Utils.Path+  ( -- * Symbolic path endpoints+    FileOrDir (..)+  , AllowAbsolute (..)++    -- ** Abstract directory locations+  , CWD+  , Pkg+  , Dist+  , Source+  , Include+  , Lib+  , Framework+  , Build+  , Artifacts+  , PkgDB+  , DataDir+  , Mix+  , Tix+  , Tmp+  , Response+  , PkgConf++    -- * Symbolic paths+  , RelativePath+  , SymbolicPath+  , AbsolutePath (..)+  , SymbolicPathX -- NB: constructor not exposed, to retain type safety.+  , FileLike (..)+  , PathLike (..)++    -- ** Symbolic path API+  , getSymbolicPath+  , getAbsolutePath+  , sameDirectory+  , makeRelativePathEx+  , makeSymbolicPath+  , unsafeMakeSymbolicPath+  , coerceSymbolicPath+  , unsafeCoerceSymbolicPath+  , relativeSymbolicPath+  , symbolicPathRelative_maybe+  , interpretSymbolicPath+  , interpretSymbolicPathAbsolute++    -- ** General filepath API+  , takeDirectorySymbolicPath+  , dropExtensionsSymbolicPath+  , replaceExtensionSymbolicPath+  , normaliseSymbolicPath++    -- ** Working directory handling+  , interpretSymbolicPathCWD+  , absoluteWorkingDir+  , tryMakeRelative++    -- ** Module names+  , moduleNameSymbolicPath+  ) where+ import Distribution.Compat.Prelude+import Prelude () +import Data.Coerce++import Distribution.ModuleName (ModuleName)+import qualified Distribution.ModuleName as ModuleName+  ( toFilePath+  ) import Distribution.Parsec import Distribution.Pretty import Distribution.Utils.Generic (isAbsoluteOnAnyPlatform)  import qualified Distribution.Compat.CharParsing as P--- import qualified Text.PrettyPrint                as Disp +import qualified System.Directory as Directory+import qualified System.FilePath as FilePath++import Data.Kind+  ( Type+  )+import GHC.Stack+  ( HasCallStack+  )+ -------------------------------------------------------------------------------+ -- * SymbolicPath+ ------------------------------------------------------------------------------- --- | Symbolic paths.+{- Note [Symbolic paths]+~~~~~~~~~~~~~~~~~~~~~~~~+We want functions within the Cabal library to support getting the working+directory from their arguments, rather than retrieving it from the current+directory, which depends on the the state of the current process+(via getCurrentDirectory).++With such a constraint, to ensure correctness we need to know, for each relative+filepath, whether it is relative to the passed in working directory or to the+current working directory. We achieve this with the following API:++  - newtype SymbolicPath from to+  - getSymbolicPath :: SymbolicPath from to -> FilePath+  - interpretSymbolicPath+      :: Maybe (SymbolicPath CWD (Dir from)) -> SymbolicPath from to -> FilePath++Note that, in the type @SymbolicPath from to@, @from@ is the name of a directory,+whereas @to@ is either @Dir toDir@ or @File@. For example, a source directory+typically has the type @SymbolicPath Pkg (Dir Source)@, while a source+file has a type such as @SymbolicPath "Source" File@.++Here, a symbolic path refers to an **uninterpreted** file path, i.e. any+passed in working directory **has not** been taken into account.+Whenever we see a symbolic path, it is a sign we must take into account this+working directory in some way.+Thus, whenever we interact with the file system, we do the following:++  - in a direct interaction (e.g. `doesFileExist`), we interpret the+    path relative to a working directory argument, e.g.++      doCheck :: Maybe (SymbolicPath CWD (Dir from))+              -> SymbolicPath from File+              -> Bool+      doCheck mbWorkDir file = doesFileExist $ interpretSymbolicPath mbWorkDir file++  - when invoking a sub-process (such as GHC), we ensure that the working directory+    of the sub-process is the same as the passed-in working directory, in which+    case we interpret the symbolic paths by using `interpretSymbolicPathCWD`:++      callGhc :: Maybe (SymbolicPath CWD (Dir Pkg))+              -> SymbolicPath (Dir Pkg) File+              -> IO ()+      callGhc mbWorkDir inputFile =+        runProgramInvocation $+          programInvocationCwd mbWorkDir ghcProg [interpretSymbolicPathCWD inputFile]++In practice, we often use:++  -- Interpret a symbolic path with respect to the working directory argument+  -- @'mbWorkDir' :: Maybe (SymbolicPath CWD (Dir Pkg))@.+  i :: SymbolicPath Pkg to -> FilePath+  i = interpretSymbolicPath mbWorkDir++  -- Interpret a symbolic path, provided that the current working directory+  -- is the package directory.+  u :: SymbolicPath Pkg to -> FilePath+  u = interpretSymbolicPathCWD++Note [Symbolic relative paths]+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+This module defines:++  data kind AllowAbsolute = AllowAbsolute | OnlyRelative+  data kind FileOrDir = File | Dir Symbol++  type SymbolicPathX :: AllowAbsolute -> Symbol -> FileOrDir -> Type+  newtype SymbolicPathX allowAbsolute from to = SymbolicPath FilePath++  type RelativePath = SymbolicPathX 'OnlyRelative+  type SymbolicPath = SymbolicPathX 'AllowAbsolute++A 'SymbolicPath' is thus a symbolic path that is allowed to be absolute, whereas+a 'RelativePath' is a symbolic path that is additionally required to be relative.++This distinction allows us to keep track of which filepaths must be kept+relative.+-}++-- | A type-level symbolic name, to an abstract file or directory+-- (e.g. the Cabal package directory).+data FileOrDir+  = -- | A file (with no further information).+    File+  | -- | The abstract name of a directory or category of directories,+    -- e.g. the package directory or a source directory.+    Dir Type++-- | Is this symbolic path allowed to be absolute, or must it be relative?+data AllowAbsolute+  = -- | The path may be absolute, or it may be relative.+    AllowAbsolute+  | -- | The path must be relative.+    OnlyRelative++-- | A symbolic path, possibly relative to an abstract location specified+-- by the @from@ type parameter. ----- These paths are system independent and relative.--- They are *symbolic* which means we cannot perform any 'IO'--- until we interpret them.+-- They are *symbolic*, which means we cannot perform any 'IO'+-- until we interpret them (using e.g. 'interpretSymbolicPath').+newtype SymbolicPathX (allowAbsolute :: AllowAbsolute) (from :: Type) (to :: FileOrDir)+  = SymbolicPath FilePath+  deriving (Generic, Show, Read, Eq, Ord, Data)++type role SymbolicPathX nominal nominal nominal++-- | A symbolic relative path, relative to an abstract location specified+-- by the @from@ type parameter. ---newtype SymbolicPath from to = SymbolicPath FilePath-  deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)+-- They are *symbolic*, which means we cannot perform any 'IO'+-- until we interpret them (using e.g. 'interpretSymbolicPath').+type RelativePath = SymbolicPathX 'OnlyRelative -instance Binary (SymbolicPath from to)-instance (Typeable from, Typeable to) => Structured (SymbolicPath from to)-instance NFData (SymbolicPath from to) where rnf = genericRnf+-- | A symbolic path which is allowed to be absolute.+--+-- They are *symbolic*, which means we cannot perform any 'IO'+-- until we interpret them (using e.g. 'interpretSymbolicPath').+type SymbolicPath = SymbolicPathX 'AllowAbsolute --- | Extract underlying 'FilePath'.+newtype AbsolutePath (to :: FileOrDir) = AbsolutePath (forall from. SymbolicPath from to)++unsafeMakeAbsolutePath :: FilePath -> AbsolutePath to+unsafeMakeAbsolutePath fp = AbsolutePath (makeSymbolicPath fp)++instance Binary (SymbolicPathX allowAbsolute from to)+instance+  (Typeable allowAbsolute, Typeable from, Typeable to)+  => Structured (SymbolicPathX allowAbsolute from to)+instance NFData (SymbolicPathX allowAbsolute from to) where rnf = genericRnf++-- | Extract the 'FilePath' underlying a 'SymbolicPath' or 'RelativePath',+-- without interpreting it. ----- Avoid using this in new code.+-- Use this function e.g. to validate the underlying filepath. ---getSymbolicPath :: SymbolicPath from to -> FilePath+-- When interacting with the file system, you should instead use+-- 'interpretSymbolicPath' or 'interpretSymbolicPathCWD'.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+getSymbolicPath :: SymbolicPathX allowAbsolute from to -> FilePath getSymbolicPath (SymbolicPath p) = p -sameDirectory :: (IsDir from, IsDir to) => SymbolicPath from to+-- | A symbolic path from a directory to itself.+sameDirectory :: SymbolicPathX allowAbsolute from (Dir to) sameDirectory = SymbolicPath "." --- | Make 'SymbolicPath' without performing any checks.-unsafeMakeSymbolicPath :: FilePath -> SymbolicPath from to-unsafeMakeSymbolicPath = SymbolicPath+-- | Make a 'RelativePath', ensuring the path is not absolute,+-- but performing no further checks.+makeRelativePathEx :: HasCallStack => FilePath -> RelativePath from to+makeRelativePathEx fp+  | isAbsoluteOnAnyPlatform fp =+      error $ "Cabal internal error: makeRelativePathEx: absolute path " ++ fp+  | otherwise =+      SymbolicPath fp +-- | Make a 'SymbolicPath', which may be relative or absolute.+makeSymbolicPath :: FilePath -> SymbolicPath from to+makeSymbolicPath fp = SymbolicPath fp++-- | Make a 'SymbolicPath' which may be relative or absolute,+-- without performing any checks.+--+-- Avoid using this function in new code.+unsafeMakeSymbolicPath :: FilePath -> SymbolicPathX allowAbs from to+unsafeMakeSymbolicPath fp = SymbolicPath fp++-- | Like 'System.FilePath.takeDirectory', for symbolic paths.+takeDirectorySymbolicPath :: SymbolicPathX allowAbsolute from File -> SymbolicPathX allowAbsolute from (Dir to')+takeDirectorySymbolicPath (SymbolicPath fp) = SymbolicPath (FilePath.takeDirectory fp)++-- | Like 'System.FilePath.dropExtensions', for symbolic paths.+dropExtensionsSymbolicPath :: SymbolicPathX allowAbsolute from File -> SymbolicPathX allowAbsolute from File+dropExtensionsSymbolicPath (SymbolicPath fp) = SymbolicPath (FilePath.dropExtensions fp)++-- | Like 'System.FilePath.replaceExtension', for symbolic paths.+replaceExtensionSymbolicPath :: SymbolicPathX allowAbsolute from File -> String -> SymbolicPathX allowAbsolute from File+replaceExtensionSymbolicPath (SymbolicPath fp) ext = SymbolicPath (FilePath.replaceExtension fp ext)++-- | Like 'System.FilePath.normalise', for symbolic paths.+normaliseSymbolicPath :: SymbolicPathX allowAbsolute from to -> SymbolicPathX allowAbsolute from to+normaliseSymbolicPath (SymbolicPath fp) = SymbolicPath (FilePath.normalise fp)++-- | Retrieve the relative symbolic path to a Haskell module.+moduleNameSymbolicPath :: ModuleName -> SymbolicPathX allowAbsolute Source File+moduleNameSymbolicPath modNm = SymbolicPath $ ModuleName.toFilePath modNm++-- | Interpret a symbolic path with respect to the given directory.+--+-- Use this function before directly interacting with the file system in order+-- to take into account a working directory argument.+--+-- NB: when invoking external programs (such as @GHC@), it is preferable to set+-- the working directory of the process and use 'interpretSymbolicPathCWD'+-- rather than calling this function, as this function will turn relative paths+-- into absolute paths if the working directory is an absolute path.+-- This can degrade error messages, or worse, break the behaviour entirely+-- (because the program might expect certain paths to be relative).+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+interpretSymbolicPath :: Maybe (SymbolicPath CWD (Dir from)) -> SymbolicPathX allowAbsolute from to -> FilePath+interpretSymbolicPath mbWorkDir (SymbolicPath p) =+  -- Note that this properly handles an absolute symbolic path,+  -- because if @q@ is absolute, then @p </> q = q@.+  maybe p ((</> p) . getSymbolicPath) mbWorkDir++-- | Interpret a symbolic path, **under the assumption that the working+-- directory is the package directory**.+--+-- Use 'interpretSymbolicPath' instead if you need to take into account a+-- working directory argument before directly interacting with the file system.+--+-- Use this function instead of 'interpretSymbolicPath' when invoking a child+-- process: set the working directory of the sub-process, and use this function,+-- e.g.:+--+-- > callGhc :: Maybe (SymbolicPath CWD (Dir Pkg))+-- >         -> SymbolicPath (Dir Pkg) File+-- >         -> IO ()+-- > callGhc mbWorkDir inputFile =+-- >   runProgramInvocation $+-- >     programInvocationCwd mbWorkDir ghcProg [interpretSymbolicPathCWD inputFile]+--+-- In this example, 'programInvocationCwd' sets the working directory, so it is+-- appropriate to use 'interpretSymbolicPathCWD' to provide its arguments.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+interpretSymbolicPathCWD :: SymbolicPathX allowAbsolute from to -> FilePath+interpretSymbolicPathCWD (SymbolicPath p) = p++getAbsolutePath :: AbsolutePath to -> FilePath+getAbsolutePath (AbsolutePath p) = getSymbolicPath p++interpretSymbolicPathAbsolute :: AbsolutePath (Dir Pkg) -> SymbolicPathX allowAbsolute Pkg to -> FilePath+interpretSymbolicPathAbsolute (AbsolutePath p) sym = interpretSymbolicPath (Just p) sym++-- | Change what a symbolic path is pointing to.+coerceSymbolicPath :: SymbolicPathX allowAbsolute from to1 -> SymbolicPathX allowAbsolute from to2+coerceSymbolicPath = coerce++-- | Change both what a symbolic path is pointing from and pointing to.+--+-- Avoid using this in new code.+unsafeCoerceSymbolicPath :: SymbolicPathX allowAbsolute from1 to1 -> SymbolicPathX allowAbsolute from2 to2+unsafeCoerceSymbolicPath = coerce++-- | Weakening: convert a relative symbolic path to a symbolic path,+-- \"forgetting\" that it is relative.+relativeSymbolicPath :: RelativePath from to -> SymbolicPath from to+relativeSymbolicPath (SymbolicPath fp) = SymbolicPath fp++-- | Is this symbolic path a relative symbolic path?+symbolicPathRelative_maybe :: SymbolicPath from to -> Maybe (RelativePath from to)+symbolicPathRelative_maybe (SymbolicPath fp) =+  if isAbsoluteOnAnyPlatform fp+    then Nothing+    else Just $ SymbolicPath fp++-- | Absolute path to the current working directory.+absoluteWorkingDir :: Maybe (SymbolicPath CWD to) -> IO (AbsolutePath to)+absoluteWorkingDir Nothing = unsafeMakeAbsolutePath <$> Directory.getCurrentDirectory+absoluteWorkingDir (Just wd) = unsafeMakeAbsolutePath <$> Directory.makeAbsolute (getSymbolicPath wd)++-- | Try to make a symbolic path relative.+--+-- This function does nothing if the path is already relative.+--+-- NB: this function may fail to make the path relative.+tryMakeRelative :: Maybe (SymbolicPath CWD (Dir dir)) -> SymbolicPath dir to -> IO (SymbolicPath dir to)+tryMakeRelative mbWorkDir (SymbolicPath fp) = do+  AbsolutePath wd <- absoluteWorkingDir mbWorkDir+  return $ SymbolicPath (FilePath.makeRelative (getSymbolicPath wd) fp)+ -------------------------------------------------------------------------------+ -- ** Parsing and pretty printing+ ------------------------------------------------------------------------------- -instance Parsec (SymbolicPath from to) where-    parsec = do-        token <- parsecToken-        if null token then P.unexpected "empty FilePath"-        else if isAbsoluteOnAnyPlatform token then P.unexpected "absolute FilePath"-        else return (SymbolicPath token) -- TODO: normalise+instance Parsec (SymbolicPathX 'OnlyRelative from to) where+  parsec = do+    token <- parsecToken+    if null token+      then P.unexpected "empty FilePath"+      else+        if isAbsoluteOnAnyPlatform token+          then P.unexpected "absolute FilePath"+          else return (SymbolicPath token) -instance Pretty (SymbolicPath from to) where-    pretty = showFilePath . getSymbolicPath+instance Parsec (SymbolicPathX 'AllowAbsolute from to) where+  parsec = do+    token <- parsecToken+    if null token+      then P.unexpected "empty FilePath"+      else return (SymbolicPath token) +instance Pretty (SymbolicPathX allowAbsolute from to) where+  pretty = showFilePath . getSymbolicPath+ -------------------------------------------------------------------------------+ -- * Composition+ ------------------------------------------------------------------------------- --- TODO--- infixr 5 <//>+infixr 7 <.>++-- | Types that support 'System.FilePath.<.>'.+class FileLike p where+  -- | Like 'System.FilePath.<.>', but also supporting symbolic paths.+  (<.>) :: p -> String -> p++instance FileLike FilePath where+  (<.>) = (FilePath.<.>)++instance p ~ File => FileLike (SymbolicPathX allowAbsolute dir p) where+  SymbolicPath p <.> ext = SymbolicPath (p <.> ext)++infixr 5 </>++-- | Types that support 'System.FilePath.</>'.+class PathLike p q r | q r -> p, p r -> q, p q -> r where+  -- | Like 'System.FilePath.</>', but also supporting symbolic paths.+  (</>) :: p -> q -> r++instance PathLike FilePath FilePath FilePath where+  (</>) = (FilePath.</>)++-- | This instance ensures we don't accidentally discard a symbolic path+-- in a 'System.FilePath.</>' operation due to the second path being absolute. ----- -- | Path composition--- ----- -- We don't reuse @</>@ name to not clash with "System.FilePath".--- ----- (<//>) :: path a b -> path b c -> path a c+-- (Recall that @a </> b = b@ whenever @b@ is absolute.)+instance+  (b1 ~ 'Dir b2, a3 ~ a1, c2 ~ c3, midAbsolute ~ OnlyRelative)+  => PathLike+      (SymbolicPathX allowAbsolute a1 b1)+      (SymbolicPathX midAbsolute b2 c2)+      (SymbolicPathX allowAbsolute a3 c3)+  where+  SymbolicPath p1 </> SymbolicPath p2 = SymbolicPath (p1 </> p2) ----------------------------------------------------------------------------------- * Path ends--------------------------------------------------------------------------------+instance+  (b1 ~ 'Dir b2, c2 ~ c3, midAbsolute ~ OnlyRelative)+  => PathLike+      (AbsolutePath b1)+      (SymbolicPathX midAbsolute b2 c2)+      (AbsolutePath c3)+  where+  AbsolutePath (SymbolicPath p1) </> SymbolicPath p2 =+    unsafeMakeAbsolutePath (p1 </> p2) --- | Class telling that index is for directories.-class IsDir dir+--------------------------------------------------------------------------------+-- Abstract directory locations. -data PackageDir deriving (Typeable)-data SourceDir  deriving (Typeable)+-- | Abstract directory: current working directory.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data CWD -data LicenseFile deriving (Typeable)+-- | Abstract directory: package directory (e.g. a directory containing the @.cabal@ file).+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Pkg --- These instances needs to be derived standalone at least on GHC-7.6-deriving instance Data PackageDir-deriving instance Data SourceDir-deriving instance Data LicenseFile+-- | Abstract directory: dist directory (e.g. @dist-newstyle@).+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Dist -instance IsDir PackageDir-instance IsDir SourceDir+-- | Abstract directory: source directory (a search directory for source files).+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Source++-- | Abstract directory: include directory (a search directory for CPP includes like header files, e.g. with @ghc -I@).+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Include++-- | Abstract directory: search directory for extra libraries.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Lib++-- | Abstract directory: MacOS framework directory.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Framework++-- | Abstract directory: build directory.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Build++-- | Abstract directory: directory for build artifacts, such as documentation or @.hie@ files.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Artifacts++-- | Abstract directory: package database directory.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data PkgDB++-- | Abstract directory: data files directory.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data DataDir++-- | Abstract directory: directory for HPC @.mix@ files.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Mix++-- | Abstract directory: directory for HPC @.tix@ files.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Tix++-- | Abstract directory: a temporary directory.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Tmp++-- | Abstract directory: directory for response files.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data Response++-- | Abstract directory: directory for pkg-config files.+--+-- See Note [Symbolic paths] in Distribution.Utils.Path.+data PkgConf
src/Distribution/Utils/ShortText.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE CPP                #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE DeriveGeneric #-}  -- | Compact representation of short 'Strings' --@@ -11,25 +11,25 @@ -- import qualified Distribution.Utils.ShortText as ShortText -- @ module Distribution.Utils.ShortText-    ( -- * 'ShortText' type-      ShortText-    , toShortText-    , fromShortText-    , unsafeFromUTF8BS+  ( -- * 'ShortText' type+    ShortText+  , toShortText+  , fromShortText+  , unsafeFromUTF8BS -      -- * Operations-    , null-    , length+    -- * Operations+  , null+  , length -      -- * internal utilities-    , decodeStringUtf8-    , encodeStringUtf8-    ) where+    -- * internal utilities+  , decodeStringUtf8+  , encodeStringUtf8+  ) where  import Distribution.Compat.Prelude hiding (length, null) import Prelude () -import Distribution.Utils.String     (decodeStringUtf8, encodeStringUtf8)+import Distribution.Utils.String (decodeStringUtf8, encodeStringUtf8) import Distribution.Utils.Structured (Structured (..), nominalStructure)  #if defined(MIN_VERSION_bytestring)@@ -56,7 +56,7 @@ #endif  import qualified Data.ByteString as BS-import qualified Data.List       as List+import qualified Data.List as List  #if HAVE_SHORTBYTESTRING import qualified Data.ByteString.Short as BS.Short@@ -93,7 +93,7 @@ -- @since 2.0.0.2 #if HAVE_SHORTBYTESTRING newtype ShortText = ST { unST :: BS.Short.ShortByteString }-                  deriving (Eq,Ord,Generic,Data,Typeable)+                  deriving (Eq,Ord,Generic,Data)  # if MIN_VERSION_binary(0,8,1) instance Binary ShortText where@@ -115,7 +115,7 @@ null = BS.Short.null . unST #else newtype ShortText = ST { unST :: String }-                  deriving (Eq,Ord,Generic,Data,Typeable)+                  deriving (Eq,Ord,Generic,Data)  instance Binary ShortText where     put = put . encodeStringUtf8 . unST@@ -133,27 +133,28 @@ instance Structured ShortText where structure = nominalStructure  instance NFData ShortText where-    rnf = rnf . unST+  rnf = rnf . unST  instance Show ShortText where-    show = show . fromShortText+  show = show . fromShortText  instance Read ShortText where-    readsPrec p = map (first toShortText) . readsPrec p+  readsPrec p = map (first toShortText) . readsPrec p  instance Semigroup ShortText where-    ST a <> ST b = ST (mappend a b)+  ST a <> ST b = ST (mappend a b)  instance Monoid ShortText where-    mempty = ST mempty-    mappend = (<>)+  mempty = ST mempty+  mappend = (<>)  instance IsString ShortText where-    fromString = toShortText+  fromString = toShortText  -- | /O(n)/. Length in characters. /Slow/ as converts to string. -- -- @since 3.2.0.0 length :: ShortText -> Int length = List.length . fromShortText+ -- Note: avoid using it, we use it @cabal check@ implementation, where it's ok.
src/Distribution/Utils/String.hs view
@@ -1,14 +1,14 @@ module Distribution.Utils.String-    ( -- * Encode to/from UTF8-      decodeStringUtf8-    , encodeStringUtf8-    , trim-    ) where+  ( -- * Encode to/from UTF8+    decodeStringUtf8+  , encodeStringUtf8+  , trim+  ) where -import Data.Word import Data.Bits-import Data.Char (chr,ord)+import Data.Char (chr, ord) import Data.List (dropWhileEnd)+import Data.Word import GHC.Unicode (isSpace)  -- | Decode 'String' from UTF8-encoded octets.@@ -21,46 +21,48 @@ decodeStringUtf8 = go   where     go :: [Word8] -> String-    go []       = []+    go [] = []     go (c : cs)       | c <= 0x7F = chr (fromIntegral c) : go cs       | c <= 0xBF = replacementChar : go cs       | c <= 0xDF = twoBytes c cs-      | c <= 0xEF = moreBytes 3 0x800     cs (fromIntegral $ c .&. 0xF)-      | c <= 0xF7 = moreBytes 4 0x10000   cs (fromIntegral $ c .&. 0x7)-      | c <= 0xFB = moreBytes 5 0x200000  cs (fromIntegral $ c .&. 0x3)+      | c <= 0xEF = moreBytes 3 0x800 cs (fromIntegral $ c .&. 0xF)+      | c <= 0xF7 = moreBytes 4 0x10000 cs (fromIntegral $ c .&. 0x7)+      | c <= 0xFB = moreBytes 5 0x200000 cs (fromIntegral $ c .&. 0x3)       | c <= 0xFD = moreBytes 6 0x4000000 cs (fromIntegral $ c .&. 0x1)-      | otherwise   = replacementChar : go cs+      | otherwise = replacementChar : go cs      twoBytes :: Word8 -> [Word8] -> String-    twoBytes c0 (c1:cs')-      | c1 .&. 0xC0 == 0x80-      = let d = (fromIntegral (c0 .&. 0x1F) `shiftL` 6)-             .|. fromIntegral (c1 .&. 0x3F)-         in if d >= 0x80-               then  chr d                : go cs'-               else  replacementChar      : go cs'-    twoBytes _ cs' = replacementChar      : go cs'+    twoBytes c0 (c1 : cs')+      | c1 .&. 0xC0 == 0x80 =+          let d =+                (fromIntegral (c0 .&. 0x1F) `shiftL` 6)+                  .|. fromIntegral (c1 .&. 0x3F)+           in if d >= 0x80+                then chr d : go cs'+                else replacementChar : go cs'+    twoBytes _ cs' = replacementChar : go cs'      moreBytes :: Int -> Int -> [Word8] -> Int -> [Char]     moreBytes 1 overlong cs' acc-      | overlong <= acc, acc <= 0x10FFFF, acc < 0xD800 || 0xDFFF < acc-      = chr acc : go cs'--      | otherwise-      = replacementChar : go cs'--    moreBytes byteCount overlong (cn:cs') acc-      | cn .&. 0xC0 == 0x80-      = moreBytes (byteCount-1) overlong cs'-          ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)--    moreBytes _ _ cs' _-      = replacementChar : go cs'+      | overlong <= acc+      , acc <= 0x10FFFF+      , acc < 0xD800 || 0xDFFF < acc =+          chr acc : go cs'+      | otherwise =+          replacementChar : go cs'+    moreBytes byteCount overlong (cn : cs') acc+      | cn .&. 0xC0 == 0x80 =+          moreBytes+            (byteCount - 1)+            overlong+            cs'+            ((acc `shiftL` 6) .|. fromIntegral cn .&. 0x3F)+    moreBytes _ _ cs' _ =+      replacementChar : go cs'      replacementChar = '\xfffd' - -- | Encode 'String' to a list of UTF8-encoded octets -- -- Code-points in the @U+D800@-@U+DFFF@ range will be encoded@@ -68,28 +70,36 @@ -- -- See also 'decodeUtf8' encodeStringUtf8 :: String -> [Word8]-encodeStringUtf8 []        = []-encodeStringUtf8 (c:cs)-  | c <= '\x07F' = w8-                 : encodeStringUtf8 cs-  | c <= '\x7FF' = (0xC0 .|.  w8ShiftR  6          )-                 : (0x80 .|. (w8          .&. 0x3F))-                 : encodeStringUtf8 cs-  | c <= '\xD7FF'= (0xE0 .|.  w8ShiftR 12          )-                 : (0x80 .|. (w8ShiftR  6 .&. 0x3F))-                 : (0x80 .|. (w8          .&. 0x3F))-                 : encodeStringUtf8 cs-  | c <= '\xDFFF'= 0xEF : 0xBF : 0xBD -- U+FFFD-                 : encodeStringUtf8 cs-  | c <= '\xFFFF'= (0xE0 .|.  w8ShiftR 12          )-                 : (0x80 .|. (w8ShiftR  6 .&. 0x3F))-                 : (0x80 .|. (w8          .&. 0x3F))-                 : encodeStringUtf8 cs-  | otherwise    = (0xf0 .|.  w8ShiftR 18          )-                 : (0x80 .|. (w8ShiftR 12 .&. 0x3F))-                 : (0x80 .|. (w8ShiftR  6 .&. 0x3F))-                 : (0x80 .|. (w8          .&. 0x3F))-                 : encodeStringUtf8 cs+encodeStringUtf8 [] = []+encodeStringUtf8 (c : cs)+  | c <= '\x07F' =+      w8+        : encodeStringUtf8 cs+  | c <= '\x7FF' =+      (0xC0 .|. w8ShiftR 6)+        : (0x80 .|. (w8 .&. 0x3F))+        : encodeStringUtf8 cs+  | c <= '\xD7FF' =+      (0xE0 .|. w8ShiftR 12)+        : (0x80 .|. (w8ShiftR 6 .&. 0x3F))+        : (0x80 .|. (w8 .&. 0x3F))+        : encodeStringUtf8 cs+  | c <= '\xDFFF' =+      0xEF+        : 0xBF+        : 0xBD -- U+FFFD+        : encodeStringUtf8 cs+  | c <= '\xFFFF' =+      (0xE0 .|. w8ShiftR 12)+        : (0x80 .|. (w8ShiftR 6 .&. 0x3F))+        : (0x80 .|. (w8 .&. 0x3F))+        : encodeStringUtf8 cs+  | otherwise =+      (0xf0 .|. w8ShiftR 18)+        : (0x80 .|. (w8ShiftR 12 .&. 0x3F))+        : (0x80 .|. (w8ShiftR 6 .&. 0x3F))+        : (0x80 .|. (w8 .&. 0x3F))+        : encodeStringUtf8 cs   where     w8 = fromIntegral (ord c) :: Word8     w8ShiftR :: Int -> Word8
src/Distribution/Utils/Structured.hs view
@@ -1,12 +1,13 @@-{-# LANGUAGE CPP                 #-}-{-# LANGUAGE DefaultSignatures   #-}-{-# LANGUAGE DeriveGeneric       #-}-{-# LANGUAGE FlexibleContexts    #-}-{-# LANGUAGE PolyKinds           #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies        #-}-{-# LANGUAGE TypeOperators       #-}-{-# LANGUAGE PatternSynonyms     #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+ -- | -- -- Copyright: (c) 2019 Oleg Grenrus@@ -38,42 +39,44 @@ -- -- Technically, 'Structured' is not related to 'Binary', and may -- be useful in other uses.----module Distribution.Utils.Structured (-    -- * Encoding and decoding+module Distribution.Utils.Structured+  ( -- * Encoding and decoding+     -- | These functions operate like @binary@'s counterparts,     -- but the serialised version has a structure hash in front.-    structuredEncode,-    structuredEncodeFile,-    structuredDecode,-    structuredDecodeOrFailIO,-    structuredDecodeFileOrFail,+    structuredEncode+  , structuredEncodeFile+  , structuredDecode+  , structuredDecodeOrFailIO+  , structuredDecodeFileOrFail+     -- * Structured class-    Structured (structure),-    MD5,-    structureHash,-    structureBuilder,-    genericStructure,-    GStructured,-    nominalStructure,-    containerStructure,+  , Structured (structure)+  , MD5+  , structureHash+  , structureBuilder+  , genericStructure+  , GStructured+  , nominalStructure+  , containerStructure+     -- * Structure type-    Structure (..),-    Tag (..),-    TypeName,-    ConstructorName,-    TypeVersion,-    SopStructure,-    hashStructure,-    typeVersion,-    typeName,-    ) where+  , Structure (..)+  , Tag (..)+  , TypeName+  , ConstructorName+  , TypeVersion+  , SopStructure+  , hashStructure+  , typeVersion+  , typeName+  ) where -import Data.Int           (Int16, Int32, Int64, Int8)+import Data.Int (Int16, Int32, Int64, Int8) import Data.List.NonEmpty (NonEmpty)-import Data.Proxy         (Proxy (..))-import Data.Ratio         (Ratio)-import Data.Word          (Word, Word16, Word32, Word64, Word8)+import Data.Proxy (Proxy (..))+import Data.Ratio (Ratio)+import Data.Word (Word, Word16, Word32, Word64, Word8)  import qualified Control.Monad.Trans.State.Strict as State @@ -81,57 +84,58 @@  import GHC.Generics -import qualified Data.ByteString              as BS-import qualified Data.ByteString.Lazy         as LBS+import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as LBS #if MIN_VERSION_bytestring(0,10,4) import qualified Data.ByteString.Builder      as Builder #else import qualified Data.ByteString.Lazy.Builder as Builder #endif-import qualified Data.IntMap                  as IM-import qualified Data.IntSet                  as IS-import qualified Data.Map                     as Map-import qualified Data.Sequence                as Seq-import qualified Data.Set                     as Set-import qualified Data.Text                    as T-import qualified Data.Text.Lazy               as LT-import qualified Data.Time                    as Time-import qualified Distribution.Compat.Binary   as Binary+import qualified Data.IntMap as IM+import qualified Data.IntSet as IS+import qualified Data.Map as Map+import qualified Data.Sequence as Seq+import qualified Data.Set as Set+import qualified Data.Text as T+import qualified Data.Text.Lazy as LT+import qualified Data.Time as Time+import qualified Distribution.Compat.Binary as Binary  #ifdef MIN_VERSION_aeson import qualified Data.Aeson as Aeson #endif  import Data.Kind (Type)+import Data.Typeable (TypeRep, Typeable, typeRep) -import Distribution.Compat.Typeable (Typeable, TypeRep, typeRep) import Distribution.Utils.MD5 -import Data.Monoid (mconcat)+import Data.Monoid (Last, mconcat) -import qualified Data.Semigroup import qualified Data.Foldable-+import qualified Data.Semigroup  ------------------------------------------------------------------------------- -- Types ------------------------------------------------------------------------------- -type TypeName        = String+type TypeName = String type ConstructorName = String  -- | A semantic version of a data type. Usually 0.-type TypeVersion     = Word32+type TypeVersion = Word32  -- | Structure of a datatype. -- -- It can be infinite, as far as 'TypeRep's involved are finite. -- (e.g. polymorphic recursion might cause troubles).--- data Structure-    = Nominal   !TypeRep !TypeVersion TypeName [Structure]  -- ^ nominal, yet can be parametrised by other structures.-    | Newtype   !TypeRep !TypeVersion TypeName Structure    -- ^ a newtype wrapper-    | Structure !TypeRep !TypeVersion TypeName SopStructure -- ^ sum-of-products structure+  = -- | nominal, yet can be parametrised by other structures.+    Nominal !TypeRep !TypeVersion TypeName [Structure]+  | -- | a newtype wrapper+    Newtype !TypeRep !TypeVersion TypeName Structure+  | -- | sum-of-products structure+    Structure !TypeRep !TypeVersion TypeName SopStructure   deriving (Eq, Ord, Show, Generic)  type SopStructure = [(ConstructorName, [Structure])]@@ -146,8 +150,8 @@ -- 'typeVersion' :: Lens' 'Structure' 'TypeVersion' -- @ typeVersion :: Functor f => (TypeVersion -> f TypeVersion) -> Structure -> f Structure-typeVersion f (Nominal   t v n s) = fmap (\v' -> Nominal   t v' n s) (f v)-typeVersion f (Newtype   t v n s) = fmap (\v' -> Newtype   t v' n s) (f v)+typeVersion f (Nominal t v n s) = fmap (\v' -> Nominal t v' n s) (f v)+typeVersion f (Newtype t v n s) = fmap (\v' -> Newtype t v' n s) (f v) typeVersion f (Structure t v n s) = fmap (\v' -> Structure t v' n s) (f v)  -- | A van-Laarhoven lens into 'TypeName' of 'Structure'@@ -156,8 +160,8 @@ -- 'typeName' :: Lens' 'Structure' 'TypeName' -- @ typeName :: Functor f => (TypeName -> f TypeName) -> Structure -> f Structure-typeName f (Nominal   t v n s) = fmap (\n' -> Nominal   t v n' s) (f n)-typeName f (Newtype   t v n s) = fmap (\n' -> Newtype   t v n' s) (f n)+typeName f (Nominal t v n s) = fmap (\n' -> Nominal t v n' s) (f n)+typeName f (Newtype t v n s) = fmap (\n' -> Newtype t v n' s) (f n) typeName f (Structure t v n s) = fmap (\n' -> Structure t v n' s) (f n)  -------------------------------------------------------------------------------@@ -170,45 +174,45 @@ -- 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+structureBuilder s0 = State.evalState (go s0) Map.empty+  where     go :: Structure -> State.State (Map.Map String (NonEmpty TypeRep)) Builder.Builder-    go (Nominal   t v n s) = withTypeRep t $ do-        s' <- traverse go s-        return $ mconcat $ Builder.word8 1 : Builder.word32LE v :  Builder.stringUtf8 n : s'--    go (Newtype   t v n s) = withTypeRep t $ do-        s' <- go s-        return $ mconcat [Builder.word8 2, Builder.word32LE v, Builder.stringUtf8 n, s']-+    go (Nominal t v n s) = withTypeRep t $ do+      s' <- traverse go s+      return $ mconcat $ Builder.word8 1 : Builder.word32LE v : Builder.stringUtf8 n : s'+    go (Newtype t v n s) = withTypeRep t $ do+      s' <- go s+      return $ mconcat [Builder.word8 2, Builder.word32LE v, Builder.stringUtf8 n, s']     go (Structure t v n s) = withTypeRep t $ do-        s' <- goSop s-        return $ mconcat [Builder.word8 3, Builder.word32LE v, Builder.stringUtf8 n, s']+      s' <- goSop s+      return $ mconcat [Builder.word8 3, Builder.word32LE v, Builder.stringUtf8 n, s']      withTypeRep t k = do-        acc <- State.get-        case insert t acc of-            Nothing -> return $ mconcat [ Builder.word8 0, Builder.stringUtf8 (show t) ]-            Just acc' -> do-                State.put acc'-                k+      acc <- State.get+      case insert t acc of+        Nothing -> return $ mconcat [Builder.word8 0, Builder.stringUtf8 (show t)]+        Just acc' -> do+          State.put acc'+          k      goSop :: SopStructure -> State.State (Map.Map String (NonEmpty TypeRep)) Builder.Builder     goSop sop = do-        parts <- traverse part sop-        return $ mconcat parts+      parts <- traverse part sop+      return $ mconcat parts      part (cn, s) = do-        s' <- traverse go s-        return $ Data.Monoid.mconcat [ Builder.stringUtf8 cn, mconcat s' ]+      s' <- traverse go s+      return $ Data.Monoid.mconcat [Builder.stringUtf8 cn, mconcat s']      insert :: TypeRep -> Map.Map String (NonEmpty TypeRep) -> Maybe (Map.Map String (NonEmpty TypeRep))     insert tr m = case Map.lookup trShown m of-        Nothing                              -> inserted-        Just ne | tr `Data.Foldable.elem` ne -> Nothing-                | otherwise                  -> inserted+      Nothing -> inserted+      Just ne+        | tr `Data.Foldable.elem` ne -> Nothing+        | otherwise -> inserted       where         inserted = Just (Map.insertWith (Data.Semigroup.<>) trShown (pure tr) m)-        trShown  = show tr+        trShown = show tr  ------------------------------------------------------------------------------- -- Classes@@ -224,18 +228,17 @@ -- @ -- -- @since 3.2.0.0--- class Typeable a => Structured a where-    structure :: Proxy a -> Structure-    default structure :: (Generic a, GStructured (Rep a)) => Proxy a -> Structure-    structure = genericStructure+  structure :: Proxy a -> Structure+  default structure :: (Generic a, GStructured (Rep a)) => Proxy a -> Structure+  structure = genericStructure -    -- This member is hidden. It's there to precalc-    structureHash' :: Tagged a MD5-    structureHash' = Tagged (hashStructure (structure (Proxy :: Proxy a)))+  -- This member is hidden. It's there to precalc+  structureHash' :: Tagged a MD5+  structureHash' = Tagged (hashStructure (structure (Proxy :: Proxy a)))  -- private Tagged-newtype Tagged a b = Tagged { untag :: b }+newtype Tagged a b = Tagged {untag :: b}  -- | Semantically @'hashStructure' . 'structure'@. structureHash :: forall a. Structured a => Proxy a -> MD5@@ -249,8 +252,10 @@ -- Encode a value to using binary serialisation to a lazy 'LBS.ByteString'. -- Encoding starts with 16 byte large structure hash. structuredEncode-  :: forall a. (Binary.Binary a, Structured a)-  => a -> LBS.ByteString+  :: forall a+   . (Binary.Binary a, Structured a)+  => a+  -> LBS.ByteString structuredEncode x = Binary.encode (Tag :: Tag a, x)  -- | Lazily serialise a value to a file@@ -261,15 +266,17 @@ -- Decode a value from a lazy 'LBS.ByteString', reconstructing the original structure. -- Throws pure exception on invalid inputs. structuredDecode-  :: forall a. (Binary.Binary a, Structured a)-  => LBS.ByteString -> a+  :: forall a+   . (Binary.Binary a, Structured a)+  => LBS.ByteString+  -> a structuredDecode lbs = snd (Binary.decode lbs :: (Tag a, a))  structuredDecodeOrFailIO :: (Binary.Binary a, Structured a) => LBS.ByteString -> IO (Either String a) structuredDecodeOrFailIO bs =-    catch (evaluate (structuredDecode bs) >>= return . Right) handler+  catch (evaluate (structuredDecode bs) >>= return . Right) handler   where-    handler (ErrorCallWithLocation str _) = return $ Left str+    handler (ErrorCall str) = return $ Left str  -- | Lazily reconstruct a value previously written to a file. structuredDecodeFileOrFail :: (Binary.Binary a, Structured a) => FilePath -> IO (Either String a)@@ -282,22 +289,24 @@ data Tag a = Tag  instance Structured a => Binary.Binary (Tag a) where-    get = do-        actual <- binaryGetMD5-        if actual == expected-        then return Tag-        else fail $ concat+  get = do+    actual <- binaryGetMD5+    if actual == expected+      then return Tag+      else+        fail $+          concat             [ "Non-matching structured hashes: "             , showMD5 actual             , "; expected: "             , showMD5 expected             ]-      where-        expected = untag (structureHash' :: Tagged a MD5)+    where+      expected = untag (structureHash' :: Tagged a MD5) -    put _ = binaryPutMD5 expected-      where-        expected = untag (structureHash' :: Tagged a MD5)+  put _ = binaryPutMD5 expected+    where+      expected = untag (structureHash' :: Tagged a MD5)  ------------------------------------------------------------------------------- -- Smart constructors@@ -305,15 +314,20 @@  -- | Use 'Typeable' to infer name nominalStructure :: Typeable a => Proxy a -> Structure-nominalStructure p = Nominal tr 0 (show tr) [] where+nominalStructure p = Nominal tr 0 (show tr) []+  where     tr = typeRep p  containerStructure :: forall f a. (Typeable f, Structured a) => Proxy (f a) -> Structure-containerStructure _ = Nominal faTypeRep 0 (show fTypeRep)+containerStructure _ =+  Nominal+    faTypeRep+    0+    (show fTypeRep)     [ structure (Proxy :: Proxy a)     ]   where-    fTypeRep  = typeRep (Proxy :: Proxy f)+    fTypeRep = typeRep (Proxy :: Proxy f)     faTypeRep = typeRep (Proxy :: Proxy (f a))  -------------------------------------------------------------------------------@@ -326,50 +340,50 @@  -- | Used to implement 'genericStructure'. class GStructured (f :: Type -> Type) where-    gstructured :: TypeRep -> Proxy f -> TypeVersion -> Structure+  gstructured :: TypeRep -> Proxy f -> TypeVersion -> Structure  instance (i ~ D, Datatype c, GStructuredSum f) => GStructured (M1 i c f) where-    gstructured tr _ v = case sop of-        [(_, [s])] | isNewtype p -> Newtype tr v name s-        _                        -> Structure tr v name sop-      where-        p    = undefined :: M1 i c f ()-        name = datatypeName p-        sop  = gstructuredSum (Proxy :: Proxy f) []+  gstructured tr _ v = case sop of+    [(_, [s])] | isNewtype p -> Newtype tr v name s+    _ -> Structure tr v name sop+    where+      p = undefined :: M1 i c f ()+      name = datatypeName p+      sop = gstructuredSum (Proxy :: Proxy f) []  class GStructuredSum (f :: Type -> Type) where-    gstructuredSum :: Proxy f -> SopStructure -> SopStructure+  gstructuredSum :: Proxy f -> SopStructure -> SopStructure  instance (i ~ C, Constructor c, GStructuredProd f) => GStructuredSum (M1 i c f) where-    gstructuredSum _ xs = (name, prod) : xs-      where-        name = conName (undefined :: M1 i c f ())-        prod = gstructuredProd (Proxy :: Proxy f) []+  gstructuredSum _ xs = (name, prod) : xs+    where+      name = conName (undefined :: M1 i c f ())+      prod = gstructuredProd (Proxy :: Proxy f) []  instance (GStructuredSum f, GStructuredSum g) => GStructuredSum (f :+: g) where-    gstructuredSum _ xs-        = gstructuredSum (Proxy :: Proxy f)-        $ gstructuredSum (Proxy :: Proxy g) xs+  gstructuredSum _ xs =+    gstructuredSum (Proxy :: Proxy f) $+      gstructuredSum (Proxy :: Proxy g) xs  instance GStructuredSum V1 where-    gstructuredSum _ = id+  gstructuredSum _ = id  class GStructuredProd (f :: Type -> Type) where-    gstructuredProd :: Proxy f -> [Structure] -> [Structure]+  gstructuredProd :: Proxy f -> [Structure] -> [Structure]  instance (i ~ S, GStructuredProd f) => GStructuredProd (M1 i c f) where-    gstructuredProd _ = gstructuredProd (Proxy :: Proxy f)+  gstructuredProd _ = gstructuredProd (Proxy :: Proxy f)  instance Structured c => GStructuredProd (K1 i c) where-    gstructuredProd _ xs = structure (Proxy :: Proxy c) : xs+  gstructuredProd _ xs = structure (Proxy :: Proxy c) : xs  instance GStructuredProd U1 where-    gstructuredProd _ = id+  gstructuredProd _ = id  instance (GStructuredProd f, GStructuredProd g) => GStructuredProd (f :*: g) where-    gstructuredProd _ xs-        = gstructuredProd (Proxy :: Proxy f)-        $ gstructuredProd (Proxy :: Proxy g) xs+  gstructuredProd _ xs =+    gstructuredProd (Proxy :: Proxy f) $+      gstructuredProd (Proxy :: Proxy g) xs  ------------------------------------------------------------------------------- -- instances@@ -379,55 +393,86 @@ instance Structured Bool instance Structured Ordering -instance Structured Char    where structure = nominalStructure-instance Structured Int     where structure = nominalStructure+instance Structured Char where structure = nominalStructure+instance Structured Int where structure = nominalStructure instance Structured Integer where structure = nominalStructure  instance Structured Data.Word.Word where structure = nominalStructure -instance Structured Int8  where structure = nominalStructure+instance Structured Int8 where structure = nominalStructure instance Structured Int16 where structure = nominalStructure instance Structured Int32 where structure = nominalStructure instance Structured Int64 where structure = nominalStructure -instance Structured Word8  where structure = nominalStructure+instance Structured Word8 where structure = nominalStructure instance Structured Word16 where structure = nominalStructure instance Structured Word32 where structure = nominalStructure instance Structured Word64 where structure = nominalStructure -instance Structured Float  where structure = nominalStructure+instance Structured Float where structure = nominalStructure instance Structured Double where structure = nominalStructure  instance Structured a => Structured (Maybe a)+instance Structured a => Structured (Last a) instance (Structured a, Structured b) => Structured (Either a b) instance Structured a => Structured (Ratio a) where structure = containerStructure instance Structured a => Structured [a] where structure = containerStructure instance Structured a => Structured (NonEmpty a) where structure = containerStructure -instance (Structured a1, Structured a2) => Structured (a1, a2)-instance (Structured a1, Structured a2, Structured a3) => Structured (a1, a2, a3)-instance (Structured a1, Structured a2, Structured a3, Structured a4) => Structured (a1, a2, a3, a4)-instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5) => Structured (a1, a2, a3, a4, a5)-instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6) => Structured (a1, a2, a3, a4, a5, a6)-instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6, Structured a7) => Structured (a1, a2, a3, a4, a5, a6, a7)+-- These instances are defined directly because the generic names for tuples changed+-- in 9.6 (https://gitlab.haskell.org/ghc/ghc/-/issues/24291).+--+-- By defining our own instances the STuple2 identifier will be used in the hash and+-- hence the same on all GHC versions. +data STuple2 a b = STuple2 a b deriving (Generic)+data STuple3 a b c = STuple3 a b c deriving (Generic)+data STuple4 a b c d = STuple4 a b c d deriving (Generic)+data STuple5 a b c d e = STuple5 a b c d e deriving (Generic)+data STuple6 a b c d e f = STuple6 a b c d e f deriving (Generic)+data STuple7 a b c d e f g = STuple7 a b c d e f g deriving (Generic)++instance (Structured a1, Structured a2) => Structured (STuple2 a1 a2)+instance (Structured a1, Structured a2) => Structured (a1, a2) where+  structure Proxy = structure @(STuple2 a1 a2) Proxy++instance (Structured a1, Structured a2, Structured a3) => Structured (STuple3 a1 a2 a3)+instance (Structured a1, Structured a2, Structured a3) => Structured (a1, a2, a3) where+  structure Proxy = structure @(STuple3 a1 a2 a3) Proxy++instance (Structured a1, Structured a2, Structured a3, Structured a4) => Structured (STuple4 a1 a2 a3 a4)+instance (Structured a1, Structured a2, Structured a3, Structured a4) => Structured (a1, a2, a3, a4) where+  structure Proxy = structure @(STuple4 a1 a2 a3 a4) Proxy++instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5) => Structured (STuple5 a1 a2 a3 a4 a5)+instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5) => Structured (a1, a2, a3, a4, a5) where+  structure Proxy = structure @(STuple5 a1 a2 a3 a4 a5) Proxy++instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6) => Structured (STuple6 a1 a2 a3 a4 a5 a6)+instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6) => Structured (a1, a2, a3, a4, a5, a6) where+  structure Proxy = structure @(STuple6 a1 a2 a3 a4 a5 a6) Proxy++instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6, Structured a7) => Structured (STuple7 a1 a2 a3 a4 a5 a6 a7)+instance (Structured a1, Structured a2, Structured a3, Structured a4, Structured a5, Structured a6, Structured a7) => Structured (a1, a2, a3, a4, a5, a6, a7) where+  structure Proxy = structure @(STuple7 a1 a2 a3 a4 a5 a6 a7) Proxy+ instance Structured BS.ByteString where structure = nominalStructure instance Structured LBS.ByteString where structure = nominalStructure  instance Structured T.Text where structure = nominalStructure instance Structured LT.Text where structure = nominalStructure -instance (Structured k, Structured v) => Structured (Map.Map k v) where structure _ = Nominal (typeRep (Proxy :: Proxy (Map.Map k v))) 0 "Map" [ structure (Proxy :: Proxy k), structure (Proxy :: Proxy v) ]-instance (Structured k) => Structured (Set.Set k) where structure = containerStructure-instance (Structured v) => Structured (IM.IntMap v) where structure = containerStructure+instance (Structured k, Structured v) => Structured (Map.Map k v) where structure _ = Nominal (typeRep (Proxy :: Proxy (Map.Map k v))) 0 "Map" [structure (Proxy :: Proxy k), structure (Proxy :: Proxy v)]+instance Structured k => Structured (Set.Set k) where structure = containerStructure+instance Structured v => Structured (IM.IntMap v) where structure = containerStructure instance Structured IS.IntSet where structure = nominalStructure-instance (Structured v) => Structured (Seq.Seq v) where structure = containerStructure+instance Structured v => Structured (Seq.Seq v) where structure = containerStructure -instance Structured Time.UTCTime         where structure = nominalStructure-instance Structured Time.DiffTime        where structure = nominalStructure-instance Structured Time.UniversalTime   where structure = nominalStructure+instance Structured Time.UTCTime where structure = nominalStructure+instance Structured Time.DiffTime where structure = nominalStructure+instance Structured Time.UniversalTime where structure = nominalStructure instance Structured Time.NominalDiffTime where structure = nominalStructure-instance Structured Time.Day             where structure = nominalStructure-instance Structured Time.TimeZone        where structure = nominalStructure-instance Structured Time.TimeOfDay       where structure = nominalStructure-instance Structured Time.LocalTime       where structure = nominalStructure+instance Structured Time.Day where structure = nominalStructure+instance Structured Time.TimeZone where structure = nominalStructure+instance Structured Time.TimeOfDay where structure = nominalStructure+instance Structured Time.LocalTime where structure = nominalStructure
src/Distribution/Version.hs view
@@ -1,4 +1,5 @@ -----------------------------------------------------------------------------+ -- | -- Module      :  Distribution.Version -- Copyright   :  Isaac Jones, Simon Marlow 2003-2004@@ -11,83 +12,89 @@ -- Exports the 'Version' type along with a parser and pretty printer. A version -- is something like @\"1.3.3\"@. It also defines the 'VersionRange' data -- types. Version ranges are like @\">= 1.2 && < 2\"@.--module Distribution.Version (-  -- * Package versions-  Version,-  version0,-  mkVersion,-  mkVersion',-  versionNumbers,-  nullVersion,-  alterVersion,+module Distribution.Version+  ( -- * Package versions+    Version+  , version0+  , mkVersion+  , mkVersion'+  , versionNumbers+  , nullVersion+  , alterVersion -  -- * Version ranges-  VersionRange,+    -- * Version ranges+  , VersionRange -  -- ** Constructing-  anyVersion, noVersion,-  thisVersion, notThisVersion,-  laterVersion, earlierVersion,-  orLaterVersion, orEarlierVersion,-  unionVersionRanges, intersectVersionRanges,-  withinVersion,-  majorBoundVersion,+    -- ** Constructing+  , anyVersion+  , noVersion+  , thisVersion+  , notThisVersion+  , laterVersion+  , earlierVersion+  , orLaterVersion+  , orEarlierVersion+  , unionVersionRanges+  , intersectVersionRanges+  , withinVersion+  , majorBoundVersion -  -- ** Inspection-  withinRange,-  isAnyVersion,-  isNoVersion,-  isSpecificVersion,-  simplifyVersionRange,-  foldVersionRange,-  normaliseVersionRange,-  stripParensVersionRange,-  hasUpperBound,-  hasLowerBound,+    -- ** Inspection+  , withinRange+  , isAnyVersion+  , isNoVersion+  , isSpecificVersion+  , simplifyVersionRange+  , foldVersionRange+  , normaliseVersionRange+  , stripParensVersionRange+  , hasUpperBound+  , hasLowerBound+  , hasLEUpperBound+  , hasTrailingZeroUpperBound+  , hasGTLowerBound -  -- ** Cata & ana-  VersionRangeF (..),-  cataVersionRange,-  anaVersionRange,-  hyloVersionRange,-  projectVersionRange,-  embedVersionRange,+    -- ** Cata & ana+  , VersionRangeF (..)+  , cataVersionRange+  , anaVersionRange+  , hyloVersionRange+  , projectVersionRange+  , embedVersionRange -  -- ** Utilities-  wildcardUpperBound,-  majorUpperBound,+    -- ** Utilities+  , wildcardUpperBound+  , majorUpperBound -  -- ** Modification-  removeUpperBound,-  removeLowerBound,-  transformCaret,-  transformCaretUpper,-  transformCaretLower,+    -- ** Modification+  , removeUpperBound+  , removeLowerBound+  , transformCaret+  , transformCaretUpper+  , transformCaretLower -  -- * Version intervals view-  asVersionIntervals,-  VersionInterval(..),-  LowerBound(..),-  UpperBound(..),-  Bound(..),+    -- * Version intervals view+  , asVersionIntervals+  , VersionInterval (..)+  , LowerBound (..)+  , UpperBound (..)+  , Bound (..) -  -- ** 'VersionIntervals' abstract type-  -- | The 'VersionIntervals' type and the accompanying functions are exposed-  -- primarily for completeness and testing purposes. In practice-  -- 'asVersionIntervals' is the main function to use to-  -- view a 'VersionRange' as a bunch of 'VersionInterval's.-  ---  VersionIntervals,-  toVersionIntervals,-  fromVersionIntervals,-  unVersionIntervals,+    -- ** 'VersionIntervals' abstract type - ) where+    -- | The 'VersionIntervals' type and the accompanying functions are exposed+    -- primarily for completeness and testing purposes. In practice+    -- 'asVersionIntervals' is the main function to use to+    -- view a 'VersionRange' as a bunch of 'VersionInterval's.+  , VersionIntervals+  , toVersionIntervals+  , fromVersionIntervals+  , unVersionIntervals+  ) where  import Distribution.Types.Version-import Distribution.Types.VersionRange import Distribution.Types.VersionInterval+import Distribution.Types.VersionRange  ------------------------------------------------------------------------------- -- Utilities on VersionRange requiring VersionInterval@@ -99,22 +106,20 @@ -- For example this is @True@ (for all @v@): -- -- > isNoVersion (EarlierVersion v `IntersectVersionRanges` LaterVersion v)--- isNoVersion :: VersionRange -> Bool isNoVersion vr = case asVersionIntervals vr of   [] -> True-  _  -> False+  _ -> False  -- | Is this version range in fact just a specific version? -- -- For example the version range @\">= 3 && <= 3\"@ contains only the version -- @3@.--- isSpecificVersion :: VersionRange -> Maybe Version isSpecificVersion vr = case asVersionIntervals vr of-  [VersionInterval (LowerBound v  InclusiveBound) (UpperBound v' InclusiveBound)]+  [VersionInterval (LowerBound v InclusiveBound) (UpperBound v' InclusiveBound)]     | v == v' -> Just v-  _           -> Nothing+  _ -> Nothing  ------------------------------------------------------------------------------- -- Transformations@@ -135,14 +140,13 @@ -- > ==> simplifyVersionRange r = simplifyVersionRange r' -- >  || isNoVersion r -- >  || isNoVersion r'--- simplifyVersionRange :: VersionRange -> VersionRange simplifyVersionRange vr-    -- If the version range is inconsistent then we just return the-    -- original since that has more information than ">1 && < 1", which-    -- is the canonical inconsistent version range.-    | null (unVersionIntervals vi) = vr-    | otherwise                    = fromVersionIntervals vi+  -- If the version range is inconsistent then we just return the+  -- original since that has more information than ">1 && < 1", which+  -- is the canonical inconsistent version range.+  | null (unVersionIntervals vi) = vr+  | otherwise = fromVersionIntervals vi   where     vi = toVersionIntervals vr @@ -160,26 +164,26 @@ -- | Rewrite @^>= x.y.z@ into @>= x.y.z && < x.(y+1)@ -- -- @since 3.6.0.0--- transformCaret :: VersionRange -> VersionRange-transformCaret = hyloVersionRange embed projectVersionRange where+transformCaret = hyloVersionRange embed projectVersionRange+  where     embed (MajorBoundVersionF v) = orLaterVersion v `intersectVersionRanges` earlierVersion (majorUpperBound v)-    embed vr                     = embedVersionRange vr+    embed vr = embedVersionRange vr  -- | Rewrite @^>= x.y.z@ into @>= x.y.z@ -- -- @since 3.6.0.0--- transformCaretUpper :: VersionRange -> VersionRange-transformCaretUpper = hyloVersionRange embed projectVersionRange where+transformCaretUpper = hyloVersionRange embed projectVersionRange+  where     embed (MajorBoundVersionF v) = orLaterVersion v-    embed vr                     = embedVersionRange vr+    embed vr = embedVersionRange vr  -- | Rewrite @^>= x.y.z@ into @<x.(y+1)@ -- -- @since 3.6.0.0--- transformCaretLower :: VersionRange -> VersionRange-transformCaretLower = hyloVersionRange embed projectVersionRange where+transformCaretLower = hyloVersionRange embed projectVersionRange+  where     embed (MajorBoundVersionF v) = earlierVersion (majorUpperBound v)-    embed vr                     = embedVersionRange vr+    embed vr = embedVersionRange vr
src/Language/Haskell/Extension.hs view
@@ -3,754 +3,626 @@ {-# LANGUAGE OverloadedStrings #-}  -------------------------------------------------------------------------------- |--- Module      :  Language.Haskell.Extension--- Copyright   :  Isaac Jones 2003-2004--- License     :  BSD3------ Maintainer  :  libraries@haskell.org--- Portability :  portable------ Haskell language dialects and extensions--module Language.Haskell.Extension (-        Language(..),-        knownLanguages,-        classifyLanguage,--        Extension(..),-        KnownExtension(..),-        deprecatedExtensions,-        classifyExtension,-        knownExtensions-  ) where--import Distribution.Compat.Prelude--import Data.Array (Array, accumArray, bounds, Ix(inRange), (!))--import Distribution.Parsec-import Distribution.Pretty--import qualified Distribution.Compat.CharParsing as P-import qualified Text.PrettyPrint as Disp---- --------------------------------------------------------------- * Language--- ---------------------------------------------------------------- | This represents a Haskell language dialect.------ Language 'Extension's are interpreted relative to one of these base--- languages.----data Language =--  -- | The Haskell 98 language as defined by the Haskell 98 report.-  -- <http://haskell.org/onlinereport/>-     Haskell98--  -- | The Haskell 2010 language as defined by the Haskell 2010 report.-  -- <http://www.haskell.org/onlinereport/haskell2010>-  | Haskell2010--  -- | The GHC2021 collection of language extensions.-  -- <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0380-ghc2021.rst>-  | GHC2021--  -- | An unknown language, identified by its name.-  | UnknownLanguage String-  deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)--instance Binary Language-instance Structured Language--instance NFData Language where rnf = genericRnf---- | List of known (supported) languages for GHC-knownLanguages :: [Language]-knownLanguages = [Haskell98, Haskell2010, GHC2021]--instance Pretty Language where-  pretty (UnknownLanguage other) = Disp.text other-  pretty other                   = Disp.text (show other)--instance Parsec Language where-  parsec = classifyLanguage <$> P.munch1 isAlphaNum--classifyLanguage :: String -> Language-classifyLanguage = \str -> case lookup str langTable of-    Just lang -> lang-    Nothing   -> UnknownLanguage str-  where-    langTable = [ (show lang, lang)-                | lang <- knownLanguages ]---- --------------------------------------------------------------- * Extension--- ---------------------------------------------------------------- Note: if you add a new 'KnownExtension':------ * also add it to the Distribution.Simple.X.languageExtensions lists---   (where X is each compiler: GHC, UHC, HaskellSuite)------ | This represents language extensions beyond a base 'Language' definition--- (such as 'Haskell98') that are supported by some implementations, usually--- in some special mode.------ Where applicable, references are given to an implementation's--- official documentation.--data Extension =-  -- | Enable a known extension-    EnableExtension KnownExtension--  -- | Disable a known extension-  | DisableExtension KnownExtension--  -- | An unknown extension, identified by the name of its @LANGUAGE@-  -- pragma.-  | UnknownExtension String--  deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)--instance Binary Extension-instance Structured Extension--instance NFData Extension where rnf = genericRnf---- | Known Haskell language extensions, including deprecated and undocumented--- ones.------ Check <https://downloads.haskell.org/~ghc/9.2.3/docs/html/users_guide/exts/table.html “Overview of all language extensions” in GHC User’s Guide>--- for more information.-data KnownExtension =--  -- | Allow overlapping class instances, provided there is a unique-  -- most specific instance for each use.-    OverlappingInstances--  -- | Ignore structural rules guaranteeing the termination of class-  -- instance resolution.  Termination is guaranteed by a fixed-depth-  -- recursion stack, and compilation may fail if this depth is-  -- exceeded.-  | UndecidableInstances--  -- | Implies 'OverlappingInstances'.  Allow the implementation to-  -- choose an instance even when it is possible that further-  -- instantiation of types will lead to a more specific instance-  -- being applicable.-  | IncoherentInstances--  -- | /(deprecated)/ Deprecated in favour of 'RecursiveDo'.-  ---  -- Old description: Allow recursive bindings in @do@ blocks, using-  -- the @rec@ keyword. See also 'RecursiveDo'.-  | DoRec--  -- | Allow recursive bindings in @do@ blocks, using the @rec@-  -- keyword, or @mdo@, a variant of @do@.-  | RecursiveDo--  -- | Provide syntax for writing list comprehensions which iterate-  -- over several lists together, like the 'zipWith' family of-  -- functions.-  | ParallelListComp--  -- | Allow multiple parameters in a type class.-  | MultiParamTypeClasses--  -- | Enable the dreaded monomorphism restriction.-  | MonomorphismRestriction--  -- | Enable deep subsumption, relaxing the simple subsumption rules,-  -- implicitly inserting eta-expansions when matching up function types-  -- with different quantification structures.-  | DeepSubsumption--  -- | Allow a specification attached to a multi-parameter type class-  -- which indicates that some parameters are entirely determined by-  -- others. The implementation will check that this property holds-  -- for the declared instances, and will use this property to reduce-  -- ambiguity in instance resolution.-  | FunctionalDependencies--  -- | /(deprecated)/ A synonym for 'RankNTypes'.-  ---  -- Old description: Like 'RankNTypes' but does not allow a-  -- higher-rank type to itself appear on the left of a function-  -- arrow.-  | Rank2Types--  -- | Allow a universally-quantified type to occur on the left of a-  -- function arrow.-  | RankNTypes--  -- | /(deprecated)/ A synonym for 'RankNTypes'.-  ---  -- Old description: Allow data constructors to have polymorphic-  -- arguments.  Unlike 'RankNTypes', does not allow this for ordinary-  -- functions.-  | PolymorphicComponents--  -- | Allow existentially-quantified data constructors.-  | ExistentialQuantification--  -- | Cause a type variable in a signature, which has an explicit-  -- @forall@ quantifier, to scope over the definition of the-  -- accompanying value declaration.-  | ScopedTypeVariables--  -- | Deprecated, use 'ScopedTypeVariables' instead.-  | PatternSignatures--  -- | Enable implicit function parameters with dynamic scope.-  | ImplicitParams--  -- | Relax some restrictions on the form of the context of a type-  -- signature.-  | FlexibleContexts--  -- | Relax some restrictions on the form of the context of an-  -- instance declaration.-  | FlexibleInstances--  -- | Allow data type declarations with no constructors.-  | EmptyDataDecls--  -- | Run the C preprocessor on Haskell source code.-  | CPP--  -- | Allow an explicit kind signature giving the kind of types over-  -- which a type variable ranges.-  | KindSignatures--  -- | Enable a form of pattern which forces evaluation before an-  -- attempted match, and a form of strict @let@/@where@ binding.-  | BangPatterns--  -- | Allow type synonyms in instance heads.-  | TypeSynonymInstances--  -- | Enable Template Haskell, a system for compile-time-  -- metaprogramming.-  | TemplateHaskell--  -- | Enable the Foreign Function Interface.  In GHC, implements the-  -- standard Haskell 98 Foreign Function Interface Addendum, plus-  -- some GHC-specific extensions.-  | ForeignFunctionInterface--  -- | Enable arrow notation.-  | Arrows--  -- | /(deprecated)/ Enable generic type classes, with default instances defined in-  -- terms of the algebraic structure of a type.-  | Generics--  -- | Enable the implicit importing of the module "Prelude".  When-  -- disabled, when desugaring certain built-in syntax into ordinary-  -- identifiers, use whatever is in scope rather than the "Prelude"-  -- -- version.-  | ImplicitPrelude--  -- | Enable syntax for implicitly binding local names corresponding-  -- to the field names of a record.  Puns bind specific names, unlike-  -- 'RecordWildCards'.-  | NamedFieldPuns--  -- | Enable a form of guard which matches a pattern and binds-  -- variables.-  | PatternGuards--  -- | Allow a type declared with @newtype@ to use @deriving@ for any-  -- class with an instance for the underlying type.-  | GeneralizedNewtypeDeriving--  -- Synonym for GeneralizedNewtypeDeriving added in GHC 8.6.1.-  | GeneralisedNewtypeDeriving--  -- | Enable the \"Trex\" extensible records system.-  | ExtensibleRecords--  -- | Enable type synonyms which are transparent in some definitions-  -- and opaque elsewhere, as a way of implementing abstract-  -- datatypes.-  | RestrictedTypeSynonyms--  -- | Enable an alternate syntax for string literals,-  -- with string templating.-  | HereDocuments--  -- | Allow the character @#@ as a postfix modifier on identifiers.-  -- Also enables literal syntax for unboxed values.-  | MagicHash--  -- | Allow data types and type synonyms which are indexed by types,-  -- i.e. ad-hoc polymorphism for types.-  | TypeFamilies--  -- | Allow a standalone declaration which invokes the type class-  -- @deriving@ mechanism.-  | StandaloneDeriving--  -- | Allow certain Unicode characters to stand for certain ASCII-  -- character sequences, e.g. keywords and punctuation.-  | UnicodeSyntax--  -- | Allow the use of unboxed types as foreign types, e.g. in-  -- @foreign import@ and @foreign export@.-  | UnliftedFFITypes--  -- | Enable interruptible FFI.-  | InterruptibleFFI--  -- | Allow use of CAPI FFI calling convention (@foreign import capi@).-  | CApiFFI--  -- | Defer validity checking of types until after expanding type-  -- synonyms, relaxing the constraints on how synonyms may be used.-  | LiberalTypeSynonyms--  -- | Allow the name of a type constructor, type class, or type-  -- variable to be an infix operator.-  | TypeOperators--  -- | Enable syntax for implicitly binding local names corresponding-  -- to the field names of a record.  A wildcard binds all unmentioned-  -- names, unlike 'NamedFieldPuns'.-  | RecordWildCards--  -- | Deprecated, use 'NamedFieldPuns' instead.-  | RecordPuns--  -- | Allow a record field name to be disambiguated by the type of-  -- the record it's in.-  | DisambiguateRecordFields--  -- | Enable traditional record syntax (as supported by Haskell 98)-  | TraditionalRecordSyntax--  -- | Enable overloading of string literals using a type class, much-  -- like integer literals.-  | OverloadedStrings--  -- | Enable generalized algebraic data types, in which type-  -- variables may be instantiated on a per-constructor basis. Implies-  -- 'GADTSyntax'.-  | GADTs--  -- | Enable GADT syntax for declaring ordinary algebraic datatypes.-  | GADTSyntax--  -- | /(deprecated)/ Has no effect.-  ---  -- Old description: Make pattern bindings monomorphic.-  | MonoPatBinds--  -- | Relax the requirements on mutually-recursive polymorphic-  -- functions.-  | RelaxedPolyRec--  -- | Allow default instantiation of polymorphic types in more-  -- situations.-  | ExtendedDefaultRules--  -- | Enable unboxed tuples.-  | UnboxedTuples--  -- | Enable @deriving@ for classes 'Data.Typeable.Typeable' and-  -- 'Data.Generics.Data'.-  | DeriveDataTypeable--  -- | Enable @deriving@ for 'GHC.Generics.Generic' and 'GHC.Generics.Generic1'.-  | DeriveGeneric--  -- | Enable support for default signatures.-  | DefaultSignatures--  -- | Allow type signatures to be specified in instance declarations.-  | InstanceSigs--  -- | Allow a class method's type to place additional constraints on-  -- a class type variable.-  | ConstrainedClassMethods--  -- | Allow imports to be qualified by the package name the module is-  -- intended to be imported from, e.g.-  ---  -- > import "network" Network.Socket-  | PackageImports--  -- | /(deprecated)/ Allow a type variable to be instantiated at a-  -- polymorphic type.-  | ImpredicativeTypes--  -- | /(deprecated)/ Change the syntax for qualified infix operators.-  | NewQualifiedOperators--  -- | Relax the interpretation of left operator sections to allow-  -- unary postfix operators.-  | PostfixOperators--  -- | Enable quasi-quotation, a mechanism for defining new concrete-  -- syntax for expressions and patterns.-  | QuasiQuotes--  -- | Enable generalized list comprehensions, supporting operations-  -- such as sorting and grouping.-  | TransformListComp--  -- | Enable monad comprehensions, which generalise the list-  -- comprehension syntax to work for any monad.-  | MonadComprehensions--  -- | Enable view patterns, which match a value by applying a-  -- function and matching on the result.-  | ViewPatterns--  -- | Allow concrete XML syntax to be used in expressions and patterns,-  -- as per the Haskell Server Pages extension language:-  -- <http://www.haskell.org/haskellwiki/HSP>. The ideas behind it are-  -- discussed in the paper \"Haskell Server Pages through Dynamic Loading\"-  -- by Niklas Broberg, from Haskell Workshop '05.-  | XmlSyntax--  -- | Allow regular pattern matching over lists, as discussed in the-  -- paper \"Regular Expression Patterns\" by Niklas Broberg, Andreas Farre-  -- and Josef Svenningsson, from ICFP '04.-  | RegularPatterns--  -- | Enable the use of tuple sections, e.g. @(, True)@ desugars into-  -- @\x -> (x, True)@.-  | TupleSections--  -- | Allow GHC primops, written in C--, to be imported into a Haskell-  -- file.-  | GHCForeignImportPrim--  -- | Support for patterns of the form @n + k@, where @k@ is an-  -- integer literal.-  | NPlusKPatterns--  -- | Improve the layout rule when @if@ expressions are used in a @do@-  -- block.-  | DoAndIfThenElse--  -- | Enable support for multi-way @if@-expressions.-  | MultiWayIf--  -- | Enable support lambda-@case@ expressions.-  | LambdaCase--  -- | Makes much of the Haskell sugar be desugared into calls to the-  -- function with a particular name that is in scope.-  | RebindableSyntax--  -- | Make @forall@ a keyword in types, which can be used to give the-  -- generalisation explicitly.-  | ExplicitForAll--  -- | Allow contexts to be put on datatypes, e.g. the @Eq a@ in-  -- @data Eq a => Set a = NilSet | ConsSet a (Set a)@.-  | DatatypeContexts--  -- | Local (@let@ and @where@) bindings are monomorphic.-  | MonoLocalBinds--  -- | Enable @deriving@ for the 'Data.Functor.Functor' class.-  | DeriveFunctor--  -- | Enable @deriving@ for the 'Data.Traversable.Traversable' class.-  | DeriveTraversable--  -- | Enable @deriving@ for the 'Data.Foldable.Foldable' class.-  | DeriveFoldable--  -- | Enable non-decreasing indentation for @do@ blocks.-  | NondecreasingIndentation--  -- | Allow imports to be qualified with a safe keyword that requires-  -- the imported module be trusted as according to the Safe Haskell-  -- definition of trust.-  ---  -- > import safe Network.Socket-  | SafeImports--  -- | Compile a module in the Safe, Safe Haskell mode -- a restricted-  -- form of the Haskell language to ensure type safety.-  | Safe--  -- | Compile a module in the Trustworthy, Safe Haskell mode -- no-  -- restrictions apply but the module is marked as trusted as long as-  -- the package the module resides in is trusted.-  | Trustworthy--  -- | Compile a module in the Unsafe, Safe Haskell mode so that-  -- modules compiled using Safe, Safe Haskell mode can't import it.-  | Unsafe--  -- | Allow type class/implicit parameter/equality constraints to be-  -- used as types with the special kind constraint.  Also generalise-  -- the @(ctxt => ty)@ syntax so that any type of kind constraint can-  -- occur before the arrow.-  | ConstraintKinds--  -- | Enable kind polymorphism.-  | PolyKinds--  -- | Enable datatype promotion.-  | DataKinds--  -- | Enable @type data@ declarations, defining constructors at the type level.-  | TypeData--  -- | Enable parallel arrays syntax (@[:@, @:]@) for /Data Parallel Haskell/.-  | ParallelArrays--  -- | Enable explicit role annotations, like in (@type role Foo representational representational@).-  | RoleAnnotations--  -- | Enable overloading of list literals, arithmetic sequences and-  -- list patterns using the 'IsList' type class.-  | OverloadedLists--  -- | Enable case expressions that have no alternatives. Also applies to lambda-case expressions if they are enabled.-  | EmptyCase--  -- | /(deprecated)/ Deprecated in favour of 'DeriveDataTypeable'.-  ---  -- Old description: Triggers the generation of derived 'Typeable'-  -- instances for every datatype and type class declaration.-  | AutoDeriveTypeable--  -- | Desugars negative literals directly (without using negate).-  | NegativeLiterals--  -- | Allow the use of binary integer literal syntax (e.g. @0b11001001@ to denote @201@).-  | BinaryLiterals--  -- | Allow the use of floating literal syntax for all instances of 'Num', including 'Int' and 'Integer'.-  | NumDecimals--  -- | Enable support for type classes with no type parameter.-  | NullaryTypeClasses--  -- | Enable explicit namespaces in module import/export lists.-  | ExplicitNamespaces--  -- | Allow the user to write ambiguous types, and the type inference engine to infer them.-  | AllowAmbiguousTypes--  -- | Enable @foreign import javascript@.-  | JavaScriptFFI--  -- | Allow giving names to and abstracting over patterns.-  | PatternSynonyms--  -- | Allow anonymous placeholders (underscore) inside type signatures.  The-  -- type inference engine will generate a message describing the type inferred-  -- at the hole's location.-  | PartialTypeSignatures--  -- | Allow named placeholders written with a leading underscore inside type-  -- signatures.  Wildcards with the same name unify to the same type.-  | NamedWildCards--  -- | Enable @deriving@ for any class.-  | DeriveAnyClass--  -- | Enable @deriving@ for the 'Language.Haskell.TH.Syntax.Lift' class.-  | DeriveLift--  -- | Enable support for 'static pointers' (and the @static@-  -- keyword) to refer to globally stable names, even across-  -- different programs.-  | StaticPointers--  -- | Switches data type declarations to be strict by default (as if-  -- they had a bang using @BangPatterns@), and allow opt-in field-  -- laziness using @~@.-  | StrictData--  -- | Switches all pattern bindings to be strict by default (as if-  -- they had a bang using @BangPatterns@), ordinary patterns are-  -- recovered using @~@. Implies @StrictData@.-  | Strict--  -- | Allows @do@-notation for types that are @'Applicative'@ as well-  -- as @'Monad'@. When enabled, desugaring @do@ notation tries to use-  -- @(<*>)@ and @'fmap'@ and @'join'@ as far as possible.-  | ApplicativeDo--  -- | Allow records to use duplicated field labels for accessors.-  | DuplicateRecordFields--  -- | Enable explicit type applications with the syntax @id \@Int@.-  | TypeApplications--  -- | Dissolve the distinction between types and kinds, allowing the compiler-  -- to reason about kind equality and therefore enabling GADTs to be promoted-  -- to the type-level.-  | TypeInType--  -- | Allow recursive (and therefore undecidable) super-class relationships.-  | UndecidableSuperClasses--  -- | A temporary extension to help library authors check if their-  -- code will compile with the new planned desugaring of fail.-  | MonadFailDesugaring--  -- | A subset of @TemplateHaskell@ including only quoting.-  | TemplateHaskellQuotes--  -- | Allows use of the @#label@ syntax.-  | OverloadedLabels--  -- | Allow functional dependency annotations on type families to declare them-  -- as injective.-  | TypeFamilyDependencies--  -- | Allow multiple @deriving@ clauses, each optionally qualified with a-  -- /strategy/.-  | DerivingStrategies--  -- | Enable deriving instances via types of the same runtime representation.-  -- Implies 'DerivingStrategies'.-  | DerivingVia--  -- | Enable the use of unboxed sum syntax.-  | UnboxedSums--  -- | Allow use of hexadecimal literal notation for floating-point values.-  | HexFloatLiterals--  -- | Allow @do@ blocks etc. in argument position.-  | BlockArguments--  -- | Allow use of underscores in numeric literals.-  | NumericUnderscores--  -- | Allow @forall@ in constraints.-  | QuantifiedConstraints--  -- | Have @*@ refer to @Type@.-  | StarIsType--  -- | Liberalises deriving to provide instances for empty data types.-  | EmptyDataDeriving--  -- | Enable detection of complete user-supplied kind signatures.-  | CUSKs--  -- | Allows the syntax @import M qualified@.-  | ImportQualifiedPost--  -- | Allow the use of standalone kind signatures.-  | StandaloneKindSignatures--  -- | Enable unlifted newtypes.-  | UnliftedNewtypes--  -- | Use whitespace to determine whether the minus sign stands for negation or subtraction.-  | LexicalNegation--  -- | Enable qualified do-notation desugaring.-  | QualifiedDo--  -- | Enable linear types.-  | LinearTypes--  -- | Allow the use of visible forall in types of terms.-  | RequiredTypeArguments--  -- | Enable the generation of selector functions corresponding to record fields.-  | FieldSelectors--  -- | Enable the use of record dot-accessor and updater syntax-  | OverloadedRecordDot--  -- | Provides record @.@ syntax in record updates, e.g. @x {foo.bar = 1}@.-  | OverloadedRecordUpdate--  -- | Enable data types for which an unlifted or levity-polymorphic result kind is inferred.-  | UnliftedDatatypes--  -- | Undocumented parsing-related extensions introduced in GHC 7.0.-  | AlternativeLayoutRule--  -- | Undocumented parsing-related extensions introduced in GHC 7.0.-  | AlternativeLayoutRuleTransitional--  -- | Undocumented parsing-related extensions introduced in GHC 7.2.-  | RelaxedLayout--  deriving (Generic, Show, Read, Eq, Ord, Enum, Bounded, Typeable, Data)--instance Binary KnownExtension-instance Structured KnownExtension--instance NFData KnownExtension where rnf = genericRnf---- | Extensions that have been deprecated, possibly paired with another--- extension that replaces it.----deprecatedExtensions :: [(Extension, Maybe Extension)]-deprecatedExtensions =-  [ (EnableExtension RecordPuns, Just (EnableExtension NamedFieldPuns))-  , (EnableExtension PatternSignatures, Just (EnableExtension ScopedTypeVariables))-  ]--- NOTE: when adding deprecated extensions that have new alternatives--- we must be careful to make sure that the deprecation messages are--- valid. We must not recommend aliases that cannot be used with older--- compilers, perhaps by adding support in Cabal to translate the new--- name to the old one for older compilers. Otherwise we are in danger--- of the scenario in ticket #689.--instance Pretty Extension where-  pretty (UnknownExtension other) = Disp.text other-  pretty (EnableExtension ke)     = Disp.text (show ke)-  pretty (DisableExtension ke)    = Disp.text ("No" ++ show ke)--instance Parsec Extension where-  parsec = classifyExtension <$> P.munch1 isAlphaNum--instance Pretty KnownExtension where-  pretty ke = Disp.text (show ke)--classifyExtension :: String -> Extension-classifyExtension string-  = case classifyKnownExtension string of-    Just ext -> EnableExtension ext-    Nothing ->-        case string of-        'N':'o':string' ->-            case classifyKnownExtension string' of-            Just ext -> DisableExtension ext-            Nothing -> UnknownExtension string-        _ -> UnknownExtension string---- | 'read' for 'KnownExtension's is really really slow so for the Text--- instance--- what we do is make a simple table indexed off the first letter in the--- extension name. The extension names actually cover the range @'A'-'Z'@--- pretty densely and the biggest bucket is 7 so it's not too bad. We just do--- a linear search within each bucket.------ This gives an order of magnitude improvement in parsing speed, and it'll--- also allow us to do case insensitive matches in future if we prefer.----classifyKnownExtension :: String -> Maybe KnownExtension-classifyKnownExtension "" = Nothing-classifyKnownExtension string@(c : _)-  | inRange (bounds knownExtensionTable) c-  = lookup string (knownExtensionTable ! c)-  | otherwise = Nothing--knownExtensionTable :: Array Char [(String, KnownExtension)]-knownExtensionTable =-  accumArray (flip (:)) [] ('A', 'Z')++-- |+-- Module      :  Language.Haskell.Extension+-- Copyright   :  Isaac Jones 2003-2004+-- License     :  BSD3+--+-- Maintainer  :  libraries@haskell.org+-- Portability :  portable+--+-- Haskell language dialects and extensions+module Language.Haskell.Extension+  ( Language (..)+  , knownLanguages+  , classifyLanguage+  , Extension (..)+  , KnownExtension (..)+  , deprecatedExtensions+  , classifyExtension+  , knownExtensions+  ) where++import Distribution.Compat.Prelude++import Data.Array (Array, Ix (inRange), accumArray, bounds, (!))++import Distribution.Parsec+import Distribution.Pretty++import qualified Distribution.Compat.CharParsing as P+import qualified Text.PrettyPrint as Disp++-- ------------------------------------------------------------++-- * Language++-- ------------------------------------------------------------++-- | This represents a Haskell language dialect.+--+-- Language 'Extension's are interpreted relative to one of these base+-- languages.+data Language+  = -- | The Haskell 98 language as defined by the Haskell 98 report.+    -- <http://haskell.org/onlinereport/>+    Haskell98+  | -- | The Haskell 2010 language as defined by the Haskell 2010 report.+    -- <http://www.haskell.org/onlinereport/haskell2010>+    Haskell2010+  | -- | The GHC2021 collection of language extensions.+    -- <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0380-ghc2021.rst>+    GHC2021+  | -- | The GHC2024 collection of language extensions.+    -- <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0613-ghc2024.rst>+    GHC2024+  | -- | An unknown language, identified by its name.+    UnknownLanguage String+  deriving (Generic, Show, Read, Eq, Ord, Data)++instance Binary Language+instance Structured Language++instance NFData Language where rnf = genericRnf++-- | List of known (supported) languages for GHC, oldest first.+knownLanguages :: [Language]+knownLanguages = [Haskell98, Haskell2010, GHC2021, GHC2024]++instance Pretty Language where+  pretty (UnknownLanguage other) = Disp.text other+  pretty other = Disp.text (show other)++instance Parsec Language where+  parsec = classifyLanguage <$> P.munch1 isAlphaNum++classifyLanguage :: String -> Language+classifyLanguage = \str -> case lookup str langTable of+  Just lang -> lang+  Nothing -> UnknownLanguage str+  where+    langTable =+      [ (show lang, lang)+      | lang <- knownLanguages+      ]++-- ------------------------------------------------------------++-- * Extension++-- ------------------------------------------------------------++-- Note: if you add a new 'KnownExtension':+--++-- * also add it to the Distribution.Simple.X.compilerExtensions lists++--   (where X is each compiler: GHC, UHC)+--++-- | This represents language extensions beyond a base 'Language' definition+-- (such as 'Haskell98') that are supported by some implementations, usually+-- in some special mode.+--+-- Where applicable, references are given to an implementation's+-- official documentation.+data Extension+  = -- | Enable a known extension+    EnableExtension KnownExtension+  | -- | Disable a known extension+    DisableExtension KnownExtension+  | -- | An unknown extension, identified by the name of its @LANGUAGE@+    -- pragma.+    UnknownExtension String+  deriving (Generic, Show, Read, Eq, Ord, Data)++instance Binary Extension+instance Structured Extension++instance NFData Extension where rnf = genericRnf++-- | Known Haskell language extensions, including deprecated and undocumented+-- ones.+--+-- Check <https://downloads.haskell.org/~ghc/9.2.3/docs/html/users_guide/exts/table.html “Overview of all language extensions” in GHC User’s Guide>+-- for more information.+data KnownExtension+  = -- | Allow overlapping class instances, provided there is a unique+    -- most specific instance for each use.+    OverlappingInstances+  | -- | Ignore structural rules guaranteeing the termination of class+    -- instance resolution.  Termination is guaranteed by a fixed-depth+    -- recursion stack, and compilation may fail if this depth is+    -- exceeded.+    UndecidableInstances+  | -- | Implies 'OverlappingInstances'.  Allow the implementation to+    -- choose an instance even when it is possible that further+    -- instantiation of types will lead to a more specific instance+    -- being applicable.+    IncoherentInstances+  | -- | /(deprecated)/ Deprecated in favour of 'RecursiveDo'.+    --+    -- Old description: Allow recursive bindings in @do@ blocks, using+    -- the @rec@ keyword. See also 'RecursiveDo'.+    DoRec+  | -- | Allow recursive bindings in @do@ blocks, using the @rec@+    -- keyword, or @mdo@, a variant of @do@.+    RecursiveDo+  | -- | Provide syntax for writing list comprehensions which iterate+    -- over several lists together, like the 'zipWith' family of+    -- functions.+    ParallelListComp+  | -- | Allow multiple parameters in a type class.+    MultiParamTypeClasses+  | -- | Enable the dreaded monomorphism restriction.+    MonomorphismRestriction+  | -- | Enable deep subsumption, relaxing the simple subsumption rules,+    -- implicitly inserting eta-expansions when matching up function types+    -- with different quantification structures.+    DeepSubsumption+  | -- | Allow a specification attached to a multi-parameter type class+    -- which indicates that some parameters are entirely determined by+    -- others. The implementation will check that this property holds+    -- for the declared instances, and will use this property to reduce+    -- ambiguity in instance resolution.+    FunctionalDependencies+  | -- | /(deprecated)/ A synonym for 'RankNTypes'.+    --+    -- Old description: Like 'RankNTypes' but does not allow a+    -- higher-rank type to itself appear on the left of a function+    -- arrow.+    Rank2Types+  | -- | Allow a universally-quantified type to occur on the left of a+    -- function arrow.+    RankNTypes+  | -- | /(deprecated)/ A synonym for 'RankNTypes'.+    --+    -- Old description: Allow data constructors to have polymorphic+    -- arguments.  Unlike 'RankNTypes', does not allow this for ordinary+    -- functions.+    PolymorphicComponents+  | -- | Allow existentially-quantified data constructors.+    ExistentialQuantification+  | -- | Cause a type variable in a signature, which has an explicit+    -- @forall@ quantifier, to scope over the definition of the+    -- accompanying value declaration.+    ScopedTypeVariables+  | -- | Deprecated, use 'ScopedTypeVariables' instead.+    PatternSignatures+  | -- | Enable implicit function parameters with dynamic scope.+    ImplicitParams+  | -- | Relax some restrictions on the form of the context of a type+    -- signature.+    FlexibleContexts+  | -- | Relax some restrictions on the form of the context of an+    -- instance declaration.+    FlexibleInstances+  | -- | Allow data type declarations with no constructors.+    EmptyDataDecls+  | -- | Run the C preprocessor on Haskell source code.+    CPP+  | -- | Allow an explicit kind signature giving the kind of types over+    -- which a type variable ranges.+    KindSignatures+  | -- | Enable a form of pattern which forces evaluation before an+    -- attempted match, and a form of strict @let@/@where@ binding.+    BangPatterns+  | -- | Allow type synonyms in instance heads.+    TypeSynonymInstances+  | -- | Enable Template Haskell, a system for compile-time+    -- metaprogramming.+    TemplateHaskell+  | -- | Enable the Foreign Function Interface.  In GHC, implements the+    -- standard Haskell 98 Foreign Function Interface Addendum, plus+    -- some GHC-specific extensions.+    ForeignFunctionInterface+  | -- | Enable arrow notation.+    Arrows+  | -- | /(deprecated)/ Enable generic type classes, with default instances defined in+    -- terms of the algebraic structure of a type.+    Generics+  | -- | Enable the implicit importing of the module "Prelude".  When+    -- disabled, when desugaring certain built-in syntax into ordinary+    -- identifiers, use whatever is in scope rather than the "Prelude"+    -- -- version.+    ImplicitPrelude+  | -- | Enable syntax for implicitly binding local names corresponding+    -- to the field names of a record.  Puns bind specific names, unlike+    -- 'RecordWildCards'.+    NamedFieldPuns+  | -- | Enable a form of guard which matches a pattern and binds+    -- variables.+    PatternGuards+  | -- | Allow a type declared with @newtype@ to use @deriving@ for any+    -- class with an instance for the underlying type.+    GeneralizedNewtypeDeriving+  | -- Synonym for GeneralizedNewtypeDeriving added in GHC 8.6.1.+    GeneralisedNewtypeDeriving+  | -- | Enable the \"Trex\" extensible records system.+    ExtensibleRecords+  | -- | Enable type synonyms which are transparent in some definitions+    -- and opaque elsewhere, as a way of implementing abstract+    -- datatypes.+    RestrictedTypeSynonyms+  | -- | Enable an alternate syntax for string literals,+    -- with string templating.+    HereDocuments+  | -- | Allow the character @#@ as a postfix modifier on identifiers.+    -- Also enables literal syntax for unboxed values.+    MagicHash+  | -- | Allow data types and type synonyms which are indexed by types,+    -- i.e. ad-hoc polymorphism for types.+    TypeFamilies+  | -- | Allow a standalone declaration which invokes the type class+    -- @deriving@ mechanism.+    StandaloneDeriving+  | -- | Allow certain Unicode characters to stand for certain ASCII+    -- character sequences, e.g. keywords and punctuation.+    UnicodeSyntax+  | -- | Allow the use of unboxed types as foreign types, e.g. in+    -- @foreign import@ and @foreign export@.+    UnliftedFFITypes+  | -- | Enable interruptible FFI.+    InterruptibleFFI+  | -- | Allow use of CAPI FFI calling convention (@foreign import capi@).+    CApiFFI+  | -- | Defer validity checking of types until after expanding type+    -- synonyms, relaxing the constraints on how synonyms may be used.+    LiberalTypeSynonyms+  | -- | Allow the name of a type constructor, type class, or type+    -- variable to be an infix operator.+    TypeOperators+  | -- | Enable syntax for implicitly binding local names corresponding+    -- to the field names of a record.  A wildcard binds all unmentioned+    -- names, unlike 'NamedFieldPuns'.+    RecordWildCards+  | -- | Deprecated, use 'NamedFieldPuns' instead.+    RecordPuns+  | -- | Allow a record field name to be disambiguated by the type of+    -- the record it's in.+    DisambiguateRecordFields+  | -- | Enable traditional record syntax (as supported by Haskell 98)+    TraditionalRecordSyntax+  | -- | Enable overloading of string literals using a type class, much+    -- like integer literals.+    OverloadedStrings+  | -- | Enable generalized algebraic data types, in which type+    -- variables may be instantiated on a per-constructor basis. Implies+    -- 'GADTSyntax'.+    GADTs+  | -- | Enable GADT syntax for declaring ordinary algebraic datatypes.+    GADTSyntax+  | -- | /(deprecated)/ Has no effect.+    --+    -- Old description: Make pattern bindings monomorphic.+    MonoPatBinds+  | -- | Relax the requirements on mutually-recursive polymorphic+    -- functions.+    RelaxedPolyRec+  | -- | Allow default instantiation of polymorphic types in more+    -- situations.+    ExtendedDefaultRules+  | -- | Allow @default@ declarations to explicitly name the class and+    -- be exported.+    NamedDefaults+  | -- | Enable unboxed tuples.+    UnboxedTuples+  | -- | Enable @deriving@ for classes 'Data.Typeable.Typeable' and+    -- 'Data.Generics.Data'.+    DeriveDataTypeable+  | -- | Enable @deriving@ for 'GHC.Generics.Generic' and 'GHC.Generics.Generic1'.+    DeriveGeneric+  | -- | Enable support for default signatures.+    DefaultSignatures+  | -- | Allow type signatures to be specified in instance declarations.+    InstanceSigs+  | -- | Allow a class method's type to place additional constraints on+    -- a class type variable.+    ConstrainedClassMethods+  | -- | Allow imports to be qualified by the package name the module is+    -- intended to be imported from, e.g.+    --+    -- > import "network" Network.Socket+    PackageImports+  | -- | /(deprecated)/ Allow a type variable to be instantiated at a+    -- polymorphic type.+    ImpredicativeTypes+  | -- | /(deprecated)/ Change the syntax for qualified infix operators.+    NewQualifiedOperators+  | -- | Relax the interpretation of left operator sections to allow+    -- unary postfix operators.+    PostfixOperators+  | -- | Enable quasi-quotation, a mechanism for defining new concrete+    -- syntax for expressions and patterns.+    QuasiQuotes+  | -- | Enable generalized list comprehensions, supporting operations+    -- such as sorting and grouping.+    TransformListComp+  | -- | Enable monad comprehensions, which generalise the list+    -- comprehension syntax to work for any monad.+    MonadComprehensions+  | -- | Enable view patterns, which match a value by applying a+    -- function and matching on the result.+    ViewPatterns+  | -- | Allow concrete XML syntax to be used in expressions and patterns,+    -- as per the Haskell Server Pages extension language:+    -- <http://www.haskell.org/haskellwiki/HSP>. The ideas behind it are+    -- discussed in the paper \"Haskell Server Pages through Dynamic Loading\"+    -- by Niklas Broberg, from Haskell Workshop '05.+    XmlSyntax+  | -- | Allow regular pattern matching over lists, as discussed in the+    -- paper \"Regular Expression Patterns\" by Niklas Broberg, Andreas Farre+    -- and Josef Svenningsson, from ICFP '04.+    RegularPatterns+  | -- | Enable the use of tuple sections, e.g. @(, True)@ desugars into+    -- @\x -> (x, True)@.+    TupleSections+  | -- | Allow GHC primops, written in C--, to be imported into a Haskell+    -- file.+    GHCForeignImportPrim+  | -- | Support for patterns of the form @n + k@, where @k@ is an+    -- integer literal.+    NPlusKPatterns+  | -- | Improve the layout rule when @if@ expressions are used in a @do@+    -- block.+    DoAndIfThenElse+  | -- | Enable support for multi-way @if@-expressions.+    MultiWayIf+  | -- | Enable support lambda-@case@ expressions.+    LambdaCase+  | -- | Makes much of the Haskell sugar be desugared into calls to the+    -- function with a particular name that is in scope.+    RebindableSyntax+  | -- | Make @forall@ a keyword in types, which can be used to give the+    -- generalisation explicitly.+    ExplicitForAll+  | -- | Allow contexts to be put on datatypes, e.g. the @Eq a@ in+    -- @data Eq a => Set a = NilSet | ConsSet a (Set a)@.+    DatatypeContexts+  | -- | Local (@let@ and @where@) bindings are monomorphic.+    MonoLocalBinds+  | -- | Enable @deriving@ for the 'Data.Functor.Functor' class.+    DeriveFunctor+  | -- | Enable @deriving@ for the 'Data.Traversable.Traversable' class.+    DeriveTraversable+  | -- | Enable @deriving@ for the 'Data.Foldable.Foldable' class.+    DeriveFoldable+  | -- | Enable non-decreasing indentation for @do@ blocks.+    NondecreasingIndentation+  | -- | Allow imports to be qualified with a safe keyword that requires+    -- the imported module be trusted as according to the Safe Haskell+    -- definition of trust.+    --+    -- > import safe Network.Socket+    SafeImports+  | -- | Compile a module in the Safe, Safe Haskell mode -- a restricted+    -- form of the Haskell language to ensure type safety.+    Safe+  | -- | Compile a module in the Trustworthy, Safe Haskell mode -- no+    -- restrictions apply but the module is marked as trusted as long as+    -- the package the module resides in is trusted.+    Trustworthy+  | -- | Compile a module in the Unsafe, Safe Haskell mode so that+    -- modules compiled using Safe, Safe Haskell mode can't import it.+    Unsafe+  | -- | Allow type class/implicit parameter/equality constraints to be+    -- used as types with the special kind constraint.  Also generalise+    -- the @(ctxt => ty)@ syntax so that any type of kind constraint can+    -- occur before the arrow.+    ConstraintKinds+  | -- | Enable kind polymorphism.+    PolyKinds+  | -- | Enable datatype promotion.+    DataKinds+  | -- | Enable @type data@ declarations, defining constructors at the type level.+    TypeData+  | -- | Enable parallel arrays syntax (@[:@, @:]@) for /Data Parallel Haskell/.+    ParallelArrays+  | -- | Enable explicit role annotations, like in (@type role Foo representational representational@).+    RoleAnnotations+  | -- | Enable overloading of list literals, arithmetic sequences and+    -- list patterns using the 'IsList' type class.+    OverloadedLists+  | -- | Enable case expressions that have no alternatives. Also applies to lambda-case expressions if they are enabled.+    EmptyCase+  | -- | /(deprecated)/ Deprecated in favour of 'DeriveDataTypeable'.+    --+    -- Old description: Triggers the generation of derived 'Typeable'+    -- instances for every datatype and type class declaration.+    AutoDeriveTypeable+  | -- | Desugars negative literals directly (without using negate).+    NegativeLiterals+  | -- | Allow the use of binary integer literal syntax (e.g. @0b11001001@ to denote @201@).+    BinaryLiterals+  | -- | Allow the use of floating literal syntax for all instances of 'Num', including 'Int' and 'Integer'.+    NumDecimals+  | -- | Enable support for type classes with no type parameter.+    NullaryTypeClasses+  | -- | Enable explicit namespaces in module import/export lists.+    ExplicitNamespaces+  | -- | Allow the user to write ambiguous types, and the type inference engine to infer them.+    AllowAmbiguousTypes+  | -- | Enable @foreign import javascript@.+    JavaScriptFFI+  | -- | Allow giving names to and abstracting over patterns.+    PatternSynonyms+  | -- | Allow anonymous placeholders (underscore) inside type signatures.  The+    -- type inference engine will generate a message describing the type inferred+    -- at the hole's location.+    PartialTypeSignatures+  | -- | Allow named placeholders written with a leading underscore inside type+    -- signatures.  Wildcards with the same name unify to the same type.+    NamedWildCards+  | -- | Enable @deriving@ for any class.+    DeriveAnyClass+  | -- | Enable @deriving@ for the 'Language.Haskell.TH.Syntax.Lift' class.+    DeriveLift+  | -- | Enable support for 'static pointers' (and the @static@+    -- keyword) to refer to globally stable names, even across+    -- different programs.+    StaticPointers+  | -- | Switches data type declarations to be strict by default (as if+    -- they had a bang using @BangPatterns@), and allow opt-in field+    -- laziness using @~@.+    StrictData+  | -- | Switches all pattern bindings to be strict by default (as if+    -- they had a bang using @BangPatterns@), ordinary patterns are+    -- recovered using @~@. Implies @StrictData@.+    Strict+  | -- | Allows @do@-notation for types that are @'Applicative'@ as well+    -- as @'Monad'@. When enabled, desugaring @do@ notation tries to use+    -- @(<*>)@ and @'fmap'@ and @'join'@ as far as possible.+    ApplicativeDo+  | -- | Allow records to use duplicated field labels for accessors.+    DuplicateRecordFields+  | -- | Enable explicit type applications with the syntax @id \@Int@.+    TypeApplications+  | -- | Dissolve the distinction between types and kinds, allowing the compiler+    -- to reason about kind equality and therefore enabling GADTs to be promoted+    -- to the type-level.+    TypeInType+  | -- | Allow recursive (and therefore undecidable) super-class relationships.+    UndecidableSuperClasses+  | -- | A temporary extension to help library authors check if their+    -- code will compile with the new planned desugaring of fail.+    MonadFailDesugaring+  | -- | A subset of @TemplateHaskell@ including only quoting.+    TemplateHaskellQuotes+  | -- | Allows use of the @#label@ syntax.+    OverloadedLabels+  | -- | Allow functional dependency annotations on type families to declare them+    -- as injective.+    TypeFamilyDependencies+  | -- | Allow multiple @deriving@ clauses, each optionally qualified with a+    -- /strategy/.+    DerivingStrategies+  | -- | Enable deriving instances via types of the same runtime representation.+    -- Implies 'DerivingStrategies'.+    DerivingVia+  | -- | Enable the use of unboxed sum syntax.+    UnboxedSums+  | -- | Allow use of hexadecimal literal notation for floating-point values.+    HexFloatLiterals+  | -- | Allow @do@ blocks etc. in argument position.+    BlockArguments+  | -- | Allow use of underscores in numeric literals.+    NumericUnderscores+  | -- | Allow @forall@ in constraints.+    QuantifiedConstraints+  | -- | Have @*@ refer to @Type@.+    StarIsType+  | -- | Liberalises deriving to provide instances for empty data types.+    EmptyDataDeriving+  | -- | Enable detection of complete user-supplied kind signatures.+    CUSKs+  | -- | Allows the syntax @import M qualified@.+    ImportQualifiedPost+  | -- | Allow the use of standalone kind signatures.+    StandaloneKindSignatures+  | -- | Enable unlifted newtypes.+    UnliftedNewtypes+  | -- | Use whitespace to determine whether the minus sign stands for negation or subtraction.+    LexicalNegation+  | -- | Enable qualified do-notation desugaring.+    QualifiedDo+  | -- | Enable linear types.+    LinearTypes+  | -- | Allow the use of visible forall in types of terms.+    RequiredTypeArguments+  | -- | Enable the generation of selector functions corresponding to record fields.+    FieldSelectors+  | -- | Enable the use of record dot-accessor and updater syntax+    OverloadedRecordDot+  | -- | Provides record @.@ syntax in record updates, e.g. @x {foo.bar = 1}@.+    OverloadedRecordUpdate+  | -- | Enable data types for which an unlifted or levity-polymorphic result kind is inferred.+    UnliftedDatatypes+  | -- | Enable syntax for primitive numeric literals, e.g. @3#Int8@+    ExtendedLiterals+  | -- | Undocumented parsing-related extensions introduced in GHC 7.0.+    AlternativeLayoutRule+  | -- | Undocumented parsing-related extensions introduced in GHC 7.0.+    AlternativeLayoutRuleTransitional+  | -- | Undocumented parsing-related extensions introduced in GHC 7.2.+    RelaxedLayout+  | -- | Allow the use of type abstraction syntax.+    TypeAbstractions+  | -- | Allow the use of built-in syntax for list, tuple and sum type constructors+    -- rather than being exclusive to data constructors.+    ListTuplePuns+  | -- | Support multiline strings.+    MultilineStrings+  | -- | Allow use of or-pattern syntax, condensing multiple patterns+    -- into a single one.+    OrPatterns+  deriving (Generic, Show, Read, Eq, Ord, Enum, Bounded, Data)++instance Binary KnownExtension+instance Structured KnownExtension++instance NFData KnownExtension where rnf = genericRnf++-- | Extensions that have been deprecated, possibly paired with another+-- extension that replaces it.+deprecatedExtensions :: [(Extension, Maybe Extension)]+deprecatedExtensions =+  [ (EnableExtension RecordPuns, Just (EnableExtension NamedFieldPuns))+  , (EnableExtension PatternSignatures, Just (EnableExtension ScopedTypeVariables))+  ]++-- NOTE: when adding deprecated extensions that have new alternatives+-- we must be careful to make sure that the deprecation messages are+-- valid. We must not recommend aliases that cannot be used with older+-- compilers, perhaps by adding support in Cabal to translate the new+-- name to the old one for older compilers. Otherwise we are in danger+-- of the scenario in ticket #689.++instance Pretty Extension where+  pretty (UnknownExtension other) = Disp.text other+  pretty (EnableExtension ke) = Disp.text (show ke)+  pretty (DisableExtension ke) = Disp.text ("No" ++ show ke)++instance Parsec Extension where+  parsec = classifyExtension <$> P.munch1 isAlphaNum++instance Pretty KnownExtension where+  pretty ke = Disp.text (show ke)++classifyExtension :: String -> Extension+classifyExtension string =+  case classifyKnownExtension string of+    Just ext -> EnableExtension ext+    Nothing ->+      case string of+        'N' : 'o' : string' ->+          case classifyKnownExtension string' of+            Just ext -> DisableExtension ext+            Nothing -> UnknownExtension string+        _ -> UnknownExtension string++-- | 'read' for 'KnownExtension's is really really slow so for the Text+-- instance+-- what we do is make a simple table indexed off the first letter in the+-- extension name. The extension names actually cover the range @'A'-'Z'@+-- pretty densely and the biggest bucket is 7 so it's not too bad. We just do+-- a linear search within each bucket.+--+-- This gives an order of magnitude improvement in parsing speed, and it'll+-- also allow us to do case insensitive matches in future if we prefer.+classifyKnownExtension :: String -> Maybe KnownExtension+classifyKnownExtension "" = Nothing+classifyKnownExtension string@(c : _)+  | inRange (bounds knownExtensionTable) c =+      lookup string (knownExtensionTable ! c)+  | otherwise = Nothing++knownExtensionTable :: Array Char [(String, KnownExtension)]+knownExtensionTable =+  accumArray+    (flip (:))+    []+    ('A', 'Z')     [ (hd, (str, extension)) -- assume KnownExtension's Show returns a non-empty string     | (extension, str@(hd : _)) <- map (\e -> (e, show e)) [toEnum 0 ..]     ]