packages feed

sized-types 0.3.4.0 → 0.3.5.1

raw patch · 5 files changed

+54/−13 lines, 5 filessetup-changednew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Data.Sized.Ix: instance Size ()
+ Data.Sized.Unsigned: instance Size ix => Ix (Unsigned ix)
+ Data.Sized.Unsigned: instance Size ix => Size (Unsigned ix)
+ Data.Sized.Vector: bounds :: Bounds s => Vector s a -> (s, s)
+ Data.Sized.Vector: foo :: (Bounds ix1, Bounds ix, Show a) => Vector (ix, ix1) a -> [[String]]
+ Data.Sized.Vector: show' :: (Bounds ix, Show a) => Vector (ix, ix) a -> String
- Data.Sized.Ix: coerceSize :: ((Index ix1) ~ (Index ix2), Size ix1, Size ix2, Num ix2) => ix1 -> ix2
+ Data.Sized.Ix: coerceSize :: (Index ix1 ~ Index ix2, Size ix1, Size ix2, Num ix2) => ix1 -> ix2
- Data.Sized.Matrix: above :: (Size m, Size top, Size bottom, Size both, (ADD top bottom) ~ both, (SUB both top) ~ bottom, (SUB both bottom) ~ top) => Matrix (top, m) a -> Matrix (bottom, m) a -> Matrix (both, m) a
+ Data.Sized.Matrix: above :: (Size m, Size top, Size bottom, Size both, ADD top bottom ~ both, SUB both top ~ bottom, SUB both bottom ~ top) => Matrix (top, m) a -> Matrix (bottom, m) a -> Matrix (both, m) a
- Data.Sized.Matrix: append :: (Size left, Size right, Size both, (ADD left right) ~ both, (SUB both left) ~ right, (SUB both right) ~ left) => Matrix left a -> Matrix right a -> Matrix both a
+ Data.Sized.Matrix: append :: (Size left, Size right, Size both, ADD left right ~ both, SUB both left ~ right, SUB both right ~ left) => Matrix left a -> Matrix right a -> Matrix both a
- Data.Sized.Matrix: beside :: (Size m, Size left, Size right, Size both, (ADD left right) ~ both, (SUB both left) ~ right, (SUB both right) ~ left) => Matrix (m, left) a -> Matrix (m, right) a -> Matrix (m, both) a
+ Data.Sized.Matrix: beside :: (Size m, Size left, Size right, Size both, ADD left right ~ both, SUB both left ~ right, SUB both right ~ left) => Matrix (m, left) a -> Matrix (m, right) a -> Matrix (m, both) a
- Data.Sized.Matrix: cropAt :: ((Index i) ~ (Index ix), Size i, Size ix) => Matrix ix a -> ix -> Matrix i a
+ Data.Sized.Matrix: cropAt :: (Index i ~ Index ix, Size i, Size ix) => Matrix ix a -> ix -> Matrix i a
- Data.Sized.Sparse.Matrix: mm :: (Size m, Size n, Size m', Size n', n ~ m', Num a) => Matrix (m, n) a -> Matrix (m', n') a -> Matrix (m, n') a
+ Data.Sized.Sparse.Matrix: mm :: (Size m, Size n, Size m', Size n', n ~ m', Eq a, Num a) => Matrix (m, n) a -> Matrix (m', n') a -> Matrix (m, n') a

Files

