I'm submitting this PR <https://github.com/arrow-k...
# arrow
r
I'm submitting this PR https://github.com/arrow-kt/arrow/pull/811 that introduces a DSL in Arrow to avoid users having to remember in which type class their favorite operation is located. This DSL adds a
syntax
function to the Companions such as that most of the important type classes a data type implements are exposed as the single
this
scope in the function block. Where before you'd have to access the functions accesing the instances like in the example below:
Copy code
Option.applicative().map(Option(1), Option(1), Option(1), { (a, b, c) -> a + b + c }) //Option(3)
Option.monad().binding {
  val a = Option(1).bind()
  val b = Option(a + 1).bind()
  a + b
} 
// Option(3)
Option.functor()...
Option.traverse()...
Now you can just use the syntax object to access all the imported extension functions and static ones in the scope like in the example below:
Copy code
import arrow.instances.*

Option syntax { //`this` is Monad, Applicative, Functor, Traverse, etc...
  binding { ... }
  map(....)
  traverse(...)
}

Either<String>() syntax { //`this` is Monad, Applicative, Functor, Traverse, etc...
  binding { ... }
  map(....)
  traverse(...)
}
If anyone has any feedback about the DSL or naming beside
syntax
feedback and ideas are welcome! Thanks!