-
Notifications
You must be signed in to change notification settings - Fork 14
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
Provide low-level API to raylib without automatic freeing (WindowResources) #55
Comments
h-raylib exposes a native version of every function, just prepend it with |
Thank you for your answer. What I would really like to have (as a user programmer) is these functions without ...and have a single Sure, it could be doable just to copy-paste all such functions (there's around 100 of them) into my module and then remove But it's also not possible, because these fns depend on helpers from module Is there a better way? |
I'll have to think of a good solution for this. I might make a |
Great! It would be really great to stay away from pointers and It seems like an Things come to my mind such as |
Done in 5.5.0.0, reopen this issue if there are any problems |
It's enjoyable to have a
raylib
API in Haskell that takes care aboutForeign
stuff (pointers and marshaling), so one doesn't have to.However, at the moment
h-raylib
enforces a particular memory management approach that may be not good for certain cases or favorable by some programmers. It would be nice for a library user programmer have a choice whether to useraylib
withoutWindowResources
facility.Here is a great article on different levels of APIs Haskell (please, note that it's HTTP, you might need to instruct the browser to render it):
http://blog.haskell-exists.com/yuras/posts/a-begginers-guide-to-over-engineering.html
Note, how the API of the lowest level allows building higher level APIs on top of it, but not vice versa.
Please, note that
raylib
philosophy is about simplicity and not enforcing things, but rather leaving a door open to have them.Low-level API with Closeable
Here's an example of a low API that allows automatic resource freeing, but can be opted out if not wanted:
User programmers can decide how they want to write:
...or...
...or something else.
With this design, user programmers can opt-out from using
bracket/with
and use something likeresourcet
ormanaged
, if they want (but let's not focus on these approaches here).Another important thing: user programmers are not forced to pass
WindowsResources
to every API call -- especially if they favor other resource-handling techniques such aswith/close
.If a user programmer want, he can still implement
WindowResources
approach in their code on top of low-level API and track all the resources (e.g. this can be useful for runtime introspection). Also, he may go even further and push theWindowResources
to a Reader monad, so he doesn't have to carry it around -- that's up to the user programmer.The text was updated successfully, but these errors were encountered: