ghc-dup-0.1: Explicitly prevent sharing

Portabilitynot at all
MaintainerJoachim Breitner <>
Safe HaskellNone



This module provides two new operations, dup and deepDup, that allow you to prevent the result of two evaluations of the same expression to be shared.



data Box a Source

The Box datatype allows you to control the time of evaluations of dup or deepDup, by pattern-matching on the result.


Box a 

dup :: a -> Box aSource

Dup copies a the parameter and returns it. The copy is shallow, i.e. referenced thunks are still shared between the parameter and its copy.

deepDup :: a -> Box aSource

This copies the parameter and changes all references therein so that when they are evaluated, they are copied again. This ensures that everything put on the heap by a function that wraps all is parameters in deepDup can be freed after the evaluation.