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
package object io { | |
sealed trait IO[A] { | |
def unsafePerformIO: A | |
} | |
object IO { | |
def apply[A](a: => A): IO[A] = new IO[A] { | |
def unsafePerformIO = 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 scalaz._ | |
import Scalaz._ | |
import effects._ | |
trait Request | |
trait Response | |
case class WebState(_request: Request, _response: Response) | |
sealed trait Web[A] extends NewType[Web.T[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
package test | |
import scalaz.{Failure => _, _} | |
import Scalaz._ | |
import effects._ | |
import iteratees._ | |
import java.io._ | |
object ScalazIter { |
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.{Failure => _, _} | |
import Scalaz._ | |
import effects._ | |
import iteratees._ | |
import java.io._ | |
object Head { | |
def main(args: Array[String]) { | |
val enum = enumStream[Seq[Byte], IO]((1 to 50).toStream.map(i => ("line " + i + "\n").getBytes.toSeq)) |
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
package scalaz | |
package concurrent | |
import Scalaz._ | |
import Promise._ | |
import Strategy._ | |
import java.util.concurrent._ | |
import locks._ | |
import atomic._ |
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 is billed as a multi-paradigm language, supporting object oriented programming and functional programming. | |
What does it mean to say that Scala is a functional programming language? What is functional programming? | |
What problems does it solve? What problems does it introduce and how can we solve them? In this presentation | |
we'll cover these questions and walk through an example of taking a traditional, imperative piece of code and | |
converting it into an example of traditional functional code. We'll iterate on the functional code, introducing | |
language features of Scala that will make our solution more generic, concise and provide better separation of concerns. | |
Finally, we'll talk about the one problem that traditionally confuses more functional programming newcomers, how to | |
do IO when you aren't allowed to do side-effects. |
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
* What is Scala? | |
** OO | |
*** example class | |
** Functional (sorta) | |
*** example map and foldLeft | |
* Some basics | |
** Defining values/variables | |
*** examples with/without type inference | |
** Defining functions | |
*** examples with/without return value |
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._, Scalaz._, effects._ | |
import scalaz._ | |
import Scalaz._ | |
import effects._ | |
scala> val hello = putStrLn("Hello") | |
hello: scalaz.effects.IO[Unit] = scalaz.effects.IO$$anon$2@401c1b5f | |
scala> val bad:IO[Unit] = throwIO(new Exception("bad thing")) | |
bad: scalaz.effects.IO[Unit] = scalaz.effects.IO$$anon$2@1d296aa3 |
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 Pointed[F[_]] { | |
def point[A](a: => A): F[A] | |
} | |
trait Functor[F[_]] { | |
def fmap[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
trait Show[A] { | |
def shows(a: => A): String |
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
type Product[F[_], G[_], A] = (F[A], G[A]) | |
trait Prod[F[_], G[_]] { | |
type and[H[_]] = Prod[F, ({type λ[α] = Prod[G, H, α]})#λ] | |
type apply[A] = (F[A], G[A]) | |
} | |
type product[F[_], G[_]] = Prod[F, G] | |
type Coproduct[F[_], G[_], A] = Either[F[A], G[A]] |
OlderNewer