Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix up dependent contract syntax #8
I'm not too happy with the syntax we have for dependent contracts right now.
Scope of $1 is not obvious and its a bit to magical. Would love to allow explicit naming:
But this conflicts with object contracts (and I don't think this can be disambiguated). Some other ideas that have been bouncing around:
The problem isn't just disambiguation. It's that the syntax I'd love (and see most often in papers) where we name the argument like
@paulmillr I think that syntax would be a bit confusing since in haskell that means to constrain by the typeclass right? Humm...maybe that'd work though. The multi arg would look like:
Or simpler since
I think my favorite syntax right now is
Your "typeclass as var" proposition seems to me as good as haskell example.
I don't think so: consider a function where we pass many similar arguments:
f :: (SomeLongClassName s, SomeLongClassName2 t) => (s, s, s, t) -> [t, s, t, s] -> t s s s # or f :: (SomeLongClassName as s, SomeLongClassName2 as t) => (s, s, s, t) -> [t, s, t, s] -> t s s s
What would this example look like without
That syntax wouldn't work for dependent types. The point is to name each parameter uniquely.
What you have might actually be useful as a kind of "contract variable" but we need something different for uniquely identifying each param. We could combine them:
But if we just want a way to alias long contract names there's already a way since contracts are just values:
Not sure if it's a good idea to introduce special syntax for this.
Why overcomplicate simple things? If return from 1st func is a param to the 2nd one, same the params of the 1st one should be. Like so:
f :: (Num) -> !(result, params) -> params > result
Using named params (
added a commit
Mar 13, 2012
Ha! Yeah you're right, that does simplify things a bit.
Realized we have a bit of an ambiguity though. A dependent contract:
f :: (Num) -> !(res, params) -> params > res
Not a dependent contract:
MyEven = (x) -> x % 2 is 0 f :: (!MyEven) -> !MyEven