Skip to content

edina-a/scala-cats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-cats

https://www.scala-exercises.org/cats

Semigroup

결합법칙이 성립되는 연산
semigroup

Semigroup[Option[Int]].combine(Option(1), Option(2)) should be(Option(3))

Monoid

Semigroup의 combine에서 Empty를 가짐
monoid

Monoid[String].combineAll(List()) should be("")

Functor

map(값을 꺼내어 f를 적용하고 다시 넣는 과정) 을 가짐
functor

val intToString: Int  String = _.toString
Apply[Option].map(Some(1))(intToString) should be(Some("1"))

Apply

Functor형 클래스를 확장
apply

val intToString: Int  String = _.toString
Apply[Option].ap(Some(intToString))(Some(1)) should be(Some("1"))

val addArity2 = (a: Int, b: Int)  a + b
Apply[Option].ap2(Some(addArity2))(Some(1), Some(2)) should be(Some(3))

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages