[ANN] play-monadic-actions 2.1.0

已查看 20 次
跳至第一个未读帖子

Valentin Kasas

未读,
2017年8月14日 19:07:322017/8/14
收件人 Play Framework
Hi everyone, 

It's been quite a long time since I first announced the release of play-monadic-actions (see there).

For the – probably many – who never heard about it, play-monadic-actions is a small DSL that allows to write most actions as a single for-comprehension, like so: 

  def orderBeer() = Action.async {
   
for {
      beerOrder
<- beerOrderForm.bindFromRequest()    ?| (formWithErrors => BadRequest(views.html.orderBeer(formWithErrors))
      user      
<- findAdultUser(beerOrder.userId)    ?| (notAnAdultUser => Conflict(displayError(notAnAdultUser))
      beer      
<- sellBeer(beerOrder.beerName, user) ?| (noSuchBeer => NotFound(displayError(noSuchBeer))  
   
} yield Ok(displayBeer(beer))
 
}

It also provide compatibility modules for cats and scalaz (allowing for example to use cats.Validated or scalaz.Validation with the DSL).

Today we've published version 2.1.0 which is compatible with Play 2.3.x up to 2.6.x and is cross-published for Scala 2.11 and 2.12.

 Your feedback is much appreciated :).

Cheers 

Valentin
回复全部
回复作者
转发
0 个新帖子