On 5/30/16 6:47 PM, Andreas Joseph Krogh wrote:
Then I use the ⊛ operator to accumulate errors:
(checkInvoiceNumber ⊛ checkSentDate ⊛ checkCompany ⊛ checkSourceCompany ⊛ checkInvoiceSource ⊛ checkBankAccount ⊛ checkCustAddressStreet ⊛ checkCustAddressPlace ⊛ checkCustAddressCity ⊛ checkCustAddressZip ⊛ checkSenderAddressStreet ⊛ checkSenderAddressPlace ).tupled match { case Failure(msgList) => prinln(msgList)case Success((invoiceNumber, invoiceDate, company, sourceComp, invoiceSource, fromBankAccount , custAddrStreet, custAddrPlace, custAddrCity, custAddrZip , senderAddrStreet, senderAddrPlace )) =>

This approach stops working when having more then 12 checks (because ApplicativeBuilder12 is the "last one"). How can I accomplish the same using a List of any length, preserving the types in Success so I can use them like the match-statement above?

The simplest way is to add more parentheses and .tupled calls. Then you can add more parentheses in the same places to your case Success, and the pattern match should work just as well.

There is an hlist approach that is less ad hoc, but requires more setup; I'd suggest it only if you are already incorporating hlists into your code.

Greetings,

Stephen.

--
You received this message because you are subscribed to the Google Groups 
"scalaz" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/scalaz.
For more options, visit https://groups.google.com/d/optout.

Reply via email to