ezyang / reflex-backpack

Reflex with Backpack
8 stars 0 forks source link

Get rid of parameter 't' #1

Open oliver-batchelor opened 7 years ago

oliver-batchelor commented 7 years ago

Probably I am missing some obvious details. But in my mind backpack would allow me to totally get rid of the whole 't' parameter, with plain data types, e.g.

Event :: Type -> Type Behavior :: Type -> Type

hold :: MonadHold m => a -> Event a -> m (Behavior a)

ezyang commented 7 years ago

Hello @Saulzar,

When I originally Backpack'ed reflex, I indeed remove the 't' parameter. But @ryantrinkle pointed out to me that the t parameter plays an important role for the Spider, because they support the rank-2 types that prevents people from mixing up different instances of Spider.

But maybe this is all moot and we should just use the global timeline in all cases. Anyway, it's a good idea for another "Backpack version" of Reflex.

ryantrinkle commented 7 years ago

Basically, the t parameter plays a dual role: selecting the implementation and distinguishing independent data flow graphs. The first role is not necessary with groundhog (unless you want to be able to be truly polymorphic in implementation). However, second still is. In particular, Spider is single-threaded, so if you want to have two Spider-based graphs executing in parallel, you need to ensure that they're unconnected. Currently, the only way to do this is to ensure that their t parameters are different. It functions much like the parameter to the ST monad.

oliver-batchelor commented 7 years ago

Yeah, I see - that makes a lot of sense. Still, I can imagine the tradeoff for simplicity vs safety might be worth it...

Unlike ST where it's highly likely you might use more than one instance, most client side apps would almost never have two Spider instances.

On Sun, Mar 19, 2017 at 1:29 AM, Ryan Trinkle notifications@github.com wrote:

Basically, the t parameter plays a dual role: selecting the implementation and distinguishing independent data flow graphs. The first role is not necessary with groundhog (unless you want to be able to be truly polymorphic in implementation). However, second still is. In particular, Spider is single-threaded, so if you want to have two Spider-based graphs executing in parallel, you need to ensure that they're unconnected. Currently, the only way to do this is to ensure that their t parameters are different. It functions much like the parameter to the ST monad.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ezyang/reflex-backpack/issues/1#issuecomment-287542603, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE45R0R78JXGqQWTRn6jx146syBT9gnks5rm84jgaJpZM4MhS9F .

ryantrinkle commented 7 years ago

@Saulzar You're quite right. To me, the ideal would be to have some way for people who don't know/care about the distinction to have it hidden, while keeping their code compatible with more "advanced" usage that the parameter allows. I'm not exactly sure how to achieve that, though!