New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluating Parameterized Types #8
Comments
I might have misunderstood the problem, but how about this solution? It has a single (The code could be simplified a bit using the |
This gave me a reason to finally try out type level naturals. The code got a lot simpler, and it works for any natural number Hope this helps. |
Thanks, that's a helpful example. However we aren't using
It appears from your In particular, I was thought that instead of using a list of pairs to represent the environment (which requires embedding the types into the |
I dug into |
Glad it worked out for you! FYI: The representation is a bit complicated. If one really wanted to pursue this track, it might be better to change the The price for this way of handling bound variables is that the interface is more complicated. For example, the type of
Note that there is currently no way of printing these expressions, since variables are represented as functions, but this should be fixable. Anyway, this was a fun exercise! |
Emil, we've spent the last week working with your solution, but we keep running into problems. For example, it doesn't allow us to use We would really encourage you to look into the type-list solution further (or some other direction than This issue is causing us such a headache that we are considering attempting to use or modify your type-lists code. Since my next step in development is probably trying to better-understand your type-list code, I would be happy to see if I can make it any cleaner and report back here. |
Before going on with the more strongly typed solution -- would it work to use the standard If so, it should be possible to change
|
We think that would suffice, if it means we could put any I just want to verify that this would remove the need for the There is one caveat to your solution: we would ideally like to use reflected types from Data.Reflection, which do not currently have a |
I've changed to using |
On the plus side, your code is now much cleaner (except for the deprecated GHC doesn't export Is the type list solution a possibility? |
Absolutely! (But we should make it a separate module beside the other ones.) What did you think about the solution given here? If it works for you, I think I can fix so that the terms can also be printed/analyzed. I have to think about how this approach plays with the |
I think that solution will work. It's not ideal, but it would be nice to have something until some point in the distance future when most (all?) types are Typeable. |
I've now incorporated the well-scoped terms into Syntactic; see the "Well-scoped terms" section in Functional.hs. I've also provided an example file which I hope will help you get going. I think this is the best we can do. There are many ways to encode well-typed and well-scoped terms[1], but as far as I can tell, they all result in ugly types (like that of [1]: The encoding I chose was with efficient evaluation in mind. |
Consider a type
where arithmetic is mod
q
. I'd like to be able to share a value of this type using something similar toshare
in NanoFeldspar from syntactic-2.0, and then evaluate that expression. My understanding is that this requires the use ofBindingT
, which requires the constraintTypeable t (Internal a)
for the instanceSyntactic (a -> b)
.Our
q
values will be reified, so I can't make instances for (e.g.)and even if I could, I don't wouldn't want to since there are an infinite number of moduli that could be used. Everything I've tried fails when I try to make a
TypeEq
instance (required forevalSem
). Is there an easy way to evaluate a syntax tree which shares a value with a reified type parameter?The text was updated successfully, but these errors were encountered: