diff options
| author | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2025-05-11 12:37:28 +0200 | 
|---|---|---|
| committer | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2025-05-11 13:34:35 +0200 | 
| commit | 4a4e0f7f9f1131477d26aa24f4eab1741d209260 (patch) | |
| tree | 27ecc38318ea757f6e0ad88a382ae3e029faad4c /src/Data/Array/Mixed | |
| parent | b334ec455eb3703873af8aef9840837f203a71d3 (diff) | |
Define fooLength and/or fooRank whenever not yet defined
Diffstat (limited to 'src/Data/Array/Mixed')
| -rw-r--r-- | src/Data/Array/Mixed/Shape.hs | 21 | 
1 files changed, 15 insertions, 6 deletions
| diff --git a/src/Data/Array/Mixed/Shape.hs b/src/Data/Array/Mixed/Shape.hs index 16f62fe..80bd55e 100644 --- a/src/Data/Array/Mixed/Shape.hs +++ b/src/Data/Array/Mixed/Shape.hs @@ -184,6 +184,12 @@ instance Foldable (IxX sh) where  instance NFData i => NFData (IxX sh i) +ixxLength :: IxX sh i -> Int +ixxLength (IxX l) = listxLength l + +ixxRank :: IxX sh i -> SNat (Rank sh) +ixxRank (IxX l) = listxRank l +  ixxZero :: StaticShX sh -> IIxX sh  ixxZero ZKX = ZIX  ixxZero (_ :!% ssh) = 0 :.% ixxZero ssh @@ -305,12 +311,6 @@ instance NFData i => NFData (ShX sh i) where    rnf (ShX (SUnknown i ::% l)) = rnf i `seq` rnf (ShX l)    rnf (ShX (SKnown SNat ::% l)) = rnf (ShX l) -shxLength :: ShX sh i -> Int -shxLength (ShX l) = listxLength l - -shxRank :: ShX sh i -> SNat (Rank sh) -shxRank (ShX list) = listxRank list -  -- | This checks only whether the types are equal; unknown dimensions might  -- still differ. This corresponds to 'testEquality', except on the penultimate  -- type parameter. @@ -340,6 +340,12 @@ shxEqual (SUnknown i :$% sh) (SUnknown j :$% sh')    = Just Refl  shxEqual _ _ = Nothing +shxLength :: ShX sh i -> Int +shxLength (ShX l) = listxLength l + +shxRank :: ShX sh i -> SNat (Rank sh) +shxRank (ShX l) = listxRank l +  -- | The number of elements in an array described by this shape.  shxSize :: IShX sh -> Int  shxSize ZSX = 1 @@ -452,6 +458,9 @@ instance TestEquality StaticShX where  ssxLength :: StaticShX sh -> Int  ssxLength (StaticShX l) = listxLength l +ssxRank :: StaticShX sh -> SNat (Rank sh) +ssxRank (StaticShX l) = listxRank l +  -- | @ssxEqType = 'testEquality'@. Provided for consistency.  ssxEqType :: StaticShX sh -> StaticShX sh' -> Maybe (sh :~: sh')  ssxEqType = testEquality | 
