Files
rose-ash/lib/haskell/tests/program-config.sx
giles f26f25f146
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
haskell: Phase 14 conformance — person.hs (7/7) + config.hs (10/10), Phase 14 complete
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 17:28:28 +00:00

64 lines
2.0 KiB
Plaintext

;; config.hs — multi-field config record; partial update; defaultConfig
;; constant.
;;
;; Exercises Phase 14: 4-field record, defaultConfig as a CAF, partial
;; updates that change one or two fields, accessors over derived configs.
(define
hk-config-source
"data Config = Config { host :: String, port :: Int, retries :: Int, debug :: Bool } deriving (Show)\n\ndefaultConfig = Config { host = \"localhost\", port = 8080, retries = 3, debug = False }\n\ndevConfig = defaultConfig { debug = True }\nremoteConfig = defaultConfig { host = \"api.example.com\", port = 443 }\n")
(hk-test
"config.hs — defaultConfig host"
(hk-deep-force (hk-run (str hk-config-source "main = host defaultConfig")))
"localhost")
(hk-test
"config.hs — defaultConfig port"
(hk-deep-force (hk-run (str hk-config-source "main = port defaultConfig")))
8080)
(hk-test
"config.hs — defaultConfig retries"
(hk-deep-force
(hk-run (str hk-config-source "main = retries defaultConfig")))
3)
(hk-test
"config.hs — devConfig flips debug"
(hk-deep-force (hk-run (str hk-config-source "main = debug devConfig")))
(list "True"))
(hk-test
"config.hs — devConfig preserves host"
(hk-deep-force (hk-run (str hk-config-source "main = host devConfig")))
"localhost")
(hk-test
"config.hs — devConfig preserves port"
(hk-deep-force (hk-run (str hk-config-source "main = port devConfig")))
8080)
(hk-test
"config.hs — remoteConfig new host"
(hk-deep-force (hk-run (str hk-config-source "main = host remoteConfig")))
"api.example.com")
(hk-test
"config.hs — remoteConfig new port"
(hk-deep-force (hk-run (str hk-config-source "main = port remoteConfig")))
443)
(hk-test
"config.hs — remoteConfig preserves retries"
(hk-deep-force
(hk-run (str hk-config-source "main = retries remoteConfig")))
3)
(hk-test
"config.hs — remoteConfig preserves debug"
(hk-deep-force (hk-run (str hk-config-source "main = debug remoteConfig")))
(list "False"))
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}