harpie 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+17/−6 lines, 3 files
Files
- harpie.cabal +1/−1
- src/Harpie/Fixed.hs +1/−1
- src/Harpie/Shape.hs +15/−4
harpie.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: harpie-version: 0.1.0.0+version: 0.1.0.1 license: BSD-3-Clause license-file: LICENSE copyright: Tony Day (c) 2016-2024
src/Harpie/Fixed.hs view
@@ -1282,7 +1282,7 @@ -- >>> pretty $ indexes (Dims @[0,1]) (S.UnsafeFins [1,1]) a -- [16,17,18,19] indexes ::- forall ds s s' xs a.+ forall s' s ds xs a. ( KnownNats s, KnownNats s', s' ~ Eval (DeleteDims ds s),
src/Harpie/Shape.hs view
@@ -981,8 +981,22 @@ -- 1 getDim :: Int -> [Int] -> Int getDim 0 [] = 1-getDim i s = fromMaybe (error "getDim outside bounds") (s List.!? i)+getDim i s = fromMaybe (error "getDim outside bounds") (maybeGetDim s i) +maybeGetDim :: [a] -> Int -> Maybe a+maybeGetDim xs n+ | n < 0 = Nothing+ | otherwise =+ foldr+ ( \x r k -> case k of+ 0 -> Just x+ _ -> r (k - 1)+ )+ (const Nothing)+ xs+ n+{-# INLINEABLE maybeGetDim #-}+ -- | Get the dimension of a shape at the supplied index. Error if out-of-bounds or non-computable (usually unknown to the compiler). -- -- >>> :k! Eval (GetDim 1 [2,3,4])@@ -1348,9 +1362,6 @@ -- >>> :k! Eval (GetLastPositions [2,0] [2,3,4]) -- ... -- = [3, 1]--- >>> :k! Eval (GetLastPositions '[0] '[0])--- ...--- = '[0 GHC.TypeNats.- 1] data GetLastPositions :: [Nat] -> [Nat] -> Exp [Nat] type instance