Proposal: rename Data.Map.fromAscList to
chris at eidhof.nl
Fri Apr 24 08:20:33 EDT 2009
I really like that, Krzysztof. That way there's still the power to do
it efficiently but at least you know when you're doing things in an
erroneous way. My problem with the current way of doing this is that
you get errors in a place where you didn't expect them.
On 24 apr 2009, at 14:14, Krzysztof Skrzętnicki wrote:
> 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.
> What do you think about this solution?
> Best regards
> Christopher Skrzętnicki
> On Fri, Apr 24, 2009 at 13:58, Chris Eidhof <chris at eidhof.nl> wrote:
> Hey all,
> 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'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.
> Now, I know that I shouldn't have used fromAscList and that it was
> totally my fault. I also realize this is something that can't easily
> be checked using the type system, so I propose we do the next best
> thing: prefix the name with 'unsafe'.
> Libraries mailing list
> Libraries at haskell.org
More information about the Libraries