diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2025-12-02 22:14:59 +0100 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2025-12-02 22:14:59 +0100 |
| commit | cd59bbd479feb2c7a3a07eb3eda6688e5776905b (patch) | |
| tree | 27070604aed78c8c28bed8aa52cafe1d5ec57c3f /src/Data/Array/Nested/Ranked/Shape.hs | |
| parent | 04818d344d367025c6f8b99357664e42cf1022ed (diff) | |
Define {list,sh,ix}*ToList functions using 'build'
This should allow foldr/build fusion
Diffstat (limited to 'src/Data/Array/Nested/Ranked/Shape.hs')
| -rw-r--r-- | src/Data/Array/Nested/Ranked/Shape.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Ranked/Shape.hs b/src/Data/Array/Nested/Ranked/Shape.hs index 2fea8c4..6d61bd5 100644 --- a/src/Data/Array/Nested/Ranked/Shape.hs +++ b/src/Data/Array/Nested/Ranked/Shape.hs @@ -36,7 +36,7 @@ import Data.Foldable qualified as Foldable import Data.Kind (Type) import Data.Proxy import Data.Type.Equality -import GHC.Exts (Int(..), Int#, quotRemInt#) +import GHC.Exts (Int(..), Int#, quotRemInt#, build) import GHC.Generics (Generic) import GHC.IsList (IsList) import GHC.IsList qualified as IsList @@ -141,8 +141,11 @@ listrFromList topsn topl = go topsn topl {-# INLINEABLE listrToList #-} listrToList :: ListR n i -> [i] -listrToList ZR = [] -listrToList (i ::: is) = i : listrToList is +listrToList list = build (\(cons :: i -> is -> is) (nil :: is) -> + let go :: ListR n i -> is + go ZR = nil + go (i ::: is) = i `cons` go is + in go list) listrHead :: ListR (n + 1) i -> i listrHead (i ::: _) = i |
