Skip to content

Instantly share code, notes, and snippets.

@bkyrlach
bkyrlach / A.scala
Created March 8, 2024 18:19
Stack/LinkedList
sealed trait Thing[+A]
object Thing {
case class SomeThing[A](value: A, next: Thing[A]) extends Thing[A]
case object NotAThing extends Thing[Nothing]
}
@bkyrlach
bkyrlach / Expressions.v
Last active June 18, 2022 02:17
Stuck on proofs...
Require Import String.
Inductive ty : Type :=
| TInt : ty
| TString : ty.
Inductive Value : Type :=
| VInt : nat -> Value
| VString : string -> Value.
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
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
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
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Age where
main :: IO ()
main = do
print "Hello, world."
print $ show $ ageOn Mecury (earthYearInSeconds * 38)
data Planet =
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
sealed trait DaxcoError
case object NotFound extends DaxcoError
case object NoClasses extends DaxcoError
case object ClassFull extends DaxcoError
def someApiCall(someInput: ???): IO[Either[DaxcoError,???]] = ...
import java.util.concurrent.Executors
import cats.effect._
import cats.implicits._
import org.http4s.{HttpApp, HttpRoutes}
import org.http4s.syntax._
import org.http4s.dsl.io._
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(System.in);
Random r = new Random();
System.out.println("Hello.");