在重大代码重构之后,我陷入了以下错误:
• Couldn't match type ‘Endpoint.AuditLog.Routes
(AsServerT (AppM '[] ()))’
with
--
-- complete API type comes here
--
Expected type: ServerT Routes (AppM '[] ())
Actual type: Endpoint.AuditLog.Routes (AsServerT (AppM '[] ()))
• In the expression: (Endpoint.AuditLog.server appRunners)
In an equation for ‘prodServer’:
prodServer = (Endpoint.AuditLog.server appRunners)
我已经阅读并重新阅读了the documentation,但似乎找不到错误的出处。这段代码之前已经工作了,我将Endpoint.AuditLog.server :: Routes (AsServerT AppM)
更改为Endpoint.AuditLog.server :: AppRunners m n -> Routes (AsServerT n)
,并确认以下表达式的类型在整个重构过程中似乎是相似的。基本上Routes (AsServerT AppM)
已更改为Routes (AsServerT (AppM '[] ()))
ghci> :t (Endpoint.AuditLog.server AppM.appRunners)
(Endpoint.AuditLog.server AppM.appRunners) :: Routes (AsServerT (AppM '[] ()))
以下代码段在重构中也是结构上相同:
type Routes = (ToServant Endpoint.AuditLog.Routes AsApi)
prodServer :: ServerT Routes (AppM '[] ())
prodServer = (Endpoint.AuditLog.server AppM.appRunners)
我该如何调试此错误?由于涉及到很多类型家族,因此有什么方法可以查看以下类型级别的表达式简化为:
ServerT Routes (AppM '[] ())
Endpoint.AuditLog.Routes (AsServerT (AppM '[] ()))
答案 0 :(得分:1)
专有!没意思!没话说!
我错过了toServant
-
prodServer :: ServerT Routes (AppM '[] ())
prodServer = (toServant $ Endpoint.AuditLog.server AppM.appRunners)