[Haskell-cafe] existential type problem

Andrew Pimlott andrew at pimlott.net
Thu Oct 21 16:15:09 EDT 2004


On Sat, Oct 16, 2004 at 05:54:46AM +0000, oleg at pobox.com wrote:
> > 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)

Is it true that I cannot have a function

    foo run op = Foo (Bar run op)

because it does not have an expressible type?  Or is there some way to
make ghc accept this?  Obviously, this expression can be used in the
context of a larger expression.

> > myFoo :: Int -> Foo
> > myFoo i = Foo (Bar run op) where
> >   run :: Monad m => StateT Int m a -> m a
> >   run prog  = do  (a, s) <- runStateT prog i
> > 		    return a
> >   op :: Monad m => StateT Int m Int
> >   op        = get

Andrew


More information about the Haskell-Cafe mailing list