Skip to content

Commit

Permalink
another syntax adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Jan 5, 2024
1 parent 7f0f5cd commit 31facb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/com/virtuslab/lynx/syntax.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.virtuslab.lynx

type require[A, M[_]] = CanReflect[M] ?=> A
type requires[A, M[_]] = CanReflect[M] ?=> A

10 changes: 5 additions & 5 deletions core/src/test/scala/com/virtuslab/lynx/data/StateTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ class StateTest extends munit.FunSuite {
test("userService") {
case class User(name: String)
trait UserService[Cap[_]] {
def addUser(name: String): Unit require Cap
def getUser(name: String): Option[User] require Cap
def addUser(name: String): Unit requires Cap
def getUser(name: String): Option[User] requires Cap
}

type Storage[A] = StateM[List[User], A]
case class StateUserService() extends UserService[Storage] {

override def addUser(name: String): Unit require Storage = {
override def addUser(name: String): Unit requires Storage = {
println("Adding user: " + name)
val newUser = User(name)
State[List[User]].update(newUser :: _)
}

override def getUser(name: String): Option[User] require Storage =
override def getUser(name: String): Option[User] requires Storage =
println("Getting user: " + name)
State[List[User]].get().find(_.name == name)
}

def program[F[_]](userService: UserService[F]): Option[User] require F = {
def program[F[_]](userService: UserService[F]): Option[User] requires F = {
userService.addUser("John")
userService.addUser("Jane")
userService.getUser("John")
Expand Down

0 comments on commit 31facb1

Please sign in to comment.