\begin{code}

import IO

findM f [] = return Nothing
findM f (x:xs) = do { b <- f x; if b then return (Just x) else findM f xs }

isLeft (Left _) = True
isLeft _ = False

main =
        findM (>>=return.isLeft) $
                map (try . uncurry (>>=)) $
                        zip (hGetCharS stdin) (hPutCharS stdout)
        where
                hGetCharS h = hGetChar h : hGetCharS h
                hPutCharS h = hPutChar h : hPutCharS h

\end{code}

Joining input list and output list by uncurried >>=
IO errors such as EOF are enclosed by try.
findM finds those EOF or IO errors.


_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to