clash-lang / ghc-typelits-extra

Extra type-level operations on GHC.TypeLits.Nat and a custom solver
Other
16 stars 9 forks source link

Add CLog with well-defined zero case #57

Open kleinreact opened 2 months ago

kleinreact commented 2 months ago

The PR adds the CLogWZ type family to the solver, which allows for a CLog definition with a well defined output for the case of the second non-base argument being zero. In this case the third argument is returned instead. The type family can be useful in cases, where the zero case needs to defined, as for example in the Index 0 case within clash-prelude (cf. clash-compiler PR #2784).

Reviewers Note

The currently used naming scheme might still be a bit adhoc, but I couldn't figure out any more elegant solution yet. One option might be to add total versions for all non-total type families of ghc-typelits-extra with extra parameters defining the return value in the undefined cases. In terms of naming we then just could add Total as a prefix / suffix to these versions, e.g., TotalDiv or DivTotal. In the particular case of CLog there are many undefined cases, however, which makes me unsure of how practical this approach would be.


TODOs