Comments (9)
We could also add an instance for Counter a => Maybe a
And then you can get your interface with:
countSuccChecked :: Counter a => a -> Maybe a
countSuccChecked = countSucc . Just
from clash-compiler.
Also I think we should probably add instances for Bool
and Bit
from clash-compiler.
I think the API I would prefer is one that consists of countMin
, and countSuccChecked :: (Counter a) => a -> Maybe a
. Then both countSucc
and countSuccOverflow
are trivially recoverable:
countSucc = fromMaybe countMin . countSuccChecked
countSuccOverflow = maybe (True, countMin) (False,) . countSuccChecked
from clash-compiler.
The nice thing about (Bool, a)
is that you don't need a branch to determine the overflowed number. While this is a bit of a micro-optimization, I do feel it's the right thing to do.
How about simply moving the internal functions public? I don't think we discovered any downsides to the private API so far, so as far as I'm concerned it's fine as it is.
from clash-compiler.
Are there any plans to implement this?
from clash-compiler.
Would simply exposing the internal functions be okay? In that case, it's easily done.
from clash-compiler.
@gergoerdi I'd be happy to move this forward; could you comment on my replies?
from clash-compiler.
I'm happy with the suggested ways of doing thidls, because the Maybe
instance would give me what I need.
from clash-compiler.
See #2692
from clash-compiler.
Related Issues (20)
- Potential name collision code
- Clash potentially unreliable on GHC 9.10 on 32-bit hosts
- Clash slow on Windows using GHC 9.8 HOT 3
- Add `maybeResize` (and friends)
- Evaluator.instantiate: Not a tylambda: Lambda ... HOT 1
- Re-export `SNat` from `base`
- CI: Need better way to run all tests
- Allow rich error messages in `clashCompileError` for simulation HOT 1
- `Counter` for `Vec`tors HOT 3
- Clash happily synthesizes literals larger then possible when asked to do so HOT 4
- `PatError` test not actually testing `patError`
- nameHint is unreliable due to foldr/build fusion HOT 4
- More stringy names in Clash.GHC.Evaluator.Primitive HOT 2
- `BiSignalDefault` breaks Haskell/HDL contract
- signalAutomaton gets shared, to disastrous results HOT 1
- Space leak in simulator
- Unmatchable constant as case subject
- `tuple3_0_sel0_std_logic_vector` is not declared
- Spine-lazy vector functions HOT 2
- Verilog and System Verilog code gen bug for `map head` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clash-compiler.