[Haskell-cafe] Re: Re[2]: [Haskell] Proposal: unification of styleof function/data/type/class definitions

Brian Hulley brianh at metamilk.com
Mon Sep 11 14:59:05 EDT 2006

Taral wrote:
> On 9/11/06, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
>>       Expr Bool = Eq (Expr t) (Expr t) | forall t . Eq t
> Still confusing, but less so.
> The problem is that it's really backwards. The symbol being defined
> is "Eq".
> Eq (Expr t) (Expr t) | Eq t = Expr Bool
> but that doesn't fit well, does it?

You could also argue that the symbol being defined is the tycon "Expr", 
since a data decl defines both a tycon and zero or more value constructors.

This leads to a symmetric relationship: to define a type we write multiple 
clauses for the same tycon and to define a function we write multiple 
clauses for the same function name.

The clauses for each tycon are "used" at compile time to find value 
constructors for the corresponding type, and the clauses for each function 
name are "used" at run time to find values for the corresponding function 

> In my mind, the current mode is a
> functional one:
> Eq :: Eq t => Expr t -> Expr t -> Expr Bool
> And this is perfectly readable. The arrow means that the argument is
> an implicit propositional one, but it's still an argument.

The => arrow ties the concept of restricted quantification to the concept of 
passing implicit arguments around behind the scenes. Is this desireable?

It is also worth mentioning that the bar syntax allows for better 
interactive syntax highlighting in an editor, because putting the quantifier 
after the type means there is no ambiguity when parsing left to right - when 
we get to a '|' we know what follows is a quantifier (restricted or 
unrestricted) whereas in the current => syntax an editor can't tell that the 
user is typing parts of a context until the whole context has already been 
typed - too late to provide interactive feedback! ;-)

Tomasz Zielonka wrote:
> On Sun, Sep 10, 2006 at 10:08:22AM +0400, Bulat Ziganshin wrote:
>> sequence :: [m a] -> m [a] | Monad m
> I am not entirely sure, but I think this syntax for type class
> context is used in the Concurrent Clean language.

Some examples can be found in the Clean report 2.0 Dec 2001 eg page 59.

Regards, Brian.
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.


More information about the Haskell-Cafe mailing list