All Projects → YannMoisan → Hands On Scalaz

YannMoisan / Hands On Scalaz

Discover scalaz in a practical way

Programming Languages

scala
5932 projects
scalaz
18 projects

Labels

Projects that are alternatives of or similar to Hands On Scalaz

Pfps Shopping Cart
🛒 The Shopping Cart application developed in the book "Practical FP in Scala: A hands-on approach"
Stars: ✭ 262 (+240.26%)
Mutual labels:  cats
Scala Pet Store
An implementation of the java pet store using FP techniques in scala
Stars: ✭ 812 (+954.55%)
Mutual labels:  cats
Stm4cats
STM monad for cats-effect
Stars: ✭ 35 (-54.55%)
Mutual labels:  cats
Cat Generator
Generate cat images with neural networks
Stars: ✭ 354 (+359.74%)
Mutual labels:  cats
Scalaz And Cats
Usage examples and benchmarks between Scalaz and Cats (w/ Haskell ground-truth).
Stars: ✭ 471 (+511.69%)
Mutual labels:  cats
Http.cat
🐱 HTTP Cats API
Stars: ✭ 898 (+1066.23%)
Mutual labels:  cats
alice
An hackathon project made for RSF/RWB by AnDaolVras' Devs (Coworking Space in #Brest , Western France)
Stars: ✭ 13 (-83.12%)
Mutual labels:  cats
Sttp
The Scala HTTP client you always wanted!
Stars: ✭ 1,078 (+1300%)
Mutual labels:  cats
Goebpf
Library to work with eBPF programs from Go
Stars: ✭ 666 (+764.94%)
Mutual labels:  cats
Mewment
Kinda like a mashup of Tinder and Instagram, but for cats 🐱 🐈
Stars: ✭ 10 (-87.01%)
Mutual labels:  cats
Guardrail
Principled code generation from OpenAPI specifications
Stars: ✭ 396 (+414.29%)
Mutual labels:  cats
Fetch
Simple & Efficient data access for Scala and Scala.js
Stars: ✭ 453 (+488.31%)
Mutual labels:  cats
Catpapers
Cool vision, learning, and graphics papers on Cats!
Stars: ✭ 918 (+1092.21%)
Mutual labels:  cats
Envoy
Cloud-native high-performance edge/middle/service proxy
Stars: ✭ 18,561 (+24005.19%)
Mutual labels:  cats
Ld40 Catsareassholes
A shelter simulation game made in 3 days for Ludum Dare 40. Even if the game was submitted to Jam instead of Compo, I still made everything all by myself.
Stars: ✭ 45 (-41.56%)
Mutual labels:  cats
Harmony
Scalaz and Cats compatibility
Stars: ✭ 22 (-71.43%)
Mutual labels:  cats
Es Cqrs Shopping Cart
A resilient and scalable shopping cart system designed using Event Sourcing (ES) and Command Query Responsibility Segregation (CQRS)
Stars: ✭ 19 (-75.32%)
Mutual labels:  cats
Skunk
A data access library for Scala + Postgres.
Stars: ✭ 1,107 (+1337.66%)
Mutual labels:  cats
Semanticsegmentation
A framework for training segmentation models in pytorch on labelme annotations with pretrained examples of skin, cat, and pizza topping segmentation
Stars: ✭ 52 (-32.47%)
Mutual labels:  cats
Foundationdb4s
Type-safe and idiomatic Scala client for FoundationDB
Stars: ✭ 23 (-70.13%)
Mutual labels:  cats

Why

Scalaz is to Scala what Guava is to Java : a must to know library ! But unfortunately, learning scalaz is not so easy.

This hand's on focuses on concrete use cases instead of complex theory. The goal is to show that you can use scalaz to improve your code and remove some boilerplate.

I've chosen some pieces of code that can benefit from scalaz. For each, a test suite will help you understand what the code does.

Read the specifications

sbt test

Prepare your project

Scalaz 7.1 is used, because it's the version that you depend on with Play 2.4/2.5

  • add the dependency in build.sbt
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.1.5"
  • import stuff
import scalaz._
import Scalaz._

Tricks

  • Since scala 2.11.8, the tab completion find methods resulting from an implicit conversion. And scalaz uses a lot of them ! e.g. type 1.show<Tab> in the REPL
@ 1.show
final def show: scalaz.Cord
  • If you want to find the source of an implicit conversion, use the following code
@ import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._
@ showCode(reify { 1.show  }.tree)
res14: String = "Scalaz.ToShowOps(1)(Scalaz.intInstance).show"

Main symbols - thanks to reactormonk

Symbol Explanation Hint
\/ Right-leaning Either Split ways, go one way or the other
-\/ Left value of \/ - is on the left side
\/- Right value of \/ - is on the right side
>>= flatMap shove result into
>> flatMap(_ => ..) shove into, but ignore the result
` @ `
` + `
`> ` fa.map(_ => b)
*> fa.flatMap(_ => fb) Do both effects, left to right, use right value
<* fa.flatMap(a => fb.map(_ => a)) Do both effects, left to right, use left value
<=< Alias for compose Left fish
>=> Alias for andThen Right fish
=== Type-safe equality check Really equals
/== Type-safe not-equality check Slashed equals
`? ?` Type-safe order comparison

List Of Symbols

Refactor using Scalaz

Your mission, if you accept it, is to implement all methods marked as todo using Scalaz. All the unit tests are provided and you don't need to modify them. When your implementation will be correct, the tests will pass.

Here are some hints if you need them.

Simple

  • Step 1 : solve compilation issue
  • Step 2 : use scalaz

TypeSafe

  • replace case class with scalaz Tag

Either

  • replace Either with scalaz \/

Validation

  • replace Try with scalaz.Validation

Monoid

  • Hint : Monoid (don't worry, it's such a pedantic word to say a type that you can merge).
trait Monoid[F]  { self =>
  def append(f1: F, f2: => F): F
}

Sequence

  • Hint : use Traverse to transform F[G[A]] into G[F[A]]

FutureOption

  • Hint : use OptionT, a tool for composing monads.

Reader

  • Hint : use a Reader monad, to inject the dependency.

Some links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].