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. Breaking into words
  3. Ch02 - effective plusNat
  4. Daggerlang
  5. Fill in the gaps in my timesheet.
  6. Find the smallest solution
  7. foldMap all the things!
  8. Grouped by commas
  9. Hughes' List
  10. I Liked the SQL Better...
  11. Interpolation Phalanx
  12. Longest Path in a Grid
  13. Metric Units - 1
  14. Minimum Transactions
  15. Product Groups
  16. Regular expression parser
  17. Simple Interactive Interpreter
  18. The King lives! the Elvis operator
  19. The most untyped typed language?
  20. Two Sum
  21. What's a beet counter to do?
  22. What's a beet packer to do?
  23. 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