正在获取 "An infinite type was inferred for an expression" 用于来自 Halogen 的查询/请求

Getting "An infinite type was inferred for an expression" for query'/request from Halogen

在我的组件中:

data Query a = SetImageUrl Int String a

主要(应用)组件:

  eval :: Query ~> H.ParentDSL State Query ChildQuery ChildSlot Void m
  eval = case _ of
    HandleItemChange groupId (LIS.ActiveChanged selected) next -> do
      let apReq = AP.SetImageUrl groupId (imageUrl selected)
      _ <- H.query' CP.cp2 AvatarPictureSlot (H.request apReq)
      pure next

编译器说:

[1/1 InfiniteType] src/App.purs:85:57

  85        _ <- H.query' CP.cp2 AvatarPictureSlot (H.request apReq)
                                                              ^^^^^

  An infinite type was inferred for an expression:

    t0 -> t0

  while trying to match type t0 -> t0
    with type t0
  while checking that expression apReq
    has type (t0 -> t0) -> t1 t0
  in value declaration app

  where t0 is an unknown type
        t1 is an unknown type

我认为插槽和子路径没问题,因为 render 函数可以正确编译和工作。

如何修复这个错误?我根据指南检查了好几次,但我根本看不出有什么不同,而且编译器消息非常无用(对我来说)。

来自github的解决方案:

  _ <- H.query' CP.cp2 AvatarPictureSlot (H.action apReq)

对于不返回任何内容的查询,应该使用 H.action 而不是 H.request