> Date: Sat, 4 Jul 1998 17:27:10 +0200 (MET DST)
> From: Koen Claessen <[EMAIL PROTECTED]>

> Francois-Nicola Demers wrote:
> 
>  | I have noticed that most monads <M, return, then> are constructed by
>  | abstraction on the feature they manage. 
>  | [...]
>  | Does anyone know monads that could not been express as an
>  | abstraction?
> 
> I think you can "encode", or "mimick" every monad by the following type,
> which is the monad of continuations:
> 
>   type M a = (a -> Action) -> Action
> 
>   unit :: a -> M a
>   unit a = \cont -> cont a
> 
>   bind :: M a -> (a -> M b) -> M b
>   m `bind` k = \cont -> m (\a -> k a cont)
> 
> As you see, the type Action is not mentioned in these definitions, so we
> can choose any structure on Action we want, to encode the "features" of
> the monad.
> 

Quite interesting.  I will study more carefully your proposition.
However, it reminds me that Andrzej Filinski from CMU (Pittsburgh) has
graduated in 1996 and in his thesis, he has studied in formal terms the
meaning of "simulating" one effect by another (or one monad by another)
and he has showed that any monadic effect can be simulated by a
continuation monad and a piece of global state (that surely can be
implemented by the state monad).  This means that in these terms, every
monad can be simulated by:

type M a = S -> (((a,S) -> O) -> O)

where the state type S represents a continuation.  This is simply the
application of the state monad transformer on the continuation monad.

Your proposition in contrary suggests the application of the
continuation monad transformer on a type you call Action.

What is the difference between Filinski's solution and your's?  I don't
know.

Whatever is the best application order of the continuation monad, it
seems that part of my original question gets an answer: any monad can
be simulated by a monad constructed by abstraction.  However, I am
also concerned on what type the abstraction is.  I would like the
abstraction made on a type that represents the "intentional meaning"
of the monad.  For instance, in the case of the continuation monad,
the abstraction is made on the continuation (what we could consider
are the "intentional meaning" of the monad).  In the case of the state
monad, the abstraction is on the state (this is ok too).  In the case
of the nondeterminism monad, I would like the abstraction also on the
"intentional meaning" of the monad: the nondeterminism itself!
However, I don't know what it could be other than a list (or a set).

In fact, I want to use the abstraction to isolate the feature of the
monad from the rest (that is simply the representation or the
"extentional meaning" of the monad).

Regards,

F-Nicola

Francois-Nicola Demers
[EMAIL PROTECTED]
[EMAIL PROTECTED]



Reply via email to