[Haskell-cafe] existential type problem

Andrew Pimlott andrew at pimlott.net
Sat Oct 16 19:18:56 EDT 2004


On Fri, Oct 15, 2004 at 07:54:46PM -0700, oleg at pobox.com wrote:
> 
> Andrew Pimlott wrote:
> > I want values in my existential type to denote, for some monad, a
> > monadic operation and a way to run the monad.  Except, I want it mix
> > the operation with operations in another monad, so it use a monad
> > transformer.
> 
> I'm afraid, that phrase was a little misleading. It seems that you
> meant:
> 	- encapsulate one _specific_ monad transformer
> 	- to be able to apply it to _any_ (not some!) monad

Yes.  I wrote that quickly (grammar mistakes too) and thought the code
would make it clear.  But it would have been better to make the words
precise.

> > data Bar a m = forall t. (MonadTrans t, Monad (t m)) =>
> > 	         Bar (t m a -> m a) (t m Int)
> >
> > data Foo = Foo (forall a m. Monad m => Bar a m)

Wow, very nice.  Just do it in two steps!  Thank you for this
enlightening solution.

Andrew


More information about the Haskell-Cafe mailing list