Even integer exponents
- Dominant language
- Haskell
- Stars
- 27
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
The boost interval library has a nice function `square :: Interval a -> Interval a` such that `square x` returns a tighter bound than `x * x` can (without observable sharing and a lot of crazy machinery) because it knows that the result must be positive.
Apparently they also have an exponentiation operator for integer exponents that does the same for all even exponents. This could be tough for us though, because (I think maybe to avoid introducing a rank-2 type?) the `Prelude` `(^)` function isn't part of the `Num` typeclass it just has a fixed implementation in the prelude that delegates to `(*)`. If the type was `(^) :: (Num a) => (forall b.(Integral b) => a -> b -> a)` (or something like that, I may have too many parentheses or too few) instead of `(^) :: (Num a, Integral b) => a -> b -> a` we would have a chance but as it stands I think the only option would be to offer this behavior under a new name.
(There is a TODO comment in the current version about this, presumably written because the type issue makes the fix a murky design area. I am promoting it to an issue because at least the `square` case is pretty useful for my work.)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the TODO mentioned in the issue and reading the existing `square` implementation and the Prelude `(^)` entry point. Determine the intended public API for tighter bounds on even integer exponents, including the naming and type constraints; done means the design is settled and the behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100