
Hi, all! When I compile my program below, ghc emits Type error. Since the return type of foo Func is IO String and first case statement has "return timedVal", I think that ghc expects the type of timedVal as String. However, the error message shows that ghc expects timedVal should have type IO b0. What am I missing? Any comments are appreciated. Thanks in advance! Chul-Woong -- import Data.Time.LocalTime (getZonedTime, zonedTimeToUTC) import System.Locale (defaultTimeLocale) import Data.Time.Format (formatTime) import Data.Time.Clock (UTCTime) currentUTCTime :: IO UTCTime currentUTCTime = do zTime <- getZonedTime return (zonedTimeToUTC zTime) fooFunc :: IO String fooFunc = do putStrLn "Hello, world" barFunc "xutc" where barFunc s = case s of "apple" -> return s ('x': val) -> return timedVal where timedVal = case val of "utc" -> do utcTime <- currentUTCTime formatTime defaultTimeLocale "%a" utcTime --- Prelude> :l test [1 of 1] Compiling Main ( test.hs, interpreted ) test.hs:21:57: Couldn't match expected type `IO b0' with actual type `String' In the return type of a call of `formatTime' In a stmt of a 'do' block: formatTime defaultTimeLocale "%a" utcTime In the expression: do { utcTime <- currentUTCTime; formatTime defaultTimeLocale "%a" utcTime }