There seems to be something funny going on here - I thought all the following were equivalent, but only listList1 works with
liftM (take 2) listListn
Is there any way to write listList2 or 3 so that they are lazy (what I'm really trying to do is get the same kind of code to work on an IO Monad that contains an infinite list, but when that failed I wondered why it worked for a list monad containing an infinite list and then managed to get that not to work either...) Thanks, Andrew (code follows) listList1 :: [[Integer]] listList1 = [x] where x = 1:x listList2 :: [[Integer]] listList2 = do rest <- listList2 return (1:rest) listList3 :: [[Integer]] listList3 = listList3 >>= (\x -> return (1:x)) -- http://www.andrewcooke.free-online.co.uk/index.html
participants (1)
-
andrewļ¼ andrewcooke.free-online.co.uk