module SessionDB where import IO import System import IOExts import Array import Foreign import CForeign import SMA import Session readSessionDB :: String -> IO [Session] readSessionDB file = do loc <- locateStock file case loc of Nothing -> do return [] Just fname -> do h <- openFileEx fname (BinaryMode ReadMode) putStrLn ("reading " ++ (show fname)) list <- readSessionList h return list readSessionList :: Handle -> IO [Session] readSessionList h = do session <- readSession h case session of Nothing -> return [] Just s -> do rest <- readSessionList h return (s:rest)