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
# 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/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |
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
// | |
// An attempt to workaround SI-2712, foiled by SI-3346 | |
// | |
trait TC[M[_]] | |
type EitherInt[A] = Either[Int, A] | |
implicit object EitherTC extends TC[EitherInt] |
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
object Poc2 { | |
trait TARInt | |
trait Basket[A,B] { | |
def iAmABasket = {} | |
} | |
trait BasketFactory[A,B] { | |
def create(v: A): Basket[A,B] |
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
/* | |
Copyright 2012-2021 Viktor Klang | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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 Multimethod | |
attr_accessor :dispatch, :methods, :heirarchy, :default_method | |
class NoMatchingMethodError < StandardError | |
end | |
def initialize(&dispatch) | |
@dispatch = dispatch | |
@methods = [] | |
@heirarchy = {} | |
end |
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
/** | |
* this is an experiment to create unboxed union types with a phantom type and a context bound. | |
* All the good ideas come from @milessabin post, comments and links: http://www.chuusai.com/2011/06/09/scala-union-types-curry-howard/#comment-22 | |
*/ | |
/** trait for anything that can be A or B */ | |
trait Or[A, B] { | |
// a phantom type, there will be no instance of this type that we'll use | |
type l[T] | |
// an alias for l[t] |
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
Original paper on A-normal form: | |
http://redlinernotes.com/docs/Classics/The%20Essence%20of%20Compiling%20with%20Continuations.pdf | |
A high-level intro to ANF: | |
http://matt.might.net/articles/a-normalization/ | |
One of the earlier attempts to relate SSA and CPS: |
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
object BenchmarkCommon { | |
import scala.util.Random | |
val DatasetSize = 10000 | |
val Iterations = 10000 | |
val ArrayPoolSize = 1000 | |
val ArrayPool = { | |
def randomArray(): Array[Int] = { | |
val array = new Array[Int](DatasetSize) | |
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
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_05). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scalaz._ | |
import scalaz._ | |
scala> val (foo, bar, baz) = (Need({println("foo") ; "foo"}), Need({ println("bar") ; "bar"}), Need({ println("baz") ; "baz"})) | |
foo: scalaz.Need[java.lang.String] = scalaz.Need$$anon$4@1d90d034 | |
bar: scalaz.Need[java.lang.String] = scalaz.Need$$anon$4@e551516 |
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 Data.Foldable | |
import Data.Monoid | |
pipeline :: [a -> a] -> a -> a | |
pipeline = appEndo . getDual . foldMap (Dual . Endo) | |
main = print $ pipeline [(+1), (*10)] 100 |
OlderNewer