-
Notifications
You must be signed in to change notification settings - Fork 8
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
Strongly separate clash-protocols-base
and clash-protocols
#118
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d45f5c8
Strongly separate `clash-protocols-base` and `clash-protocols`
lmbollen b745853
Rename `Protocols.Internal.Classes` to `Protocols.Internal.Types`
lmbollen ee8bff2
Move `IdleCircuit` to `clash-protocols` and move Template haskell cod…
lmbollen 4d65fb0
Move all plugin related modules to `Protocols.Plugin`
lmbollen dfc0b07
Haddock improvements
lmbollen 34d51cb
Fix error message
DigitalBrains1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# OPTIONS_HADDOCK hide #-} | ||
DigitalBrains1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
module Protocols.Plugin.TH where | ||
|
||
import Language.Haskell.TH | ||
|
||
appTs :: Q Type -> [Q Type] -> Q Type | ||
appTs = foldl appT | ||
|
||
-- | Generate @Protocol@ instances for n-tuples | ||
protocolTupleInstances :: Int -> Int -> Q [Dec] | ||
protocolTupleInstances n m = mapM protocolTupleInstance [n .. m] | ||
|
||
protocolTupleInstance :: Int -> Q Dec | ||
protocolTupleInstance n = | ||
instanceD | ||
(pure []) -- context | ||
(protocolConT `appT` tup) -- head | ||
[mkTyInst fwdConName, mkTyInst bwdConName] -- body | ||
where | ||
fwdConName = mkName "Fwd" | ||
bwdConName = mkName "Bwd" | ||
protocolConT = conT (mkName "Protocol") | ||
|
||
tyVars :: [TypeQ] | ||
tyVars = map (varT . mkName . ('a' :) . show) [1 .. n] | ||
|
||
tup = tupleT n `appTs` tyVars | ||
|
||
mkTyInst :: Name -> DecQ | ||
mkTyInst con = | ||
tySynInstD $ tySynEqn Nothing lhs rhs | ||
where | ||
lhs, rhs :: TypeQ | ||
lhs = conT con `appT` tup | ||
rhs = tupleT n `appTs` map (conT con `appT`) tyVars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...src/Protocols/Internal/TaggedBundle/TH.hs → ...e/src/Protocols/Plugin/TaggedBundle/TH.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s-base/src/Protocols/Internal/Units/TH.hs → ...ols-base/src/Protocols/Plugin/Units/TH.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is slightly misleading. People will encounter this documentation in
clash-protocols
. So they might set the-flarge-tuples
flag onclash-protocols
when really they should set it on bothclash-protocols-base
as well asclash-protocols
.However, I now see it's actually worse than that. The instances defined in
clash-protocols-base
are not documented at all in the Haddock forclash-protocols
. I think this is a real shortcoming. People will not easily be able to know that these instances exist at all.