Closed rgrempel closed 8 years ago
I'm not really sure, but it does sound like the problem might be in the Unfoldable List
instance; that's where I'd start looking. I'll leave this open for now, though.
Here's the unfoldableList
implementation ...
instance unfoldableList :: Unfoldable List where
unfoldr f b = go (f b)
where
go Nothing = Nil
go (Just (Tuple a b)) = Cons a (go (f b))
Now, I think the recursive call to go
must be the problem ... it doesn't look properly tail-recursive to me. I'll play with this a bit and see if I can fix it.
Yep, that's correct: it isn't, because of the call to Cons
on the last line.
I submitted a PR in purescript-lists, so I'll close this here.
I was using
fromSeq
to convert from large sequences to lists, and ran into problems with the stack size:However, an alternative approach with
foldr
works fine:Just as an experiment, I tried implementing
fromSeq
asunfoldr uncons
. This works, but has the same problem with stack size.Now, I think this suggests that the problem is either in
Unfoldable
or in the implementation ofUnfoldable
inList
-- not inData.Sequence
as such. However, I'm new to Purescript, so I could easily be interpreting all of this inaccurately.In fact, I just tried
fromSeq
to convert to a largeData.Array
instead of a largeData.List
, and that works fine.So, I guess the problem is in
Data.List
? If so, feel free to close this issue.