-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use DriveVoid typeclass instead of Default for underscored circuits #25
base: master
Are you sure you want to change the base?
Use DriveVoid typeclass instead of Default for underscored circuits #25
Conversation
src/Circuit.hs
Outdated
instance (Void a) => Void (Signal dom a) where | ||
driveVoid = pure driveVoid | ||
|
||
instance Void (DFM2S a) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? I can see in the code addDef
could be used for a Forward, But when does this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples do not only contain function like this:
fstC2 :: Circuit (Signal domain a, Signal domain b) (Signal domain a)
fstC2 = circuit $ \ab -> do
(a, _b) <- idC -< ab
idC -< a
But also functions like this:
unfstC3 :: Circuit (DF dom a) (DF dom a, DF dom b)
unfstC3 = circuit $ \a -> do
ab <- idC -< (a, _b)
ab' <- idC -< ab
idC -< ab'
So you can easily create an empty stream if you need it.
|
|
After thinking about this for a little bit: it seems to me that this abstraction isn't quite right. We'll end up with situations where multiple protocols use the same type (e.g., class DriveVoid a where
driveVoidFwd :: Fwd a
driveVoidBwd :: Bwd a However, this means type family Fwd a
type family Bwd a
-- vs
class Protocol a where
type Fwd (a :: Type)
type Bwd (a :: Type) and newtype Circuit a b = Circuit { runCircuit :: CircuitT a b }
type CircuitT a b = (Fwd a :-> Bwd b) -> (Bwd a :-> Fwd b)
-- vs
newtype Circuit a b = Circuit ((Fwd a, Bwd b) -> (Bwd a, Fwd b)) |
If we rewrite it to: class DriveVoid a where
driveVoidFwd :: Fwd a
driveVoidBwd :: Bwd a We might want to consider adding a possibility to stall the pipeline: class DriveVoid a where
driveVoidFwd :: Fwd a
driveVoidBwd :: Bwd a
driveVoidBwdNack :: Bwd a -- needs better name? Then we could drop the |
See clash-lang/clash-protocols#92. Feel free to suggest different different names for the typeclass/functions.