4 ms·
> But pure functional programming in the Haskell sense doesn't really manage file handles for you, or database connections. That's what monads are for. Haskel
by marcosdumay 3y ago
> But pure functional programming in the Haskell sense doesn't really manage file handles for you, or database connections.
That's what monads are for.
Haskell doesn't require that you use automatic management. But it does absolutely have a solution.
- eru 3y agoHow are monads useful for managing file handles or database connections? You might want to look into 'indexed monads', they can perhaps help with that. But they aren't a type monads (it's the other way round, vanilla monads can be seen as a trivial kind of 'indexed monads', I guess).
- valenterry 3y agoThe encapsulate direct access to those resource and therefore allow a properly controlled lifecycle because usage is then local and cleanup in case of errors is automatic. The caller pretty much can't do anything wrong. No linear types or indexed monads needed actually.