packages feed

exherbo-cabal 0.1.0.4 → 0.1.1.0

raw patch · 3 files changed

+78/−15 lines, 3 filesdep +doctestdep +exherbo-cabal

Dependencies added: doctest, exherbo-cabal

Files

exherbo-cabal.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.4+version:             0.1.1.0  -- A short (one-line) description of the package. synopsis:            Exheres generator for cabal packages@@ -50,13 +50,36 @@   type:     git   location: https://github.com/ony/exherbo-cabal +library+  Exposed-modules:+    ExRender++  build-depends:+    Cabal >=1.20 && <1.23,+    base >=4.7 && <4.9,+    containers,+    haddock-library >=1.0 && <1.3,+    pretty >=1.1 && <1.2++  hs-source-dirs: src+  default-language: Haskell2010+  ghc-options: -O3 -Wall -fwarn-tabs -fwarn-monomorphism-restriction++test-suite doctests+  type: exitcode-stdio-1.0+  ghc-options: -threaded+  main-is: src/doctests.hs+  build-depends:+    base >=4.7 && <4.9,+    doctest >=0.8+  default-language: Haskell2010+ executable exherbo-cabal   ghc-options: -O3 -Wall -fwarn-tabs -fwarn-monomorphism-restriction   -- .hs or .lhs file containing the Main module.-  main-is: Main.hs+  main-is: src/Main.hs      -- Modules included in this executable, other than Main.-  other-modules: ExRender      -- LANGUAGE extensions used by modules in this package.   other-extensions:@@ -71,16 +94,10 @@     Cabal >=1.20 && <1.23,     base >=4.7 && <4.9,     bytestring >=0.10 && <0.11,-    containers,-    haddock-library >=1.0 && <1.3,+    exherbo-cabal >=0.1.1 && <0.2,     http-client >=0.4 && <0.5,     http-types <1,-    pcre-light <0.5,-    pretty >=1.1 && <1.2-  -  -- Directories containing source files.-  -- hs-source-dirs:      -  hs-source-dirs:      src+    pcre-light <0.5      -- Base language which the package is written in.   default-language:    Haskell2010
src/ExRender.hs view
@@ -35,7 +35,7 @@                 x → error $ "Unsupported compiler " ++ show x  exKnownLicenses ∷ [String]-exKnownLicenses = ["CC0"]+exKnownLicenses = ["CC0", "AGPL-3"]  -- | Double-quoted string for bash dquoted ∷ String → String@@ -112,8 +112,10 @@     exDisp (UpperBound v ExclusiveBound) = "<" <> disp v     exDisp x = error $ "Unsupported UpperBound: " ++ show x --- | Render some of VersionInterval's that can be represented with a single--- condition and thus suitable for using in disjunction list+-- | Render some of VersionInterval's that can be represented with a single condition and thus suitable for using in disjunction list.+--+-- >>> map maybeExVersion $ asVersionIntervals (fromJust $ simpleParse ">=1.0 || ==0.1.*" :: VersionRange)+-- [Just =0.1*,Just >=1.0] maybeExVersion ∷ VersionInterval → Maybe Doc maybeExVersion = \case     -- >=x && <=x@@ -142,6 +144,35 @@      _ → Nothing +-- | Transform VersionInterval in a sequence of disjunctions+--+-- >>> map exVersions $ asVersionIntervals (fromJust $ simpleParse ">=1.0" :: VersionRange)+-- [[>=1.0]]+-- >>> map exVersions $ asVersionIntervals (fromJust $ simpleParse ">=1.0 && <1.3" :: VersionRange)+-- [[=1.0*,=1.1*,=1.2*]]+-- >>> map exVersions $ asVersionIntervals (fromJust $ simpleParse ">=1.0 && <=1.3" :: VersionRange)+-- [[=1.0*,=1.1*,=1.2*,=1.3]]+-- >>> map exVersions $ asVersionIntervals (fromJust $ simpleParse ">=1 && <=1.3" :: VersionRange)+-- [[=1,=1.0*,=1.1*,=1.2*,=1.3]]+-- >>> map exVersions $ asVersionIntervals (fromJust $ simpleParse ">=1 && <=1.0.3" :: VersionRange)+-- [[=1,=1.0,=1.0.0*,=1.0.1*,=1.0.2*,=1.0.3]]+exVersions ∷ VersionInterval → [Doc]+exVersions = \case+    (maybeExVersion → Just x) → [x]++    -- ... && <=x.b+    (lb, UpperBound v InclusiveBound) →+        exVersions (lb, UpperBound v ExclusiveBound) ++ [char '=' <> disp v]++    -- >=x.a && <x.b+    (LowerBound va@(Version a _) InclusiveBound, ub@(UpperBound (Version b _) ExclusiveBound))+        | init a == init b → do+            c ← [init a ++ [i] | i ← [last a .. last b - 1]]+            return $ char '=' <> disp (Version c []) <> char '*'+        | length a < length b →+            char '=' <> disp va : exVersions (LowerBound (Version (a ++ [0]) []) InclusiveBound, ub)+    _ → []+ instance ExRender VersionInterval where     exDisp (LowerBound (Version [0] []) InclusiveBound, NoUpperBound) = empty     exDisp (maybeExVersion → Just exVi) = exVi@@ -150,7 +181,7 @@ instance ExRender VersionRange where     exDisp vr = case asVersionIntervals vr of         [vi] → nbrackets $ exDisp vi-        (mapM maybeExVersion → Just exVis) → nbrackets . hcat $ punctuate (char '|') exVis+        (concatMap exVersions → exVis) | not $ null exVis → nbrackets . hcat $ punctuate (char '|') exVis         _ → error $ "Unsupported version range: " ++ display vr  instance ExRender Dependency where@@ -316,3 +347,16 @@  -- TODO: drop test deps that already in build -- TODO: use renderStyle instead of manual wrapping++-- $setup+--+-- doctest examples:+--+-- >>> exRender (fromJust $ simpleParse ">=1.0 && <1.3" :: VersionRange)+-- "[>=1.0&<1.3]"+-- >>> exRender (fromJust $ simpleParse ">=1.1 && <2" :: VersionRange)+-- "[~1.1]"+-- >>> exRender (fromJust $ simpleParse "==1.* || ==3.*" :: VersionRange)+-- "[=1*|=3*]"+-- >>> exRender (fromJust $ simpleParse "==1.1.* || ==1.0.* || ==0.11.*" :: VersionRange)+-- "[=0.11*|=1.0*|=1.1*]"
+ src/doctests.hs view
@@ -0,0 +1,2 @@+import Test.DocTest+main = doctest ["-isrc", "src/ExRender.hs"]