[Haskell] ANNOUNCE: How to make a type-safe alloca: a new construction of a restricted IO monad

Stefan O'Rear stefanor at cox.net
Tue Nov 28 01:02:00 EST 2006


Introducing RIO, an experimental library for extensible restricted IO in
Haskell.

Selling features:
 * Automatic permissions inference.  If you define a function:
   
   fun fd r = do { str <- hGetContents fd ; modifyRIORef r (+1) ; return str }

   RIO can infer the requirements as part of the type signature:

   fun :: (Elem (ReadHandle a) o, Elem (ReadRef b) o, Elem (WriteRef b) o,
          Num c) => RHandle a -> RIORef b c -> RIO o String

 * Recursive context aquisition.  If we have:
 
   foo ref1 = withContextRef $ \p ->
                  do ref2 <- newRIORef p (undefined :: Int)
	             -- do some stuff with ref1 and ref2
   
   it works.
 
 * Potential for region allocation.

   When you use withContextRef, any variables allocated cannot be type-
   correctly accessed after withContextRef returns.  Hence, they can be
   deallocated at that time.

   It is possible to write a function withNewRef that allocates a
   reference and does not grant the capability to allocate more in the
   same context; this could be implemented using *stack* allocation.

 * It is extremely extensible.  It is possible to implement a new set
   of restricted actions in a separate module with very little code.

See the file README.LONG for a detailed demonstration.

http://members.cox.net/stefanor/RIO-0.1.tar.gz



More information about the Haskell mailing list