;; instance-where.sx — Phase 13: where-clauses inside instance bodies. (hk-test "instance method body with where-helper (Bool)" (hk-deep-force (hk-run "class Greet a where\n greet :: a -> String\ninstance Greet Bool where\n greet x = mkMsg x\n where mkMsg True = \"yes\"\n mkMsg False = \"no\"\nmain = greet True")) "yes") (hk-test "instance method body with where-helper (False branch)" (hk-deep-force (hk-run "class Greet a where\n greet :: a -> String\ninstance Greet Bool where\n greet x = mkMsg x\n where mkMsg True = \"yes\"\n mkMsg False = \"no\"\nmain = greet False")) "no") (hk-test "instance method body with where-binding referenced multiple times" (hk-deep-force (hk-run "class Twice a where\n twice :: a -> Int\ninstance Twice Int where\n twice x = h + h\n where h = x + 1\nmain = twice 5")) 12) (hk-test "instance method body with multi-binding where" (hk-deep-force (hk-run "class Calc a where\n calc :: a -> Int\ninstance Calc Int where\n calc x = a + b\n where a = x * 2\n b = x + 1\nmain = calc 3")) 10) {:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}