This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use .base | |
use List Optional Some None drop map | |
List.head : [a] -> Optional a | |
List.head a = List.at 0 a | |
use List head | |
ability State s where | |
put : s -> {State s} () | |
get : {State s} s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use .base | |
use List Optional | |
List.head : [a] -> Optional a | |
List.head a = List.at 0 a | |
ability State s where | |
put : s -> {State s} () | |
get : {State s} s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use .base | |
use List Optional | |
List.head : [a] -> Optional a | |
List.head a = List.at 0 a | |
ability State s where | |
put : s -> {State s} () | |
get : {State s} s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FruitSalad = { | |
Apple: AppleVariety | |
Banana: BananaVariety | |
Cherries: CherryVariety | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Solution to https://adventofcode.com/2019/day/1 by @philip_schwarz | |
-- Based on following solution by @runarorama: | |
-- https://gist.github.com/runarorama/21e6876bd62812b9d61a312c75ec87a3 | |
use .base | |
use .base.test.internals.v1.Test forAll | |
use .base.Test | |
-- Part 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fizzbuzz :: [String] | |
fizzbuzz = | |
let fizzes = cycle ["", "", "fizz"] | |
buzzes = cycle ["", "", "", "", "buzz"] | |
pattern = zipWith (++) fizzes buzzes | |
in zipWith combine pattern [1..] where | |
combine word number = | |
if null word then show number else word |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.std.vector.vectorMonoid | |
import scalaz.syntax.foldable.ToFoldableOps | |
import scalaz.syntax.semigroup._ | |
import scalaz.std.list.listInstance | |
// Vector append and prepend functions | |
assert( Vector(1,2) :+ 3 == Vector(1,2,3) ) | |
assert( 1 +: Vector(2,3) == Vector(1,2,3) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.{Date, Calendar} | |
import util.{Try, Success, Failure} | |
type Amount = BigDecimal | |
def today = Calendar.getInstance.getTime | |
case class Balance(amount: Amount = 0) | |
sealed trait Account { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.{Await, Future} | |
import scala.concurrent.duration._ | |
import scala.io.StdIn.readLine | |
object Main { | |
trait Terminal[C[_]] { | |
def read: C[String] | |
def write(t: String): C[Unit] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._ | |
import Scalaz._ | |
import simulacrum._ | |
import stalactite._ | |
import scala.concurrent.Future | |
import scala.io.StdIn.readLine | |
object Main { | |
trait Terminal[C[_]] { |