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
{'EXIT',{{assertEqual_failed,[{module,hashtree_eqc}, | |
{line,207}, | |
{expression,"Res"}, | |
{expected,ok}, | |
{value,precondition_failed}]}, | |
[{hashtree_eqc,'-prop_correct/0-fun-1-',2, | |
[{file,"test/hashtree_eqc.erl"},{line,207}]}, | |
{hashtree_eqc,'-prop_correct/0-fun-3-',2, | |
[{file,"test/hashtree_eqc.erl"},{line,207}]}]}} | |
{{call,erlang,'*',[32,256]},256,4} |
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> type Validated[X] = Option[X] | |
defined type alias Validated | |
scala> badData.traverse[Validated,Int](i => if (i < 0) none[Int] else i.point[Validated]) | |
res3: Validated[List[Int]] = None | |
scala> goodData.traverse[Validated,Int](i => if (i < 0) none[Int] else i.point[Validated]) | |
res4: Validated[List[Int]] = Some(List(4, 5, 123, 6, 7)) | |
scala> import scalaz.syntax.validation._; import scalaz.Validation; import Validation._; import scalaz.std.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
case class MediaInfo(mediaRangeType: String, mediaRangeParams: List[(String,String)], qVal: Option[Double], acceptParams: List[(String,String)]) | |
object AcceptHeaderParsers extends JavaTokenParsers { | |
def acceptHeader: Parser[List[MediaInfo]] = repsep(mediaInfo, ",") | |
def mediaInfo: Parser[MediaInfo] = (mediaRange ~ opt(qParam ~ rep(params))) ^^ { | |
case range~None => MediaInfo(range._1,range._2,None,Nil) | |
case range~Some(q~ap) => MediaInfo(range._1,range._2,Some(q),ap) | |
} |
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 updateCondition(toyBox: ToyBox, name: String, newCondition: ToyCondition): ToyBox = { | |
toyBox.toys.get(name) | |
.map(t => toys.mod(toyBox, _ + (name -> condition.set(t, newCondition))) | |
.getOrElse(toyBox) | |
} |
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
// https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/Lens.scala | |
case class Lens[A,B](get: A => B, set: (A,B) => A) { | |
def apply(a: A) = get(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
-- requires hoauth http://hackage.haskell.org/package/hoauth | |
import Network.OAuth.Consumer | |
import Network.OAuth.Http.CurlHttpClient | |
import Network.OAuth.Http.Request (parseURL) | |
import Network.OAuth.Http.Response | |
import Data.Maybe (fromJust) | |
reqUrl = fromJust . parseURL $ "http://SUBDOMAIN.stackmob.com/api/0/APPNAME/listapi" | |
app = Application "public key" "private key" OOB | |
response :: IO Response |
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._ | |
case class ConditionalMapLens[A, K, V](lens: Lens[A, Map[K,V]]) { | |
def +=?(elem: (K, Option[V])) = lens.mods(m => elem._2.cata(v => m + (elem._1 -> v), m)) | |
def +=?(elem: (K, V), bool: Boolean) = lens.mods(m => if (bool) m + elem else m) | |
def -=?(k: K, bool: Boolean) = lens.mods(m => if (bool) (m - k) else 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
val deleteSomeKey: DeleteObject = bucket.delete("some-key") | |
deleteSomeKey.execute() // actually makes the request to delete the key |
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] error: java.lang.Error: no-symbol does not have owner | |
[INFO] at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:34) | |
[INFO] at scala.tools.nsc.symtab.Symbols$NoSymbol$.owner(Symbols.scala:2150) | |
[INFO] at scala.tools.nsc.symtab.Symbols$Symbol.logicallyEnclosingMember(Symbols.scala:1248) | |
[INFO] at scala.tools.nsc.transform.LambdaLift$LambdaLifter.searchIn$1(LambdaLift.scala:234) | |
[INFO] at scala.tools.nsc.transform.LambdaLift$LambdaLifter.proxy(LambdaLift.scala:243) | |
[INFO] at scala.tools.nsc.transform.LambdaLift$LambdaLifter.scala$tools$nsc$transform$LambdaLift$LambdaLifter$$proxyRef(LambdaLift.scala:259) | |
[INFO] at scala.tools.nsc.transform.LambdaLift$LambdaLifter.postTransform(LambdaLift.scala:389) | |
[INFO] at scala.tools.nsc.transform.LambdaLift$LambdaLifter.transform(LambdaLift.scala:412) | |
[INFO] at scala.tools.nsc.ast.Trees$Transformer$$anonfun$transform$4.apply(Trees.scala:777) |
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
@snapshot = Snapshot.first | |
----- | |
{ | |
:stats => { | |
'accounts' => { 'count' => 8, 'a' => 1 }, | |
'subscriptions' => { 'count' => 16, 'b' => 1 } | |
}, | |
:activity => [ {'ns' => 'accounts.users', ...}, {'ns' => 'subscriptions.users' =>, ...} ] | |
} | |
----- |