úÎ[ÜY¿     #Bas van Dijk <v.dijk.bas@gmail.com> Duplicate an ± in the parent region. This ± will usually be some type of regional handle. 3For 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:  3r1h :: RegionalHandle (RegionT cs (RegionT ps ppr))where cs is bound by the inner (child)  runRegionT and ps is bound by the outer (parent)  runRegionT. 6Suppose 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. HHowever, if you duplicate the regional handle you can safely return it.    r1hDup < - dup r1h  return r1hDup  Note that )r1hDup :: RegionalHandle (RegionT ps ppr) 4Back in the parent region you can safely operate on r1hDup. A region which has . as its parent region which enables it to be:  directly executed in  by , * concurrently executed in a new thread by . A handle to a . that allows you to duplicate the action to a  parent region using . An > computation that closes or finalizes a resource. For example  hClose or free. <A monad transformer in which scarce resources can be opened ;which are automatically closed when the region terminates. !Note that regions can be nested. pr) (for parent region) is a monad which is Pusually the region which is running this region. However when you are running a  the parent region will be .  Register the / in the region. When the region terminates all 2 registered close actions will be perfomed if they're not duplicated to a  parent region. *Execute a region inside its parent region pr. HAll resources which have been opened in the given region and which haven't been duplicated using 6, will be closed on exit from this function wether by /normal termination or by raising an exception. QAlso all resources which have been duplicated to this region from a child region  are closed on exit if they haven't been duplicated themselves. Note the type variable s7 of the region wich is only quantified over the region itself. This ensures that all" values, having a type containing s, can not >be returned from this function. (Note the similarity with the ST monad.) @Note that it is possible to run a region inside another region. "Convenience funtion for running a  top-level region in .  Note that: runTopRegion =  )Return a region which executes the given  top-level region in a new thread. 7Note that the forked region has the same type variable s as the resulting Lregion. This means that all values which can be referenced in the resulting 4region can also be referenced in the forked region. &For example the following is allowed:    $ do  regionalHndl <- open resource  threadId <-   $ doSomethingWith regionalHndl # doSomethingElseWith regionalHndl Note that the  regionalHndl/ and all other resources opened in the current Othread are closed only when the current thread or the forked thread terminates whichever comes last. Like   but internally uses . Like   but internally uses  . !LInternally used function that actually runs the region on the given list of  opened resources. "HInternally used function that atomically decrements the reference count  that is stored in the given IORef'. The function returns the decremented  reference count. #MInternally used function that atomically increments the reference count that  is stored in the given IORef. Lift a callCC operation to the new monad. +Transform the computation inside a region. Lift a  catchError operation to the new monad.   #Bas van Dijk <v.dijk.bas@gmail.com>#Bas van Dijk <v.dijk.bas@gmail.com>$%&The ParentOf class declares the parent/$child relationship between regions. 0A region is the parent of another region if they're either equivalent like:   RegionT ps pr `ParentOf` RegionT ps pr 8or if it is the parent of the parent of the child like:  RegionT ps ppr `ParentOf` RegionT cs + (RegionT pcs . (RegionT ppcs 5 (RegionT ps ppr))) #Bas van Dijk <v.dijk.bas@gmail.com>     #Bas van Dijk <v.dijk.bas@gmail.com> +A mutable variable storing a value of type ± which can only be used  in region r, r's children or r'%s parent when you duplicate it using  . '(Transform the region type r of the regional reference to r' s parent so % that it can be used in that region. HYield a regional computation that returns a new regional reference that stores the given value. LNote that the reference is parameterized by the same region in which it was Ocreated. This ensures you can never use this reference outside that region and Eit allows you to use this reference in a child region of that region 0Read the value of the given regional reference. 5Write a new value into the given regional reference. DMutate the contents of the given regional reference using the given  function. KAtomically modifies the contents of the given regional reference using the given function. JThis function is useful for using a regional reference in a safe way in a Kmultithreaded program. If you only have one regional reference, then using atomicModifyRegionRef7 to access and modify it will prevent race conditions. )       !"" #$%&$'()*+,-./0 regions-0.7Control.Monad.Trans.Region!Control.Monad.Trans.Region.OnExit#Control.Monad.Trans.Region.ParentOfData.RegionRef#Control.Monad.Trans.Region.InternalDupdup TopRegion CloseHandle CloseActionRegionTonExit runRegionT runTopRegionforkIOTopRegionforkOSTopRegionforkOnIOTopRegion liftCallCC mapRegionT liftCatchParentOf RegionRefpureDup newRegionRef readRegionRefwriteRegionRefmodifyRegionRefatomicModifyRegionRefghc-prim GHC.TypesIO forkTopRegionRefCntHandle unRegionTbaseControl.ConcurrentforkOSGHC.ConcforkOnIO runRegionWith decrement increment TypeCast2'' TypeCast2' TypeCast2 unRegionRef