Some clarity please! (was Re: [Haskell-cafe] Re: (flawed?)
benchmark : sort)
conor at strictlypositive.org
Thu Mar 13 21:42:28 EDT 2008
On 13 Mar 2008, at 23:42, kahl at cas.mcmaster.ca wrote:
> Conor McBride <conor at strictlypositive.org> responded to my comment:
>>> (mapMonotonic should of course be removed, too,
>>> or specified to fail (preferably in some MonadZero)
>>> if the precondition is violated,
>>> which should still be implementable in linear time.)
>> What's wrong with mapMonotonic that isn't wrong
>> with, say, sortBy?, or Eq instances for parametrized
> Prelude> :m + Data.Set
> Prelude Data.Set> toAscList $ mapMonotonic (10 -) (fromList [1 .. 5])
> Prelude Data.Set> 5 `member` mapMonotonic (10 -) (fromList [1 .. 5])
> Something's certainly wrong there!
But nothing out of the ordinary: garbage in,
garbage out. Happens all the time, even in
Haskell. Why pick on mapMonotonic?
Prelude Data.List> sortBy (\_ _ -> GT) [1,3,2,5,4]
Prelude Data.List> sortBy (\_ _ -> GT) [4,5,3,2,1]
I guess there's a question of what we might
call "toxic waste"---junk values other than
undefined. I think undefined is bad enough
already. So the type system can't express
the spec. I don't think we should be casual
about that: we should be precise in
documentation about the obligations which
fall on the programmer. Some dirt is
pragmatically necessary: we shouldn't pretend
that it ain't so; we shouldn't pretend that dirt
>> Before we can talk about what == should return,
>> can we settle what we mean by = ?
> ``='' is not in the Haskell interface! ;-)
No, but "is" is in the human interface!
> Therefore, I talked only about (==).
Ah, but you talked about things. Which
things? Is one of the things you talked
about the same as (==)? the same as
> The best way to include ``='' seems to be the semantic equality of
> [Harrison-Kieburtz-2005], which is quite a heavy calibre,
> and at least in that paper, classes are not yet included.
I expect it's hard work. It's hard work in
much better behaved systems. My point is that
it's worth it, in order to facilitate more
All the best
More information about the Haskell-prime