Skip to content

Commit

Permalink
#40 Fix fromInfinite error
Browse files Browse the repository at this point in the history
In the implementation of fromInfinite, we pass an infinite list to
Data.Primitive.Array.fromListN (bits + 1), but fromListN expects a list
a list of length (bits + 1), which results in a runtime error.

To fix this, we take the first (bits + 1) of the infinite list before
passing to fromListN.
  • Loading branch information
pgujjula committed Apr 12, 2024
1 parent a1ab71a commit ddc9840
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Data/Chimera/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fromInfinite
:: G.Vector v a
=> Infinite a
-> Chimera v a
fromInfinite = Chimera . fromListN (bits + 1) . go0
fromInfinite = Chimera . fromListN (bits + 1) . take (bits + 1) . go0
where
go0 (x :< xs) = G.singleton x : go 0 xs

Expand Down

0 comments on commit ddc9840

Please sign in to comment.