Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE InstanceSigs #-}
module WriteStateForYourself where
import Test.Hspec (describe, hspec, shouldBe, it)
import Test.QuickCheck.Classes (functor, applicative, monad)
import Test.Hspec.Checkers (testBatch)
import Test.QuickCheck (Arbitrary(..), CoArbitrary(..))
import Test.QuickCheck.Checkers (EqProp(..))
import Text.Show.Functions () -- For generating instances of show for functions

Some Recommended Kotlin Resources

Books

Kotlin Programming: The Big Nerd Ranch Guide
Josh Skeen, David Greenhalgh
First on the list for a reason.

This is the most well-rounded Kotlin book I have come across. It was written by teachers, has exercises at the end of chapters, recommendations for clean/idiomatic code, and doesn't lend on prior Java knowledge. Additionally it was released in 2018 so it includes more of the recent language features.
Safari

import kotlin.math.abs
data class Player(val name: String, var points: Int = 0)
class TennisGameKotlin(player1Name: String, player2Name: String) : TennisGame {
private val player1 = Player(player1Name)
private val player2 = Player(player2Name)
private val scores = listOf("Love", "Fifteen", "Thirty", "Forty")
override fun wonPoint(player: String) =
@jaymoid
jaymoid / diamond_kata_solution_kotlin.kt
Created July 26, 2018 20:39
Diamond Kata part 2 solution in Kotlin
package diamond
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import java.lang.System.lineSeparator
@DisplayName("Diamond Kata Tests")
class DiamondTest {
@jaymoid
jaymoid / diamond_kata.md
Last active July 30, 2018 20:00
Diamond Kata, Leeds Code Dojo

Leeds Code Dojo Strong Pair Programming, Diamond Kata

(Extended/Inspired from Seb Rose's Diamond kata at http://cyber-dojo.org/ )

1. Sparkly Diamonds (New to the code dojo / programming?)

Given a number, print a diamond made up of asterisks (*)

The number passed to your function indicates the number of rows of stars to print until it reaches the widest point of the diamond.

@jaymoid
jaymoid / ComparatorLawEnforcer.java
Created June 14, 2017 19:45
JavaComparatorLawEnforcer
import java.util.Comparator;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
/**