[Haskell-beginners] How to construct complex string
Kim-Ee Yeoh
ky3 at atamo.com
Fri Aug 9 23:11:17 CEST 2013
On Sat, Aug 10, 2013 at 12:41 AM, martin <martin.drautzburg at web.de> wrote:
> > instance Monad Dot where
> > return a = Dot $ \ uq -> ([],uq,a)
> > m >>= k = Dot $ \ uq -> case unDot m uq of
> > (g1,uq',r) -> case unDot (k r) uq' of
> > (g2,uq2,r2) -> (g1 ++ g2,uq2,r2)
>
> I tried to rewrite this using "where" and was bitten badly, because
> inside the "where" uq would not be defined.
>
You could write:
m >>= k = Dot f where
f uq = (g1 ++ g2, uq2, r2) where
(g1, uq', r) = unDot m uq
(g2, uq2, r2) = unDot (k r) uq'
Doubtless, there has to be a way of revealing the inner structure, which
looks like some state monad with icing on top.
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130810/28b646c9/attachment.htm>
More information about the Beginners
mailing list