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 Circuit1 #18

Open
martijnbastiaan opened this issue Dec 15, 2020 · 0 comments
Open

Add Circuit1 #18

martijnbastiaan opened this issue Dec 15, 2020 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@martijnbastiaan
Copy link
Member

martijnbastiaan commented Dec 15, 2020

The current implementation of Circuit is doing quite a lot of bundling and unbundling. For example, see:

route =
Circuit (B.second C.unbundle . C.unbundle . fmap go . C.bundle . B.second C.bundle)

This needs to happen in every component due to the definition of Fwd/Bwd. We, unfortunately, need to do that as Fwd/Bwd could result in Signals on any domain. If we would instead define:

newtype Circuit1 dom a b =
  Circuit1 ( (Fwd1 dom a, Bwd1 dom b) -> (Bwd1 dom a, Fwd1 dom b) )

class Protocol1 (dom :: Domain) a where
  type Fwd1 (dom :: Domain) (a :: Type) = (r :: Type) | r -> dom a
  type Bwd1 (dom :: Domain) (a :: Type) = (r :: Type) | r -> dom a

  fromCircuit1 ::
    Protocol1 dom b =>
    Circuit1 dom a b ->
    Circuit a b

  toCircuit1 ::
    Protocol1 dom b =>
    Circuit a b ->
    Circuit1 dom a b

..we wouldn't have to go through all the unbundling.

I expect almost all implementations could live under Circuit1 with their Circuitcounterparts simply doing fromCircuit1 foo. We should measure before we commit ot this of course.

Edit: This would need changing the plugin too.

@martijnbastiaan martijnbastiaan added the enhancement New feature or request label Dec 15, 2020
@martijnbastiaan martijnbastiaan added this to the 0.2 milestone Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant