From 2bfd35243211d2acbc35629d448d27a51a9112bc Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 19 May 2024 16:59:25 +0200 Subject: Fix some fromLists --- src/Data/Array/Mixed.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs index 398a3de..fa61b01 100644 --- a/src/Data/Array/Mixed.hs +++ b/src/Data/Array/Mixed.hs @@ -243,9 +243,8 @@ instance KnownShX sh => IsList (ListX sh (Const i)) where go ZKX [] = ZX go (_ :!% sh) (i : is) = Const i ::% go sh is go _ _ = error $ "IsList(ListX): Mismatched list length (type says " - ++ show typelen ++ ", list has length " + ++ show (lengthStaticShX (knownShX @sh)) ++ ", list has length " ++ show (length topl) ++ ")" - where typelen = let StaticShX l = knownShX @sh in lengthListX l toList = go where go :: ListX sh' (Const i) -> [i] @@ -261,7 +260,7 @@ instance KnownShX sh => IsList (IxX sh i) where -- | Untyped: length and known dimensions are checked (at runtime). instance KnownShX sh => IsList (ShX sh Int) where type Item (ShX sh Int) = Int - fromList = ShX . go (knownShX @sh) + fromList topl = ShX (go (knownShX @sh) topl) where go :: StaticShX sh' -> [Int] -> ListX sh' (SMayNat Int SNat) go ZKX [] = ZX @@ -270,7 +269,9 @@ instance KnownShX sh => IsList (ShX sh Int) where | otherwise = error $ "IsList(ShX): Value does not match typing (type says " ++ show (fromSNat' sn) ++ ", list contains " ++ show i ++ ")" go (SUnknown () :!% sh) (i : is) = SUnknown i ::% go sh is - go _ _ = error "IsList(ShX): Mismatched list length" + go _ _ = error $ "IsList(ShX): Mismatched list length (type says " + ++ show (lengthStaticShX (knownShX @sh)) ++ ", list has length " + ++ show (length topl) ++ ")" toList = go where go :: ShX sh' Int -> [Int] -- cgit v1.2.3-70-g09d2