Skip to content

Commit

Permalink
Merge pull request #35 from Shimuuar/new-unbox
Browse files Browse the repository at this point in the history
New design for unboxed vectors
  • Loading branch information
Shimuuar authored Dec 24, 2024
2 parents 4db1a55 + 1641a9e commit be48042
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 279 deletions.
4 changes: 4 additions & 0 deletions fixed-vector/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Changes in 1.3.0.0
* In `ArityPeano` type class methods `reverseF` and `gunfoldF` are replaced
with more general `accumPeano` and `reducePeano`.

* `Unbox` vector are fully reworked. All uses of data types with `Unbox`
instances which are defined in the library except `Bool` should work without
changes.

* `Data.Vector.Fixed.Cont.arity` dropped

* Type of `D.V.F.Cont.withFun` generalized
Expand Down
13 changes: 12 additions & 1 deletion fixed-vector/Data/Vector/Fixed/Cont.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Data.Vector.Fixed.Cont (
, apLast
, shuffleFun
, withFun
, dimapFun
-- * Vector type class
, Dim
, Vector(..)
Expand Down Expand Up @@ -417,6 +418,15 @@ shuffleFun f0

newtype T_shuffle x a r n = T_shuffle (x -> Fn n a r)

-- | Apply function to parameters and result of @Fun@ simultaneously.
dimapFun :: ArityPeano n => (a -> b) -> (c -> d) -> Fun n b c -> Fun n a d
{-# INLINE dimapFun #-}
dimapFun fA fR fun
= accum (\(T_Flip g) a -> T_Flip (curryFirst g (fA a)))
(\(T_Flip x) -> fR (unFun x))
(T_Flip fun)




----------------------------------------------------------------
Expand Down Expand Up @@ -881,7 +891,8 @@ zipWith f vecA vecB = ContVec $ \funC ->
zipWith3 :: (ArityPeano n) => (a -> b -> c -> d)
-> ContVec n a -> ContVec n b -> ContVec n c -> ContVec n d
{-# INLINE zipWith3 #-}
zipWith3 f v1 v2 v3 = zipWith (\a (b, c) -> f a b c) v1 (zipWith (,) v2 v3)
zipWith3 f v1 v2 v3
= zipWith ($) (zipWith f v1 v2) v3

-- | Zip two vector together using function which takes element index
-- as well.
Expand Down
Loading

0 comments on commit be48042

Please sign in to comment.