reactive-banana
reactive-banana copied to clipboard
Add role annotations to `Behavior` and `Event`
Currently these are inferred as nominal
, but I think the parameter should be representational. This would let us say
newtype CheckboxEvent = CheckboxEvent { toEvent :: Event Bool }
deriving (Monoid, Semigroup) via Event Any
which seems a perfectly reasonable thought.
Huh. Based on a cursory understanding of type roles, I would also say that its role should be representational
. However, I'm hesitant to change the role manually if the compile inferred nominal
for a good reason — why did that happen? 🤔
I think it happened because way down in what a Behavior
actually is is something with a GADT or something that forces us to be nominal. This means we'll probably need to employ a trick to get this to be representational (usually I do this with a Coyoneda-like existential mapping function). I'll give this a shot and open up a PR!