Tagged implementation#14
Conversation
|
My ultimate motivation for this is to extend the The main problem is at the moment we rely on the |
|
Could you expand on this? I'm not familiar with the |
|
So the use case is around having better support for The The problem with the current implementation is relies on knowing the Doing the tagging fixes this problem because it can use the type of the user supplied function. In the example above So the type inference would just work. |
|
This is the example I added that shows what you can do now: |
95931b5 to
7864325
Compare
9c0c9e0 to
91a2149
Compare
91a2149 to
1d28041
Compare
| -- Names --------------------------------------------------------------- | ||
|
|
||
| fwdNames :: [String] | ||
| fwdNames = ["Fwd", "Signal"] |
There was a problem hiding this comment.
I'd expect writing Signal to enforce the type to be Signal. I'm fine with it how it is if that's too much hassle.
There was a problem hiding this comment.
Yeah it'd be pretty annoying because I would need an inference_helper to do it..
|
For what it's worth, this work is extremely useful for my use-case (which sounds very similar to @jonfowler's). I do, however, wish that more of the PR description had made it into the Haddocks. It would have been extremely hard to deduce the motivation for things like, e.g., |
Since #14 the error locations often pointed to the end of the circuit instead of the correct location. Locate each generated binding at its circuit expression so GHC blames the offending statement. The regression test is in a separate PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This is a work in progress rework of the type inference solution to use a "Tagged" implementation:
With circuits passing around these Tagged types which include the type of the
Bus. This has a major advantage for type inference because it can use the type of pre-defined circuits e.g.:Which means the type of input & output (
a) can be unified.Generated Code
This meas the generated code no longer needs the
inferenceHelperand can be just written withTaggedstuff:results in:
TaggedBundle
The main challenge is we need to bundle up typed elements. Consider for example:
We will be given
TagFwd (a,b)but we needTagFwd aandTagFwd b. We do this using aTagbundle class which seems to work nicely in practice.This only needs to support the types with special support in
Circuitnotation i.e. tuples, unit and vec