Hello community,

here is the log from the commit of package ghc-Spintax for openSUSE:Factory 
checked in at 2016-11-10 13:19:25
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-Spintax (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-Spintax.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-Spintax"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-Spintax/ghc-Spintax.changes  2016-09-05 
21:19:46.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-Spintax.new/ghc-Spintax.changes     
2016-11-10 13:19:26.000000000 +0100
@@ -1,0 +2,5 @@
+Thu Oct 27 15:54:51 UTC 2016 - [email protected]
+
+- Update to version 0.1.0.1 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  Spintax-0.1.0.0.tar.gz

New:
----
  Spintax-0.1.0.1.tar.gz

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

Other differences:
------------------
++++++ ghc-Spintax.spec ++++++
--- /var/tmp/diff_new_pack.OwIEwA/_old  2016-11-10 13:19:27.000000000 +0100
+++ /var/tmp/diff_new_pack.OwIEwA/_new  2016-11-10 13:19:27.000000000 +0100
@@ -18,22 +18,20 @@
 
 %global pkg_name Spintax
 Name:           ghc-%{pkg_name}
-Version:        0.1.0.0
+Version:        0.1.0.1
 Release:        0
 Summary:        Random text generation based on spintax
 License:        BSD-3-Clause
-Group:          System/Libraries
+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
 BuildRequires:  ghc-Cabal-devel
-# Begin cabal-rpm deps:
 BuildRequires:  ghc-attoparsec-devel
 BuildRequires:  ghc-extra-devel
 BuildRequires:  ghc-mwc-random-devel
 BuildRequires:  ghc-rpm-macros
 BuildRequires:  ghc-text-devel
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-# End cabal-rpm deps
 
 %description
 Random text generation based on spintax with nested alternatives and empty
@@ -53,15 +51,12 @@
 %prep
 %setup -q -n %{pkg_name}-%{version}
 
-
 %build
 %ghc_lib_build
 
-
 %install
 %ghc_lib_install
 
-
 %post devel
 %ghc_pkg_recache
 

++++++ Spintax-0.1.0.0.tar.gz -> Spintax-0.1.0.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Spintax-0.1.0.0/Spintax.cabal 
new/Spintax-0.1.0.1/Spintax.cabal
--- old/Spintax-0.1.0.0/Spintax.cabal   2016-01-07 14:23:47.000000000 +0100
+++ new/Spintax-0.1.0.1/Spintax.cabal   2016-10-19 11:36:08.000000000 +0200
@@ -1,13 +1,13 @@
 name:                Spintax
-version:             0.1.0.0
+version:             0.1.0.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
 license:             BSD3
 license-file:        LICENSE
 author:              Michel Boucey
-maintainer:          [email protected]
-copyright:           Copyright © 2016 - Michel Boucey
+maintainer:          [email protected]
+copyright:           Copyright (c) 2016 - Michel Boucey
 category:            Text
 build-type:          Simple
 cabal-version:       >=1.10
@@ -21,7 +21,9 @@
                      , mwc-random
                      , extra
   default-language:    Haskell2010
+  GHC-Options:         -Wall
 
 source-repository head
   type:     git
   location: https://github.com/MichelBoucey/spintax
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Spintax-0.1.0.0/src/Text/Spintax.hs 
new/Spintax-0.1.0.1/src/Text/Spintax.hs
--- old/Spintax-0.1.0.0/src/Text/Spintax.hs     2016-01-07 14:13:02.000000000 
+0100
+++ new/Spintax-0.1.0.1/src/Text/Spintax.hs     2016-10-19 11:26:20.000000000 
+0200
@@ -1,80 +1,83 @@
 {-# LANGUAGE OverloadedStrings #-}
 
-module Text.Spintax where
+module Text.Spintax (spintax) where
 
-import Control.Applicative ((<|>))
-import Data.Attoparsec.Text
-import Data.Either
-import Data.List.Extra as E
-import Data.Text as T
-import System.Random.MWC
+import           Control.Applicative  ((<|>))
+import           Data.Attoparsec.Text
+import qualified Data.List.Extra      as E
+import           Data.Monoid          ((<>))
+import qualified Data.Text            as T
+import           System.Random.MWC
 
 -- | Generate random texts based on a spinning syntax template, with nested 
alternatives and empty options.
 --
--- >λ> spintax "{A|B|C|{a|b|c{1|2|3}|d}|D}{|, {..|etc}.}"
--- > Right "c2"
+-- >λ> 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 template =
-    createSystemRandom >>= \gen -> runParse gen template
-  where
-    runParse gen input =
-        getText gen "" [] input 0
-      where
-        getText gen output alters input nestlev 
-            | nestlev < 0  = return failure
-            | nestlev == 0 =
-                case parse spinSyntax input of
-                    Done rest match ->
-                        case match of
-                            "{" -> getText gen output alters rest (nestlev+1)
-                            "}" -> return failure
-                            "|" -> return failure
-                            _   -> getText gen (output `append` match) alters 
rest nestlev
-                    Partial _ -> return $ Right $ output `append` input
-                    Fail {} -> return failure
-            | nestlev == 1 =
-                case parse spinSyntax input of
-                    Done rest match ->
-                        case match of
-                            "{" -> getText gen output (addToLast alters match) 
rest (nestlev+1)
-                            "}" -> do result <- runParse gen =<< randAlter gen 
alters
-                                      case result of
-                                          Left _ -> return failure
-                                          Right text -> getText gen (output 
`append` text) [] rest (nestlev-1)
-                            "|" -> if E.null alters
-                                    then getText gen output ["",""] rest 
nestlev
-                                    else getText gen output (E.snoc alters "") 
rest nestlev
-                            _   -> getText gen output (addToLast alters match) 
rest nestlev
-                    Partial _ -> return failure
-                    Fail {} -> return failure 
-            | nestlev > 1 =
-                case parse spinSyntax input of
-                    Done rest match ->
-                        case match of
-                            "{" -> getText gen output (addToLast alters match) 
rest (nestlev+1)
-                            "}" -> getText gen output (addToLast alters match) 
rest (nestlev-1)
-                            _   -> getText gen output (addToLast alters match) 
rest nestlev
-                    Partial _ -> return failure
-                    Fail {} -> return failure
-          where
-            failure = Left "Spintax template parsing failure"
-            addToLast l t =
-                case E.unsnoc l of
-                    Just (xs,x) -> E.snoc xs $ x `append` t
-                    Nothing     -> [t]
-            randAlter g as = uniformR (1,E.length as) g >>= \r -> return $ 
(!!) as (r-1)
-            spinSyntax =
+  createSystemRandom >>= flip runParse template
+    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
-                pipe = string "|"
-                openBrace = string "{"
-                closeBrace = string "}"
-                content =
-                    takeWhile1 ctt
                   where
-                    ctt '{' = False
-                    ctt '}' = False
-                    ctt '|' = False
-                    ctt _   = True
+                    openBrace = string "{"
+                    closeBrace = string "}"
+                    pipe = string "|"
+                    content =
+                      takeWhile1 ctt
+                        where
+                          ctt '{' = False
+                          ctt '}' = False
+                          ctt '|' = False
+                          ctt _   = True
+          go _ _ _ _ _ = failure
+
+failure :: IO (Either T.Text b)
+failure = return $ Left "Spintax template parsing failure"
 


Reply via email to