Skip to content

Instantly share code, notes, and snippets.

View labra's full-sized avatar

Jose Emilio Labra Gayo labra

View GitHub Profile
@labra
labra / ComputationOrder1.scala
Created August 19, 2016 07:01
Another example with computation order...
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
object ComputationOrder {
//// With 3 effects, it fails when I use runNel at the beginning
type C3 = Fx.fx3[State[String,?],Choose,Validate[String,?]]
@labra
labra / ComputationOrder.scala
Created August 19, 2016 06:41
Example playing with different computation orders
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
object ComputationOrder {
type C = Fx.fx4[Reader[String,?],State[String,?],Choose,Validate[String,?]]
type Check[A] = Eff[C,A]
@labra
labra / exampleLocalReader.scala
Last active September 8, 2016 12:34
Example using eff-cats localReader
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
import cats.implicits._
object ExampleLocalReader {
def exampleInterpreter = {
type Env = Map[String,Int]
@labra
labra / UsingShow.scala
Created August 12, 2016 08:24
A question about how to use abstract types and typeclasses
package examples
import cats._
import cats.data._
import cats.implicits._
import cats.syntax.show._
class UsingShow1 {
type Value <: Show[Value]
def showValues(vs: List[Value]): String =
@labra
labra / ExampleCatchWrong.scala
Created August 5, 2016 21:49
Example of catchWrong with a WriterEffect
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
import cats.implicits._
object ExampleCatchWrong {
type E = String
type Comput = Validate[E, ?] |: Writer[E,?] |: NoEffect
@labra
labra / ExampleCatchWrong.scala
Created August 5, 2016 21:34
Example using eff-cats with catchWrong
package examples
import cats._, data._
import org.atnos.eff._, all._
import org.atnos.eff.syntax.all._
object ExampleCatchWrong {
type E = String
type Comput = Validate[E, ?] |: NoEffect
type Check[A] = Eff[Comput,A]
@labra
labra / FreeExprExplicit.scala
Created August 1, 2016 07:41
A possible solution to define Free monads for simple recursive arithmetic expressions in Scala cats using a explicit Semigroup evidence
package examples
import cats._
import cats.data._
import cats.free._
import cats.free.Free._
import cats.implicits._
import scala.language.higherKinds
object FreeExpr {
@labra
labra / FreeExprInt.scala
Created August 1, 2016 07:31
A possible solution to define Free monads for simple recursive arithmetic expressions in Scala cats
package examples
import cats._
import cats.data._
import cats.free._
import cats.free.Free._
import cats.implicits._
import scala.language.higherKinds
object FreeExprInt {
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<h1>Values</h1>
<ol id="valores"></ol>
</body>
<script type="text/javascript">
var url = "http://dbpedia.org/sparql";
@Test
public void postUserKnown() throws Exception {
mvc
.perform(post("/user")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"email\":\"[email protected]\", \"password\": \"jj\"}")
).andExpect(status().isOk())
.andExpect(jsonPath("name", equalTo("jose")))
.andExpect(jsonPath("pollingStationCode").value(23));
}