ekmett / machines

Networks of composable stream transducers
Other
339 stars 46 forks source link

Generalizations to Tee #80

Closed alang9 closed 7 years ago

HuwCampbell commented 7 years ago

I think your version of tee is inside out.

Isn't the point that the tee's plan can use a different language on each side? So Tee (Stack a) (Is c) d can be used?

alang9 commented 7 years ago

Right, I'm not sure what you mean by "inside out".

HuwCampbell commented 7 years ago

You appear to be providing ways to construct a generalised tee from a simple one, (which one could also do with a plan) but not a way to use one.

alang9 commented 7 years ago

Ah yes, I think that's right. I think to be able to use the more generalized tee effectively requires solving #39. I posted a gist of a solution there, but it's not very elegant.

YoEight commented 7 years ago

So are you still interested in merging this PR ?

alang9 commented 7 years ago

No I don't think this is so interesting unless #39 can be solved, but I'd like to hear others' opinions.

EDIT: Sorry I haven't looked at this in a while and I got confused when I got back to it. I do still think it can be useful.

@HuwCampbell I think it's right that this PR exposes ways to construct a generalised tee, but not ways to use them. #81 demonstrates ways you could use them though.

YoEight commented 7 years ago

Any news on this front ?

alang9 commented 7 years ago

Sorry I've been incredibly busy and haven't had time to look at this. I'd love for @HuwCampbell to chime in

HuwCampbell commented 7 years ago

Time... it gets away.

Nonetheless, I would probably not go with merging this as it stands.

First it breaks backwards compatibility. But excluding that: TG may well be actually prove a good encoding, but the tee function seems inverted (as the requirement of an internal Refl in it shows, it shouldn't hold any preconceptions of its internals). If tees are to be composable, then their drivers need to be too.

Hypothetically, as I haven't really nutted this out, one might pass <~ and stack to a new tee function to drive a TG (Is a) (Stack b), which then makes a TG (Is a) (Is b). They may then cap it with two sources to make a new source. But the stack push and pop commands are expressed inside the plan for the TG, so one is able to express more.

A nested tee within a tee might then be possible by passing the tee driver to one side. So one could in effect source from 4 sources at once.

YoEight commented 7 years ago

I close this PR for now then. Thanks for your input

gelisam commented 1 year ago

Looks like this PR is trying to generalize T so that it can be nested in order to describe a machine with more than 2 inputs. Have you considered generalizing from T (a :: *) (b :: *) (i :: *) to Elem :: (as :: [*]) (i :: *), thus enumerating the inputs in a list instead of in a binary tree?

'cause I just wrote a Machine which uses that :)

https://gist.github.com/gelisam/a8bee217410b74f030c21f782de23d11