[Racket] Ferti hydroponic nutrient solver, redux.
Add contracts related to nutrient-value.
Changed files
models/crop-requirement.rkt
@@ -6,20 +6,17 @@
6
6
crop-requirement-profile
7
7
crop-requirement-crop-id
8
8
(rename-out [crop-requirement-nutrient-values crop-requirement-values])
9
Removed:
(contract-out [create-crop-requirement!
10
Removed:
(->* (string? nutrient-value-hash/c) ((or/c #f crop?)) crop-requirement?)]
11
Removed:
[get-crop-requirements (-> (listof crop-requirement?))]
12
Removed:
[get-crop-requirement
13
Removed:
(->* ()
14
Removed:
(#:id (or/c #f exact-nonnegative-integer?) #:profile (or/c #f string?))
15
Removed:
(or/c crop-requirement? #f))]
16
Removed:
[get-crop-requirement-values
17
Removed:
(-> crop-requirement-or-id/c nutrient-value-hash/c)]
18
Removed:
[get-crop-requirement-value (-> crop-requirement-or-id/c nutrient? number?)]
19
Removed:
[delete-crop-requirement! (-> crop-requirement-or-id/c void?)]
20
Removed:
[average-crop-requirement-nutrient-values
21
Removed:
(-> (listof (cons/c crop-requirement? (and/c real? (>=/c 0) (<=/c 100))))
22
Removed:
nutrient-value-hash/c)]))
9
Added:
(contract-out
10
Added:
[create-crop-requirement! (->* (string? nutrient-value-hash/c) (crop?) crop-requirement?)]
11
Added:
[get-crop-requirements (-> (listof crop-requirement?))]
12
Added:
[get-crop-requirement
13
Added:
(->* () (#:id exact-nonnegative-integer? #:profile string?) (or/c crop-requirement? #f))]
14
Added:
[get-crop-requirement-values (-> crop-requirement-or-id/c nutrient-value-hash/c)]
15
Added:
[get-crop-requirement-value (-> crop-requirement-or-id/c nutrient? maybe-nutrient-value?)]
16
Added:
[delete-crop-requirement! (-> crop-requirement-or-id/c void?)]
17
Added:
[average-crop-requirement-nutrient-values
18
Added:
(-> (listof (cons/c crop-requirement? (and/c real? (>=/c 0) (<=/c 100))))
19
Added:
nutrient-value-hash/c)]))
23
20
24
21
(require racket/contract
25
22
db
models/fertilizer-product.rkt
@@ -14,7 +14,8 @@
14
14
(#:id (or/c #f exact-nonnegative-integer?) #:canonical-name (or/c #f string?))
15
15
(or/c fertilizer-product? #f))]
16
16
[get-fertilizer-product-values (-> fertilizer-product-or-id/c nutrient-value-hash/c)]
17
Removed:
[get-fertilizer-product-value (-> fertilizer-product-or-id/c nutrient? (or/c #f number?))]
17
Added:
[get-fertilizer-product-value
18
Added:
(-> fertilizer-product-or-id/c nutrient? maybe-nutrient-value?)]
18
19
[delete-fertilizer-product! (-> fertilizer-product-or-id/c void?)]))
19
20
20
21
(require racket/contract
models/nutrient-measurement.rkt
@@ -10,11 +10,12 @@
10
10
[get-nutrient-measurements (-> (listof nutrient-measurement?))]
11
11
[get-nutrient-measurement
12
12
(->* ()
13
Removed:
(#:id (or/c #f exact-nonnegative-integer?) #:measured-on (or/c #f string?))
13
Added:
(#:id exact-nonnegative-integer? #:measured-on string?)
14
14
(or/c nutrient-measurement? #f))]
15
15
[get-nutrient-measurement-values (-> nutrient-measurement-or-id/c nutrient-value-hash/c)]
16
Removed:
[get-nutrient-measurement-value (-> nutrient-measurement-or-id/c nutrient? (or/c real? #f))]
17
Removed:
[get-latest-nutrient-measurement-value (-> nutrient? (or/c real? #f))]
16
Added:
[get-nutrient-measurement-value
17
Added:
(-> nutrient-measurement-or-id/c nutrient? maybe-nutrient-value?)]
18
Added:
[get-latest-nutrient-measurement-value (-> nutrient? maybe-nutrient-value?)]
18
19
[get-latest-nutrient-measurement-hash (-> nutrient-value-hash/c)]
19
20
[delete-nutrient-measurement! (-> nutrient-measurement-or-id/c void?)]))
20
21
models/nutrient-target.rkt
@@ -13,8 +13,8 @@
13
13
(#:id (or/c #f exact-nonnegative-integer?) #:effective-on (or/c #f string?))
14
14
(or/c nutrient-target? #f))]
15
15
[get-nutrient-target-values (-> nutrient-target-or-id/c nutrient-value-hash/c)]
16
Removed:
[get-nutrient-target-value (-> nutrient-target-or-id/c nutrient? (or/c number? #f))]
17
Removed:
[get-latest-nutrient-target-value (-> nutrient? (or/c number? #f))]
16
Added:
[get-nutrient-target-value (-> nutrient-target-or-id/c nutrient? maybe-nutrient-value?)]
17
Added:
[get-latest-nutrient-target-value (-> nutrient? maybe-nutrient-value?)]
18
18
[get-latest-nutrient-target-hash (-> nutrient-value-hash/c)]
19
19
[delete-nutrient-target! (-> nutrient-target-or-id/c void?)]))
20
20
models/nutrient.rkt
@@ -6,6 +6,8 @@
6
6
nutrient-canonical-name
7
7
nutrient-french-name
8
8
nutrient-formula
9
Added:
nutrient-value?
10
Added:
maybe-nutrient-value?
9
11
nutrient-value-hash/c
10
12
(contract-out [create-nutrient! (-> string? string? string? nutrient?)]
11
13
[get-nutrients (-> (listof nutrient?))]
@@ -33,7 +35,9 @@
33
35
#:property prop:custom-write
34
36
(λ (v out _) (fprintf out "#<~a ~a>" (nutrient-id v) (nutrient-canonical-name v))))
35
37
36
Removed:
(define nutrient-value-hash/c (hash/c nutrient? (and/c real? (>=/c 0)) #:immutable #t))
38
Added:
(define nutrient-value? (and/c real? (>=/c 0)))
39
Added:
(define maybe-nutrient-value? (or/c nutrient-value? #f))
40
Added:
(define nutrient-value-hash/c (hash/c nutrient? nutrient-value? #:immutable #t))
37
41
38
42
;; vector/c id, canonical name, french name, nutrient formula, value (ppm)
39
43
(define residual-vector/c (vector/c exact-nonnegative-integer? string? string? string? real?))