Skip to content

Commit

Permalink
Merge pull request #9 from Mikolaj/more-inlineable
Browse files Browse the repository at this point in the history
Add INLINABLE to a couple more functions
  • Loading branch information
augustss authored Apr 13, 2024
2 parents 20420d4 + 31a28e6 commit 9717153
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Data/Array/Internal/RankedG.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ data Array (n :: Nat) v a = A !ShapeL !(T v a)
deriving (Generic, Data)

instance (Vector v, Show a, VecElem v a) => Show (Array n v a) where
{-# INLINABLE showsPrec #-}
showsPrec p a@(A s _) = showParen (p > 10) $
showString "fromList " . showsPrec 11 s . showString " " . showsPrec 11 (toList a)

Expand Down
1 change: 1 addition & 0 deletions Data/Array/Internal/RankedS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ unScalar = G.unScalar . unA

-- | Make an array with all elements having the same value.
-- O(1) time
{-# INLINABLE constant #-}
constant :: (Unbox a, KnownNat n) => ShapeL -> a -> Array n a
constant sh = A . G.constant sh

Expand Down
1 change: 1 addition & 0 deletions Data/Array/Internal/ShapedG.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ newtype Array (sh :: [Nat]) v a = A (T v a)
deriving (Generic, Data)

instance (Vector v, Show a, VecElem v a, Shape sh, Show (v a)) => Show (Array sh v a) where
{-# INLINABLE showsPrec #-}
showsPrec p a@(A _) = showParen (p > 10) $
showString "fromList @" . showsPrec 11 (shapeL a) . showString" " . showsPrec 11 (toList a)

Expand Down
1 change: 1 addition & 0 deletions Data/Array/Internal/ShapedS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ unScalar = G.unScalar . unA

-- | Make an array with all elements having the same value.
-- O(1) time.
{-# INLINABLE constant #-}
constant :: forall sh a . (Unbox a, Shape sh) =>
a -> Array sh a
constant = A . G.constant
Expand Down

0 comments on commit 9717153

Please # to comment.