From 574468a37a0e662c5d63d1cf3f8f876b11b4e332 Mon Sep 17 00:00:00 2001 From: Mikolaj Konarski Date: Sun, 5 Apr 2026 18:30:30 +0200 Subject: Tweak sized list type synonyms slightly --- src/Data/Array/Nested/Mixed/ListX.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Data/Array/Nested/Mixed/ListX.hs') diff --git a/src/Data/Array/Nested/Mixed/ListX.hs b/src/Data/Array/Nested/Mixed/ListX.hs index ae3c89f..048003f 100644 --- a/src/Data/Array/Nested/Mixed/ListX.hs +++ b/src/Data/Array/Nested/Mixed/ListX.hs @@ -48,6 +48,7 @@ type ListX :: [Maybe Nat] -> Type -> Type newtype ListX sh i = ListX [i] deriving (Eq, Ord, NFData, Foldable) +{-# INLINE ZX #-} pattern ZX :: forall sh i. () => sh ~ '[] => ListX sh i pattern ZX <- (listxNull -> Just Refl) where ZX = ListX [] @@ -62,16 +63,16 @@ pattern (::%) :: forall {sh1} {i}. forall n sh. (n : sh ~ sh1) => i -> ListX sh i -> ListX sh1 i -pattern i ::% l <- (listxUncons -> Just (UnconsListXRes l i)) +pattern i ::% l <- (listxUncons -> Just (UnconsListXRes i l)) where !i ::% ListX !l = ListX (i : l) infixr 3 ::% data UnconsListXRes i sh1 = - forall n sh. (n : sh ~ sh1) => UnconsListXRes (ListX sh i) i + forall n sh. (n : sh ~ sh1) => UnconsListXRes i (ListX sh i) {-# INLINE listxUncons #-} listxUncons :: forall sh1 i. ListX sh1 i -> Maybe (UnconsListXRes i sh1) listxUncons (ListX (i : l)) = gcastWith (unsafeCoerceRefl :: Head sh1 ': Tail sh1 :~: sh1) $ - Just (UnconsListXRes (ListX @(Tail sh1) l) i) + Just (UnconsListXRes i (ListX @(Tail sh1) l)) listxUncons (ListX []) = Nothing {-# COMPLETE ZX, (::%) #-} @@ -123,7 +124,7 @@ instance Functor (ListX l) where let fmap' [] = [] fmap' (x : xs) = let y = f x rest = fmap' xs - in y `seq` rest `seq` y : rest + in y `seq` rest `seq` (y : rest) in ListX $ fmap' l -- | Very untyped: not even length is checked (at runtime). -- cgit v1.3