Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Support for KeyboardEvent, MouseEvent, ... #23

@sharkdp

Description

@sharkdp

Currently, we have

addEventListener :: forall eff. EventType
                 -> EventListener (dom :: DOM | eff)
                 -> Boolean
                 -> EventTarget
                 -> Eff (dom :: DOM | eff) Unit

where EventListener (dom :: DOM | eff) is basically a function Event -> Eff eff a (why not Eff eff Unit?).

In order to add support for KeyboardEvent, MouseEvent, .., we would need a way to add event listeners of the form KeyboardEvent -> _ instead of Event -> _. Otherwise, there would only be unsafe ways to convert Event to KeyboardEvent within the listener (?). That's certainly not a good design choice.

So how can this be fixed on the type level? Is it useful to annotate EventType with the type of the event? (sounds weird, but currently, EventType is just a string indicating the sort/kind/type of event). I would be happy to implement support for keyboard and mouse events, but I don't have the experience to choose the best way to proceed here...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions