I'm absolutely new to purescript and halogen. I'm trying to display an halogen component (myButton) when an html element exists, and do nothing otherwise.
displayButton :: Eff (HA.HalogenEffects ()) Unit
displayButton = HA.runHalogenAff do
containerElement <- HA.selectElement (QuerySelector "#halogen-button")
case containerElement of
Nothing -> ???
Just element -> runUI myButton unit element
I don't know what code to put in the Nothing clause so that my code type checks and do nothing in that case.
pure unit
is the "do nothing" you could put in. You can also use for_
to make this a little nicer:
for_ containerElement \element ->
runUI myButton unit element
Which, if you take currying into account is the same as:
for_ containerElement (runUI myButton unit)