Hello community,

here is the log from the commit of package ghc-Spintax for openSUSE:Factory 
checked in at 2017-03-03 17:47:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-Spintax (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-Spintax.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-Spintax"

Fri Mar  3 17:47:32 2017 rev:3 rq:461528 version:0.3.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-Spintax/ghc-Spintax.changes  2016-11-10 
13:19:26.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-Spintax.new/ghc-Spintax.changes     
2017-03-03 17:48:06.010904398 +0100
@@ -1,0 +2,5 @@
+Sun Feb 12 14:08:03 UTC 2017 - [email protected]
+
+- Update to version 0.3.1 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  Spintax-0.1.0.1.tar.gz

New:
----
  Spintax-0.3.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-Spintax.spec ++++++
--- /var/tmp/diff_new_pack.avIvmg/_old  2017-03-03 17:48:06.682809508 +0100
+++ /var/tmp/diff_new_pack.avIvmg/_new  2017-03-03 17:48:06.682809508 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-Spintax
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %global pkg_name Spintax
 Name:           ghc-%{pkg_name}
-Version:        0.1.0.1
+Version:        0.3.1
 Release:        0
 Summary:        Random text generation based on spintax
 License:        BSD-3-Clause
@@ -28,6 +28,7 @@
 BuildRequires:  ghc-Cabal-devel
 BuildRequires:  ghc-attoparsec-devel
 BuildRequires:  ghc-extra-devel
+BuildRequires:  ghc-mtl-devel
 BuildRequires:  ghc-mwc-random-devel
 BuildRequires:  ghc-rpm-macros
 BuildRequires:  ghc-text-devel

++++++ Spintax-0.1.0.1.tar.gz -> Spintax-0.3.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Spintax-0.1.0.1/Spintax.cabal 
new/Spintax-0.3.1/Spintax.cabal
--- old/Spintax-0.1.0.1/Spintax.cabal   2016-10-19 11:36:08.000000000 +0200
+++ new/Spintax-0.3.1/Spintax.cabal     2016-12-26 16:30:29.000000000 +0100
@@ -1,5 +1,5 @@
 name:                Spintax
-version:             0.1.0.1
+version:             0.3.1
 synopsis:            Random text generation based on spintax
 description:         Random text generation based on spintax with nested 
alternatives and empty options.
 homepage:            https://github.com/MichelBoucey/spintax
@@ -7,21 +7,22 @@
 license-file:        LICENSE
 author:              Michel Boucey
 maintainer:          [email protected]
-copyright:           Copyright (c) 2016 - Michel Boucey
+copyright:           (c) 2016 - Michel Boucey
 category:            Text
 build-type:          Simple
 cabal-version:       >=1.10
 
 library
-  hs-source-dirs:      src
-  exposed-modules:     Text.Spintax
-  build-depends:       base >= 4.7 && < 5
-                     , text
-                     , attoparsec
-                     , mwc-random
-                     , extra
-  default-language:    Haskell2010
-  GHC-Options:         -Wall
+  hs-source-dirs:    src
+  exposed-modules:   Text.Spintax
+  build-depends:     attoparsec   >= 0.12.1.6 && < 0.14
+                   , base         >= 4.7 && < 5
+                   , extra        >= 1.4.3 && < 1.6
+                   , mtl          >= 2.2.1 && < 2.3
+                   , mwc-random   >= 0.13.3.2 && < 0.14
+                   , text         >= 1.2.2 && < 1.3
+  default-language:  Haskell2010
+  GHC-Options:       -Wall
 
 source-repository head
   type:     git
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Spintax-0.1.0.1/src/Text/Spintax.hs 
new/Spintax-0.3.1/src/Text/Spintax.hs
--- old/Spintax-0.1.0.1/src/Text/Spintax.hs     2016-10-19 11:26:20.000000000 
+0200
+++ new/Spintax-0.3.1/src/Text/Spintax.hs       2016-11-28 10:22:17.000000000 
+0100
@@ -1,8 +1,10 @@
 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE FlexibleContexts #-}
 
 module Text.Spintax (spintax) where
 
 import           Control.Applicative  ((<|>))
+import           Control.Monad.Reader (runReaderT, ask)
 import           Data.Attoparsec.Text
 import qualified Data.List.Extra      as E
 import           Data.Monoid          ((<>))
@@ -11,73 +13,77 @@
 
 -- | Generate random texts based on a spinning syntax template, with nested 
alternatives and empty options.
 --
--- >λ> spintax {{Oh my God|Awesome}, {a|the}|A|The} {quick {and dirty 
|||}||}{brown |pink |grey |}{fox|flea|elephant} jumps over {the|a} {lazy 
|smelly |sleepy |}{dog|cat|whale}{.|!|...}
+-- >λ> spintax "{{Oh my God|Awesome}, {a|the}|A|The} {quick {and dirty 
|||}||}{brown |pink |grey |}{fox|flea|elephant} jumps over {the|a} {lazy 
|smelly |sleepy |}{dog|cat|whale}{.|!|...}"
 -- > Right "Awesome, the quick pink fox jumps over a sleepy whale."
 --
