thomashoneyman / purescript-halogen-portal

Portals for Halogen: Render child components anywhere in the DOM
MIT License
26 stars 5 forks source link

New code from PortalM type class breaks project #11

Open flip111 opened 1 year ago

flip111 commented 1 year ago

@noisyscanner i follow the main branch of this project. When i pulled your new code this happened.

Error found:
in module Halogen.Portal
at .spago/halogen-portal/main/src/Halogen/Portal.purs:99:13 - 99:29 (line 99, column 13 - line 99, column 29)

  No type class instance was found for

    Control.Monad.Trans.Class.MonadTrans (StoreT act3 r4)

while applying a function lift
  of type MonadTrans t0 => Monad t1 => t1 t2 -> t0 t1 t2
  to argument toPortalAff
while inferring the type of lift toPortalAff

where act3 is a rigid type variable
        bound at (line 0, column 0 - line 0, column 0)
      r4 is a rigid type variable
        bound at (line 0, column 0 - line 0, column 0)
      t0 is an unknown type
      t1 is an unknown type
      t2 is an unknown type

See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
or to contribute content related to this error.

When i go back to the previous commit all is fine. Can you write a bugfix and a test for this?

noisyscanner commented 1 year ago

Hi @flip111. Can you provide a repo that recreates the issue please?

Edit: do you mean that this library itself fails to compile, or another project that you are using this library in?

flip111 commented 1 year ago

@noisyscanner The error occurs in the portal library as is visible from the error .spago/halogen-portal/main/src/Halogen/Portal.purs.

I did an investigation it seems that after the code change the requirements for other code changed too. Things have to implement MonadTrans now where this was not the case before. I'm not sure if your code change is possible without this new requirement. I don't know if the new requirement of having MonadTrans is either good or bad, nevertheless it would be nice to document the requirement.

I was using portal together with store, but i don't believe this is a store issue but rather something general about how monad transformers work.

I uploaded a reproduction here https://github.com/flip111/halogen-portal-bug covering 6 cases of which one was my case. I made a new fork from halogen store now (see linked repo above) which includes this line https://github.com/thomashoneyman/purescript-halogen-store/blob/main/src/Halogen/Store/Monad.purs#L88 which i think solved it.

I will leave the issue open in case you decide to investigate too or add some documentation.