Skip to content

Fix warnings revealed by v0.14.1 PS release #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

New features:
- Export `HugeInt`'s `abs` and `neg` and `HugeNum`'s `subHugeNum`, both implemented by @Thimoteus (#25 by @JordanMartinez)

Bugfixes:

Other improvements:
- Fix warnings revealed by v0.14.1 PS release, including the removal of `fromKRep` function (#25 by @JordanMartinez)
- Install missing dependencies used in source code (#25 by @JordanMartinez)

## [v5.0.0](https://github.com/purescript-contrib/purescript-precise/releases/tag/v5.0.0) - 2021-02-26

Expand Down
10 changes: 7 additions & 3 deletions spago.dhall
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{ name = "precise"
, dependencies =
[ "arrays"
, "console"
[ "console"
, "effect"
, "exceptions"
, "foldable-traversable"
, "gen"
, "numbers"
, "integers"
, "lists"
, "maybe"
, "numbers"
, "partial"
, "prelude"
, "psci-support"
, "quickcheck"
, "quickcheck-laws"
, "strings"
, "tuples"
, "unfoldable"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
Expand Down
2 changes: 2 additions & 0 deletions src/Data/HugeInt.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Data.HugeInt
, toInt
, toHugeNum
, fromHugeNum
, abs
, neg
, round
, ceil
, floor
Expand Down
11 changes: 2 additions & 9 deletions src/Data/HugeNum.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Data.HugeNum
, ceil
, round
, googol
, subHugeNum
, pow, (^)
, truncate
) where
Expand Down Expand Up @@ -457,14 +458,6 @@ takeMeatyParts :: List Digit -> List Digit
takeMeatyParts arr =
L.reverse (L.dropWhile (_ == _zero) (L.reverse arr))

-- | Turn a `KRep` into a `HugeNum`.
fromKRep :: KRep -> HugeNum
fromKRep k = z where
bm = { sign: Plus, digits: _one : replicate (k.exp + 1) _zero, decimal: k.exp + 1 }
prod = k.coeff <> L.drop 1 bm.digits
leftSummand = HugeNum { digits: prod, sign: Plus, decimal: bm.decimal + L.length k.coeff - 1 }
z = plus leftSummand k.const

-- | Turn a `HugeNum` into a `KRep`, given an exponent m for B^m.
toKRep :: Int -> HugeNum -> KRep
toKRep exp h@(HugeNum r) = z where
Expand Down Expand Up @@ -583,7 +576,7 @@ adjustDecimalForTriviality h1 h2 (HugeNum r3) = dropZeroes (HugeNum r) where

-- | Raise a HugeNum to an integer power.
pow :: HugeNum -> Int -> HugeNum
pow r 0 = one
pow _ 0 = one
pow r 1 = r
pow r n =
let c = r * r
Expand Down