;; 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}