basvandijk / regions

Provides the region monad for safely opening and working with scarce resources
Other
30 stars 7 forks source link

`base` dependency is too restrictive #7

Open ocharles opened 9 years ago

basvandijk commented 9 years ago

I try to make a new release when I have some time.

ocharles commented 9 years ago

:+1:

Is master usable atm? I'm mostly looking to see if regions is a good fit for some work I'm doing.

basvandijk commented 9 years ago

Yes master should be usable.

However, I haven't updated all its reverse dependencies yet.

What are you thinking to use regions for, if I may ask?

ocharles commented 9 years ago

Ah, gotcha.

Over at @haskell-game we're trying to get a decent mid/high-level API written for the SDL2 graphics library. We're a good way there, but we need a good story around handling of scarce resources. Finalizers don't cut it, because even though something is no longer lexically in scope, it's still operationally in scope via OpenGL's massive state machine (or various other state machines). It seems that if we want automatic memory management, regions are going to be the way to go.

I prefer regions over resourcet, because there's considerably less scope to shoot yourself in the foot :)

basvandijk commented 9 years ago

Another more restrictive but simpler library might be Gabriel Gonzalez's managed library.

I'll try to make a release of regions sometime this week so you can more easily work with it.

ocharles commented 9 years ago

managed is nice, but it has the same problem most other naive regions-like libraries have - you can't interleave operations. The key benefit of lightweight monadic regions is the ability to duplicate something into another scope. But then, you already know this as you wrote the library :)