Skip to content

List of Haskell Kata to Update

JohanWiltink edited this page Dec 11, 2020 · 200 revisions

The following kata are not compatible with the new GHC 8.8.4. Please help with updating.

  1. (A+B)+C=A+(B+C)? Prove it!
  2. Ch02 - effective plusNat
  3. Fill in the gaps in my timesheet.
  4. Grouped by commas
  5. Hughes' List
  6. I Liked the SQL Better...
  7. Interpolation Phalanx
  8. Metric Units - 1
  9. Product Groups
  10. Regular expression parser
  11. Simple Interactive Interpreter
  12. The most untyped typed language? - error Simplifier ticks exhausted ?!?
  13. What's a beet counter to do?
  14. What's a beet packer to do?
  15. Yet another Collatz kata

Background

Tests for Haskell GHC 7.10 and GHC 8.2 on Codewars are not compatible for historical reasons.

Tests for GHC 7.10 works by wrapping Hspec/HUnit and using patched hspec function to report the test results. This was very difficult to maintain, introduced unexpected behaviors, and confused users because Test.Hspec is not actually Hspec.

The new runner supports multiple language versions so we decided to clean this mess up when adding GHC 8.2 support and use Hspec as is.

Example

Test for GHC 7.10:

module ExampleTest where
import Test.Hspec
import Example
    
main :: IO ()
main = hspec $ do
  describe "Example" $ do
    it "add a b" $ do
      (add 1 1) `shouldBe` (2 :: Integer)

can be updated by making the following changes:

module ExampleSpec where -- test module name MUST end with Spec
import Test.Hspec
import Example

spec :: Spec -- `spec` is required
spec = do
  describe "Example" $ do
    it "add a b" $ do
      (add 1 1) `shouldBe` (2 :: Integer)

main :: IO () --- optionally keep `main`
main = hspec spec

More work might be necessary if it depends on GHC 7.10 environment somehow.

If a kata uses hidden from Codewars wrapper, it needs to be rewritten using solutionShouldHidesolutionShouldHideAll from Test.Hspec.Codewars. This needs to be imported explicitly in the test file.

Exceptional Cases

Haskell version should be removed because this kata is pointless in Haskell (limitation cannot be enforced by virtue).

List of Kata

The following kata doesn't have GHC 8.2 supported:

nil

List of Kata with quickCheck/quickCheckWith

nil

List of Kata with import System.Random

  1. Befunge Interpreter Required
  2. Spies! Expose the dirty double crossers
Clone this wiki locally