packages feed

repa-bytestring (empty) → 1.1.0.0

raw patch · 4 files changed

+120/−0 lines, 4 filesdep +basedep +bytestringdep +dph-prim-parsetup-changed

Dependencies added: base, bytestring, dph-prim-par, repa

Files

+ Data/Array/Repa/ByteString.hs view
@@ -0,0 +1,60 @@+{-# LANGUAGE ScopedTypeVariables, PackageImports #-}++-- | Conversions between Repa Arrays and ByteStrings.+module Data.Array.Repa.ByteString+	( toByteString+	, fromByteString)+where+import Data.Word+import Data.Array.Repa+import Foreign.Marshal.Alloc+import Foreign.Ptr+import Foreign.Storable+import System.IO.Unsafe+import qualified Data.ByteString	as BS+import Data.ByteString			(ByteString)+import qualified "dph-prim-par" Data.Array.Parallel.Unlifted as U+++-- | Convert an `Array` to a (strict) `ByteString`.+toByteString +	:: Shape sh+	=> Array sh Word8+	-> ByteString+	+toByteString arr+ = unsafePerformIO+ $ allocaBytes (size $ extent arr)	$ \(bufDest :: Ptr Word8) ->+   let 	uarr	= toUArray arr+	len	= size $ extent arr++	copy offset+	 | offset >= len+	 = return ()++	 | otherwise+	 = do	pokeByteOff bufDest offset (uarr U.!: offset)+		copy (offset + 1)++    in do+	copy 0+	BS.packCStringLen (castPtr bufDest, len)+++-- | Convert a (strict) `ByteString` to an `Array`.+--	The given array size must match the length of the `ByteString`, else `error`.+fromByteString +	:: Shape sh+	=> sh+	-> ByteString +	-> Array sh Word8++-- TODO: Use an intermediate CString when we do this, to avoid+--	 the overhead from bounds checks in ByteString+fromByteString sh str+	| size sh /= BS.length str+	= error "Data.Array.Repa.fromByteString: given array size does not match length of string"+	+	| otherwise+	= fromFunction sh (\ix -> str `BS.index` toIndex sh ix)+
+ LICENSE view
@@ -0,0 +1,24 @@+Copyright (c) 2010, University of New South Wales.+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:+    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.+    * Redistributions in binary form must reproduce the above copyright+      notice, this list of conditions and the following disclaimer in the+      documentation and/or other materials provided with the distribution.+    * Neither the name of the University of New South Wales nor the+      names of its contributors may be used to endorse or promote products+      derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ repa-bytestring.cabal view
@@ -0,0 +1,34 @@+Name:                repa-bytestring+Version:             1.1.0.0+License:             BSD3+License-file:        LICENSE+Author:              The DPH Team+Maintainer:          Ben Lippmeier <benl@ouroborus.net>+Build-Type:          Simple+Cabal-Version:       >=1.6+Stability:           experimental+Category:            Data Structures+Homepage:            http://trac.haskell.org/repa+Bug-reports:         http://trac.haskell.org/repa/newticket+Description:+        NOTE: You must use the GHC head branch > 6.13.20100309 to get decent performance.+        Conversions between Repa Arrays and ByteStrings.++Synopsis:+        Conversions between Repa Arrays and ByteStrings.++Tested-with: GHC == 6.13.20100309, GHC == 6.12.1++Library+  Build-Depends: +        base                 == 4.*,+        dph-prim-par         == 0.4.*,+        repa                 == 1.1.*,+        bytestring           == 0.9.1.*++  ghc-options:+        -Odph -Wall -fno-warn-missing-signatures++  Exposed-modules:+        Data.Array.Repa.ByteString+