When building user interfaces, it is common to have two screens side by side evolving their states independently. In order to implement this behavior, we can use Day.

Day is a comonadic data structure that holds two Comonads and a rendering function for both states.

import arrow.core.*
import arrow.ui.*

val renderHtml = { left: String, right: Int -> """     
    | <p>$left</p>                                     
    | <p>$right</p>                                    
val day = Day(Id.just("Hello"), Id.just(0), renderHtml)
day.extract(Id.comonad(), Id.comonad())
// <div>                                             
//  <p>Hello</p>                                     
//  <p>0</p>                                    
// </div>                                            

Do you like Arrow?

Arrow Org