POSIXTime
и поэтому
start :: IO ()
start = scotty 3000 $
get "/" $ do
tm <- getPOSIXTime
json Time { unixtime = tm }
вот так не работает, с ошибкой
~/coding/hastest/src/Dirty/ 2
└╴ Start.hs 2
├╴E • Couldn't match type ‘IO’
│ with ‘Web.Scotty.Internal.Types.ActionT IO’
│ Expected: Web.Scotty.Internal.Types.ActionT IO POSIXTime
│ Actual: IO POSIXTime
│ • In a stmt of a 'do' block: tm <- getPOSIXTime
│ In the second argument of ‘($)’, namely
│ ‘do tm <- getPOSIXTime
│ json Time {unixtime = tm}’
│ In the second argument of ‘($)’, namely
│ ‘get "/"
│ $ do tm <- getPOSIXTime
│ json Time {unixtime = tm}’ typecheck (-Wdeferred-type-errors) [15, 15]
└╴E • Couldn't match type ‘time-1.12.2:Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime’
with ‘Int’
Expected: Int
Actual: POSIXTime
• In the ‘unixtime’ field of a record
In the first argument of ‘json’, namely ‘Time {unixtime = tm}’
In a stmt of a 'do' block: json Time {unixtime = tm} typecheck (-Wdeferred-type-errors) [16, 32]
сложно с монадами, можете помочь?
если что, тип Time определен и неправильно, но щас не это важно
tm <- liftIO getPOSIXTime
пробовал, └╴E Variable not in scope: liftIO :: IO POSIXTime -> Web.Scotty.Internal.Types.ActionT IO Int Suggested fix: Perhaps use ‘liftA2’ (imported from Prelude) typecheck (-Wdeferred-out-of-scope-variables) [15, 15]
> Variable not in scope:
Стикер
он же написал, что эта ошибка неважна
Обсуждают сегодня