[Haskell-cafe] implementing try for RWST ?
Chris Kuklewicz
haskell at list.mightyreason.com
Tue Apr 17 09:35:31 EDT 2007
Brandon S. Allbery KF8NH wrote:
>
> On Apr 17, 2007, at 0:03 , oleg at pobox.com wrote:
>> eventually run in the IO monad. One may wonder then why do we need
>> RWST transformer, given that the IO monad can implement both the state
>
> For what it's worth, I got the impression that RWST was an example of a
> complex monad transformer --- not necessarily something useful.
>
I actually used RWS (not RWST in this case). The analysis and transformation of
the regular expression parse tree in regex-tdfa is done by execRWS with monad type:
> type PM = RWS (Maybe GroupIndex) [Either Tag GroupInfo] ([OP]->[OP],Tag)
And to make it more complicated, some of the operations are via GHC's recursive
'mdo' syntax. The reader is tracking which capture group we are inside (if any)
and the writer collects two streams of included Tags and capture GroupInfo. The
state is a difference list of all the OP's and the next available Tag.
I use all of 'tell' 'listens' 'ask' 'local' 'get' 'put'
--
Chris
More information about the Haskell-Cafe
mailing list