This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait λ { type ap[_<:λ]<:λ } | |
type I = λ{type ap[X<:λ] = X } | |
type K = λ{type ap[X<:λ] = λ{type ap[Y<:λ] = X }} | |
type S = λ{type ap[X<:λ] = λ{type ap[Y<:λ] = λ{type ap[Z<:λ] = X#ap[Z]#ap[Y#ap[Z]] }}} | |
type Y = S#ap[I]#ap[I]#ap[S#ap[I]#ap[I]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!! fonts | |
Xft.dpi: 86 | |
Xft.antialias: true | |
Xft.autohint: false | |
Xft.hinting: true | |
! hintnone, hintslight, hintmedium, hintfull | |
Xft.hintstyle: hintmedium | |
Xft.rgba: rgb | |
! lcdnone, lcddefault, lcdlight, lcdlegacy | |
Xft.lcdfilter: lcddefault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import scalaz._ | |
import scalaz._ | |
scala> case class Person(name: String, age: Int) | |
defined class Person | |
scala> val nameLens: Lens[Person, String] = | |
| Lens((p: Person) => p.name, | |
| (p: Person, changed: String) => p.copy(name = changed)) | |
nameLens: scalaz.Lens[Person,String] = Lens(<function1>,<function2>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'generic-x) | |
(defvar roy-keywords | |
'("with" "macro" "return" "bind" "do" "case" "match" | |
"type" "data" "else" "then" "if" "fn" "let" "true" "false") | |
"Roy keywords.") | |
;; | |
;; Syntax highligh | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- courtesy of hpc on #haskell | |
import Unsafe.Coerce | |
import Control.Monad.ST | |
toInteger :: Int -> Integer | |
isJust :: Maybe a -> Bool | |
null :: [a] -> Bool | |
id :: a -> a | |
toInteger = unsafeCoerce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative | |
main = print $ answer succ 0 where | |
one = pure <*> (pure :: a -> b -> a) | |
inc = (<*>) ((<*>) <$> pure) | |
mul = (<*>) <$> pure | |
h = mul <*> inc | |
answer = h . h . h $ one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> console | |
[info] Starting scala interpreter... | |
[info] | |
Welcome to Scala version 2.9.2 (OpenJDK 64-Bit Server VM, Java 1.6.0_24). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scala.xml._ | |
import scala.xml._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{tufte-handout} | |
%\geometry{showframe}% for debugging purposes -- displays the margins | |
\usepackage{amsmath} | |
% Set up the images/graphics package | |
\usepackage{graphicx} | |
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio} | |
\graphicspath{{graphics/}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Monad m => Ref r m where | |
ref :: a -> m (r a) | |
(*) :: r a -> m a | |
(*=) :: r a -> a -> m () | |
(*$) :: r a -> (a -> a) -> m () | |
r *$ f = (r *) >>= (*=) r . f | |
instance Ref IORef IO where | |
ref = newIORef | |
(*) = readIORef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class T() // your data type that you want to "implicitly" thread through | |
case class TReader[+A](run: T ⇒ A) { | |
def map[B](f: A ⇒ B): TReader[B] = | |
TReader((r: T) ⇒ f(run(r))) | |
def flatMap[B](f: A ⇒ TReader[B]): TReader[B] = | |
TReader((r: T) ⇒ f(run(r)).run(r)) | |
def &&&[B](x: TReader[B]): TReader[(A, B)] = |