informatikr / hedis

A Redis client library for Haskell.
http://hackage.haskell.org/package/hedis
BSD 3-Clause "New" or "Revised" License
330 stars 125 forks source link

Redis constructor unavailable #144

Closed ekmett closed 4 years ago

ekmett commented 4 years ago

Due to the Redis data constructor not being available to outside users, there is no way to support things like Control.Exception.mask, the "ReaderT design pattern" or any of the unliftio-core tricks or dozens of other calls that could otherwise be compatible with the current API.

Please consider exporting this type, even if only in an .Internal module that is clearly labeled as containing dragons. Right now requirements along these lines drives me to either use a private fork, or pay unnecessary channel costs, just to talk back and forth with a dedicated Redis thread, that per force has to be less robust at handling exceptions due to this issue, and I'd like to be able to credit your work and release things publicly.

[Edit: no way is apparently hyperbolic here]

k-bx commented 4 years ago

@ekmett I wouldn't mind doing that, but I remember we've provided the unRedis symbol for a similar purpose. It's available and has an "internal warning" in its docstring. Would that be enough?

ekmett commented 4 years ago

Lack of access to the constructor still blocks GeneralizedNewtypeDeriving, but unRedis/reRedis do let me work with mask and the like. My immediate blocker is removed, but I'd still like to get access to the constructor somewhere so that GND can just write the instances for me. (It failing was what caused me to look in the first place.)

ekmett commented 4 years ago

I just noticed that the RedisEnv type that is mentioned in the type of unRedis/reRedis isn't exported. So long as the hack fits on a line or stays scoped to within a method this works, but I wish you'd expose that type at least somewhere .Internal as well.

Consider a scenario where I have two such libraries providing me a base type, with fairly prescriptive APIs like this, like, say, you and Haskeline. I can't really run in one fused monad because I can't name RedisEnv to hold onto it in my own monad type.

k-bx commented 4 years ago

@ekmett all right, thanks for the detailed info, released under 0.12.9. Please see the Database.Redis.Core.Internal module.

ekmett commented 4 years ago

Thanks so much!