-
Notifications
You must be signed in to change notification settings - Fork 6
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
Inference helper class #23
Comments
I'm glad that |
I was able to make it a superclass and it Just Worked! Very cool - I've never used superclasses for type-level computations like that. Thank for the code review 🤠 |
Closing for now - if you have any further suggestions/questions let me know! |
This is what the |
I just wanted to share some code I'm using to help with type inference for higher-kinded effects.
cleff-plugin
wasn't an option for me because I am x-compiling. See this GHC ticket.The effects I was using were unique for my effect stack anyways, so I was able to use a helper type class with a fundep to get GHC to figure out the type parameter that the plugin would normally help with. I added a little more stuff to guarantee the effect is only used once (just like mtl fundeps ensure in that world).
Here's the code! https://gist.github.com/ramirez7/fab0ba053f27b73c2a50bafa69c26be4
^
theAsk
will never run into inference issues even if the function you pass to it is highly parametric (e.g. optics and labels and such. LiketheAsks $ view #player % #speed
). The only downside is you can't have multipleReader
s.PS I love the library and it's working great for me so far! I'm using it for gamedev and it's really cleaned up my code compared to
mtl
style. And my small stuff is still humming at 60fps with plenty of headroom.PPS I also have an alternative that uses implicit
Proxy
params in a similar way to nudge inference. That was mostly for fun, but it was cool nonetheless.The text was updated successfully, but these errors were encountered: