Skip to content

Instantly share code, notes, and snippets.

bkyrlach / Expressions.v
Last active June 18, 2022 02:17
Stuck on proofs...
View Expressions.v
Require Import String.
Inductive ty : Type :=
| TInt : ty
| TString : ty.
Inductive Value : Type :=
| VInt : nat -> Value
| VString : string -> Value.
View Traverse.hs
module Traverse where
import Prelude hiding (Monad, Functor, Either, Left, Right, map, traverse, pure)
-- So, you probably already have a natural intuition for
-- the fact that types are similar to the idea of sets
-- from mathematics.
-- So, lets imagine all of the sets (types) we can describe
-- in Haskell. We understand how to work with the inhabitants
View Combining.hs
module Combining where
import Prelude hiding (Semigroup)
import Data.List as List
-- We know that lots of things can be combined together.
combineLists :: [a] -> [a] -> [a]
combineLists [] [] = []
combineLists [] ys = ys
View Pangram.hs
module Pangram where
import Data.Set (Set)
import Data.Set as Set
import Data.Char (toLower, isLetter)
import Data.List as List
isPangram :: [Char] -> Bool
View Age.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Age where
main :: IO ()
main = do
print "Hello, world."
print $ show $ ageOn Mecury (earthYearInSeconds * 38)
data Planet =
View sqlast.scala
sealed trait AST
case class Query(selectClause: List[ColumnExp], ...) extends AST
sealed trait Exp extends AST
sealed trait QIdent extends Exp
case class QIdentBase(name: String) extends QIdent
case class QIdentDot(qualifier: QIdent, name: QIdentBase) extends QIdent
View CustomError.scala
sealed trait DaxcoError
case object NotFound extends DaxcoError
case object NoClasses extends DaxcoError
case object ClassFull extends DaxcoError
def someApiCall(someInput: ???): IO[Either[DaxcoError,???]] = ...
View main.scala
import java.util.concurrent.Executors
import cats.effect._
import cats.implicits._
import org.http4s.{HttpApp, HttpRoutes}
import org.http4s.syntax._
import org.http4s.implicits._
import org.http4s.server.Router
import org.http4s.server.blaze._
package com.kyrlach.coinflip;
import java.util.Random;
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner s = new Scanner(;
Random r = new Random();
bkyrlach /
Created February 21, 2020 01:54
How to print the tic-tac-toe board...
public String toString() {
StringBuilder sb = new StringBuilder();
for(int i = 1; i <= 9; i++) {
Piece piece;
try {
piece = pieceAt(i);
} catch (Exception ex) {
throw new RuntimeException(ex);
switch(piece) {