packages feed

repa-io 3.3.1.2 → 3.4.0.1

raw patch · 6 files changed

+158/−158 lines, 6 filesdep ~basedep ~repaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, repa

API changes (from Hackage documentation)

Files

Data/Array/Repa/IO/BMP.hs view
@@ -2,15 +2,15 @@  -- | Reading and writing arrays as uncompressed 24 or 32 bit Windows BMP files. module Data.Array.Repa.IO.BMP-	( readImageFromBMP+        ( readImageFromBMP         , writeImageToBMP) where-import Data.Array.Repa				as R+import Data.Array.Repa                          as R import Data.Array.Repa.Unsafe                   as R-import Data.Array.Repa.Repr.ForeignPtr		as R-import Data.Array.Repa.Repr.ByteString		as R+import Data.Array.Repa.Repr.ForeignPtr          as R+import Data.Array.Repa.Repr.ByteString          as R import Data.Vector.Unboxed                      as U-import Prelude					as P+import Prelude                                  as P import Foreign.ForeignPtr import Foreign.Marshal.Alloc import Data.ByteString.Unsafe                   as B@@ -21,59 +21,59 @@ --       what's going on in the core programs. The top-level IO functions are --       only called a few times each, so it doesn't matter if they're not --       worker/wrappered etc.-	+         -- Read ------------------------------------------------------------------------------------------- -- | Read RGB components from a BMP file. readImageFromBMP-	:: FilePath-	-> IO (Either Error (Array U DIM2 (Word8, Word8, Word8)))+        :: FilePath+        -> IO (Either Error (Array U DIM2 (Word8, Word8, Word8)))  {-# NOINLINE readImageFromBMP #-} readImageFromBMP filePath- = do   ebmp	<- readBMP filePath+ = do   ebmp    <- readBMP filePath -	case ebmp of-	 Left err	-> return $ Left err-	 Right bmp	-	  -> do arr     <- readImageFromBMP' bmp-	        return  $ Right arr+        case ebmp of+         Left err       -> return $ Left err+         Right bmp      +          -> do arr     <- readImageFromBMP' bmp+                return  $ Right arr  readImageFromBMP' bmp- = do	let (width, height) = bmpDimensions bmp+ = do   let (width, height) = bmpDimensions bmp -	let arr		= R.fromByteString (Z :. height :. width * 4)-			$ unpackBMPToRGBA32 bmp+        let arr         = R.fromByteString (Z :. height :. width * 4)+                        $ unpackBMPToRGBA32 bmp -	let shapeFn _ 	= Z :. height :. width+        let shapeFn _   = Z :. height :. width          -- Read out the components into their own arrays,          -- skipping the alpha channel.-	vecRed         <- computeP +        vecRed         <- computeP                          $ unsafeTraverse arr shapeFn-                	       (\get (sh :. x) -> get (sh :. (x * 4)))+                               (\get (sh :. x) -> get (sh :. (x * 4))) -	vecGreen       <- computeP +        vecGreen       <- computeP                          $ unsafeTraverse arr shapeFn-                		(\get (sh :. x) -> get (sh :. (x * 4 + 1)))+                                (\get (sh :. x) -> get (sh :. (x * 4 + 1))) -	vecBlue        <- computeP+        vecBlue        <- computeP                         $ unsafeTraverse arr shapeFn-                		(\get (sh :. x) -> get (sh :. (x * 4 + 2)))+                                (\get (sh :. x) -> get (sh :. (x * 4 + 2))) -	-- O(1). zip the components together-	let vecRGB     = U.zip3 (toUnboxed vecRed)+        -- O(1). zip the components together+        let vecRGB     = U.zip3 (toUnboxed vecRed)                                 (toUnboxed vecGreen)                                 (toUnboxed vecBlue)-	+                 return $ fromUnboxed (Z :. height :. width) vecRGB    -- | Write RGB components to a BMP file. writeImageToBMP-	:: FilePath-	-> Array U DIM2 (Word8, Word8, Word8)-	-> IO ()+        :: FilePath+        -> Array U DIM2 (Word8, Word8, Word8)+        -> IO ()  {-# NOINLINE writeImageToBMP #-} writeImageToBMP fileName arrRGB@@ -81,8 +81,8 @@                         = extent arrRGB          -- O(1). unzip the components-	let (vecRed, vecGreen, vecBlue)-	        = U.unzip3 $ toUnboxed arrRGB+        let (vecRed, vecGreen, vecBlue)+                = U.unzip3 $ toUnboxed arrRGB           -- Create a bytestring with all the data@@ -91,10 +91,10 @@          computeIntoP fptr           $ interleave4 -	        (fromUnboxed sh vecRed)-	        (fromUnboxed sh vecGreen)-	        (fromUnboxed sh vecBlue)-	        (fromFunction sh (\_ -> 255))+                (fromUnboxed sh vecRed)+                (fromUnboxed sh vecGreen)+                (fromUnboxed sh vecBlue)+                (fromFunction sh (\_ -> 255))          -- Pack the data into a BMP file and write it out.         withForeignPtr fptr@@ -107,21 +107,21 @@ {- -- Normalise -------------------------------------------------------------------------------------- -- | Normalise a matrix to to [0 .. 1], discarding negative values.---	If the maximum value is 0 then return the array unchanged.+--      If the maximum value is 0 then return the array unchanged. normalisePositive01-	:: (Shape sh, Fractional a, Ord a)-	=> Array sh a-	-> Array sh a+        :: (Shape sh, Fractional a, Ord a)+        => Array sh a+        -> Array sh a  {-# INLINE normalisePositive01 #-}-normalisePositive01 arr	- = let	mx		= foldAll max 0 arr-   	elemFn x-	 | x >= 0	= x / mx-	 | otherwise	= x-   in	mx `seq`-	 if mx == 0 -	  then arr-	  else R.map elemFn arr+normalisePositive01 arr + = let  mx              = foldAll max 0 arr+        elemFn x+         | x >= 0       = x / mx+         | otherwise    = x+   in   mx `seq`+         if mx == 0 +          then arr+          else R.map elemFn arr  -}
Data/Array/Repa/IO/Internals/Text.hs view
@@ -1,7 +1,7 @@ {-# OPTIONS_HADDOCK hide #-} module Data.Array.Repa.IO.Internals.Text-	( hWriteValues-	, readValues)+        ( hWriteValues+        , readValues) where import System.IO import Data.Char@@ -9,33 +9,33 @@ -- Stuff shared with Matrix module ------------------------------------------------------------- -- | Write out values to a file. hWriteValues-	:: Show a-	=> Handle -	-> [a] 				-- ^ Data values.-	-> IO ()+        :: Show a+        => Handle +        -> [a]                          -- ^ Data values.+        -> IO ()  hWriteValues handle xx  = go xx- where	go []		= return ()-	go (x:xs)-	 = do	hPutStr handle $ show x-		hPutStr handle $ "\n"-		go xs+ where  go []           = return ()+        go (x:xs)+         = do   hPutStr handle $ show x+                hPutStr handle $ "\n"+                go xs  --- | Read a string containing ints separated by whitespace.	+-- | Read a string containing ints separated by whitespace.      readValues :: (Num a, Read a) => String -> [a]-readValues cs	= readValues' [] cs- where	readValues' _ []	= []-	readValues' acc (c : rest)-		| isSpace c-		= if null acc -			then readValues' [] rest-			else read (reverse acc) : readValues' [] rest+readValues cs   = readValues' [] cs+ where  readValues' _ []        = []+        readValues' acc (c : rest)+                | isSpace c+                = if null acc +                        then readValues' [] rest+                        else read (reverse acc) : readValues' [] rest -		| isDigit c || c == '.' || c == 'e' || c == '-'-		= readValues' (c : acc) rest+                | isDigit c || c == '.' || c == 'e' || c == '-'+                = readValues' (c : acc) rest -		| otherwise-		= error $ "unexpected char in Matrix file " ++ show (ord c)+                | otherwise+                = error $ "unexpected char in Matrix file " ++ show (ord c) 
Data/Array/Repa/IO/Matrix.hs view
@@ -4,22 +4,22 @@ --   The file format is like: -- --   @---	MATRIX			-- header---	100 100			-- width and height---	1.23 1.56 1.23 ...	-- data, separated by whitespace---	....+--      MATRIX                  -- header+--      100 100                 -- width and height+--      1.23 1.56 1.23 ...      -- data, separated by whitespace+--      .... --   @ module Data.Array.Repa.IO.Matrix-	( readMatrixFromTextFile-	, writeMatrixToTextFile)+        ( readMatrixFromTextFile+        , writeMatrixToTextFile) where import Data.Array.Repa.IO.Internals.Text import Control.Monad import System.IO-import Data.List				as L-import Data.Array.Repa				as A+import Data.List                                as L+import Data.Array.Repa                          as A import Data.Array.Repa.Repr.Unboxed             as A-import Prelude					as P+import Prelude                                  as P   -- | Read a matrix from a text file.@@ -31,38 +31,38 @@ --     If the file has the wrong format you'll get a confusing `error`. -- readMatrixFromTextFile-	:: (Num e, Read e, Unbox e)-	=> FilePath-	-> IO (Array U DIM2 e)	+        :: (Num e, Read e, Unbox e)+        => FilePath+        -> IO (Array U DIM2 e)    readMatrixFromTextFile fileName- = do	handle		<- openFile fileName ReadMode-	-	"MATRIX"	<- hGetLine handle-	[width, height]	<- liftM (P.map read . words) $ hGetLine handle-	str		<- hGetContents handle-	let vals	= readValues str+ = do   handle          <- openFile fileName ReadMode+        +        "MATRIX"        <- hGetLine handle+        [width, height] <- liftM (P.map read . words) $ hGetLine handle+        str             <- hGetContents handle+        let vals        = readValues str -	let dims	= Z :. width :. height-	return $ fromListUnboxed dims vals+        let dims        = Z :. width :. height+        return $ fromListUnboxed dims vals   -- | Write a matrix as a text file. writeMatrixToTextFile -	:: (Show e, Source r e)-	=> FilePath-	-> Array r DIM2 e-	-> IO ()+        :: (Show e, Source r e)+        => FilePath+        -> Array r DIM2 e+        -> IO ()  writeMatrixToTextFile fileName arr- = do	file	<- openFile fileName WriteMode	+ = do   file    <- openFile fileName WriteMode   -	hPutStrLn file "MATRIX"+        hPutStrLn file "MATRIX" -	let Z :. width :. height	-		= extent arr+        let Z :. width :. height        +                = extent arr -	hPutStrLn file $ show width P.++ " " P.++ show height-	hWriteValues file $ toList arr-	hClose file+        hPutStrLn file $ show width P.++ " " P.++ show height+        hWriteValues file $ toList arr+        hClose file 
Data/Array/Repa/IO/Timing.hs view
@@ -1,13 +1,13 @@  -- | Timing utilities used for benchmarks in the @repa-examples@ package. module Data.Array.Repa.IO.Timing-	( Time-	, milliseconds+        ( Time+        , milliseconds         , microseconds         , cpuTime, wallTime-	, time, minus, plus-	, showTime-	, prettyTime)+        , time, minus, plus+        , showTime+        , prettyTime) where import System.CPUTime import System.Time@@ -16,14 +16,14 @@ -- Time ----------------------------------------------------------------------- -- | Abstract representation of process time. data Time -	= Time -	{ cpu_time  :: Integer+        = Time +        { cpu_time  :: Integer         , wall_time :: Integer         }  zipT :: (Integer -> Integer -> Integer) -> Time -> Time -> Time zipT f (Time cpu1 wall1) (Time cpu2 wall2) -	= Time (f cpu1 cpu2) (f wall1 wall2)+        = Time (f cpu1 cpu2) (f wall1 wall2)  -- | Subtract second time from the first. minus :: Time -> Time -> Time@@ -38,7 +38,7 @@ -- TimeUnit ------------------------------------------------------------------- -- | Conversion  type TimeUnit -	= Integer -> Integer+        = Integer -> Integer  microseconds :: TimeUnit  microseconds n = n `div` 1000000@@ -71,9 +71,9 @@ -- | Pretty print the times, in milliseconds. prettyTime :: Time -> String prettyTime t-	= unlines-	[ "elapsedTimeMS   = " ++ (show $ wallTime milliseconds t)-	, "cpuTimeMS       = " ++ (show $ cpuTime  milliseconds t) ]+        = unlines+        [ "elapsedTimeMS   = " ++ (show $ wallTime milliseconds t)+        , "cpuTimeMS       = " ++ (show $ cpuTime  milliseconds t) ]  -- Timing benchmarks ---------------------------------------------------------- 
Data/Array/Repa/IO/Vector.hs view
@@ -4,20 +4,20 @@ --   The file format is like: -- --   @---	VECTOR			-- header---	100			-- length of vector---	1.23 1.56 1.23 ...	-- data, separated by whitespace---	....+--      VECTOR                  -- header+--      100                     -- length of vector+--      1.23 1.56 1.23 ...      -- data, separated by whitespace+--      .... --   @ module Data.Array.Repa.IO.Vector-	( readVectorFromTextFile-	, writeVectorToTextFile)+        ( readVectorFromTextFile+        , writeVectorToTextFile) where-import Data.Array.Repa				as A+import Data.Array.Repa                          as A import Data.Array.Repa.Repr.Unboxed             as A import Data.Array.Repa.IO.Internals.Text-import Data.List				as L-import Prelude					as P+import Data.List                                as L+import Prelude                                  as P import System.IO import Control.Monad import Data.Char@@ -32,48 +32,48 @@ --     If the file has the wrong format you'll get a confusing `error`. -- readVectorFromTextFile-	:: (Num e, Read e, Unbox e)-	=> FilePath-	-> IO (Array U DIM1 e)	+        :: (Num e, Read e, Unbox e)+        => FilePath+        -> IO (Array U DIM1 e)    readVectorFromTextFile fileName- = do	handle		<- openFile fileName ReadMode-	-	"VECTOR"	<- hGetLine handle-	[len]		<- liftM (P.map readInt . words) $ hGetLine handle-	str		<- hGetContents handle-	let vals	= readValues str+ = do   handle          <- openFile fileName ReadMode+        +        "VECTOR"        <- hGetLine handle+        [len]           <- liftM (P.map readInt . words) $ hGetLine handle+        str             <- hGetContents handle+        let vals        = readValues str -	let dims	= Z :. len-	return $ fromListUnboxed dims vals+        let dims        = Z :. len+        return $ fromListUnboxed dims vals   readInt :: String -> Int readInt str-	| and $ P.map isDigit str-	= read str-	-	| otherwise-	= error "Data.Array.Repa.IO.Vector.readVectorFromTextFile parse error when reading data"-	-	+        | and $ P.map isDigit str+        = read str+        +        | otherwise+        = error "Data.Array.Repa.IO.Vector.readVectorFromTextFile parse error when reading data"+        +         -- | Write a vector as a text file. writeVectorToTextFile -	:: (Show e, Source r e)-	=> Array r DIM1 e-	-> FilePath-	-> IO ()+        :: (Show e, Source r e)+        => Array r DIM1 e+        -> FilePath+        -> IO ()  writeVectorToTextFile arr fileName- = do	file	<- openFile fileName WriteMode	+ = do   file    <- openFile fileName WriteMode   -	hPutStrLn file "VECTOR"+        hPutStrLn file "VECTOR" -	let Z :. len-		= extent arr+        let Z :. len+                = extent arr -	hPutStrLn file 	$ show len-	hWriteValues file $ toList arr-	hClose file-	hFlush file-	+        hPutStrLn file  $ show len+        hWriteValues file $ toList arr+        hClose file+        hFlush file+        
repa-io.cabal view
@@ -1,5 +1,5 @@ Name:                repa-io-Version:             3.3.1.2+Version:             3.4.0.1 License:             BSD3 License-file:        LICENSE Author:              The DPH Team@@ -18,12 +18,12 @@  Library   Build-Depends: -        base                 == 4.7.*,+        base                 == 4.8.*,         vector               == 0.10.*,         binary               == 0.7.*,         old-time             == 1.1.*,-        repa                 == 3.3.*,         bytestring           == 0.10.*,+        repa                 == 3.4.*,         bmp                  == 1.2.*    ghc-options: