为什么不能使用多功能厅?

时间:2018-10-03 19:12:06

标签: haskell

我的代码:

getDateFromUser :: IO (Either UserError UTCTime)
getDateFromUser = do
  Prelude.putStrLn "Пожалуйста, укажите дату для прогноза в формате ГГГГ-ММ-ДД:"
  currentTime <- getCurrentTime
  date        <- Prelude.getLine
  let dayFromUser = parseTimeM True defaultTimeLocale "%Y-%-m-%-d" date :: Maybe UTCTime
  case dayFromUser of
    Nothing -> return $ Left InvalidDate
    Just validDay -> do
       let differenceInNominalDiffTime = diffUTCTime validDay currentTime
           differenceInDays            = floor $ differenceInNominalDiffTime / nominalDay
       if  differenceInNominalDiffTime >= 0 && differenceInNominalDiffTime <= 16
           then return $ Right validDay
           else return $ Left InvalidDate

在没有floor的情况下,将编译此代码。但是,但是有了floor我得到了这个错误

Defaulting the following constraint to type ‘Integer’
    Integral b0 arising from a use of ‘floor’
• In the expression:
    floor $ differenceInNominalDiffTime / nominalDay
  In an equation for ‘differenceInDays’:
      differenceInDays = floor $ differenceInNominalDiffTime / nominalDay
  In the expression:
    do let differenceInNominalDiffTime
             = diffUTCTime validDay currentTime
           differenceInDays = floor $ differenceInNominalDiffTime / nominalDay
       if differenceInNominalDiffTime >= 0
            && differenceInNominalDiffTime <= 16 then
           return $ Right validDay
       else
           return $ Left InvalidDate 

37 | differenceInDays = floor $ differenceInNominalDiffTime / nominalDay

此错误是什么以及如何解决?

0 个答案:

没有答案