packages feed

fixed-point-vector (empty) → 0.5.0.0

raw patch · 4 files changed

+121/−0 lines, 4 filesdep +basedep +fixed-pointdep +vectorsetup-changed

Dependencies added: base, fixed-point, vector

Files

+ Data/Fixed/Binary/Unboxed.hs view
@@ -0,0 +1,66 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# OPTIONS -fno-warn-orphans #-}+module Data.Fixed.Binary.Unboxed () where++import Control.Monad+import Data.Function+import Unsafe.Coerce++import qualified Data.Vector.Generic as VG+import qualified Data.Vector.Generic.Mutable as VGM+import qualified Data.Vector.Unboxed as VU++import Data.Fixed.Binary++fixed :: a -> Fixed r a+fixed = unsafeCoerce++unFixed :: Fixed r a -> a+unFixed = unsafeCoerce++newtype instance VU.MVector s (Fixed r a) = MVFixed { unMVFixed :: VU.MVector s a }+newtype instance VU.Vector    (Fixed r a) = VFixed  { unVFixed  :: VU.Vector    a }++instance VGM.MVector VU.MVector a => VGM.MVector VU.MVector (Fixed r a) where+  {-# INLINE basicLength #-}+  basicLength                     = VGM.basicLength . unMVFixed+  {-# INLINE basicUnsafeSlice #-}+  basicUnsafeSlice i n            = MVFixed . VGM.basicUnsafeSlice i n . unMVFixed+  {-# INLINE basicOverlaps #-}+  basicOverlaps                   = VGM.basicOverlaps `on` unMVFixed+  {-# INLINE basicUnsafeNew #-}+  basicUnsafeNew                  = liftM MVFixed . VGM.basicUnsafeNew+  {-# INLINE basicUnsafeReplicate #-}+  basicUnsafeReplicate n          = liftM MVFixed . VGM.basicUnsafeReplicate n . unFixed+  {-# INLINE basicUnsafeRead #-}+  basicUnsafeRead (MVFixed mv)    = liftM fixed . VGM.basicUnsafeRead mv+  {-# INLINE basicUnsafeWrite #-}+  basicUnsafeWrite (MVFixed mv) i = VGM.basicUnsafeWrite mv i . unFixed+  {-# INLINE basicClear #-}+  basicClear                      = VGM.basicClear . unMVFixed+  {-# INLINE basicSet #-}+  basicSet (MVFixed mv)           = VGM.basicSet mv . unFixed+  {-# INLINE basicUnsafeCopy #-}+  basicUnsafeCopy                 = VGM.basicUnsafeCopy `on` unMVFixed+  {-# INLINE basicUnsafeGrow #-}+  basicUnsafeGrow (MVFixed mv)    = liftM MVFixed . VGM.basicUnsafeGrow mv++instance VG.Vector VU.Vector a => VG.Vector VU.Vector (Fixed r a) where+  {-# INLINE basicUnsafeFreeze #-}+  basicUnsafeFreeze            = liftM VFixed . VG.basicUnsafeFreeze . unMVFixed+  {-# INLINE basicUnsafeThaw #-}+  basicUnsafeThaw              = liftM MVFixed . VG.basicUnsafeThaw . unVFixed+  {-# INLINE basicLength #-}+  basicLength                  = VG.basicLength . unVFixed+  {-# INLINE basicUnsafeSlice #-}+  basicUnsafeSlice i n         = VFixed . VG.basicUnsafeSlice i n . unVFixed+  {-# INLINE basicUnsafeIndexM #-}+  basicUnsafeIndexM (VFixed v) = liftM fixed . VG.basicUnsafeIndexM v+  {-# INLINE basicUnsafeCopy #-}+  basicUnsafeCopy (MVFixed mv) = VG.basicUnsafeCopy mv . unVFixed+  {-# INLINE elemseq #-}+  elemseq (VFixed v)           = VG.elemseq v . unFixed++instance VU.Unbox a => VU.Unbox (Fixed r a)
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (C) 2011 by Jake McArthur++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ fixed-point-vector.cabal view
@@ -0,0 +1,33 @@+Name:                fixed-point-vector+Version:             0.5.0.0+Synopsis:            Unbox instances for the fixed-point package+Description:         This package allows you to construct unboxed+                     vectors of binary fixed-point numerals.+License:             MIT+License-file:        LICENSE+Author:              Jake McArthur+Maintainer:          Jake McArthur <Jake.McArthur@gmail.com>+Category:            Data, Game, Math, Numerical++Build-type:          Simple+Cabal-version:       >=1.6+++Library+  Exposed-modules:   Data.Fixed.Binary.Unboxed+  Extensions:        FlexibleContexts,+                     MultiParamTypeClasses,+                     TypeFamilies+  Build-depends:     base == 4.3.*,+                     fixed-point == 0.5.0.0,+                     vector == 0.7.*+  GHC-options:       -Wall -fno-warn-orphans -fwarn-tabs -funfolding-use-threshold=16++Source-repository head+  type:     darcs+  location: http://patch-tag.com/r/jmcarthur/fixed-point++source-repository this+  type:     darcs+  location: http://patch-tag.com/r/jmcarthur/fixed-point+  tag:      v0.5.0.0