
Am 08/09/2013 12:18 AM, schrieb Stephen Tetley:
Hi 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)
Thanks Stephen I have a related question to the one above: The "case .. of" is just required to bind the variables left of the "->", as there is only one alternative, right? I tried to rewrite this using "where" and was bitten badly, because inside the "where" uq would not be defined. I found a way to write (a simplified version of) this using "let .. in", but I had to put the entire "let .. in" after the "->" in the lambda and it ended up equally ugly. So my question is: is "case .. of" the the "where" of lambdas? Are there alternatives? I find this confusing because "case .. of" looks like a decision between alternatives, rather than a way to bind variables.