
30 Jul
2004
30 Jul
'04
4:28 a.m.
On Thu, 29 Jul 2004, Tomasz Zielonka wrote:
On Thu, Jul 29, 2004 at 06:29:52PM +0200, Henning Thielemann wrote:
Say, you have some stop condition that you want to use in connection with unfoldr:
unfoldr (\n -> toMaybe (n<10) (n,n+1)) 0
How about using MonadPlus instance for Maybe? It seems a bit clearer to me.
unfoldr (\n -> guard (n<10) >> return (n,n+1)) 0
Ok, nice. Though then again I think about falling back to unfoldr (\n -> if n<10 then Just (n,n+1) else Nothing) 0 I just use toMaybe as common abbreviation. If no one needs it, forget it. :-)