Data/Sized/Ix.hs view
@@ -299,6 +299,14 @@ 	-- | look at an 'ix' as an 'Index', typically just an 'Int'. 	toIndex  :: ix -> Index ix +type instance Index () = ()++instance Size () where+	size () = 1+	addIndex () () = ()+	toIndex () = ()++ type instance Index (a,b) = (Index a,Index b) --type instance Row (a,b)  = a --type instance Column (a,b)  = b
Data/Sized/Sparse/Matrix.hs view
@@ -47,7 +47,7 @@ sparse :: (Size ix, Eq a) => a -> M.Matrix ix a -> Matrix ix a sparse d other = Matrix d (Map.fromList [ (i,v) | (i,v) <- M.assocs other, v /= d ]) -mm :: (Size m, Size n, Size m', Size n', n ~ m', Num a) => Matrix (m,n) a -> Matrix (m',n') a -> Matrix (m,n') a+mm :: (Size m, Size n, Size m', Size n', n ~ m', Eq a, Num a) => Matrix (m,n) a -> Matrix (m',n') a -> Matrix (m,n') a mm s1 s2 = Matrix 0 mp   where 	mp = Map.fromList [ ((x,y),v)
Data/Sized/Unsigned.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables, TypeFamilies #-}  -- | Unsigned, fixed sized numbers.--- +-- -- Copyright: (c) 2009 University of Kansas -- License: BSD3 --@@ -9,7 +9,7 @@ -- Stability: unstable -- Portability: ghc -module Data.Sized.Unsigned +module Data.Sized.Unsigned 	( Unsigned 	, toMatrix 	, fromMatrix@@ -18,20 +18,20 @@ 	, U20, U21, U22, U23, U24, U25, U26, U27, U28, U29 	, U30, U31, U32 	) where-	+ import Data.Sized.Matrix as M import Data.Sized.Ix-import Data.List as L import Data.Bits+import Data.Ix -newtype Unsigned ix = Unsigned Integer +newtype Unsigned ix = Unsigned Integer  toMatrix :: forall ix . (Size ix) => Unsigned ix -> Matrix ix Bool-toMatrix s@(Unsigned v) = matrix $ take (size (error "toMatrix" :: ix)) $ map odd $ iterate (`div` 2) v+toMatrix (Unsigned v) = matrix $ take (size (error "toMatrix" :: ix)) $ map odd $ iterate (`div` 2) v  fromMatrix :: (Size ix) => Matrix ix Bool -> Unsigned ix fromMatrix m = mkUnsigned $-	  sum [ n	+	  sum [ n 	      | (n,b) <- zip (iterate (* 2) 1) 			      (M.toList m) 	      , b@@ -53,7 +53,7 @@ 	readsPrec i str = [ (mkUnsigned a,r) | (a,r) <- readsPrec i str ] instance (Size ix) => Integral (Unsigned ix) where   	toInteger (Unsigned m) = m-	quotRem (Unsigned a) (Unsigned b) = +	quotRem (Unsigned a) (Unsigned b) = 		case quotRem a b of 		   (q,r) -> (mkUnsigned q,mkUnsigned r) instance (Size ix) => Num (Unsigned ix) where@@ -67,7 +67,7 @@ 	toRational (Unsigned n) = toRational n instance (Size ix) => Enum (Unsigned ix) where 	fromEnum (Unsigned n) = fromEnum n-	toEnum n = mkUnsigned (toInteger n)	+	toEnum n = mkUnsigned (toInteger n) instance (Size ix, Integral ix) => Bits (Unsigned ix) where 	bitSize s = f s undefined 	  where@@ -88,6 +88,25 @@ instance forall ix . (Size ix) => Bounded (Unsigned ix) where 	minBound = Unsigned 0         maxBound = Unsigned (2 ^ (size (error "Bounded/Unsigned" :: ix)) - 1)++-- Unsigned ix as member of Size class.+-- We do not address efficiency in this implementation.++type instance Index (Unsigned ix)  = Int++instance forall ix . (Size ix) => Ix (Unsigned ix) where+    range     (l, u)    = [l .. u]+    inRange   (l, u) v  =  (l <= v) && (v <= u)+    index     (l, u) v | inRange (l,u) v = fromIntegral (v - l)+                       | otherwise       = error "Error in Ix array index"+    rangeSize (l, u)   | l <= u           = fromIntegral $ (toInteger u) - (toInteger l) + 1+                       | otherwise       = 0++instance forall ix . (Size ix) => Size (Unsigned ix) where+    size         = const s+	where s  = fromIntegral $ toInteger (maxBound :: Unsigned ix) + 1+    addIndex v n =  v + (fromIntegral n)  -- fix bounds issues+    toIndex v    = fromIntegral v  -- | common; numerically boolean. type U1 = Unsigned X1
Setup.hs view
@@ -1,2 +1,6 @@+module Main (main) where+ import Distribution.Simple++main :: IO () main = defaultMain
sized-types.cabal view
@@ -1,5 +1,5 @@ Name:                sized-types-Version:             0.3.4.0+Version:             0.3.5.1 Synopsis:            Sized types in Haskell. Description:         Providing indices, matrixes, sparse matrixes, and signed and unsigned bit vectors. Category:            Language@@ -29,7 +29,7 @@        Data.Sized.Vector,        Data.Sized.Sampled -  Ghc-Options:  -Wall -O2+  Ghc-Options:  -Wall  Executable sized-types-test1     if flag(all)@@ -54,3 +54,13 @@     Main-Is:        Example1.hs     Hs-Source-Dirs: ., test     Ghc-Options: -Wall++source-repository head+  type:     git+  location: git://github.com/ku-fpg/sized-types++source-repository this+  type:     git+  location: git://github.com/gergoerdi/sized-types+  branch:   sized-types-0.3+  tag:      0.3.5.1