I'm trying to define an event listener that can trigger its own removal.

The usual way is to define the listener, then use the reference when calling addEventListener. And using the same reference when calling removeEventListener. As Purescript is a strict language, it seems I can't do that because I can't refer to the listener I'm defining.

import Web.Event.EventTarget do listener <- eventListever (\event -> do somethingUsefulWith event _ <- removeEventListener evType listener' false target pure unit ) addEventListener evType listener false target

I expect listener' to be listener but, as it is impossible, I don't know if there is a simple solution.