Basically, quantified types can't be given as arguments to type
constructors (other than -, which is its own thing). I'm not entirely
sure
why, but it apparently makes the type system very complicated from a
theoretical standpoint. By wrapping the quantified type in a newtype, the
argument
David Menendez wrote:
On Thu, Nov 29, 2012 at 7:50 AM, Dmitry Kulagin dmitry.kula...@gmail.comwrote:
Thank you, MigMit!
If I replace your type FoldSTVoid with:
data FoldMVoid = FoldMVoid {runFold :: Monad m = (Int - m ()) - m ()}
then everything works magically with any monad!
That is
On Thu, Nov 29, 2012 at 7:50 AM, Dmitry Kulagin dmitry.kula...@gmail.comwrote:
Thank you, MigMit!
If I replace your type FoldSTVoid with:
data FoldMVoid = FoldMVoid {runFold :: Monad m = (Int - m ()) - m ()}
then everything works magically with any monad!
That is exactly what I wanted,
Thank you, MigMit!
If I replace your type FoldSTVoid with:
data FoldMVoid = FoldMVoid {runFold :: Monad m = (Int - m ()) - m ()}
then everything works magically with any monad!
That is exactly what I wanted, though I still do not quite understand why
wrapping the type solves the problem
Dmitry
Hi Cafe,
I try to implement some sort of monadic fold, where traversing is
polymorphic over monad type.
The problem is that the code below does not compile. It works with any
monad except for ST.
I suspect that monomorphism is at work here, but it is unclear for me how
to change the code to make
Yes, monomorphism. do binding requires your fold'' to be of some monomorphic
type, but runST requires some polymorphism.
If you want, you can use special type like that:
data FoldSTVoid = FoldSTVoid {runFold :: forall a. (Int - ST a ()) - ST a ()}
fold :: Monad m = (Int - m ()) - m ()
fold f =