Reference types
Ashley Yakeley
ashley@semantic.org
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
etc.
You might be interested in:
<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/jvm-bridge/sourc
e/Haskell/Ref.hs?rev=HEAD&content-type=text/plain>
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