purescriptpurescript-halogen

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


In my component:

data Query a = SetImageUrl Int String a

Main (app) component:

  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

Compiler says:

[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

I think slots and child paths are alright, because render function compiles and works correctly.

How to fix this error? I checked several times against guide, but I simply don't see any difference and the compiler message is super unhelpful (for me).


Solution

  • Solution from github:

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

    For queries not returning anything one should use H.action not H.request.