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 std.option._ | |
import argonaut._,Argonaut._ | |
object JsonDb { | |
sealed trait SumType | |
case class Option1( foo:String ) extends SumType | |
case class Option2( bar:Int ) extends SumType |
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 argonaut._,Argonaut._ | |
object JsonDb { | |
sealed trait SumType | |
case class Option1( foo:String ) extends SumType | |
case class Option2( bar:Int ) extends SumType | |
private implicit val option1Codec = casecodec1( Option1.apply , Option1.unapply _ )("foo") |
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 argonaut._,Argonaut._ | |
object JsonDb { | |
sealed trait SumType | |
case class Option1( foo:String ) extends SumType | |
case class Option2( bar:Int ) extends SumType | |
private implicit val option1Codec = casecodec1( Option1.apply , Option1.unapply _ )("foo") |
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
[info] Loading project definition from /home/vagrant/src/iseek/corp/iseek-salesfarce/project | |
[info] Set current project to salesfarce (in build file:/home/vagrant/src/iseek/corp/iseek-salesfarce/) | |
> clean | |
[success] Total time: 0 s, completed Dec 5, 2013 5:31:36 PM | |
> compile | |
[info] Updating {file:/home/vagrant/src/iseek/corp/iseek-salesfarce/}iseek-salesfarce... | |
[info] Resolving org.scala-lang#scala-library;2.10.3 ... | |
[info] Resolving au.com.iseek#logback_2.10;0.1.0 ... | |
[info] Resolving org.slf4j#slf4j-api;1.7.5 ... | |
[info] Resolving ch.qos.logback#logback-core;1.0.10 ... |
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;CONNECT 4 - By Ben Kolera | |
;; | |
;;Last Revised, 6/7/05 | |
;;N.B - "Best Moves" functionality still not implemented. | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;Interact with the game object, "g" defined in the last line of these defns. | |
;;You could create other games in the interactions window on the fly, or just | |
;;Alter the defintion of g to change players, board size and etc... | |
;; |
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 argonaut._, Argonaut._ | |
case class Message ( id:String , event:String, data:Json ) | |
object Message { | |
implicit val messageCodec = casecodec3( Message.apply , Message.unapply )( "id" , "event" , "data" ) | |
//scala> """{"id":"foo","event":"bar","data":"string"}""".decodeOption[Message] | |
//res1: Option[Message] = Some(Message(foo,bar,"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
-- 1) Is there way to get a warning if you aren't being explicit with your imports and exports? | |
-- OK: | |
module Foo (bar) where | |
import Foo (bar) | |
import qualified Foo as F | |
-- Warnings: | |
module Foo where |
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
recoverEitherT :: Monad m => (e -> EitherT e m a) -> EitherT e m a -> EitherT e m a | |
recoverEitherT lf et = EitherT $ runEitherT et >>= (runEitherT . either lf right) |
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> Json.obj( "foo" := Json.jString("bar") ).obj.map(_.toMap).map( m => Json.jObjectAssocList( m.toList ) ) | |
res6: Option[argonaut.Json] = Some({"foo":"bar"}) |
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 intent = { | |
case req @ GET(Path(Seg("admin" :: "accounts" :: rest ))) => req match { | |
case Session(session) if (session.get("username").nonEmpty) => Pass | |
case _ => req.respond(Unauthorized) | |
} | |
case req @ GET(Path(Seg("admin" :: "accounts" :: Nil))) => | |
list(req) | |
case req @ GET(Path(Seg("admin" :: "accounts" :: "uncreated" :: Nil))) => | |
uncreated(req) | |
case req @ GET(Path(Seg("admin" :: "accounts" :: id :: Nil))) => |