[Haskell-cafe] Problem trying to get class Bounded to work
Brian Hulley
brianh at metamilk.com
Tue May 23 12:37:10 EDT 2006
Jacques Carette wrote:
> I guess I prefer a type annotation over a dummy function that is
> there just to force the type checker to believe me. If one has to
> force the type checker, may as well do it with a type, not code!
I agree totally.
Also, I think there is a more general issue regarding the relative
importance of type inference when programming, since it seems to me that a
lot of awkwardness is introduced into Haskell by the insistence that the
type inference algorithm should be able to infer everything by itself to
surprise the programmer with knowledge that the programmer should already
know in the first place and could quite easily have written down directly.
An example is the fact that constructors and record field names currently
have to be unique within a whole module. If instead of this, constructors
and field names were always in seperate namespaces indexed by type, instead
of them determining the type, programming would be tremendously easier
because the same names could be reused without worrying about conflicts.
eg compare
data Either a b = Left a | Right b -- Prelude got there first
as usual
data Location = Location_Left | Location_Right
foo (Location_Left, Location_Left, Location_Left) = Left 5
foo (Location_Left, Location_Left, Location_Right) = Right
"something"
-- 6 more wordy patterns
with
data Either a b = Left a | Right b
data Location = Left | Right -- all names local to type
Location
foo :: (Location, Location, Location) -> Either Int String
foo (Left, Left, Left) = Left 5
foo (Left, Left, Right) = Right "something"
-- 6 more simple patterns
Regards, Brian.
More information about the Haskell-Cafe
mailing list