Jon Fairbairn wrote:
I currently only get f :: [t] -> something, so if I later
discover that I need to change the input representation to
be more efficient than lists, I have to rewrite f. Wouldn't
it be so much nicer if I could simply add a declaration
f:: Stream s => s t -> something
and get a function that works on anything in the Stream
class?
The core of the idea would be to allow classes to include
constructors (and associated destructors) so the definition
of Stream would include something for ":" and "[]" and their
inverses, though I've no real idea of the details; can
anyone come up with a plan?
I had been avoiding adding my two cents, but I must object to this.
Because this is starting to sound like one of the maddening things about C++.
Namely, the automatic implicit casting conversions of classes via their single
argument constructors. This is one of the (several) things that makes reading
and understanding a function or method call in C++ incredibly difficult.
What if the 'f' in the quoted message above is itself part of a type class.
Then one has to decide which instance 'f' is being called and what
constructors/destructors are being called to view the 's t' parameter as the
correct concrete type. That way lies madness.
Any magical view logic is dangerous in this respect. Thus I would probably not
want any special implicit (class View a b) or (call View a b | a -> b), etc.
At least the proposal that (=> _) is (-> Just _) makes you change the syntax
instead of overloading (->).
--
Chris
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe