Reference types

Ashley Yakeley
Tue, 5 Feb 2002 11:43:13 -0800

At 2002-02-05 07:50, Simon Peyton-Jones wrote:

>	data Ref m a	-- References in monad m, values of type a

You might be interested in:


	data Ref m a = MkRef
		get :: m a,
		set :: a -> m (),
		modify :: (a -> a) -> m ()

JVM-Bridge uses Refs for fields in Java classes. The monads in question 
are of type "(IsJVMMonad m) => m".

As a general rule, if your class has a lot of members of the form "a -> 
b", where the a's are all the same, it's a clue to consider using a data 
type instead.

Ashley Yakeley, Seattle WA