Duplicate an α in the parent region. This α will usually be a
(RegionalHandle resource) but it can be any value "derived" from this
regional handle.
For example, suppose you run the following region:
runRegionT $ do
Inside this region you run a nested child region like:
r1hDup <- runRegionT $ do
Now in this child region you open the resource r1:
r1h <- open r1
...yielding the regional handle r1h. Note that:
r1h :: RegionalHandle resource (RegionT cs (RegionT ps ppr)) where cs is bound by the inner (child) runRegionT and ps is
bound by the outer (parent) runRegionT.
Suppose you want to use the resulting regional handle r1h in the parent
region. You can't simply return r1h because then the type variable cs,
escapes the inner region.
However, if you duplicate the regional handle you can safely return it.
r1hDup <- dup r1h
return r1hDup
Note that r1hDup :: RegionalHandle resource (RegionT ps ppr)
Back in the parent region you can safely operate on r1hDup.
|