-spintax :: T.Text -> IO (Either T.Text T.Text)
+spintax :: T.Text -> IO (Either String T.Text)
 spintax template =
-  createSystemRandom >>= flip runParse template
+  createSystemRandom >>= runReaderT (spin template)
+  where
+    spin t = go T.empty [] t (0::Int)
+      where
+        go o as i l
+          | l < 0  = parseFail
+          | l == 0 =
+            case parse spinSyntax i of
+              Done r m  ->
+                case m of
+                  "{" -> go o as r (l+1)
+                  n | n == "}" || n == "|" -> parseFail
+                  _   -> go (o <> m) as r l
+              Partial _ -> return $ Right $ o <> i
+              Fail {}   -> parseFail
+          | l == 1 =
+            case parse spinSyntax i of
+              Done r m ->
+                case m of
+                  "{" -> go o (add as m) r (l+1)
+                  "}" -> do
+                    a <- spin =<< randAlter as =<< ask
+                    case a of
+                      Left _   -> parseFail
+                      Right t' -> go (o <> t') [] r (l-1)
+                  "|" ->
+                    if E.null as
+                      then go o ["",""] r l
+                      else go o (E.snoc as "") r l
+                  _   -> go o (add as m) r l
+              Partial _ -> parseFail
+              Fail {} -> parseFail
+          | l > 1 =
+            case parse spinSyntax i of
+              Done r m ->
+                case m of
+                  "{" -> go o (add as m) r (l+1)
+                  "}" -> go o (add as m) r (l-1)
+                  _   -> go o (add as m) r l
+              Partial _ -> parseFail
+              Fail {}   -> parseFail
+          where
+            add _l _t =
+              case E.unsnoc _l of
+                Just (xs,x) -> E.snoc xs $ x <> _t
+                Nothing     -> [_t]
+            randAlter _as _g =
+              (\r -> (!!) as (r-1)) <$> uniformR (1,E.length _as) _g
+        go _ _ _ _ = parseFail 
+        parseFail = fail msg
+
+spinSyntax :: Parser T.Text
+spinSyntax =
+  openBrace <|> closeBrace <|> pipe <|> content
     where
-      runParse g' i' = go g' "" [] i' (0::Int)
-        where
-          go g o as i l
-            | l < 0  = failure
-            | l == 0 =
-              case parse spinSyntax i of
-                Done r m  ->
-                  case m of
-                    "{" -> go g o as r (l+1)
-                    "}" -> failure
-                    "|" -> failure
-                    _   -> go g (o <> m) as r l
-                Partial _ -> return $ Right $ o <> i
-                Fail {}   -> failure
-            | l == 1 =
-              case parse spinSyntax i of
-                Done r m ->
-                  case m of
-                    "{" -> go g o (add as m) r (l+1)
-                    "}" -> do r' <- runParse g =<< randAlter g as
-                              case r' of
-                                Left _ -> failure
-                                Right t -> go g (o <> t) [] r (l-1)
-                    "|" -> if E.null as
-                             then go g o ["",""] r l
-                             else go g o (E.snoc as "") r l
-                    _   -> go g o (add as m) r l
-                Partial _ -> failure
-                Fail {} -> failure
-            | l > 1 =
-              case parse spinSyntax i of
-                Done r m ->
-                  case m of
-                    "{" -> go g o (add as m) r (l+1)
-                    "}" -> go g o (add as m) r (l-1)
-                    _   -> go g o (add as m) r l
-                Partial _ -> failure
-                Fail {} -> failure
-            where
-              add _l _t =
-                case E.unsnoc _l of
-                  Just (xs,x) -> E.snoc xs $ x <> _t
-                  Nothing     -> [_t]
-              randAlter _g _as =
-                (\r -> (!!) as (r-1)) <$> uniformR (1,E.length _as) _g
-              spinSyntax =
-                openBrace <|> closeBrace <|> pipe <|> content
-                  where
-                    openBrace = string "{"
-                    closeBrace = string "}"
-                    pipe = string "|"
-                    content =
-                      takeWhile1 ctt
-                        where
-                          ctt '{' = False
-                          ctt '}' = False
-                          ctt '|' = False
-                          ctt _   = True
-          go _ _ _ _ _ = failure
+      openBrace = string "{"
+      closeBrace = string "}"
+      pipe = string "|"
+      content =
+        takeWhile1 ctt
+          where
+            ctt '{' = False
+            ctt '}' = False
+            ctt '|' = False
+            ctt _   = True
 
-failure :: IO (Either T.Text b)
-failure = return $ Left "Spintax template parsing failure"
+msg :: String
+msg = "Spintax template parsing failure"
 


Reply via email to