Proposal: Dependent arguments and ForAll<...> type constructor. #9590
Replies: 3 comments 8 replies
-
Can you give some real use cases? Your example is very easily accomplished in C# today: Func<A, C> Combine<A, B, C>(Func<A, B> f, Func<B, C> g) => x => g(f(x)); |
Beta Was this translation helpful? Give feedback.
-
Yes indeed. The typical example is the Vector type: Usually in proof checkers, for example, you may have to provide a "proof" for example which is a function or term which has a particular type required. (Such as proving a function result is in the correct range). But for a practical language like C#, we could just use a I think dependent types is one of those things which is not easily understood at first glance why it's useful (so it'll be hard to convince anyone). You either like it or hate it. |
Beta Was this translation helpful? Give feedback.
-
I'm struggling to understand what is being requested. None of the snippets make any sense to me. C# doesn't have templates - it has generics - a very different feature. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Inspired by languages such as Agda and Lean. First we can write a function which takes two functions and combines them to demonstrate the syntax:
This can already be done using templates and writing
Func<A,B>
forA->B
. But now, what is the type of Combine? We should have:typeof(Combine) = ForAll<Type A, ForAll<Type B, ForAll<Type C, (A->B)∧(B->C)->(A->C) >>>
Now we can use this type as arguments of other functions and it will be properly type checked.
Why do we want to do this?
<A>
to refer to implicit arguments.ForAll<..>
syntax is used for when later types depend on former.P.S. Notice that the typeof(Combine) is actually the proposition of logic called "Hypothetical syllogism". The function is like a proof of the proposition. This is an interesting consequence.
We should also have numbers in types. Such as
typeOf(Vect) = Type->uint->Type
.Beta Was this translation helpful? Give feedback.
All reactions