Halogen: What shoud the type passed to onValueChange be?

Hi,

If I create this function -

ponk onk = HH.input [ HE.onValueChange onk ]

The compiler tells me it would like me to provide a top-level declaration for ponk. The inferred type is -

forall t2 t3. (String -> Maybe t2) -> HTML t3 t2

Looks fair enough. So I stick this in as the top-level declaration -

ponk :: forall t2 t3. (String -> Maybe t2) -> H.HTML t3 t2
ponk onk = HH.input [ HE.onValueChange onk ] 

But now the compiler gives me this error -

Could not match kind
Type -> Type
with kind
Type

while checking the kind of (String -> Maybe t2) -> HTML t3 t2
in value declaration ponk

What gives? Any ideas what the type should be?

You’re using H.HTML: https://pursuit.purescript.org/packages/purescript-halogen/3.1.3/docs/Halogen#t:HTML

But you want HH.HTML: https://pursuit.purescript.org/packages/purescript-halogen/3.1.3/docs/Halogen.HTML.Core#t:HTML

Or, alternatively, change it to forall p q. (String -> Maybe (q Unit)) -> H.HTML p q … that’s slightly less general, but it will work for most of the times you need it.

2 Likes

Ah. Doh! Thanks. I didn’t realise there was an HTML in several packages…