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 OurApp[A] = Coproduct[Auth, Interact, A] | |
type OurAppPlus[A] = Coproduct[OurApp, ThirdAlgebra, A] | |
type ACoyo[A] = Coyoneda[OurAppPlus,A] | |
type AFree[A] = Free[ACoyo,A] | |
def point[A](a: ⇒ A): FreeC[OurAppPlus, A] = Monad[AFree].point(a) |
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
/** Determine if the list l contains a sequence which follows the recurrence relation for the function f. | |
* | |
* A recurrence relation is where numbers in the list determine the rest of the list, for example the Fibonacci sequence | |
* is defined for function plus and you could call this function with the parameters l = List(0,1,1,2,3,5,8,13), f = _ + + | |
* | |
* See InterviewSpec for a test example. | |
* */ | |
def isRecurrenceRelation(l: List[Int], f: (Int, Int) => Int) : Boolean = ??? |
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
4702 30248 0.1 19.5 1449112 721088 ? Sl Jul01 8:49 /usr/java/jdk1.7.0_09/bin/java -cp /opt/glassfish3/glassfish/modules/glassfish.jar -XX:+UnlockDiagnosticVMOptions -XX:PermSize=64m -XX:MaxPermSize=192m -XX:NewRatio=2 -XX:+LogVMOutput -XX:LogFile=/opt/glassfish3/glassfish/domains/gcsi/logs/jvm.log -Xmx512m -client -javaagent:/opt/glassfish3/glassfish/lib/monitor/flashlight-agent.jar -Dfelix.fileinstall.disableConfigSave=false -Djavax.net.ssl.keyStore=/opt/glassfish3/glassfish/domains/gcsi/config/keystore.jks -Djava.awt.headless=true -Dfelix.fileinstall.poll=5000 -Djava.endorsed.dirs=/opt/glassfish3/glassfish/modules/endorsed:/opt/glassfish3/glassfish/lib/endorsed -Dfelix.fileinstall.bundles.startTransient=true -Djavax.net.ssl.trustStore=/opt/glassfish3/glassfish/domains/gcsi/config/cacerts.jks -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -DANTLR_USE_DIRECT_CLASS_LOADING=true -Djava.security.auth.login.config=/opt/glassfish3/glassfish/domains/gcsi/config/login.conf -Dgosh.args=--noint |
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 bootstrap.liftweb { | |
import com.gaiam.gcsis._ | |
import com.gaiam.gcsis.util.Logging | |
class Boot { | |
val log = Logging.logger(classOf[Boot]) | |
def boot: Unit = { |
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
trait PaymentSource { | |
def accept[T](visitor: PsVisitor[T]) : T | |
} | |
class CreditCard extends PaymentSource{ | |
override def accept[T](visitor: PsVisitor[T]) = { | |
visitor.visit(this) | |
} | |
} |
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
def maxTen(i: Int) = | |
if (i <= 10) \/-(i) | |
else "Must be less than ten" | |
def divisibleByTwo(i: Int) = | |
if (i % 2 == 0) == 0 \/-(i) | |
else "Must be divisable by two" | |
def whatType(input: Int): ???[NonEmptyList[String], Int] = | |
( parseInt(input) |@| divisibleByTow(input) ) |
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 com.czarism.blog | |
import scalaz._ | |
import Scalaz._ | |
/** | |
* Created by tstevens on 7/18/14. | |
*/ | |
object FavorValidation { |
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
trait A { | |
def a: String => String | |
} | |
trait B { | |
//TypeOf is something magical | |
def b: TypeOf[A.a] | |
} |
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
val validInt: String => ValidationNEL[String, Int] = s => | |
for { | |
validStr <- (allDigits(s) |@| maxSizeOfTen(s))((_,x) => x) | |
i <- toInt(validStr) | |
} yield(i) |
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
def lineToOffer(line: String, headers: List[String]) : Validation[NonEmptyList[String], Offer] = { | |
({commaSplit(_)} andThen {extractFields(_: List[String], headers)} apply line) :-> | |
{(v) => Offer(v._1, v._2, v._3, v._4)} | |
} | |
def commaSplit(l: String): String => List[String] = l.split(",").toList | |
def extractFields(x: List[String], headers: List[String]): Validation[NonEmptyList[String], (String, String, String, String)] = { | |
notEmpty(x(headers.indexOf("offer_name")), "No offer name specified on line:" + x.mkString(","))) <|***|> ( | |
notEmpty(x(headers.indexOf("email")), "No email specified on line:" + x.mkString(",")), |
NewerOlder