X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=blobdiff_plain;f=clash%2FData%2FParam%2FVector.hs;h=f726945702d7af5bca9162327553357e35b2244c;hp=32218be266f4d9f1e85cccfcf164414a31cc229e;hb=7f6a8f38eea6aec322fad713d9b8dd67ffd0a9de;hpb=04f836932ad17dd557af0ba388a12d2b74c1e7d7 diff --git a/clash/Data/Param/Vector.hs b/clash/Data/Param/Vector.hs index 32218be..f726945 100644 --- a/clash/Data/Param/Vector.hs +++ b/clash/Data/Param/Vector.hs @@ -28,8 +28,8 @@ module Data.Param.Vector , foldr , zip , unzip - , shiftl - , shiftr + , shiftIntoL + , shiftIntoR , rotl , rotr , concat @@ -109,16 +109,14 @@ fromVector (Vector xs) = xs null :: Vector D0 a -> Bool null _ = True -(!) :: ( PositiveT s - , NaturalT u - , (s :>: u) ~ True) => Vector s a -> Index u -> a +(!) :: PositiveT s => Vector s a -> Index s -> a (Vector xs) ! i = xs !! (fromInteger (toInteger i)) -- ========================== -- = Transforming functions = -- ========================== -replace :: (PositiveT s, NaturalT u, (s :>: u) ~ True) => - Vector s a -> Index u -> a -> Vector s a +replace :: PositiveT s => + Vector s a -> Index s -> a -> Vector s a replace (Vector xs) i y = Vector $ replace' xs (toInteger i) y where replace' [] _ _ = [] replace' (_:xs) 0 y = (y:xs) @@ -181,13 +179,13 @@ zip = liftV2 P.zip unzip :: Vector s (a, b) -> (Vector s a, Vector s b) unzip (Vector xs) = let (a,b) = P.unzip xs in (Vector a, Vector b) -shiftl :: (PositiveT s, NaturalT n, n ~ Pred s, s ~ Succ n) => - Vector s a -> a -> Vector s a -shiftl xs x = x +> init xs +shiftIntoL :: (PositiveT s, NaturalT n, n ~ Pred s, s ~ Succ n) => + Vector s a -> a -> Vector s a +shiftIntoL xs x = x +> init xs -shiftr :: (PositiveT s, NaturalT n, n ~ Pred s, s ~ Succ n) => - Vector s a -> a -> Vector s a -shiftr xs x = tail xs <+ x +shiftIntoR :: (PositiveT s, NaturalT n, n ~ Pred s, s ~ Succ n) => + Vector s a -> a -> Vector s a +shiftIntoR xs x = tail xs <+ x rotl :: forall s a . NaturalT s => Vector s a -> Vector s a rotl = liftV rotl'