Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
integer-simple
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
integer-simple
Commits
44dd6306
Commit
44dd6306
authored
13 years ago
by
Ian Lynagh
Browse files
Options
Downloads
Patches
Plain Diff
Don't define our own list type
We can now use [] as it has been moved to ghc-prim.
parent
1f3ef8a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GHC/Integer/Type.hs
+6
-9
6 additions, 9 deletions
GHC/Integer/Type.hs
with
6 additions
and
9 deletions
GHC/Integer/Type.hs
+
6
−
9
View file @
44dd6306
...
@@ -42,15 +42,12 @@ data Integer = Positive !Positive | Negative !Positive | Naught
...
@@ -42,15 +42,12 @@ data Integer = Positive !Positive | Negative !Positive | Naught
-- Positive's have the property that they contain at least one Bit,
-- Positive's have the property that they contain at least one Bit,
-- and their last Bit is One.
-- and their last Bit is One.
type
Positive
=
Digits
type
Positive
=
Digits
type
Positives
=
List
Positive
type
Positives
=
[
Positive
]
data
Digits
=
Some
!
Digit
!
Digits
data
Digits
=
Some
!
Digit
!
Digits
|
None
|
None
type
Digit
=
Word
#
type
Digit
=
Word
#
-- XXX Could move [] above us
data
List
a
=
Nil
|
Cons
a
(
List
a
)
mkInteger
::
Bool
-- non-negative?
mkInteger
::
Bool
-- non-negative?
->
[
Int
]
-- absolute value in 31 bit chunks, least significant first
->
[
Int
]
-- absolute value in 31 bit chunks, least significant first
-- ideally these would be Words rather than Ints, but
-- ideally these would be Words rather than Ints, but
...
@@ -743,9 +740,9 @@ quotRemPositive :: Positive -> Positive -> (# Integer, Integer #)
...
@@ -743,9 +740,9 @@ quotRemPositive :: Positive -> Positive -> (# Integer, Integer #)
subtractors
=
mkSubtractors
(
WORD_SIZE_IN_BITS
#
-#
1
#
)
subtractors
=
mkSubtractors
(
WORD_SIZE_IN_BITS
#
-#
1
#
)
mkSubtractors
(
!
n
)
=
if
n
==#
0
#
mkSubtractors
(
!
n
)
=
if
n
==#
0
#
then
Cons
ys
Nil
then
[
ys
]
else
Cons
(
ys
`
smallShiftLPositive
`
n
)
else
(
ys
`
smallShiftLPositive
`
n
)
(
mkSubtractors
(
n
-#
1
#
))
:
(
mkSubtractors
(
n
-#
1
#
))
-- The main function. Go the the end of xs, then walk
-- The main function. Go the the end of xs, then walk
-- back trying to divide the number we accumulate by ys.
-- back trying to divide the number we accumulate by ys.
...
@@ -761,8 +758,8 @@ quotRemPositive :: Positive -> Positive -> (# Integer, Integer #)
...
@@ -761,8 +758,8 @@ quotRemPositive :: Positive -> Positive -> (# Integer, Integer #)
(
#
some
d
ds
,
m''
#
)
(
#
some
d
ds
,
m''
#
)
g
::
Digit
->
Positives
->
Digits
->
(
#
Digit
,
Digits
#
)
g
::
Digit
->
Positives
->
Digits
->
(
#
Digit
,
Digits
#
)
g
(
!
d
)
Nil
(
!
m
)
=
(
#
d
,
m
#
)
g
(
!
d
)
[]
(
!
m
)
=
(
#
d
,
m
#
)
g
(
!
d
)
(
Cons
sub
subs
)
(
!
m
)
g
(
!
d
)
(
sub
:
subs
)
(
!
m
)
=
case
d
`
uncheckedShiftL
#
`
1
#
of
=
case
d
`
uncheckedShiftL
#
`
1
#
of
d'
->
d'
->
case
m
`
comparePositive
`
sub
of
case
m
`
comparePositive
`
sub
of
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment