Comments (13)
this is released. thank you everyone
from semirings.
I've actually had the same thought, and wanted this several times.
I'll take a PR for this. If there isn't a PR by the time I take up a sudden obsessive interest for 20 minutes, I'll do this
from semirings.
A PR should consist of (in Data.Semiring or perhaps another module):
- Adding the
Field
typeclass - Adding all instances for that typeclass
- documenting the laws of the typeclass
- useful functions acting on types which are instances of the typeclass
from semirings.
This is secondary, and not necessary work to be done in semirings
, but I'd also like fieldLaws
to be added to quickcheck-classes and hedgehog-classes. (I will do this)
from semirings.
Perhaps the name should not be called invert
? I know it fits, but doesn't mesh well with the popular groups
package? If there's no better name then I'll yield on that. Note that I'm not worried about name-clashing with the Prelude. Perhaps call it recip
?
from semirings.
Some useful functions that can be defined in terms of recip:
a / b = a * recip b
fromRational r = fromInteger (numerator r) / fromInteger (denonimator r)
from semirings.
Also, not sure what other instances in base there are other than Float,Double,Ratio,Complex
.
My strategy thus far has been to supply instances for all types in base
that have relevant instances (here i think that would be Fractional
). Though, this recently got me into trouble with windows users (see #34)
from semirings.
Also, we should probably only allow instances we know to be "traditional". To that end, ratios of functions form a commutative ring (field), so i wonder if we should provide a type/instance for that?
An example of a non-traditional instance would be for a non-field where the density of units is high, e.g. certain residue classes. This high density of units allows the instance to still be useful.
from semirings.
This corresponds to division/reciprocal numbers, and can be implemented for e.g. rational numbers and reals.
We already have Fractional
for this. Are there any examples of Field
(in base
, containers
, etc.), which are not Num
? If there are none, I struggle to find a use case for a new type class.
from semirings.
Except for adding fieldLaws
to quickcheck-classes
and hedgehog-classes
(and possibly instances for ratios of functions and non-fields), this issue should be completed with the latest pull request #48.
from semirings.
Will this be released on Hackage anytime soon?
from semirings.
Yes, tomorrow
from semirings.
Thanks!
from semirings.
Related Issues (20)
- Add some useful predicates HOT 3
- Ring vs. Num HOT 5
- 0.4 release HOT 2
- Remove Ring instance for Natural HOT 2
- Implementation of (^) does not match documentation HOT 2
- semiring newtype over Bool HOT 6
- missing instances for GcdDomain/Euclidean HOT 5
- WrappedFractional's Ring instance requires Fractional, but its semiring instance only requires Num HOT 2
- Mention RebindableSyntax in haddocks HOT 2
- Implement extended gcd
- semirings 0.5.2 released HOT 1
- Euclidean: Minimal-magnitude quotients break modular arithmetic HOT 7
- Division is definable and useful already in Semirings HOT 15
- Replace CPP instance derivation code with TH/DerivingVia HOT 8
- semirings doesn't build with ghc-7.4.2 HOT 2
- Ord instance is backward? HOT 1
- Support window? HOT 9
- Document list instance HOT 2
- GHC 9.10 support - please bump containers dep to "< 0.8" HOT 3
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 semirings.