
9 Aug
2013
9 Aug
'13
5:11 p.m.
On Sat, Aug 10, 2013 at 12:41 AM, martin
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