Hello community, here is the log from the commit of package ghc-slug for openSUSE:Factory checked in at 2017-08-31 20:59:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-slug (Old) and /work/SRC/openSUSE:Factory/.ghc-slug.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-slug" Thu Aug 31 20:59:42 2017 rev:4 rq:513498 version:0.1.7 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-slug/ghc-slug.changes 2017-05-10 20:49:47.357013048 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-slug.new/ghc-slug.changes 2017-08-31 20:59:46.439508461 +0200 @@ -1,0 +2,5 @@ +Thu Jul 27 14:06:59 UTC 2017 - psimons@suse.com + +- Update to version 0.1.7. + +------------------------------------------------------------------- Old: ---- slug-0.1.6.tar.gz slug.cabal New: ---- slug-0.1.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-slug.spec ++++++ --- /var/tmp/diff_new_pack.3AUCgV/_old 2017-08-31 20:59:48.271251097 +0200 +++ /var/tmp/diff_new_pack.3AUCgV/_new 2017-08-31 20:59:48.279249973 +0200 @@ -19,14 +19,13 @@ %global pkg_name slug %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.1.6 +Version: 0.1.7 Release: 0 Summary: Type-safe slugs for Yesod ecosystem License: BSD-3-Clause Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz -Source1: https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/1.cabal#/%{pkg_name}.cabal BuildRequires: ghc-Cabal-devel BuildRequires: ghc-QuickCheck-devel BuildRequires: ghc-aeson-devel @@ -57,7 +56,6 @@ %prep %setup -q -n %{pkg_name}-%{version} -cp -p %{SOURCE1} %{pkg_name}.cabal %build %ghc_lib_build ++++++ slug-0.1.6.tar.gz -> slug-0.1.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/slug-0.1.6/CHANGELOG.md new/slug-0.1.7/CHANGELOG.md --- old/slug-0.1.6/CHANGELOG.md 2017-01-02 22:52:16.000000000 +0100 +++ new/slug-0.1.7/CHANGELOG.md 2017-07-22 07:25:18.000000000 +0200 @@ -1,3 +1,9 @@ +## Slug 0.1.7 + +* Defined `Semigroup` instance for `Slug`. + +* Improved documentation and metadata. + ## Slug 0.1.6 * Allowed Aeson 1.1. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/slug-0.1.6/README.md new/slug-0.1.7/README.md --- old/slug-0.1.6/README.md 2017-01-01 01:21:17.000000000 +0100 +++ new/slug-0.1.7/README.md 2017-06-02 17:36:47.000000000 +0200 @@ -7,17 +7,17 @@ [![Build Status](https://travis-ci.org/mrkkrp/slug.svg?branch=master)](https://travis-ci.org/mrkkrp/slug) [![Coverage Status](https://coveralls.io/repos/mrkkrp/slug/badge.svg?branch=master&service=github)](https://coveralls.io/github/mrkkrp/slug?branch=master) -This is [slug](https://en.wikipedia.org/wiki/Semantic_URL#Slug) -implementation that plays nicely with [Yesod](http://www.yesodweb.com/) +This is a [slug](https://en.wikipedia.org/wiki/Semantic_URL#Slug) +implementation that plays nicely with the [Yesod](http://www.yesodweb.com/) ecosystem. Although it's fairly easy to write this thing, slugs are useful and general enough to be coded once and be used again and again. So this little package eliminates some boilerplate you might find yourself writing. ## Quick start -The package provides data type `Slug` that is instance of various type -classes, so it can be used with Persistent or as part of route. It also -works with `aeson` package. +The package provides the data type `Slug` that is an instance of various +type classes, so it can be used with Persistent or as a part of a route. It +also works with the `aeson` package. The slugs are completely type-safe. When you have a `Slug`, you can be sure that there is a valid slug inside. Valid slug has the following qualities: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/slug-0.1.6/Web/Slug.hs new/slug-0.1.7/Web/Slug.hs --- old/slug-0.1.6/Web/Slug.hs 2017-01-03 00:29:08.000000000 +0100 +++ new/slug-0.1.7/Web/Slug.hs 2017-06-02 17:36:47.000000000 +0200 @@ -3,7 +3,7 @@ -- Copyright : © 2015–2017 Mark Karpov -- License : BSD 3 clause -- --- Maintainer : Mark Karpov <markkarpov@openmailbox.org> +-- Maintainer : Mark Karpov <markkarpov92@gmail.com> -- Stability : experimental -- Portability : portable -- @@ -23,12 +23,13 @@ where import Control.Exception (Exception (..)) -import Control.Monad ((>=>), liftM) +import Control.Monad import Control.Monad.Catch (MonadThrow (..)) import Data.Aeson.Types (ToJSON (..), FromJSON (..)) import Data.Char (isAlphaNum) import Data.Data (Data) import Data.Maybe (isJust, fromJust) +import Data.Semigroup import Data.Text (Text) import Data.Typeable (Typeable) import Database.Persist.Class (PersistField (..)) @@ -41,11 +42,11 @@ import qualified Data.Text as T #if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>)) +import Control.Applicative #endif -- | This exception is thrown by 'mkSlug' when its input cannot be converted --- into proper 'Slug'. +-- into a proper 'Slug'. data SlugException = InvalidInput Text -- ^ Slug cannot be generated for given text @@ -74,12 +75,15 @@ newtype Slug = Slug Text deriving (Eq, Ord, Data, Typeable) --- | Create 'Slug' from 'Text', all necessary transformations are --- applied. Argument of this function can be title of an article or +instance Semigroup Slug where + x <> y = Slug (unSlug x <> "-" <> unSlug y) + +-- | Create a 'Slug' from a 'Text' value, all necessary transformations are +-- applied. The argument of this function can be title of an article or -- something like that. -- --- Note that result is inside 'MonadThrow', that means you can just get it --- in 'Maybe', in more complex contexts it will throw 'SlugException' +-- Note that the result is inside 'MonadThrow', that means you can just get +-- it in 'Maybe', in more complex contexts it will throw 'SlugException' -- exception using 'InvalidInput' constructor. -- -- This function also has a useful property: @@ -93,30 +97,32 @@ then throwM (InvalidInput text) else return . Slug . T.intercalate "-" $ ws --- | Get textual representation if 'Slug'. +-- | Get textual representation of a 'Slug'. unSlug :: Slug -> Text unSlug (Slug x) = x --- | Convert 'Text' to possibly empty collection of words. Every word is --- guaranteed to be non-empty alpha-numeric lowercased sequence of +-- | Convert 'Text' to a possibly empty collection of words. Every word is +-- guaranteed to be non-empty alpha-numeric lower-cased sequence of -- characters. getSlugWords :: Text -> [Text] getSlugWords = T.words . T.toLower . T.map f . T.replace "'" "" - where f x = if isAlphaNum x then x else ' ' + where + f x = if isAlphaNum x then x else ' ' --- | Convert 'Text' into 'Slug' only when it is already valid slug. +-- | Convert a 'Text' into a 'Slug' only when it is already valid slug. -- --- This function can throw 'SlugException' exception using 'InvalidSlug' +-- This function can throw the 'SlugException' exception using 'InvalidSlug' -- constructor. parseSlug :: MonadThrow m => Text -> m Slug parseSlug v = mkSlug v >>= check - where check s = - if unSlug s == v - then return s - else throwM (InvalidSlug v) + where + check s = + if unSlug s == v + then return s + else throwM (InvalidSlug v) -- | Ensure that given 'Slug' is not longer than given maximum number of -- characters. If truncated slug ends in a dash, remove that dash too. (Dash diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/slug-0.1.6/slug.cabal new/slug-0.1.7/slug.cabal --- old/slug-0.1.6/slug.cabal 2017-01-03 00:30:48.000000000 +0100 +++ new/slug-0.1.7/slug.cabal 2017-07-22 07:57:13.000000000 +0200 @@ -1,42 +1,11 @@ --- --- Cabal configuration for ‘slug’. --- --- Copyright © 2015–2017 Mark Karpov --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- * Neither the name Mark Karpov nor the names of contributors may be used --- to endorse or promote products derived from this software without --- specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY --- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY --- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, --- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN --- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. - name: slug -version: 0.1.6 -cabal-version: >= 1.10 +version: 0.1.7 +cabal-version: >= 1.18 +tested-with: GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.1 license: BSD3 license-file: LICENSE.md -author: Mark Karpov <markkarpov@opmbx.org> -maintainer: Mark Karpov <markkarpov@opmbx.org> +author: Mark Karpov <markkarpov92@gmail.com> +maintainer: Mark Karpov <markkarpov92@gmail.com> homepage: https://github.com/mrkkrp/slug bug-reports: https://github.com/mrkkrp/slug/issues category: Web, Yesod @@ -53,13 +22,15 @@ library build-depends: QuickCheck >= 2.4 && < 3.0 - , aeson >= 0.8 && < 1.2 + , aeson >= 0.8 && < 1.3 , base >= 4.7 && < 5.0 , exceptions >= 0.6 && < 0.9 , http-api-data >= 0.2 && < 0.4 , path-pieces >= 0.1.5 && < 0.3 , persistent >= 2.0 && < 3.0 , text >= 1.0 && < 1.3 + if !impl(ghc >= 8.0) + build-depends: semigroups == 0.18.* default-extensions: OverloadedStrings exposed-modules: Web.Slug if flag(dev) @@ -83,8 +54,10 @@ , hspec >= 2.0 && < 3.0 , http-api-data >= 0.2 && < 0.4 , path-pieces >= 0.1.5 && < 0.3 - , slug >= 0.1.6 + , slug , text >= 1.0 && < 1.3 + if !impl(ghc >= 8.0) + build-depends: semigroups == 0.18.* default-language: Haskell2010 source-repository head diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/slug-0.1.6/tests/Main.hs new/slug-0.1.7/tests/Main.hs --- old/slug-0.1.6/tests/Main.hs 2017-01-03 00:29:34.000000000 +0100 +++ new/slug-0.1.7/tests/Main.hs 2017-07-22 07:24:52.000000000 +0200 @@ -1,44 +1,13 @@ --- --- Slug tests. --- --- Copyright © 2015–2017 Mark Karpov --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- * Neither the name Mark Karpov nor the names of contributors may be used --- to endorse or promote products derived from this software without --- specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY --- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY --- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, --- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN --- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. - {-# LANGUAGE CPP #-} {-# OPTIONS -fno-warn-orphans #-} module Main (main) where import Control.Monad ((>=>)) -import Data.Char (isAlphaNum, isUpper) +import Data.Char (isAlphaNum) import Data.Function (on) import Data.Maybe (isJust, isNothing) +import Data.Semigroup import Data.Text (Text) import Test.Hspec import Test.QuickCheck @@ -73,9 +42,9 @@ it "does not contain empty words between dashes" $ property $ \slug -> T.splitOn "-" (unSlug slug) `shouldNotSatisfy` any T.null - it "no upper-cased chars found in slugs" $ - property $ \slug -> - unSlug slug `shouldNotSatisfy` T.any isUpper + -- it "no upper-cased chars found in slugs" $ + -- property $ \slug -> + -- unSlug slug `shouldNotSatisfy` T.any isUpper it "showed Slug looks the same as its inner Text" $ property $ \slug -> show slug === show (unSlug slug) @@ -91,6 +60,12 @@ it "valid Slug text is a valid HTTP API data" $ property $ \slug -> parseUrlPiece (toUrlPiece slug) === Right (slug :: Slug) + describe "Semigroup instance of Slug" $ + it "the (<>) operation produces valid slugs in all cases" $ + property $ \x y -> do + let slug = unSlug (x <> y) + slug' <- unSlug <$> parseSlug slug + slug' `shouldBe` slug describe "mkSlug" $ do it "Slug transformation in idempotent" $ property $ \x ->