#5714: Add 'state' to the MonadState class
----------------------------------+-----------------------------------------
    Reporter:  twanvl             |       Owner:  ekmett@…        
        Type:  task               |      Status:  patch           
    Priority:  normal             |   Milestone:  7.6.1           
   Component:  libraries (other)  |     Version:  7.2.1           
    Keywords:  mtl, monads-tf     |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple   |     Failure:  None/Unknown    
  Difficulty:  Unknown            |    Testcase:                  
   Blockedby:                     |    Blocking:                  
     Related:                     |  
----------------------------------+-----------------------------------------

Comment(by ekmett):

 Probably a good idea. A similar embedding can be defined for list, etc. if
 we want to carry this through to its logical conclusion.

 For reader, of course, the generalization of reader is 'asks', so the
 question is which is the better name to put in the class?

 One caveat with the above definition is that for the .Lazy versions

 {{{
 state :: (Monoid w, Monad m) => (s -> (a,s)) -> RWST r w s m a
 state f = RWST $ \_ s -> let (a,s') = f a  in  return (a, s', mempty)
 }}}

 isn't as lazy as it could be with an extra ~ in the let.

 These are a lot less ad hoc than they seem, since one can view them as the
 rank 1 version of a higher rank hoisting operation which lifts monad
 homomorphisms from n -> m into the monad transformer t n -> t m, where we
 fix n to Identity, and use the canonical homomorphism from Identity -> m
 given to us by return. The fully general version needs a rank 2 type
 though, so its out of the question.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5714#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to