Installed from this base centos package list: https://gist.github.com/casr/235395cdcb23c00ad409
(Had epel & build tools already installed.)
- ncurses-devel
- ghc-7.0.3 (from EPEL)
def decodeJson[A:DecodeJson] = Directive{ req:HttpRequest[Any] => | |
def error(msg:String) = Result.Error( | |
BadRequest ~> ResponseString("Invalid JSON request: " + msg) | |
) | |
JsonRequest(req).decode[A] match { | |
case -\/(-\/(invalidJsonErr)) => error(invalidJsonErr) | |
case -\/(\/-((decodeFailErr,_))) => error(decodeFailErr) | |
case \/-(a) => Result.Success(a) | |
} |
def eitherPLens[X,A,B]( | |
lensLeft: X @?> A , | |
lensRight: X @?> B | |
): X @?> (A \/ B) = PLens.plensg( | |
x => Some( | |
_.fold( lensLeft.setOr( x , _ , x ), lensRight.setOr( x , _ , x) ) | |
), | |
x => lensLeft.get( x ).map( -\/[A](_) ).orElse( | |
lensRight.get( x ).map( \/-[B](_) ) | |
) |
import scalaz._ | |
import scalaz.stream._ | |
import scalaz.stream.actor._ | |
object Foo { | |
// I need to create a bidirectional link between a websocket and a tcp socket. | |
// To do the TCP side, I was hoping to use the new NIO stream from scalaz-stream (snapshot-0.4) | |
// The problem that I am hitting, though, is that I will have the requirement |
module Main where | |
import Prelude hiding (mapM_) | |
import Control.Concurrent (forkIO) | |
import Control.Concurrent.STM (STM,atomically) | |
import Control.Concurrent.STM.TQueue | |
( TQueue | |
, newTQueue | |
, readTQueue | |
, writeTQueue ) |
scala> import argonaut._, Argonaut._ | |
import argonaut._ | |
import Argonaut._ | |
scala> Map( "foo" -> List("bar","baz") , "test" -> List() ) .jencode.spaces2 | |
res7: String = | |
{ | |
"foo" : [ | |
"bar", | |
"baz" |
Installed from this base centos package list: https://gist.github.com/casr/235395cdcb23c00ad409
(Had epel & build tools already installed.)
import scalaz._ | |
import syntax.std.option._ | |
import syntax.monad._ | |
import syntax.show._ | |
import xml._ | |
import cursor._ | |
import Xml._ | |
object DecoderTest { |
import org.joda.time.DateTime | |
import org.joda.time.format.DateTimeFormat | |
import argonaut._ | |
import Argonaut._ | |
object InvariantFunctorBug { | |
case class RecordMeta( | |
externalId:String, |
import argonaut._ , Argonaut._ | |
object Recursive { | |
val jsonStr0 = """{ | |
| "name": "name1", | |
| "entities": [] | |
|} | |
""".stripMargin |
An idea came up at lambda jam that I'm not sure whether it is feasible or even useful. A recurring problem that people seem to have (including me) is the sheer breadth of concepts in FP and the difficulty that that presents when trying to prioritise what they should learn next to get closer to being able to solve their problems. The idea was some kind of map / "fp skill tree" which could be used to get a high level picture of the ecosystem and how all the bits related.
For instance, a question that this tool could be used to answer would be: