-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add typing information for all builtins (revisit after #1016) #294
Comments
I'd be interested in attempting to do this, but am very much still a Haskell rookie. Where would be the best way to add this? My naive approach would be to just add a HashMap in |
Yes, my inclination would be to add a |
I think I will attempt to try this at the weekend then! Thank you for the pointers. |
Okay, so I've started trying to do this using primops.cc as a reference, along with the nix manual, but I had a few questions about how to contribute cleanly. I've had to use a qualified import as Next, I have extended Also appreciate any other early feedback and thanks in advance, I hope I am not blocking anything! edit: I now realise I am being foolish and can just check the implementations of each builtin as well. |
How about this for a way to avoid ambiguity: We create a set of function exports from the
Then we can just hide the Other than that, you're headed in the right direction! |
Okay, I like this a lot, will experiment and see what I can do! |
@johnchildren Hey, how's it going so far with this? |
A little mixed, I wasn't able to work on it as much as I would have liked the past few weeks, but picked it up again as I am currently at ZuriHac. I initially had some trouble groking the way heterogenous lists and attribute sets should be typed, but I think I understand what I was doing wrong now. The issue is that in order to define some of the types of the builtins I may need dependent types, which may be undesirable if unavoidable? Some examples of this are edit: I suppose this is because I need the equivalent of |
I am fixing the kinda related #277 and was actually thinking about adding some type information. Did you made progress on this? PS: I was also at ZuriHac, too bad we did not meet. |
Ah that's a shame, I considered asking in the #nix channel for help but was moving between a few different rooms and didn't commit as much time to this issue as I could have. I didn't manage to make much progress, but most builtins involve a list or set in some way so I can't see a way to type them easily. The small fruit of my efforts can be seen here. I've defined everything I am not sure about as Have been trying to read up on the way the HList package works as well as a few other concepts to see if I can find a solution, but it may take some time for me to really grok this, so would recommend that someone else pick this up if they can. I'll keep working on it anyway though. edit: The other issue is that though I could evaluate expressions they do have side effects so I don't really want to do that just to type check for dependent types? |
The other issue I encountered was typing functions that performed some kind of type inspection, for example A lot of these functions will work on any possible type just due to their implementation so should be reasonably "safe", but it's not something guaranteed by the type system. |
You should be able to type them with variables:
I haven't tried this manually before, but you can use the output from
Where |
Ah thanks, using |
|
That often points to some unexpected |
For example, builtins.add would have the type: TMany [typeInt ~> typeInt, typeInt ~> typeFloat, typeFloat ~> typeInt, typeFloat ~> typeFloat]
The text was updated successfully, but these errors were encountered: