Skip to content

Instantly share code, notes, and snippets.

View rockymadden's full-sized avatar
Setting status

Rocky Madden rockymadden

Setting status
  • UiPath
  • Pale Blue Dot
View GitHub Profile
import scala.collection.immutable.ListMap
sealed abstract class Validated[+T]
case class Valid[+T](value:T) extends Validated[T]
case class Error(message:String) extends Validated[Nothing]
class ValidationException(s:String) extends Exception(s)
case class Score(p1: Int, p2: Int)
// Alles ist eine Expression
val score = Score(5, 1)
val winner = if (score.p1 > score.p2) "Player 1" else "Player 2"
val looser = if (score.p1 > score.p2) "Player 2" else "Player 1"
// Tupel
val winnerLooser =
trait Pointed[F[_]] {
def point[A](a: => A): F[A]
trait Functor[F[_]] {
def fmap[A, B](fa: F[A])(f: A => B): F[B]
trait Show[A] {
def shows(a: => A): String
* A functional Conway's game of life.
package object conwaydef {
type Coord[A] = (Int, Int) => A
type Calculator = Coord[Coord[Boolean] => Boolean]
type Size = Int
def nextCell(old: Boolean)(mates: Int) = if (mates > 3) false else if (mates == 3) true else (old && mates == 2)
trait Functor[T[_]]{
def fmap[A,B](f:A=>B)(ta:T[A]):T[B]
trait Applicative[T[_]] extends Functor[T]{
def pure[A](a:A):T[A]
def <*>[A,B](tf:T[A=>B])(ta:T[A]):T[B]
trait Monad[M[_]] extends Applicative[M]{
package pong.imperative
sealed trait Event
class PongConnection {
def isConnected(): Boolean = sys.error("not implemented")
def readEvent(): Event = sys.error("not implemented")
def moveUp(): Unit = sys.error("not implemented")
def moveDown(): Unit = sys.error("not implemented")
def shootMissile(): Unit = sys.error("not implemented")
module Main where
-- A simple directory summing thing for Haskell.
-- by Daniel Lyons <>
-- BSD licensed.
import Control.Applicative
import Data.Either
import Data.Foldable
{-# LANGUAGE PackageImports #-}
You need to register your Twitter application at <>
to get the consumer key and secret needed for OAuth. When connecting to
Twitter for the first time, do this:
let consumer = Consumer "consumer key" "consumer secret"
token <- authenticate

Business Models


Models Examples
Display ads Yahoo!
Search ads Google
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
echo unregistering $p; ghc-pkg $* unregister $p
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.