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
let | |
pkgs = import <nixpkgs> {}; | |
name = "test"; | |
in pkgs.myEnvFun { | |
buildInputs = [ | |
pkgs.haskell.packages.ghcjs.ghcWithPackages(p: with p; [ ghcjs-base ghcjs-dom lens text ]) | |
pkgs.nodejs | |
]; | |
inherit name; | |
} |
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
def time[T](expression: => T): T = { | |
val start = System.nanoTime | |
val result: T = expression | |
val timeTaken = System.nanoTime - start | |
if (timeTaken >= 0) println("Time taken: %s nanoseconds".format(timeTaken)) | |
result | |
} |
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
unstable-shell () { nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz -j 8 $* } | |
ghci-with-deps () { unstable-shell -p "haskell.packages.ghc7103.ghcWithPackages (pkgs: with pkgs; [ghc $*])" --command ghci } |
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 scalaz._,Scalaz._,scalaz.effect._,OptionT._,Kleisli._ | |
type OptionTIO[+X] = OptionT[IO, X] | |
val reader1: ReaderT[Option, Int, String] = kleisli[Option, Int, String](n => n.toString.some) | |
val reader2: ReaderT[IO, Int, String] = kleisli[IO, Int, String](n => IO((n * 2).toString)) | |
val convertedReader1: ReaderT[OptionTIO, Int, String] = reader1.mapK[OptionTIO, String](opt => optionT(IO(opt))) | |
val convertedReader2: ReaderT[OptionTIO, Int, String] = reader2.mapK[OptionTIO, String](io => io.liftM[OptionT]) |
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.Parallel | |
nfib :: Int -> Int | |
nfib = (map fib [0 ..] !!) | |
where fib 0 = 0 | |
fib 1 = 1 | |
fib n = par n1 (pseq n2 (n1 + n2)) | |
where n2 = nfib (n-2) | |
n1 = nfib (n-1) |
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
def doThing[M[+_]: Monad, T, U, V] | |
(actionOne: () => ReaderT[M, T, Unit], | |
actionTwo: () => ReaderT[M, T, Unit], | |
actionThree: () => ReaderT[M, T, Unit], | |
actionFour: () => ReaderT[M, (T, U), Unit], | |
actionFive: () => ReaderT[M, T, Unit, | |
actionSix: () => ReaderT[M, V, Unit]) | |
(): ReaderT[M, (T, U, V), Unit] = { | |
for { | |
_ <- actionOne().localFrom[(T, U, V)] |
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
[error] (myproject/compile:compile) scala.reflect.internal.FatalError: class Universe does not have a member Quasiquote |
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
[error] (myproject/compile:compile) scala.reflect.internal.FatalError: class Universe does not have a member Quasiquote |
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 org.apache.commons.codec.binary.Base64 | |
import java.nio.file._ | |
import java.nio.file.attribute._ | |
import scala.collection.mutable.ListBuffer | |
val htmlTemplate = """ | |
<html> | |
<head> | |
<title>Encoded Images!</title> | |
</head> |