deepseq icon indicating copy to clipboard operation
deepseq copied to clipboard

Instance for `TVar`

Open hvr opened this issue 9 years ago • 7 comments

This is a left-over issue from #6

As described in https://github.com/haskell/deepseq/issues/6#issuecomment-147619390 by @glguy defining an instance for TVar is complicated since we'd lose {-# LANGUAGE Safe #-} by import TVar which seems undesirable, given all other instances can be imported safely.

hvr avatar Apr 19 '16 15:04 hvr

should the instance live in stm package instead? No safety problem then?

phadej avatar Oct 11 '16 06:10 phadej

@phadej yeah, the only not-so-nice thing about that is that in stm it'd be an orphan

hvr avatar Nov 20 '16 18:11 hvr

One option would be to add a Trustworthy module to define the rnf function and import it into Control.DeepSeq. But that seems pretty silly! The right answer is surely to add a safe TVar re-export somewhere in base.

treeowl avatar Sep 23 '17 17:09 treeowl

The right answer is surely to add a safe TVar re-export somewhere in base.

That would be nice. But this needn't stop us from adding an NFData instance for TVar today, since there's a module Control.DeepSeq.BackDoor specifically for the purpose of safely re-exporting things from base that currently can't be imported safely. We'd likely have to perform some surgery on the CPP bounds to accommodate TVar, but it should be possible.

RyanGlScott avatar Sep 24 '17 14:09 RyanGlScott

Yeah, this ticket predates the backdoor module by 1 year... so I mostly forgot about this... if anyone wants to take a stab at a PR...? :-)

hvr avatar Sep 24 '17 17:09 hvr

Anyone?

spacekitteh avatar Mar 10 '24 00:03 spacekitteh

Pull requests are welcome.

mixphix avatar Mar 10 '24 02:03 mixphix