<div dir="auto">Data.Sequence actually doesn't support anything outside the Int range. It could, at a small cost. We perform some range checks cheaply using unsigned comparisons. We'd have to stop doing that to allow sequences to be just a tad more absurdly large. Since that's not often useful, sequences are currently limited to lengths of maxBound @Int.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 15, 2018, 5:53 PM Zemyla <<a href="mailto:zemyla@gmail.com">zemyla@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It's not actually impossible to have an in RAM structure that exceeds<br>
the largest positive value for Int. Data.Sequence.replicate does it by<br>
exploiting sharing. replicate n a uses O(lg n) space.<br>
<br>
> length $ let x = Data.Sequence.Replicate maxBound 'a' :> 'b' in mappend x x<br>
0<br>
<br>
Also, I really would like to have all the length and count-based<br>
functions in base, containers, etc. take or return Words, but there's<br>
way too much inertia behind Ints, even if it means you have to check<br>
for negative numbers (which really runs counter to the main thesis<br>
behind Haskell; i.e. have your types say what you mean).<br>
<br>
On Thu, Nov 15, 2018 at 12:30 AM Carter Schonwald<br>
<<a href="mailto:carter.schonwald@gmail.com" target="_blank" rel="noreferrer">carter.schonwald@gmail.com</a>> wrote:<br>
><br>
> Agreed.<br>
><br>
> As David and Eric both say:<br>
> For in heap / memory size structures, it’s impossible to ever have an in ram structure that exceeds the largest positive value for Int. And ghc is also quite good at optimizing int.<br>
><br>
> 1) what is your application domain / context ?<br>
><br>
> 2) all of these are implementable in user space, what design / implementation experiments have you done ?<br>
><br>
> It’s worth mentioning that RULES style optimization in this case would only run AFTER it’s been specialized to a concrete type. And that short of lots of specialize pragmas or inlining , the generic code will thusly miss out on all sorts of unboxong etc.<br>
><br>
> On Tue, Nov 13, 2018 at 10:31 PM David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank" rel="noreferrer">david.feuer@gmail.com</a>> wrote:<br>
>><br>
>> That won't help whatsoever in most cases. The matter has been discussed several times with no progress. If you want to add RULES for Int8, Int16, ..., Word, Word8, ..., and Natural to match the ones for Int and Integer, that would make sense, but the basic problem will remain for unmentioned types.<br>
>><br>
>> On Tue, Nov 13, 2018, 10:24 PM Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io" target="_blank" rel="noreferrer">vanessa.mchale@iohk.io</a> wrote:<br>
>>><br>
>>> This is perhaps not the right place, but if there are benchmarks proving that genericLength is slower than it should be, it should be easy to add a SPECIALIZE pragma.<br>
>>><br>
>>> On 11/13/18 9:13 PM, David Feuer wrote:<br>
>>><br>
>>> genericLength is extremely inefficient for typical numeric types. Int is a rather sad type for these things; it really should be Word. But that may not be worth fixing.<br>
>>><br>
>>> On Tue, Nov 13, 2018, 9:51 PM Evan Laforge <<a href="mailto:qdunkan@gmail.com" target="_blank" rel="noreferrer">qdunkan@gmail.com</a> wrote:<br>
>>>><br>
>>>> You can already get these as Data.List.genericLength and<br>
>>>> Data.List.genericReplicate<br>
>>>><br>
>>>> As for changing the prelude ones, this would probably cause a lot of<br>
>>>> busywork. Where I work we compile with -Werror and -Wtype-defaults,<br>
>>>> so a lot of places might have to get type annotations.<br>
>>>> On Tue, Nov 13, 2018 at 5:19 PM Vanessa McHale <<a href="mailto:vanessa.mchale@iohk.io" target="_blank" rel="noreferrer">vanessa.mchale@iohk.io</a>> wrote:<br>
>>>> ><br>
>>>> > Would it be possible to generalize replicate and length to have type<br>
>>>> > signatures<br>
>>>> ><br>
>>>> > replicate :: Integral a => a -> b -> [b]<br>
>>>> ><br>
>>>> > and<br>
>>>> ><br>
>>>> > length :: (Integral a, Foldable t) => t b -> a<br>
>>>> ><br>
>>>> > ?<br>
>>>> ><br>
>>>> > There have been a few instances where such a thing would have been<br>
>>>> > useful to me.<br>
>>>> ><br>
>>>> > Cheers<br>
>>>> ><br>
>>>> ><br>
>>>> > _______________________________________________<br>
>>>> > Libraries mailing list<br>
>>>> > <a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
>>>> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>>>> _______________________________________________<br>
>>>> Libraries mailing list<br>
>>>> <a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
>>>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>><br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
><br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>