[Haskell-cafe] Re: Is StateT what I need?

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Mon Dec 17 15:40:28 EST 2007


Am Montag, 17. Dezember 2007 21:06 schrieb ChrisK:
> Andre Nathan wrote:
> > Hello (Newbie question ahead :
> >
> > I tried this for insertProc, but it obviously doesn't work... what would
> > be the correct way to do this?
> >
> >> insertProc :: Pid -> StateT PsMap IO PsInfo
> >> insertProc pid = do
> >>   proc <- procInfo pid -- XXX this is obviously wrong...
> >>   psMap <- get
> >>   put (Map.insert pid proc psMap)
> >>   return (proc)
>
> I see that using "lift" makes it compile (Control.Monad.Trans.lift):
>
> > insertProc pid = do
> >   proc <- lift (procInfo pid)

By the way, be careful with identifiers named “proc”.  There is a syntax 
extension (arrow notation) which introduces a new keyword “proc”.

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list