newsham | (a:) `fmap` iteratemM f (f a) ? |

LoganCapaldo | I'm not really sure what it should look like :) |

mdmkolbe | @ty let iterateM act val = do {x <- act val; xs <- iterateM act x; return (x:xs) } in iterateM |

lambdabot | forall t (t1 :: * -> *). (Monad t1) => (t -> t1 t) -> t -> t1 [t] |

LoganCapaldo | I guess somewhat like that :) |

encryptio | :t let iterateM f v = iterate (>>= . f) (return v) |

newsham | except the normal "iterate" also returns the arg as its first value |

lambdabot | parse error on input `.' |

encryptio | :t let iterateM f v = iterate (>>= f) (return v) in iterateM |

lambdabot | forall a (m :: * -> *). (Monad m) => (a -> m a) -> a -> [m a] |

encryptio | eh, close :t let iterateM f v = sequence $ iterate (>>= f) (return v) in iterateM |

LoganCapaldo | :t let iterateM f v = sequence $ iterate (>>= f) (return v) in iterateM |

lambdabot | Ambiguous occurrence `sequence' It could refer to either `sequence', imported from Control.Monad.Writer Ambiguous occurrence `sequence' It could refer to either `sequence', imported from Control.Monad.Writer |

LoganCapaldo | LOL |

encryptio | :t let iterateM f v = Prelude.sequence $ iterate (>>= f) (return v) in iterateM |

lambdabot | forall a (m :: * -> *). (Monad m) => (a -> m a) -> a -> m [a] |

newsham | let iterateM f v = Prelude.sequence $ iterate (>>= f) return v) in iterateM (\x -> return [succ x]) 'a' > let iterateM f v = Prelude.sequence $ iterate (>>= f) return v) in iterateM (\x -> return [succ x]) 'a' |

lambdabot | Parse error |

mdmkolbe | LoganCapaldo, newsham: I think that any iterateM that returns a m [a] would have problems with strictness because the modad would have to be completely evaluated before the first element could be removed |

encryptio | newsham: (return v) |

newsham | > let iterateM f v = Prelude.sequence $ iterate (>>= f) return v) in iterateM (\x -> [succ x]) 'a' |

lambdabot | Parse error |

mdmkolbe | s/returns a m [a]/reutrns a "m [a]'/ |

sorear | mdmkolbe: monads don't make things stricter |

newsham | > let iterateM f v = Prelude.sequence $ iterate (>>= f) (return v) in iterateM (\x -> [succ x]) 'a' |

lambdabot | Exception: stack overflow |

encryptio | aww. |

sorear | @ty let repeatM a = liftM2 (:) a (repeatM a) in repeatM |

lambdabot | forall (m :: * -> *) a1. (Monad m) => m a1 -> m [a1] |

mdmkolbe | sorear: not always, but often. Consider a state monad. Evaluating the resulting state means that the entire list would have to be generated (which in this case would be an infinite list) |

sorear | > let repeatM a = liftM2 (:) a (repeatM a) in flip evalState 0 $ repeatM (do { x <- get ; put (x+1) ; return x}) -- mdmkolbe |

lambdabot | [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,2... |

sorear | non strict monads are neat... |

action | mdmkolbe does a double take |

mdmkolbe | does a double take |

sorear | of course, this works precisely because I *don't* evaluate the resulting state. |