On the second thought, another thing can be made. Since we know that fromAscList should take a list of ascending items, we can check whether it is sorted. If this precondition is not met, we simply call error. We also rename current fromAscList to unsafeFromAscList. This is similar to index and unsafeIndex from arrays code.<br>
<br>What do you think about this solution?<br><br>Best regards<br><br>Christopher SkrzÄ™tnicki<br><br><div class="gmail_quote">On Fri, Apr 24, 2009 at 13:58, Chris Eidhof <span dir="ltr">&lt;<a href="mailto:chris@eidhof.nl">chris@eidhof.nl</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hey all,<br>
<br>
I had some code where the function elems said a certain key was present, but looking it up returned a Nothing. After some debugging I found out that it did work if I used Prelude&#39;s lookup in combination with toList. After even more debugging it turned out there was a fromAscList somewhere deep down in my code where it should have been a fromList.<br>

<br>
Now, I know that I shouldn&#39;t have used fromAscList and that it was totally my fault. I also realize this is something that can&#39;t easily be checked using the type system, so I propose we do the next best thing: prefix the name with &#39;unsafe&#39;.<br>

<br>
-chris<br>
<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</blockquote></div><br>