This would be extremely valuable for parsing e.g. a HTTP response into a response type for an API binding. fmap alone isn’t enough because you need to be able to turn a HTTP response into either a higher-level error from the remote service or the expected response type.
(I am specifically thinking of amazonka here, where the library has its own logging and retry logic baked in, and I’d love to be able to punt it in favour of just accepting a generic middleware for client retry logic.)
I have released all three libraries now with the Category , Arrow , and ArrowChoice instances for Service in tower-hs I think its awesome to make a simple construct as Service as useful as possible and i will see if i can find some nice use cases for it myself too in my own projects.
You implemented all the instances by hand. I would recommend always using deriving via if possible. In this case, your type is isomorphic to Kleisli (ExceptT ServiceError IO), and all the instances (including others that we haven’t talked about like Alternative) come from there. This way you (and readers of your code) can be sure all the instances are correct.
Cool. Thanks for that tip. I will look into it.
Im a seasoned developer but not in type theory or advanced haskell so this is perfect learning but i have been deep down in cats 2 and cats 3 in scala and know how useful a good Kleisli abstraction can be (and how painful it is in scala too..)
I released a new version of tower-hs with automatic derivation (patch bump, no need to release versions for the other libraries). I kept the tests though. Less code, less to maintain and worry about
this library looks awesome though, as a formerly avid Rustacean… i noticed the same gap when i was working on my website/server stuff recently, leading me to cave and just use Hakyll + Go for the other parts
to give an idea about how ridiculous useful this library is I am making a pure haskell terminal dungeon crawler, with AI features, that leans on http-tower-hs for llm call resilience. And as said before I am also a heavy user already on http-tower-hs in my sentinel project (posted further up), which is running all the time in production now. Hoping to see more usages of either of the libraries by someone else than myself