我试图使用精致的来基于基元创建智能构造函数,并避免包装,因为在大型集合中可能使用相同的类型。我这样做对吗?似乎可以工作,但有点笨拙
type ONE_Pred = = MatchesRegex[W....
type ONE = String @@ ONE_Pred
type TWO_Pred = OneOf[...
type TWO = String @@ TWO_PRED
然后
case class C(one:ONE,two:TWO)
object C {
def apply(one:String,two:String):Either[String,C] =
(
refineT[ONE_Pred](one),refineT[TWO_Pred](two)
).mapN(C.apply)
}