We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 898f35a commit fcd1777Copy full SHA for fcd1777
CHANGELOG.md
@@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
7
Breaking changes:
8
9
New features:
10
+- `fromInt`
11
12
Bugfixes:
13
src/Data/Ring/Extra.purs
@@ -0,0 +1,12 @@
1
+module Data.Ring.Extra where
2
+
3
+import Data.Ord ((>=))
4
+import Data.Ring (class Ring, one, negate)
5
+import Data.Monoid (power)
6
+import Data.Monoid.Additive (Additive(..))
+fromInt :: forall a. Ring a => Int -> a
+fromInt x =
+ if x >= 0
+ then (\(Additive i) -> i) (power (Additive one) x)
+ else negate (fromInt (negate x))
0 commit comments