start new:
tmux
start new with session name:
tmux new -s myname
scala> trait Forall[F[_]]{ def apply[A]: F[A] } | |
defined trait Forall | |
scala> type ListFun[A] = List[A] => List[A] | |
defined type alias ListFun | |
scala> object Reverse extends Forall[ListFun] { def apply[A] = _.reverse} | |
defined module Reverse | |
scala> Reverse[String](List("1", "2")) |
object OperationalMonad extends App { | |
class Operational { | |
type instr[A] <: { def run: A } | |
sealed abstract class Program[A] { | |
def map[B](k: A => B) = flatMap(k andThen Lift.apply) | |
def flatMap[B](k: A => Program[B]): Program[B] = { | |
Bind(this, k) | |
} | |
def run: A | |
} |
/* | |
Based on the first part of the talk "Dead-Simple Dependency Injection in Scala" by @runarorama at NEScala 2012 | |
http://marakana.com/s/dependency_injection_in_scala,1108/index.html | |
*/ | |
class Connection { | |
def prepareStatement(query: String) = new Statement() | |
} | |
class Statement { |
import scalaz._ | |
import Scalaz._ | |
object Foo { | |
type Result[A] = Validation[String,A] | |
type Reader[A] = Int => Result[A] | |
implicit val readerBind: Bind[Reader] = new Bind[Reader] { | |
def map[A,B](fa: Reader[A])(f: A=>B) : Reader[B] = x => fa(x) map f | |
def bind[A,B](fa: Reader[A])(f: A => Reader[B]) : Reader[B] = { |
import Control.Monad | |
import Control.Monad.Identity (runIdentity) | |
import Control.Monad.Error | |
import Control.Monad.State.Lazy | |
import Data.Maybe (listToMaybe) | |
-- |Monad transformer which stores a stack internally | |
type StackT s m = StateT [s] m |
"For comprehension" is a another syntaxe to use map
, flatMap
and withFilter
(or filter) methods.
yield
keyword is used to aggregate values in the resulting structure.
This composition can be used on any type implementing this methods, like List
, Option
, Future
...
-server | |
-Xms2048m | |
-Xmx2048m | |
-XX:NewSize=512m | |
-XX:MaxNewSize=512m | |
-XX:PermSize=512m | |
-XX:MaxPermSize=512m | |
-XX:+UseParNewGC | |
-XX:ParallelGCThreads=4 | |
-XX:MaxTenuringThreshold=1 |
Given a Haskell Typeclass:
class Point a where
distance :: a -> a -> Double
data Point2D = Point2D { x :: Int
, y :: Int } deriving (Show, Eq)
instance Point Point2D where
distance (Point2D x y) (Point2D x' y') =
Generate the list yourself:
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./* | \
sed 's/NS_AVAILABLE_IOS(.*)//g' | \
sed 's/NS_DEPRECATED_IOS(.*)//g' | \
sed 's/API_AVAILABLE(.*)//g' | \
sed 's/API_UNAVAILABLE(.*)//g' | \
sed 's/UI_APPEARANCE_SELECTOR//g' | \