On 1 May 2015 at 15:30, Matt Oliveri <[email protected]> wrote:
>
> Bull crap. As you said yourself, with coherent typeclasses, you may
> want alternatives that take an explicit comparison function. So with
> coherent typeclasses, you certainly want first-class functions too.
> Since typeclasses generally require passing dictionaries, you already
> effectively have first-class functions anyway, whether you like it or
> not. But really, who wants to get rid of first-class functions? No
> one. So don't write flame bait.
>
This seems a bit of an over-reaction. My point was nobody is arguing to get
rid of first-class functions, which allow you to pass in ordering
operators, so why would you not want implicits where you can have one
definition for both ways of doing things.
> The one and only problem with instance arguments, I gather, is that
> instances are not guaranteed to be coherent.
I don't see this at all. Instances available for implicit resolution have
to be coherent., however you could still pass explicit instances.
The way I have looked at this is that a type-class and a record are really
the same thing with different resolution:
data Ord a = Ord {
cmp :: a -> a -> Bool
}
ord1 = Ord {
cmp = >
} :: Ord Int
ord2 = Ord {
cmp = <
} :: Ord Int
-- everything is fine so far and we can call sort:
sort ord1 [3, 1, 2]
-- we can select which instance is to be used as-if it were a type-class:
use ord1
-- then we can call
sort [3, 1, 2]
-- if we want to enforce global coherence the following would result in a
compile error
use ord2
Keean.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev