Code Monkey home page Code Monkey logo

Comments (9)

leonschoorl avatar leonschoorl commented on September 26, 2024 2

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.

leonschoorl avatar leonschoorl commented on September 26, 2024 1

Also I think we should probably add instances for Bool and Bit

from clash-compiler.

gergoerdi avatar gergoerdi commented on September 26, 2024

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.

martijnbastiaan avatar martijnbastiaan commented on September 26, 2024

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.

gergoerdi avatar gergoerdi commented on September 26, 2024

Are there any plans to implement this?

from clash-compiler.

martijnbastiaan avatar martijnbastiaan commented on September 26, 2024

Would simply exposing the internal functions be okay? In that case, it's easily done.

from clash-compiler.

martijnbastiaan avatar martijnbastiaan commented on September 26, 2024

@gergoerdi I'd be happy to move this forward; could you comment on my replies?

from clash-compiler.

gergoerdi avatar gergoerdi commented on September 26, 2024

I'm happy with the suggested ways of doing thidls, because the Maybe instance would give me what I need.

from clash-compiler.

martijnbastiaan avatar martijnbastiaan commented on September 26, 2024

See #2692

from clash-compiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.