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
/** Your task is to reason your way to which compiler | |
* options which will be passed for each of | |
* 1) sbt root/compile | |
* 2) sbt p1/compile | |
*/ | |
scalacOptions := Seq("-DSBT") | |
scalacOptions in ThisBuild += "-D0" | |
scalacOptions in Global += "-D1" |
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
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Control.Monad.IO.Class | |
import Control.Monad.Trans.Class | |
import Prelude hiding (log) | |
-------------------------------------------------------------------------------- | |
-- The API for cloud files. | |
class Monad m => MonadCloud m where | |
saveFile :: Path -> Bytes -> m () |
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
// a simple process1 that splits the frames up based on a "\r\n" sequence of chars | |
val partitioner = { | |
import java.util.regex.Pattern | |
import scalaz.stream.process1 | |
import scalaz.std.string._ | |
val pattern = Pattern.compile("\r\n") | |
process1.repartition { s: String => | |
pattern.split(s, -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
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
import Control.Lens | |
import Data.Maybe | |
import Data.Monoid | |
data Constant a b = | |
Constant a |
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
Pieces you need: | |
* emacs | |
* ghcid | |
ghcid needs to know the height of the terminal, we'll set it explicitly | |
height = (window-height) - (scroll-margin) - 1 | |
set this height as your term-buffer-maximum-size |
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
// Implementing functor manually | |
import scalaz._, Scalaz._, Free.liftF | |
sealed trait TestF[+A] | |
case class Foo[A](o: A) extends TestF[A] | |
case class Bar[A](h: (Int => A)) extends TestF[A] | |
case class Baz[A](h: (Int => A)) extends TestF[A] | |
implicit def testFFunctor[B]: Functor[TestF] = new Functor[TestF] { |
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
#!/bin/bash | |
exec ~/src/scala/bin/scala -savecompiled "$0" "$@" | |
!# | |
// Example of object algebras, based on the scala example at http://ropas.snu.ac.kr/~bruno/oa/ | |
// type Term = ∀A,O. O[A] -> A | |
trait Term[O[_]] { | |
def apply[A](o: O[A]): A | |
} |
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
sealed trait Interact[A] | |
case class Ask(prompt: String) | |
extends Interact[String] | |
case class Tell(msg: String) | |
extends Interact[Unit] | |
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] |
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.Exception | |
import Control.Monad | |
import Data.Maybe | |
import Data.Version | |
import Distribution.PackageDescription (PackageDescription(..), HookedBuildInfo, GenericPackageDescription(..)) | |
import Distribution.Package (PackageIdentifier(..)) | |
import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, UserHooks(..)) | |
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..)) | |
import Distribution.Simple.Setup (BuildFlags(..), ConfigFlags(..)) | |
import Distribution.Simple.Utils (die) |
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._ | |
import Scalaz._ | |
import Free._ | |
/** "Pure" interactions with a console. */ | |
sealed trait Console[+A] | |
case class GetLine[A](k: String => A) extends Console[A] | |
case class PutLine[A](s: String, a: A) extends Console[A] | |
object Console { |
NewerOlder