Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reflex.Host.Headless #413

Merged
merged 4 commits into from
May 1, 2020
Merged

Add Reflex.Host.Headless #413

merged 4 commits into from
May 1, 2020

Conversation

meditans
Copy link
Member

This originally came from the reflex-ghci test suite, but it's more broadly useful.

@meditans meditans force-pushed the cn-upstream-headless-reflex-host branch from 3a6b598 to c96bffa Compare April 30, 2020 16:26
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
@meditans meditans force-pushed the cn-upstream-headless-reflex-host branch from c96bffa to b3f2b0f Compare April 30, 2020 17:09
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
@meditans meditans force-pushed the cn-upstream-headless-reflex-host branch from b3f2b0f to 7e75086 Compare April 30, 2020 17:20
@ali-abrar
Copy link
Member

@meditans can you look at the reflex-vty host and maybe grab some of the source documentation from there? this module will be easier to find than that one.

@ali-abrar
Copy link
Member

@meditans
Copy link
Member Author

Sure, let me do that @ali-abrar

@3noch 3noch requested a review from ali-abrar April 30, 2020 22:06
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
Copy link
Contributor

@endgame endgame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really exciting, and with a little bit of work could totally deprecate reflex-basic-host. I would love to have the ability to run multiple headless hosts be a part of mainline reflex.

Feel free to mine https://github.com/qfpl/reflex-basic-host/blob/f60ca05d5b7daec9513653cf6b805afe07bcac47/src/Reflex/Host/Basic.hs for other ideas.

-- allows us to take actions on the FRP timeline. The scoped type signature
-- specifies that our host runs on the Global timeline.
-- For more information, see 'Reflex.Spider.Internal.runSpiderHost'.
(runSpiderHost :: SpiderHost Global a -> IO a) $ do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflex-basic-host is able to run independent networks in different threads. Here's some example code showing two basic hosts triggering each other's events. Would it be possible to do that here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I believe the answer is "yes", but is there any reason we shouldn't? I can't think of any.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a great idea, but I still think it should be weighted and examined in another PR. @3noch what would be your suggestion on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a nice thing to have, but should not hold up this PR.

-- | Run a headless FRP network. Inside the action, you will most probably use
-- the capabilities provided by the 'TriggerEvent' and 'PerformEvent' type
-- classes to interface the FRP network with the outside world. Useful for
-- testing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that's obvious in hindsight but confused me when I was fixing reflex-basic-host: if none of your triggering events can fire, the whole thing jams up and falls over with a cryptic BlockedIndefinitelyOnMVar-style message. Worth documenting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also useful for servers, which is where I'm most excited to be playing with headless hosts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One major deficiency for servers: Spider is completely single-threaded. For anything expecting high traffic, this is likely to be a problem. However, there's no reason in principle that we couldn't have a multithreaded Reflex implementation.

src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Outdated Show resolved Hide resolved
src/Reflex/Host/Headless.hs Show resolved Hide resolved
@meditans meditans requested a review from 3noch May 1, 2020 15:51
@3noch 3noch requested a review from ryantrinkle May 1, 2020 16:02
@3noch 3noch merged commit 0638b49 into develop May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants