Philipp :emacs: :nixos: on Nostr: In #haskell, is there a version of "bracket" that works on lists? Say I give it a ...
In #haskell, is there a version of "bracket" that works on lists? Say I give it a list [a] and "acquire :: a -> IO b" as well as "release :: a -> IO c" and it'll try to acquire "IO [b]" and if one of the acquires fails, rolls back the already acquired resources?
I could fiddle around with resourcet, but is that the only option? For now, my custom-made function for this makes me uneasy. 🥲
Published at
2024-11-06 14:04:01Event JSON
{
"id": "11efed080c17cd2a75a2b105d486ff6f1e1e198a5f91c86d9fef5dc7f46a4622",
"pubkey": "ac4affaf50335b62981fe0ffff6059e4fb619f4934d6f40082175acb87737e5f",
"created_at": 1730901841,
"kind": 1,
"tags": [
[
"t",
"haskell"
],
[
"proxy",
"https://fosstodon.org/users/pmidden/statuses/113436383064549951",
"activitypub"
]
],
"content": "In #haskell, is there a version of \"bracket\" that works on lists? Say I give it a list [a] and \"acquire :: a -\u003e IO b\" as well as \"release :: a -\u003e IO c\" and it'll try to acquire \"IO [b]\" and if one of the acquires fails, rolls back the already acquired resources?\n\nI could fiddle around with resourcet, but is that the only option? For now, my custom-made function for this makes me uneasy. 🥲",
"sig": "9b528548e7a6241542abe666b44ce90e8fc21956e651112a3bef740e26eb0fc9f8571c92aea591ee70049dd07eadd5381e78ee0315cfc2e238e4df5d32751211"
}