Hi,
You are right, the constraints in:
sumlength :: [t] t t -> (t,t) | +, one t
state that there must be an instance available for the type t of the
type class + and one. I think you are a bit confused by the fact that
type classes not necessarily need to start with an uppercase letter
(like one), or even a letter at all (like +). Identifiers after the |
symbol always refer to a type class, never to a function. However, a
type class can define a function with the same identifier as the type
class itself.
For example,
class foo where
foo :: a -> a
and
class Bar where
Bar :: a -> a
are valid type class definitions and can be used as constraints in the
type of a function
f :: a a -> a | foo, Bar a
It seems like the constraints refer to functions, but actually refer to
type classes.
Regards,
Thomas
Note: Functions can appear in the constraints of a function. However,
these are *generic* functions, which happen to be implemented in Clean
using overloading.
terrence.brannon wrote:
terrence.brannon wrote:
I am confused by the pipe syntax. Where is it fully discussed with
examples?
Here's another example:
sumlength :: [t] t t -> (t,t) | +, one t
I'm guessing this is saying that both + and one must be applicable to the
argument of type t
So in some cases it seems to be saying that a certain function must be
applicable and in other cases it is saying that the datum has to be of a
certain type.
But I dont know where to find this fully described with examples, so I'm
sort of hitting in the dark :)
_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list