[Haskell-cafe] sharing

Tom Schouten tom at zwizwa.be
Thu Feb 6 01:15:58 UTC 2020

On 2/5/20 1:18 PM, Emil Axelsson wrote:
> Den 2020-02-05 kl. 17:40, skrev Tom Schouten:
>> I think there is probably a use for a generic library that can do 
>> this kind of sharing recovery. Still I'm not quite happy with the 
>> "can be unsafe in some cases" remarks and would like to learn more. 
>> However there might be a tradeoff to use this as a simplified 
>> interface to something that is implemented in a safe monadic style 
>> under the hood.
> Here's the generic library that Kansas Lava uses for sharing recovery:
> https://hackage.haskell.org/package/data-reify
> The original Observable Sharing paper explains in more detail the 
> properties of observable sharing:
> https://www.researchgate.net/profile/David_Sands3/publication/225679607_Observable_Sharing_for_Functional_Circuit_Description/links/0a85e530b7beb39a9c000000.pdf 
> Basically, the worst thing that can happen is that you get less 
> sharing (and maybe in some cases even more) than you expect because of 
> whether or not GHC decides to inline something. Also, beware that 
> overloaded definitions may not be shared due to the extra dictionary 
> argument.
> In practice, I've had very few surprises with observable sharing. But 
> of course, the risk of unexpected duplication is not ideal when we're 
> talking hardware :-)
> / Emil

That unpredictable nature doesn't sit well with me :)


More information about the Haskell-Cafe mailing list