reactive-banana icon indicating copy to clipboard operation
reactive-banana copied to clipboard

Add role annotations to `Behavior` and `Event`

Open ocharles opened this issue 2 years ago • 2 comments

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.

ocharles avatar Sep 13 '21 09:09 ocharles

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? 🤔

HeinrichApfelmus avatar Sep 14 '21 19:09 HeinrichApfelmus

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!

ocharles avatar Sep 14 '21 19:09 ocharles