A =>的Monoid实例在猫

时间:2017-03-18 08:27:02

标签: scala functional-programming monoids scala-cats

函数typename BaseClass<PointT>::Parameter x; <div id="responsive-form" class="clearfix"> <div class="vc_row "> <div class="vc_col-sm-6"> <label> Your Name (required) [text* your-name] </label> </div> <div class="vc_col-sm-6"> <label> Your Email (required) [email* your-email] </label> </div> </div> <label> Arrival date [date date-79 id:Arrivaldate date-format:mm/dd/yy] </label> <label> Departure date [date date-80 id:Departuredate date-format:mm/dd/yy] </label> <label> How many guests? [text your-guests] </label> <div class="form-row"> <p>Number of adults [text your-adults]</p> <p>Number of children under 6 years old [text your-little-children]</p> <p>Number of children under 12 years old [text your-big-children]</p> </div> Select your preferred accomodation [checkbox your-accomodation use_label_element "Wayan (Two-story villa)" "Kadek (Two-story villa)" "Nyoman (Garden bungalow)" "Kehut (Garden bungalow)" "Pasca (Garden bungalow)"] Do you need transportation to the hotel ? [radio your-pickup default:1 use_label_element exclusive "No transport needed" "Transport from Denpasar airport" "Transsport from Gilimanuk Ferry"] <label> Do you want us to arrange motorbike rental for you ? [text your-motorbikes] </label> <label> Tell us more about what brings you to Balian [textarea your-message] </label> [submit "Send"] </div>A => A,组成为identity。不幸的是我没有在empty库中找到它。库是否为这些函数提供了monoid实例?

combine怎么样,cats是monad还是appative?

1 个答案:

答案 0 :(得分:2)

Cats在instances/function.scala中有一个A => A的Monoid实例。

A => M[A]要求Monad M接缝形成一个Monoid,a => M.pure(a)empty以下combine op:

def compose(f1 = A => M[A], f2 = A => M[A]): A => M[A] =
  a => f1(a).flatMap { e => f2(e) }

这不是在图书馆中实施的 Monoid法则的证明留给了读者。