Hizmetkârda bir silme işlemi gerçekleştirmek ve bir hata veya() döndürmek istiyorum.Tip uyuşmazlığı, mutlaka liftIO kullanmalı mıyım?
del :: Int -> ExceptT ServantErr IO()
del myId = liftIO $ do
cn <- getConnection
a <- execute cn "delete from table1 where id = ?" [myId]
case a of
1 -> return()
_ -> throwE err503 --compile error
hatadır: İşte benim kod
Couldn't match expected type ‘IO()’
with actual type ‘ExceptT ServantErr m0 a0’
In the expression: throwE err503
In a case alternative: _ -> throwE err503
Ben eğer mümkünse her ifadenin öncesinde liftIO kullanmamayı tercih ediyorum
: O zamanlar bir hata döndürür nasıl
del myId = do
cn <- liftIO getConnection
a <- liftIO $ execute cn "delete from table1 where id = ?" [myId]
case a of
1 -> return()
_ -> throwE err503
?