@@ -3,12 +3,14 @@ module Data.Int.AtLeast
33 , fromInt
44 , fromInt'
55 , toInt
6+ , toNumber
67 , (%+%), plus
78 , (%-%), minus
89 , (%*%), times
910 , (%/%), quotient
1011 , modulo
1112 , remainder
13+ , divide
1214 , weaken
1315 , strengthen
1416 , gcd
@@ -24,6 +26,7 @@ import Data.Array (length) as Array
2426import Data.Array.NonEmpty (NonEmptyArray , cons' , length , singleton ) as NEA
2527import Data.Enum (class Enum )
2628import Data.EuclideanRing (gcd ) as Int
29+ import Data.Int (toNumber ) as Int
2730import Data.Maybe (Maybe (Nothing, Just))
2831import Data.Reflectable (class Reflectable , reflectType )
2932import Partial (crashWith )
@@ -84,6 +87,10 @@ fromInt' i =
8487toInt :: ∀ (min :: Int ). IntAL min -> Int
8588toInt (IntAL i) = i
8689
90+ -- | Convert an `IntAL` to a Number
91+ toNumber :: ∀ (min :: Int ). IntAL min -> Number
92+ toNumber (IntAL i) = Int .toNumber i
93+
8794-- | Add two IntAL values with possibly different type-level minimums
8895plus
8996 :: ∀ (min_i :: Int ) (min_j :: Int ) (min_sum :: Int )
@@ -130,7 +137,7 @@ quotient (IntAL i) (IntAL j) = IntAL $ div i j
130137infixl 7 quotient as %/%
131138
132139-- | Compute the remainder after division of one `IntAL` by another, returning
133- -- | an `IntAL 0`. Similar to `mod` by accepts and returns `IntAL`
140+ -- | an `IntAL 0`. Similar to `mod` by accepts and returns `IntAL 0 `
134141modulo :: ∀ (min_i :: Int ) (min_j :: Int ). IntAL min_i -> IntAL min_j -> IntAL 0
135142modulo (IntAL i) (IntAL j) = remainder i j
136143
@@ -139,6 +146,10 @@ modulo (IntAL i) (IntAL j) = remainder i j
139146remainder :: Int -> Int -> IntAL 0
140147remainder i j = IntAL (mod i j)
141148
149+ -- | Divide one `IntAL` by another, returning a Number
150+ divide :: ∀ (min_i :: Int ) (min_j :: Int ). IntAL min_i -> IntAL min_j -> Number
151+ divide i j = toNumber i / toNumber j
152+
142153-- | Decrease the type-level minimum value without changing the runtime value
143154weaken
144155 :: ∀ (min_from :: Int ) (min_to :: Int ) (min_from_plus_one :: Int )
0 commit comments