[Haskell-cafe] Problem with own written monad

Derek Elkins derek.a.elkins at gmail.com
Mon Jan 7 12:54:14 EST 2008


On Mon, 2008-01-07 at 18:15 +0300, Miguel Mitrofanov wrote:
> > 	data Stack a = Stack { run :: [a] -> (a, [a]) }
> 
> [...skipped...]
> 
> > But, I have simply no clue how to fix that. :-(
> > Can anybody give my a hint?
> 
> Yes. It's simply impossible. The Stack data type can't be turned into  
> a monad.

Indeed, the very first hint is that Stack isn't a functor because the
type variable a occurs both positively and negatively.



More information about the Haskell-Cafe mailing list