[bitc-dev] Constraint syntax

wren ng thornton wren at freegeek.org
Thu Nov 11 21:13:44 PST 2010


On 11/11/10 4:21 PM, Rick Richardson wrote:
> I prefer the first option. Even though I consider Haskell my second
> language, I still find the =>  hard to parse.

Much as I love Haskell, I agree: the first option is easier to read. 
Also, it has more of the feel of quantifiers (a la \forall, \exists,...) 
which is a boon IMO. In particular, this boon makes it syntactically 
possible to "share" constraints among multiple definitions. That is, we 
could provide the syntax:

     where foo...
         def bar...

         def baz...

which would be interpreted as a shorthand for:

     def foo... => bar...

     def foo... => baz...

When you have a bunch of related definitions, being able to share 
constraints like this can cut down a lot on boilerplate. It also 
suggests the (possibly dubious?) idea of having nested 'where' clauses 
for specifying constraints with differing scopes. Of course, both of 
these suggestions raise deeper questions about what the scope of the 
type variables really is, i.e. how quantification should be handled in 
the face of mutual recursion and the like... So that's probably better 
left to the future.

-- 
Live well,
~wren


More information about the bitc-dev mailing list