This file contains hidden or 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 slickdemo.experiments | |
| import scala.slick.driver.{BasicStatementBuilderComponent, H2Driver} | |
| import scala.language.implicitConversions | |
| /** | |
| * Created with IntelliJ IDEA. | |
| * User: pedrofurla | |
| * Date: 18/07/13 | |
| * Time: 19:00 |
This file contains hidden or 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
| source: | |
| lazy val sxr = scalaz.configure{ | |
| p => | |
| Project( | |
| id=p.id+"-sxr", | |
| base = file("."), | |
| settings = p.settings ++ | |
| Seq( | |
| addCompilerPlugin("org.scala-sbt.sxr" % "sxr_2.10" % "0.3.0-SNAPSHOT"), |
This file contains hidden or 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 Foo | Bleh | Dummy(val x:Int) | |
| Into: | |
| sealed trait Foo | |
| case class Bleh extends Foo | |
| case class Dummy(val x:Int) extends Foo |
This file contains hidden or 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
| // Show the problem | |
| override def doGet(req: HttpServletRequest, resp: HttpServletResponse) { | |
| resp.setContentType("text/html") | |
| resp.setCharacterEncoding("UTF-8") | |
| // TROUBLE // TROUBLE // TROUBLE | |
| var a:Int = req.getParameter("a").toInt | |
| var b:Int = req.getParameter("b").toInt | |
| var c:Int = req.getParameter("c").toInt |
This file contains hidden or 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 fpis | |
| /** | |
| * User: pedrofurla | |
| * Date: 11/09/13 | |
| * Time: 08:17 | |
| */ | |
| object Church { | |
| /* |
This file contains hidden or 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> ru.typeOf[Monad[List]] | |
| res13: reflect.runtime.universe.Type = Monad[scala.List] | |
| scala> res13.typeSymbol.typeSignature | |
| res19: reflect.runtime.universe.Type = [F[_]]Applicative[F] with Bind[F] | |
| scala> res13.typeSymbol.typeSignature.asInstanceOf[scala.reflect.internal.Types$PolyType] | |
| res25: scala.reflect.internal.Types$PolyType = [F[_]]Applicative[F] with Bind[F] | |
| scala> res25.parents |
This file contains hidden or 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 fpis | |
| /** | |
| * User: pedrofurla | |
| * Date: 11/09/13 | |
| * Time: 08:17 | |
| */ | |
| object Church extends App { | |
| /* |
This file contains hidden or 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 NUM[A] = (A => A) => A => A | |
| def succ [A]: NUM[A] => NUM[A] = m => n => x => n(m(n)(x)) | |
| def plus [A]: (NUM[A]) => (NUM[A]) => NUM[A] = m => n => f => x => m(f)(n(f)(x)) | |
| def times [A]: (NUM[A]) => (NUM[A]) => NUM[A] = m => n => f => x => m(n(f))(x) | |
| def isZero[A]: (NUM[A]) => BOOL[A] = m => a => b => m(_ => F[A](a)(b))(T[A](a)(b)) | |
| // | |
| /* | |
| pred ≡ λn.λf.λx. n (λg.λh. h (g f)) (λu. x) (λu. u) | |
| SHIT: http://okmij.org/ftp/Computation/lambda-calc.html#predecessor | |
| http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=70E6927502DB038ABB1DF6AD0390312F?doi=10.1.1.26.7908&rep=rep1&type=pdf |
This file contains hidden or 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> List(1,2); | |
| res12: List[Int] = List(1, 2) | |
| scala> for(x <- res12) yield List(x) | |
| res16: List[List[Int]] = List(List(1), List(2)) | |
| scala> for(x <- res12; y <- res12) yield List(x,y) | |
| res13: List[List[Int]] = List(List(1, 1), List(1, 2), List(2, 1), List(2, 2)) | |
| scala> for(x <- res12; y <- res12; z <- res12) yield List(x,y,z) |
This file contains hidden or 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 Misty m where | |
| banana :: (a -> m b) -> m a -> m b | |
| unicorn :: a -> m a | |
| -- Exercise 6 | |
| -- Relative Difficulty: 3 | |
| -- (use banana and/or unicorn) | |
| furry' :: (a -> b) -> m a -> m b | |
| furry' f mm = banana (unicorn . f) mm |