commit ghc-MemoTrie for openSUSE:Factory
Hello community, here is the log from the commit of package ghc-MemoTrie for openSUSE:Factory checked in at 2017-04-13 10:44:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-MemoTrie (Old) and /work/SRC/openSUSE:Factory/.ghc-MemoTrie.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-MemoTrie" Thu Apr 13 10:44:38 2017 rev:2 rq:461523 version:0.6.7 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-MemoTrie/ghc-MemoTrie.changes 2016-09-24 15:21:56.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-MemoTrie.new/ghc-MemoTrie.changes 2017-04-13 10:44:39.540915161 +0200 @@ -1,0 +2,5 @@ +Sun Feb 12 14:17:37 UTC 2017 - psimons@suse.com + +- Update to version 0.6.7 with cabal2obs. + +------------------------------------------------------------------- Old: ---- 1.cabal MemoTrie-0.6.4.tar.gz New: ---- MemoTrie-0.6.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-MemoTrie.spec ++++++ --- /var/tmp/diff_new_pack.JZ5AgN/_old 2017-04-13 10:44:40.012848421 +0200 +++ /var/tmp/diff_new_pack.JZ5AgN/_new 2017-04-13 10:44:40.016847856 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-MemoTrie # -# 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,26 +18,26 @@ %global pkg_name MemoTrie Name: ghc-%{pkg_name} -Version: 0.6.4 +Version: 0.6.7 Release: 0 Summary: Trie-based memo functions 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 -Source1: https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/1.cabal BuildRequires: ghc-Cabal-devel +BuildRequires: ghc-newtype-generics-devel BuildRequires: ghc-rpm-macros BuildRoot: %{_tmppath}/%{name}-%{version}-build %description MemoTrie provides a basis for memoized functions over some domains, using tries. It's based on ideas from Ralf Hinze and code from Spencer Janssen. +Generic support thanks to Sam Boosalis. Project wiki page: http://haskell.org/haskellwiki/MemoTrie -© 2008-2015 by Conal Elliott; BSD3 license. Generic support thanks to Sam -Boosalis. +© 2008-2016 by Conal Elliott; BSD3 license. %package devel Summary: Haskell %{pkg_name} library development files @@ -52,17 +52,13 @@ %prep %setup -q -n %{pkg_name}-%{version} -cp -p %{SOURCE1} %{pkg_name}.cabal - %build %ghc_lib_build - %install %ghc_lib_install - %post devel %ghc_pkg_recache ++++++ MemoTrie-0.6.4.tar.gz -> MemoTrie-0.6.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MemoTrie-0.6.4/MemoTrie.cabal new/MemoTrie-0.6.7/MemoTrie.cabal --- old/MemoTrie-0.6.4/MemoTrie.cabal 2015-11-21 20:12:36.000000000 +0100 +++ new/MemoTrie-0.6.7/MemoTrie.cabal 2016-09-19 19:03:23.000000000 +0200 @@ -1,17 +1,16 @@ Name: MemoTrie -Version: 0.6.4 +Version: 0.6.7 Cabal-Version: >= 1.10 Synopsis: Trie-based memo functions Category: Data Description: MemoTrie provides a basis for memoized functions over some domains, using tries. It's based on ideas from Ralf Hinze and code from - Spencer Janssen. + Spencer Janssen. Generic support thanks to Sam Boosalis. . Project wiki page: http://haskell.org/haskellwiki/MemoTrie . - © 2008-2015 by Conal Elliott; BSD3 license. - Generic support thanks to Sam Boosalis. + © 2008-2016 by Conal Elliott; BSD3 license. Homepage: https://github.com/conal/MemoTrie Author: Conal Elliott Maintainer: conal@conal.net @@ -34,16 +33,14 @@ hs-Source-Dirs: src if impl(ghc >= 7.10.0) - Build-Depends: base >=4.8.0.0 && <5 + Build-Depends: base >=4.8.0.0 && <5, newtype-generics >= 0.4 else - Build-Depends: base <4.8.0.0, void + Build-Depends: base <4.8.0.0, void, newtype-generics >= 0.4 Exposed-Modules: Data.MemoTrie Other-Modules: - ghc-prof-options: -prof -auto-all - default-language: Haskell2010 executable generic diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MemoTrie-0.6.4/examples/Generic.hs new/MemoTrie-0.6.7/examples/Generic.hs --- old/MemoTrie-0.6.4/examples/Generic.hs 2015-11-21 20:12:36.000000000 +0100 +++ new/MemoTrie-0.6.7/examples/Generic.hs 2016-09-19 19:03:23.000000000 +0200 @@ -2,25 +2,24 @@ import Data.MemoTrie import GHC.Generics (Generic) -data Color - = RGB Int Int Int - | Color String - deriving (Generic) +data Color = RGB Int Int Int + | NamedColor String + deriving (Generic) instance HasTrie Color where - newtype (Color :->: b) = ColorTrie { unColorTrie :: Reg Color :->: b } - trie = trieGeneric ColorTrie - untrie = untrieGeneric unColorTrie - enumerate = enumerateGeneric unColorTrie + newtype (Color :->: b) = ColorTrie { unColorTrie :: Reg Color :->: b } + trie = trieGeneric ColorTrie + untrie = untrieGeneric unColorTrie + enumerate = enumerateGeneric unColorTrie runColor (RGB r g b) = r + g + b -runColor (Color s) = length [1..10e7] +runColor (NamedColor s) = length [1..10e7] runColorMemoized = memo runColor -main = do - putStrLn "first call (should take a few seconds): " - print$ runColorMemoized (Color "") - putStrLn "cached call (should be instantaneous): " - print$ runColorMemoized (Color "") +main = + do putStrLn "first call (should take a few seconds): " + print$ runColorMemoized (NamedColor "") + putStrLn "cached call (should be instantaneous): " + print$ runColorMemoized (NamedColor "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MemoTrie-0.6.4/src/Data/MemoTrie.hs new/MemoTrie-0.6.7/src/Data/MemoTrie.hs --- old/MemoTrie-0.6.4/src/Data/MemoTrie.hs 2015-11-21 20:12:36.000000000 +0100 +++ new/MemoTrie-0.6.7/src/Data/MemoTrie.hs 2016-09-19 19:03:23.000000000 +0200 @@ -1,6 +1,6 @@ {-# LANGUAGE GADTs, TypeFamilies, TypeOperators, ScopedTypeVariables, CPP #-} {-# LANGUAGE StandaloneDeriving, FlexibleInstances #-} -{-# LANGUAGE DefaultSignatures, FlexibleContexts, EmptyCase, LambdaCase #-} +{-# LANGUAGE DefaultSignatures, FlexibleContexts, LambdaCase #-} {-# OPTIONS_GHC -Wall -fenable-rewrite-rules #-} -- ScopedTypeVariables works around a 6.10 bug. The forall keyword is @@ -42,7 +42,7 @@ -- see @examples/Generic.hs@, which can be run with: -- -- @ --- $ cabal configure -fexamples && cabal run generic +-- cabal configure -fexamples && cabal run generic -- @ -- -- @@ -55,21 +55,29 @@ , memo, memo2, memo3, mup , inTrie, inTrie2, inTrie3 -- , untrieBits - , trieGeneric, untrieGeneric, enumerateGeneric, Reg + , trieGeneric, untrieGeneric, enumerateGeneric, Reg + , memoFix ) where -- Export the parts of HasTrie separately in order to get the associated data -- type constructors, so I can define instances of other classes on them. +import Data.Function (fix) import Data.Bits import Data.Word import Data.Int +#if !MIN_VERSION_base(4,8,0) import Control.Applicative +#endif import Control.Arrow (first,(&&&)) +#if !MIN_VERSION_base(4,8,0) import Data.Monoid +#endif import Data.Function (on) import GHC.Generics +import Control.Newtype + import Data.Void (Void) -- import Prelude hiding (id,(.)) @@ -128,7 +136,13 @@ -} -{-# RULES "trie/untrie" forall t. trie (untrie t) = t #-} +-- {-# RULES "trie/untrie" forall t. trie (untrie t) = t #-} + +-- warning: [-Winline-rule-shadowing] … +-- Rule "trie/untrie" may never fire +-- because rule "Class op untrie" for ‘untrie’ might fire first +-- Probable fix: add phase [n] or [~n] to the competing rule + -- Don't include the dual rule: -- "untrie/trie" forall f. untrie (trie f) = f @@ -156,6 +170,42 @@ memo2 = mup memo memo3 = mup memo2 +-- | Memoizing recursion. Use like `fix`. +memoFix :: HasTrie a => ((a -> b) -> (a -> b)) -> (a -> b) +memoFix h = fix (memo . h) + +#if 0 +-- Equivalently, + +memoFix h = fix (\ f' -> memo (h f')) + +memoFix h = f' + where f' = memo (h f') + +memoFix h = f' + where + f' = memo f + f = h f' +#endif + +#if 0 +-- Example + +fibF :: (Integer -> Integer) -> (Integer -> Integer) +fibF _ 0 = 1 +fibF _ 1 = 1 +fibF f n = f (n-1) + f (n-2) + +fib :: Integer -> Integer +fib = fix fibF + +fib' :: Integer -> Integer +fib' = memoFix fibF + +-- Try fib 30 vs fib' 30 +#endif + + -- | Apply a unary function inside of a trie inTrie :: (HasTrie a, HasTrie c) => ((a -> b) -> (c -> d)) @@ -179,17 +229,28 @@ instance HasTrie Void where -- As suggested by Audun Skaugen - data Void :->: a = VoidTrie + data Void :->: a = VoidTrie trie _ = VoidTrie - untrie VoidTrie = \case + untrie VoidTrie = \ _ -> error "untrie VoidTrie" + -- \case -- needs EmptyCase enumerate VoidTrie = [] +instance Newtype (Void :->: a) where + type O (Void :->: a) = () + pack () = VoidTrie + unpack VoidTrie = () + instance HasTrie () where newtype () :->: a = UnitTrie a trie f = UnitTrie (f ()) untrie (UnitTrie a) = \ () -> a enumerate (UnitTrie a) = [((),a)] +instance Newtype (() :->: a) where + type O (() :->: a) = a + pack a = UnitTrie a + unpack (UnitTrie a) = a + -- Proofs of inverse properties: {- @@ -225,6 +286,11 @@ untrie (BoolTrie f t) = if' f t enumerate (BoolTrie f t) = [(False,f),(True,t)] +instance Newtype (Bool :->: a) where + type O (Bool :->: a) = (a,a) + pack (a,a') = BoolTrie a a' + unpack (BoolTrie a a') = (a,a') + -- | Conditional with boolean last. -- Spec: @if' (f False) (f True) == f@ if' :: x -> x -> Bool -> x @@ -256,6 +322,11 @@ untrie (EitherTrie s t) = either (untrie s) (untrie t) enumerate (EitherTrie s t) = enum' Left s `weave` enum' Right t +instance Newtype (Either a b :->: x) where + type O (Either a b :->: x) = (a :->: x, b :->: x) + pack (f,g) = EitherTrie f g + unpack (EitherTrie f g) = (f,g) + enum' :: (HasTrie a) => (a -> a') -> (a :->: b) -> [(a', b)] enum' f = (fmap.first) f . enumerate @@ -295,6 +366,11 @@ enumerate (PairTrie tt) = [ ((a,b),x) | (a,t) <- enumerate tt , (b,x) <- enumerate t ] +instance Newtype ((a,b) :->: x) where + type O ((a,b) :->: x) = a :->: b :->: x + pack abx = PairTrie abx + unpack (PairTrie abx) = abx + {- untrie (trie f) == { trie def } @@ -563,7 +639,8 @@ instance HasTrie (V1 x) where data (V1 x :->: b) = V1Trie trie _ = V1Trie - untrie V1Trie = \case + untrie V1Trie = \ _ -> error "untrie V1Trie" + -- \case -- needs EmptyCase enumerate V1Trie = [] -- | just like @()@ @@ -605,6 +682,7 @@ -- "unlifted" generic representation. (i.e. is a unary type constructor). type Reg a = Rep a () +-- | 'Generic'-friendly default for 'trie' trieGeneric :: (Generic a, HasTrie (Reg a)) => ((Reg a :->: b) -> (a :->: b)) -> (a -> b) @@ -612,6 +690,7 @@ trieGeneric theConstructor f = theConstructor (trie (f . to)) {-# INLINEABLE trieGeneric #-} +-- | 'Generic'-friendly default for 'untrie' untrieGeneric :: (Generic a, HasTrie (Reg a)) => ((a :->: b) -> (Reg a :->: b)) -> (a :->: b) @@ -619,6 +698,7 @@ untrieGeneric theDestructor t = \a -> (untrie (theDestructor t)) (from a) {-# INLINEABLE untrieGeneric #-} +-- | 'Generic'-friendly default for 'enumerate' enumerateGeneric :: (Generic a, HasTrie (Reg a)) => ((a :->: b) -> (Reg a :->: b)) -> (a :->: b) @@ -643,4 +723,3 @@ liftSum :: Either (f a) (g a) -> (f :+: g) a liftSum = either L1 R1 {-# INLINEABLE liftSum #-} -
participants (1)
-
root@hilbert.suse.de