Skip to content

Instantly share code, notes, and snippets.

View no-longer-on-githu-b's full-sized avatar

no longer on github no-longer-on-githu-b

View GitHub Profile
def saveUser(ds: DataSource)(user: User): UserID = {
// blabla
}
abstract class UserValidationError
case object FirstNameEmpty extends UserValidationError
case object LastNameEmpty extends UserValidationError
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = {
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success
def saveUser(ds: DataSource)(user: User): UserID = {
// blabla
}
abstract class UserValidationError
case object FirstNameEmpty extends UserValidationError
case object LastNameEmpty extends UserValidationError
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = {
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success
def saveUser(ds: DataSource)(user: User): UserID = {
// blabla
}
abstract class UserValidationError
case object FirstNameEmpty extends UserValidationError
case object LastNameEmpty extends UserValidationError
def createUser(saveUser: User => UserID)(firstName: String, lastName: String): ValidationNel[UserValidationError, UserID] = {
def validateFirstName(name: String) = if (name.isEmpty) FirstNameEmpty.fail else name.success
f :: obj1 -> obj2
class Diffable delta obj
applyDiff :: delta -> obj -> obj
instance Diffable obj1Delta obj1
instance Diffable obj2Delta obj2
class PipeThroughDiff o1 d1 o2 d2 where
pipeThroughDiff :: o1 -> d1 -> o2 -> d2
data TExpr
= TInt Int
| TBool Bool
| TStructVal (Map String TExpr)
| TVar StrictText
| TSum [TExpr]
data TType = TypeInt | TypeBool | TypeVec TType
data TExpr a where
TInt :: Int -> TExpr Int
TBool :: Bool -> TExpr Bool
TIVar :: StrictText -> TExpr Int
TBVar :: StrictText -> TExpr Bool
TSum :: [TExpr Int] -> TExpr Int
TVecGet ::
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open System.Linq
open System.Collections.Generic
open System
type Card =
| Guard
T& value( ) const {
typedef decltype( std::addressof( storage ) ) storage_address_t;
typedef typename std::conditional<std::is_const<T>::value, const void, void>::type void_t;
typedef typename std::remove_const<storage_address_t>::type address_t;
return *static_cast<T*>( static_cast<void_t*>( const_cast<address_t>( std::addressof( storage ) ) ) );
}
namespace ErSharp {
public sealed class Sender<T> {
private BlockingCollection<T> Queue;
internal Sender(BlockingCollection<T> queue) {
Queue = queue;
}
public void Send(T value) {
queue.Add(value);
<!doctype html>
<html><head></head>
<head>
<style type="text/css">
div.block {
background-color: #36C;
min-width: 200px;
height: 100px;
float: left;