Proposal: rename Data.Map.fromAscList to
sfvisser at cs.uu.nl
Fri Apr 24 09:50:15 EDT 2009
On Apr 24, 2009, at 2:51 PM, Neil Mitchell wrote:
> I totally disagree. unsafe/unchecked means nothing other than "beware
> of the bogey monster", or for most Haskell users, "just another
> function that might launch missiles". fromAscList has the specific
> precondition for this function in the name. Should we call unsafeHead?
> uncheckedHead? mightCrashIfNotConsHead?
> Adding a check for the precondition would be the ideal thing to do,
> but I wouldn't want to do it if it added an extra comparison or was
> any runtime cost at all. Perhaps adding checkedFromAscList might be
> acceptable, but I can't imagine anyone would call it until they'd got
> it wrong the first time, at which point the chances of them getting it
> wrong again are quite low.
> On Fri, Apr 24, 2009 at 1:36 PM, Christian Maeder
> <Christian.Maeder at dfki.de> wrote:
Personally I very much hope that Haskell' will change the definition
of head to a safe version and include the current head function as
unsafeHead. Encouraging developers to use and write total function is
probably a good thing and prevents us from having to explain all those
messy corners in the Haskell language to our Ruby and Python friends.
Adding a new function safeFromAscList that actually checks the
precondition and returns a |Maybe (Map a b)| may sound as a nice
compromise, but shouldn't all function be safe by default? I'd much
rather see to version of which one is called the `unsafe' than two
version of which one is called `safe'.
Safe feels like a safe default.
More information about the Libraries