{ (0,a) | a ∈ A } ∪ { (1,b) | b ∈ B } A⊕B = { a | a ∈ A } ∪ { (b) | b ∈ B } ただし A ∩ B = { 0 } A = {a,b,c}、B={1,2} A⊕B = {a,b,c,1,2} 例1 例2 enum Color: case Red, Green, Blue, Yellow, Cyan 1+1+1+1+1 5通り
case EmailAndTel(email: EmailAddress, tel: TelephoneNumber) ) EmailAndTel Tel Email b3 b2 b1 A B f: ContractInfo → B EmailもTelも指定され ないケースが発生しない ことを保証できる
programs contain no side-effects at all. A function call can have no effect other than to compute its result. This eliminates a major source of bugs Hughes, J.. "Why Functional Programming Matters." Computer Journal 32 , no. 2 (1989): 98--107.
Cases UI W eb Devices D B External Interfaces Martin, R. C. (2017). Clean Architecture: A Craftsman's Guide to Software Structure and Design. Prentice Hall. 40 A → B A → Option[B] A → Either[E, B]
Cases UI W eb Devices D B External Interfaces Martin, R. C. (2017). Clean Architecture: A Craftsman's Guide to Software Structure and Design. Prentice Hall. 41 副作用が現れる A → F[B] A → F[Option[B]] A → F[Either[E, B]]