Proposal: rename Data.Map.fromAscList to Data.Map.unsafeFromAscList

Krzysztof Skrzętnicki gtener at
Fri Apr 24 08:14:37 EDT 2009

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> 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'.
> -chris
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Libraries mailing list