[ghc-ForSyDe] fix build for ghc-7.4 adding Eq and Show to Num contexts

Jens Petersen petersen at fedoraproject.org
Wed Apr 11 04:26:46 UTC 2012


commit 0a43c9fceea68e3e8569baf585e9b8fb498d806e
Author: Jens Petersen <petersen at redhat.com>
Date:   Wed Apr 11 13:26:39 2012 +0900

    fix build for ghc-7.4 adding Eq and Show to Num contexts

 ForSyDe-3.1.1-ghc74-Num-superclass.patch |  267 ++++++++++++++++++++++++++++++
 ghc-ForSyDe.spec                         |    7 +-
 2 files changed, 273 insertions(+), 1 deletions(-)
---
diff --git a/ForSyDe-3.1.1-ghc74-Num-superclass.patch b/ForSyDe-3.1.1-ghc74-Num-superclass.patch
new file mode 100644
index 0000000..db750fd
--- /dev/null
+++ b/ForSyDe-3.1.1-ghc74-Num-superclass.patch
@@ -0,0 +1,267 @@
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/BitVector.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/BitVector.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/BitVector.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/BitVector.hs	2012-04-11 12:51:34.166998789 +0900
+@@ -31,7 +31,7 @@ import ForSyDe.Shallow.Vector
+ type BitVector = Vector Integer
+ 
+ -- |To judge whether the input bit-vector is in a proper form.
+-isBitVector :: (Num t) =>
++isBitVector :: (Num t, Eq t) =>
+           Vector t  -- ^Input bit-vector
+        -> Bool      -- ^Output boolean value
+ isBitVector NullV = True
+@@ -75,13 +75,13 @@ bitVectorToInt' (x:>xv) bit = x * 2^(bit
+ data Parity = Even | Odd deriving (Show, Eq)
+ 
+ -- |To add even parity bit on the bit-vector in the tail.
+-addEvenParityBit :: Num a => Vector a -> Vector a
++addEvenParityBit :: (Num a, Eq a) => Vector a -> Vector a
+ addEvenParityBit = addParityBit Even
+ -- |To add odd parity bit on the bit-vector in the tail.
+-addOddParityBit :: Num a => Vector a -> Vector a
++addOddParityBit :: (Num a, Eq a) => Vector a -> Vector a
+ addOddParityBit  = addParityBit Odd
+ 
+-addParityBit :: Num a => Parity -> Vector a -> Vector a
++addParityBit :: (Num a, Eq a) => Parity -> Vector a -> Vector a
+ addParityBit p v 
+   | isBitVector v = case p of
+                      Even -> resZero even
+@@ -92,24 +92,24 @@ addParityBit p v
+ 
+ 
+ -- |To remove the parity bit in the tail.
+-removeParityBit :: Num t => Vector t -> Vector t
++removeParityBit :: (Num t, Eq t) => Vector t -> Vector t
+ removeParityBit v 
+  | isBitVector v = takeV (lengthV v - 1) v
+  | otherwise = error "removeParityBit: Vector is not a BitVector "
+ 
+ -- |To check the even parity of the bit-vector.
+-isEvenParity :: Num t => Vector t -> Bool
++isEvenParity :: (Num t, Eq t) => Vector t -> Bool
+ isEvenParity = isParityCorrect Even
+ 
+ -- |To check the odd parity of the bit-vector.
+-isOddParity :: Num t => Vector t -> Bool
++isOddParity :: (Num t, Eq t) => Vector t -> Bool
+ isOddParity = isParityCorrect Odd
+ 
+-isParityCorrect :: Num t => Parity -> Vector t -> Bool 
++isParityCorrect :: (Num t, Eq t) => Parity -> Vector t -> Bool 
+ isParityCorrect Even xv = evenNumber xv
+ isParityCorrect Odd xv  = not $ evenNumber xv 
+ 
+-evenNumber :: Num t => Vector t -> Bool
++evenNumber :: (Num t, Eq t) => Vector t -> Bool
+ evenNumber NullV   = True
+ evenNumber (0:>xv) = xor False (evenNumber xv)
+ evenNumber (1:>xv) = xor True (evenNumber xv)
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/CTLib.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/CTLib.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/CTLib.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/CTLib.hs	2012-04-11 12:56:30.770999396 +0900
+@@ -86,7 +86,7 @@ data (Num a) =>
+                            (Rational,Rational)) -- The interval on which the
+                                                 --  function is defined
+ 
+-instance (Num a) => Show (SubsigCT a) where
++instance (Num a, Show a) => Show (SubsigCT a) where
+     show ss = show (sampleSubsig timeStep ss)
+ 
+ --unit :: String -- all time numbers are in terms of this unit.
+@@ -581,7 +581,7 @@ showParts (SubsigCT (_,(a,b)):-s) = (fro
+ -----------------------------------------------------------------------------
+ -- |'plot' plots one signal in a graph with the default sampling period 
+ -- of 1\/200 of the duration of the signal.
+-plot :: (Num a) =>
++plot :: (Num a, Show a) =>
+         Signal (SubsigCT a) -- ^The signal to be plotted.
+      -> IO String          -- ^A reporting message.
+ plot s = plotCT step [s]
+@@ -590,7 +590,7 @@ plot s = plotCT step [s]
+ -- |'plotCT' plots a list of signals in the same graph. The sampling period 
+ -- has to be given as argument. In the graph default label names are used
+ -- to identify the signals.
+-plotCT :: (Num a) =>
++plotCT :: (Num a, Show a) =>
+           Rational              -- ^The sampling period
+        -> [Signal (SubsigCT a)] -- ^The list of signals to be ploted 
+                                 -- in the same graph
+@@ -622,7 +622,7 @@ plotCT step sigs = plotCT' step (map (\
+ 			       while the .tex file contains the labels and 
+                                text.
+ -}
+-plotCT' :: (Num a) =>
++plotCT' :: (Num a, Show a) =>
+            Rational             -- ^Sampling period
+         -> [(Signal (SubsigCT a), String)]
+            -- ^A list of (signal,label) pairs. The signals are plotted and
+@@ -638,7 +638,7 @@ plotCT' step sigs = plotSig (expandSig 1
+       expandSig _ [] = []
+       expandSig i ((sig,label):sigs) 
+           = (i, label, (sample step sig)) : (expandSig (i+1) sigs)
+-      plotSig :: (Num a) => [(Int,String,[(Rational,a)])] -> IO String
++      plotSig :: (Num a, Show a) => [(Int,String,[(Rational,a)])] -> IO String
+       plotSig sigs 
+           = do mkDir "./fig"
+                writeDatFiles sigs
+@@ -675,7 +675,7 @@ plotCT' step sigs = plotSig (expandSig 1
+       replChar _ [] = []
+       replChar replSet (c:s) | elem c replSet = '_' : (replChar replSet s)
+                              | otherwise      = c   : (replChar replSet s)
+-      dumpSig :: (Num a) => [(Rational,a)] -> String
++      dumpSig :: (Num a, Show a) => [(Rational,a)] -> String
+       dumpSig points = concatMap f points
+         where f (x,y) = show ((fromRational x) :: Float) ++ "    " 
+                         ++ show (y) ++ "\n"
+@@ -748,7 +748,7 @@ The values are written to the file ./fig
+ is overwritten. If the directory does not exist, it is created.
+ 
+ -}
+-vcdGen :: (Num a) 
++vcdGen :: (Num a, Show a) 
+           => Rational             -- ^Sampling period; defines for what
+                                   -- time stamps the values are written.
+               -> [(Signal (SubsigCT a), String)]
+@@ -768,7 +768,7 @@ vcdGen step sigs =
+       expandSig _ [] = []
+       expandSig i ((sig,label):sigs) 
+           = (i, label, (sample step sig)) : (expandSig (i+1) sigs)
+-      plotSig :: (Num a) => [(Int,String,[(Rational,a)])] -> IO String
++      plotSig :: (Num a, Show a) => [(Int,String,[(Rational,a)])] -> IO String
+       plotSig sigs 
+           = do writeVCDFile sigs
+                -- We return some reporting string:
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/DFT.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/DFT.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/DFT.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/DFT.hs	2012-04-11 11:59:44.014997896 +0900
+@@ -40,7 +40,7 @@ fft :: Int -> Vector (Complex Double) ->
+ fft bigN xv | bigN == (lengthV xv) = mapV (bigX xv) (kVector bigN)
+ 	    | otherwise = error "FFT: Vector has not the right size!"
+ 
+-kVector :: (Num b, Num a) => a -> Vector b      
++kVector :: (Num b, Num a, Eq a) => a -> Vector b      
+ kVector bigN = iterateV bigN (+1) 0 
+ 
+ 
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/DomainInterfaces.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/DomainInterfaces.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/DomainInterfaces.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/DomainInterfaces.hs	2012-04-11 12:57:48.431998467 +0900
+@@ -20,10 +20,10 @@ import ForSyDe.Shallow.SynchronousLib
+ 
+ 
+ -- | The domain interface constructor 'downDI' takes a parameter 'k' and downsamples an input signal.
+-downDI     :: Num a => a -> Signal b -> Signal b
++downDI     :: (Num a, Eq a) => a -> Signal b -> Signal b
+ 
+ -- | The domain interface constructors 'upDI' takes a parameter 'k' and upsamples an input signal.
+-upDI       :: Num a => a -> Signal b -> Signal (AbstExt b)
++upDI       :: (Num a, Eq a) => a -> Signal b -> Signal (AbstExt b)
+ 
+ -- | The domain interface constructor 'par2ser2DI' converts two parallel signals into one signal.
+ par2ser2DI :: Signal a -> Signal a -> Signal a
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/FilterLib.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/FilterLib.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/FilterLib.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/FilterLib.hs	2012-04-11 13:01:17.395999909 +0900
+@@ -139,7 +139,7 @@ data SolverMode = S2Z   -- ^Tustin tranf
+ -- There are two solver modes, 'S2Z' and 'RK4'.
+ -- Caused by the precision problem, the time interval in CT uses Rational data
+ -- type and the digital data types in all the domains are Double.
+-sLinearFilter :: (Num a, Fractional a) =>
++sLinearFilter :: (Num a, Fractional a, Eq a) =>
+         SolverMode   -- ^Specify the solver mode
+     ->  Rational     -- ^Fixed simulation interval
+     -> [a]  -- ^Coefficients of the polynomial numerator in s-domain
+@@ -158,7 +158,7 @@ sLinearFilter filterMode step bs as inS
+                       where (bs',as') = h2ARMACoef $ s2zCoef step bs as
+ 
+ -- |Digital filter using Runge Kutta 4 solver.
+-rk4FilterDigital :: Fractional a => 
++rk4FilterDigital :: (Fractional a, Eq a) => 
+                     Rational -> [a] -> [a] -> Signal a -> Signal a
+ rk4FilterDigital step as bs inSDigital = outSDigital
+   where
+@@ -188,11 +188,11 @@ rk4FilterDigital step as bs inSDigital =
+     step' = fromRational step
+ 
+ -- The length of the function list is 'n-1' for nth order filter
+-ffn' :: (Num t, Num t1) => t -> [[t1] -> t1]
++ffn' :: (Num t, Num t1, Eq t) => t -> [[t1] -> t1]
+ ffn' n = ffn 0 n
+ 
+ -- Construct the functions for the diagonal '1'
+-ffn :: (Num t1, Num t) => Int -> t -> [[t1] -> t1]
++ffn :: (Num t1, Num t, Eq t) => Int -> t -> [[t1] -> t1]
+ ffn _ 1 = []
+ ffn m n = ff1 m : ffn (m+1) (n-1) 
+ 
+@@ -247,7 +247,7 @@ zLinearFilter bs as = armaFilterTrim bs'
+ -- >      T(z + 1)
+ --
+ -- in which, 'T' is the sampling interval.
+-s2zCoef :: (Num a, Fractional a) =>
++s2zCoef :: (Num a, Fractional a, Eq a) =>
+             Rational   -- ^Sampling rate in Z-domain
+         -> [a] -- ^Coefficients of the polynomial numerator in s-domain
+         -> [a] -- ^Coefficients of the polynomial denominator in s-domain
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/PolyArith.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/PolyArith.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/PolyArith.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/PolyArith.hs	2012-04-11 12:52:04.522001728 +0900
+@@ -53,7 +53,7 @@ divPoly (Poly c) (PolyPair (a, b)) =
+   PolyPair (mulPoly b (Poly c), a)
+ 
+ -- |Addition operations of polynomials.
+-addPoly :: Num a => Poly a -> Poly a -> Poly a
++addPoly :: (Num a, Eq a) => Poly a -> Poly a -> Poly a
+ addPoly (Poly a) (Poly b) = Poly $ addPolyCoef a b
+ addPoly (PolyPair (a, b)) (PolyPair (c, d)) =
+     if b==d then  -- simplifyPolyPair $
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/Signal.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/Signal.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/Signal.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/Signal.hs	2012-04-11 12:52:31.143988443 +0900
+@@ -96,7 +96,7 @@ readS		   :: Read a => [Char] -> Signal
+ 
+ 
+ -- | The function 'copyS' creates a signal with n values 'x'.
+-copyS :: Num a => a -> b -> Signal b
++copyS :: (Num a, Eq a) => a -> b -> Signal b
+ 
+ 
+ -- | The combinator 'fanS' takes two processes 'p1' and 'p2' and and generates a process network, where a signal is split and processed by the processes 'p1' and 'p2'.
+diff -up ForSyDe-3.1.1/src/ForSyDe/Shallow/Vector.hs~ ForSyDe-3.1.1/src/ForSyDe/Shallow/Vector.hs
+--- ForSyDe-3.1.1/src/ForSyDe/Shallow/Vector.hs~	2010-06-26 02:06:37.000000000 +0900
++++ ForSyDe-3.1.1/src/ForSyDe/Shallow/Vector.hs	2012-04-11 11:59:08.124002172 +0900
+@@ -54,7 +54,7 @@ nullV    :: Vector a -> Bool
+ lengthV  :: Vector a -> Int
+ 
+ -- | The function 'atV' returns the n-th element in a vector, starting from zero.
+-atV      :: Num a => Vector b -> a -> b
++atV      :: (Num a, Eq a) => Vector b -> a -> b
+ 
+ -- |  The function 'replaceV' replaces an element in a vector.
+ replaceV :: Vector a -> Int -> a -> Vector a
+@@ -145,21 +145,21 @@ reverseV  :: Vector a -> Vector a
+ -- > Vector> iterateV 5 (+1) 1
+ --
+ -- > <1,2,3,4,5> :: Vector Integer
+-iterateV :: Num a => a -> (b -> b) -> b -> Vector b
++iterateV :: (Num a, Eq a) => a -> (b -> b) -> b -> Vector b
+ 
+ -- | The function 'generateV' behaves in the same way, but starts with the application of the supplied function to the supplied value. 
+ --
+ -- > Vector> generateV 5 (+1) 1
+ -- 
+ -- > <2,3,4,5,6> :: Vector Integer
+-generateV :: Num a => a -> (b -> b) -> b -> Vector b
++generateV :: (Num a, Eq a) => a -> (b -> b) -> b -> Vector b
+ 
+ -- | The function 'copyV' generates a vector with a given number of copies of the same element. 
+ --
+ -- > Vector> copyV 7 5 
+ -- 
+ -- > <5,5,5,5,5,5,5> :: Vector Integer
+-copyV     :: Num a => a -> b -> Vector b
++copyV     :: (Num a, Eq a) => a -> b -> Vector b
+ 
+ 
+ {-
diff --git a/ghc-ForSyDe.spec b/ghc-ForSyDe.spec
index 7550691..7ff0ca4 100644
--- a/ghc-ForSyDe.spec
+++ b/ghc-ForSyDe.spec
@@ -10,7 +10,7 @@
 
 Name:           ghc-%{pkg_name}
 Version:        3.1.1
-Release:        7%{?dist}
+Release:        8%{?dist}
 Summary:        %{common_summary}
 
 Group:          System Environment/Libraries
@@ -27,6 +27,7 @@ BuildRequires:  ghc-random-prof
 BuildRequires:  ghc-regex-posix-prof
 BuildRequires:  ghc-type-level-prof
 BuildRequires:  ghc-mtl-prof
+Patch1:         ForSyDe-3.1.1-ghc74-Num-superclass.patch
 
 %description
 %{common_description}
@@ -34,6 +35,7 @@ BuildRequires:  ghc-mtl-prof
 
 %prep
 %setup -q -n %{pkg_name}-%{version}
+%patch1 -p1 -b .orig
 
 
 %build
@@ -58,6 +60,9 @@ echo "%{_datadir}/%{pkg_name}-%{version}/lib/forsyde.vhd" >> %{name}%{?ghc_witho
 
 
 %changelog
+* Wed Apr 11 2012 Jens Petersen <petersen at redhat.com> - 3.1.1-8
+- fix build for ghc-7.4 adding Eq and Show to Num contexts
+
 * Sat Mar 24 2012 Jens Petersen <petersen at redhat.com> - 3.1.1-7
 - add license to ghc_files
 


More information about the scm-commits mailing list