Skip to content

Make IndexedStateT contravariant on SA #2049

@dragisak

Description

@dragisak

Change from IndexedStateT[F[_], SA, SB, A] to IndexedStateT[F[_], -SA, SB, A]

Example of use:

trait Animal { def age: Int }
case class Cat(age: Int) extends Animal

val incrementCatAge: IndexedStateT[Id, Cat, Cat, Unit] = IndexedStateT.modify(cat => cat.copy(age = cat.age + 1))
val incrementAnimalAge: IndexedStateT[Id, Animal, Int, Unit] = IndexedStateT.modify(_.age + 1)

val composite = for {
  _ <- incrementCatAge
  _ <- incrementAnimalAge
  r <- IndexedStateT.get[Id, Int]
} yield r

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions