In some cases, a pure amortized data structure may only be efficient when used in a single threaded fashion. This suggests a linear interface
-- Pairing heaps
data PQ a = ...
insert :: Ord a => a -> PQ a %1-> PQ a
merge :: Ord a => PQ a %1-> PQ a %1-> PQ a
extractMin :: Ord a => PQ a %1-> Maybe (Ur a, PQ a)
Would it be appropriate for something like PQ a to be an instance of Moveable? If so, move would be a no-op (move = Unsafe.coerce Ur), and the user would be fully responsible for making sure performance was okay in context. Or would it be better to only have a perflyRiskyMove in the module to make it clear that there's a performance risk?
The Dupable instance is much more obviously reasonable: it would fully reassociate the queue into a "safe" configuration that has no credit. Do we want to provide a module giving an example of a structure like this?
In some cases, a pure amortized data structure may only be efficient when used in a single threaded fashion. This suggests a linear interface
Would it be appropriate for something like
PQ ato be an instance ofMoveable? If so,movewould be a no-op (move = Unsafe.coerce Ur), and the user would be fully responsible for making sure performance was okay in context. Or would it be better to only have aperflyRiskyMovein the module to make it clear that there's a performance risk?The
Dupableinstance is much more obviously reasonable: it would fully reassociate the queue into a "safe" configuration that has no credit. Do we want to provide a module giving an example of a structure like this?