In my custom Halogen/Purescript project I follow the pattern from the AJAX Example where I split my actions up into pure Input
s and effectful Request
s.
I want to change my event handler to use the preventDefault
behavior, but don't understand what consequences for the type of the UI function this entails.
I made the same changes to the AJAX Example by changing the event handler the following way:
Before:
H.button [ A.classes [B.btn, B.btnPrimary]
, A.disabled busy
, A.onclick (\_ -> pure (handler code))
] [ H.text "Compile" ]
After:
H.a [ A.classes [B.btn, B.btnPrimary]
, A.href "#compile"
, A.disabled busy
, A.onclick (\_ -> E.preventDefault $> pure (handler code))
] [ H.text "Compile" ]
(Full diff available here)
I end up with this type error:
Cannot unify type
Example.Ajax.Input
with type
Halogen.HTML.Events.Monad.Event Halogen.HalogenEffects<(http ::
Example.Ajax.HTTP | u32519)> Example.Ajax.Input
At this point, I'm a bit lost whether I would need to adjust the type signature of the UI function or I apply the preventDefault
modifier the wrong way.