facebook/Haxl

Don't rely on `Show` to be valid Haskell code

alexbiehl opened this issue · 4 comments

dumpCacheAsHaskell is a neat thing. Unfortunately this relies on the fact that Show emits valid code. Not always are the instances under control of the developer. Just recently I tried to dumpCacheAsHaskell with types from the time library which resulted in invalid Haskell code being generated.

Could we introduce a new type class, maybe with a default implementation for types that are showable?

There is a insertWithShow function in which you can pass custom functions to show the request and result in dumpCacheAsHaskell. Does this solve your problem?

-- | Inserts a request-result pair into the 'DataCache', with the given
-- functions used to show the request and result.
insertWithShow

Interesting! And I see there is also dataFetchWithShow. That would be the one I need, right?

Yes, exactly.

Thanks this helped!