From d0156b57bf111881faafe66b1699faae5dd66893 Mon Sep 17 00:00:00 2001 From: Izaak Walton Date: Mon, 14 Oct 2024 12:32:17 -0700 Subject: [PATCH] Move math package to math directory --- coalton.asd | 3 ++- library/big-float/impl-default.lisp | 4 ++-- library/big-float/impl-sbcl.lisp | 4 ++-- library/big-float/package.lisp | 4 ++-- library/list.lisp | 6 +++--- library/math/package.lisp | 15 +++++++++++++++ library/prelude.lisp | 16 ---------------- library/seq.lisp | 2 +- library/slice.lisp | 3 +-- 9 files changed, 28 insertions(+), 29 deletions(-) create mode 100644 library/math/package.lisp diff --git a/coalton.asd b/coalton.asd index 1abbc956a..5c398008c 100644 --- a/coalton.asd +++ b/coalton.asd @@ -63,7 +63,8 @@ (:file "complex") (:file "elementary") (:file "dyadic") - (:file "dual"))) + (:file "dual") + (:file "package"))) (:file "randomaccess") (:file "cell") (:file "tuple") diff --git a/library/big-float/impl-default.lisp b/library/big-float/impl-default.lisp index f4b897c9f..ad4e822ec 100644 --- a/library/big-float/impl-default.lisp +++ b/library/big-float/impl-default.lisp @@ -352,7 +352,7 @@ ((BFNegInf) (error "Cannot rationalize -Inf")) ((BFNaN) (error "Cannot rationalize NaN")))) (define (best-approx x) - (coalton-library/math/real::rational-approx (get-precision) x))) + (real-approx (get-precision) x))) (define-instance (Quantizable Big-Float) (define (proper x) @@ -434,7 +434,7 @@ ((BFInf) 0) (_ BFNaN)))) -(coalton-library/math/complex::%define-standard-complex-instances Big-Float) +(complex::%define-standard-complex-instances Big-Float) (coalton-toplevel ;; SeriesSplit/SeriesResult could be extended to any ring (e.g. polynomials) diff --git a/library/big-float/impl-sbcl.lisp b/library/big-float/impl-sbcl.lisp index a4fb47431..8758a7552 100644 --- a/library/big-float/impl-sbcl.lisp +++ b/library/big-float/impl-sbcl.lisp @@ -244,7 +244,7 @@ (define-instance (Real Big-Float) (define (real-approx prec x) - (coalton-library/math/real::rational-approx prec x))) + (real-approx prec x))) (define-instance (Rational Big-Float) (define (to-fraction x) @@ -269,7 +269,7 @@ (/ (fromInt a) (fromInt b)) (into (exact/ a b)))))) -(coalton-library/math/complex::%define-standard-complex-instances Big-Float) +(complex::%define-standard-complex-instances Big-Float) (coalton-toplevel diff --git a/library/big-float/package.lisp b/library/big-float/package.lisp index fa721ff57..4e7fb8ed7 100644 --- a/library/big-float/package.lisp +++ b/library/big-float/package.lisp @@ -6,11 +6,11 @@ (:use #:coalton #:coalton-library/classes #:coalton-library/functions - #:coalton-library/math - #:coalton-library/math/integral) + #:coalton-library/math) (:import-from #:coalton-library/math/dyadic #:Dyadic) (:local-nicknames (#:dyadic #:coalton-library/math/dyadic) + (#:complex #:coalton-library/math/complex) (#:bits #:coalton-library/bits)) (:export #:RoundingMode diff --git a/library/list.lisp b/library/list.lisp index d472cfd66..cd5db47d0 100644 --- a/library/list.lisp +++ b/library/list.lisp @@ -10,7 +10,7 @@ (:local-nicknames (#:cell #:coalton-library/cell) (#:iter #:coalton-library/iterator) - (#:arith #:coalton-library/math/arith)) + (#:math #:coalton-library/math)) (:export #:head #:tail @@ -250,10 +250,10 @@ "Returns the nth-cdr of a list." (cond ((null? l) Nil) - ((arith:zero? n) + ((math:zero? n) l) (True - (nth-cdr (arith:1- n) (cdr l))))) + (nth-cdr (math:1- n) (cdr l))))) (declare elemIndex (Eq :a => :a -> List :a -> Optional UFix)) (define (elemIndex x xs) diff --git a/library/math/package.lisp b/library/math/package.lisp new file mode 100644 index 000000000..9c01ac948 --- /dev/null +++ b/library/math/package.lisp @@ -0,0 +1,15 @@ +(uiop:define-package #:coalton-library/math + (:use-reexport + #:coalton-library/math/arith + #:coalton-library/math/num + #:coalton-library/math/bounded + #:coalton-library/math/conversions + #:coalton-library/math/fraction + #:coalton-library/math/integral + #:coalton-library/math/real + #:coalton-library/math/complex + #:coalton-library/math/elementary + #:coalton-library/math/dual)) + +#+sb-package-locks +(sb-ext:lock-package "COALTON-LIBRARY/MATH") diff --git a/library/prelude.lisp b/library/prelude.lisp index 34edc2363..f7756e22c 100644 --- a/library/prelude.lisp +++ b/library/prelude.lisp @@ -2,22 +2,6 @@ ;;;; ;;;; Collections of packages -(uiop:define-package #:coalton-library/math - (:use-reexport - #:coalton-library/math/arith - #:coalton-library/math/num - #:coalton-library/math/bounded - #:coalton-library/math/conversions - #:coalton-library/math/fraction - #:coalton-library/math/integral - #:coalton-library/math/real - #:coalton-library/math/complex - #:coalton-library/math/elementary - #:coalton-library/math/dual)) - -#+sb-package-locks -(sb-ext:lock-package "COALTON-LIBRARY/MATH") - (uiop:define-package #:coalton-prelude (:use-reexport #:coalton-library/classes diff --git a/library/seq.lisp b/library/seq.lisp index 2bd81f621..e1fe7a19a 100644 --- a/library/seq.lisp +++ b/library/seq.lisp @@ -6,7 +6,7 @@ #:coalton-library/classes) (:local-nicknames (#:types #:coalton-library/types) - (#:math #:coalton-library/math/integral) + (#:math #:coalton-library/math) (#:optional #:coalton-library/optional) (#:cell #:coalton-library/cell) (#:vector #:coalton-library/vector) diff --git a/library/slice.lisp b/library/slice.lisp index c15c516ea..d9df32300 100644 --- a/library/slice.lisp +++ b/library/slice.lisp @@ -4,8 +4,7 @@ #:coalton-library/builtin #:coalton-library/functions #:coalton-library/classes - #:coalton-library/math/arith - #:coalton-library/math/integral) + #:coalton-library/math) (:local-nicknames (#:types #:coalton-library/types) (#:cell #:coalton-library/cell)