
On Fri, 22 Jun 2007, Olivier Boudry wrote:
-- | create sections from tag type and attribute getSectionsByTypeAndAttr :: String -> (String, String) -> String -> IO [[Tag]] getSectionsByTypeAndAttr tagType attr url = do tags <- unsafeInterleaveIO $ liftM parseTags $ openURL $ url (return . filterByTypeAndAttr tagType attr) tags where filterByTypeAndAttr :: String -> (String, String) -> [Tag] -> [[Tag]] filterByTypeAndAttr t a = sections (~== TagOpen t [a])
I think if openURL is not lazy, then the unsafeInterleaveIO will not help much because it only defers the whole computation until the first part of the result is requested. One call to unsafeInterleaveIO cannot divide a big IO action into small pieces of lazily triggered actions. I think unsafeInterleaveIO is unnecessary here.