é¢æ°åããã°ã©ãã³ã°ã§ãã¡ã¤ã³é§åè¨è¨ãé²ããããã«ã¯ã©ãããã°ããã®ãã¨ããã¡ãã£ã¨ããã¢ãã¯ãªåãå£ã®æ¬ã§ãã
èªè 層ã«é¢ãã¦ãé¢æ°åããã°ã©ãã³ã°åå¿è ã§ãOKã¨ããåæã«ã¯ãªã£ã¦ãã¾ãããæ£ç´ãªã¨ããã¾ã£ãã触ãããã¨ã®ãªãã¬ãã«ã ã¨èªãã®ã¯å³ããããããã¾ãã (åå¿è ã«å¯¾ãã¦ããªãããããããè¨è¼ã«ã¯ãªã£ã¦ãã¾ãã)ããã F#ã«ã¤ãã¦ã¯ãé¢æ°åããã°ã©ãã³ã°è¨èªã®ä¸ä¾ã¨ãã¦å©ç¨ãã¦ããæããªã®ã§ãã»ãã®é¢æ°åããã°ã©ãã³ã°è¨èªã®çµé¨ãããã°ããªããªãç解ã§ããã¨æãã¾ããF#ç¹æã®ç¥èãç¹å¥å¿ è¦ã ã£ãããããã°ãããç´¹ä»ãããããããã¾ããã
é¢æ°åããã°ã©ãã³ã°åå¿è ã ã¨å³ããã¨ãã¾ãããããã¡ã¤ã³é§åè¨è¨åå¿è ã«å¯¾ãã¦ã¯ããããããããã§ããã¬ãã«ã ã¨æãã¾ããããã¤ããã¡ã¤ã³é§åè¨è¨ã«é¢ããæ¬ãèªãã§ãã¾ãããããã®ãªãã§ã¯ãã£ã¨ãç°¡æ½ã§ããããããã¨æãã¾ããããã¡ã¤ã³é§åè¨è¨å°å ¥ã«ã¯ã´ã£ããã§ãããã
èªãã§ã¿ã¦ã®ææ³ã¨ãã¦ãæ¬æ¸ã®å 容ãã¹ã¦ããã¸ãã¹ã«åãå ¥ãããã¨ã¯é£ãããããããå¤ãã®ç¤ºåã«å¯ãã æ¬ã§ããã¨æãã¾ãããç¾ä»£ã®ããã°ã©ãã³ã°è¨èªããã¬ã¼ã ã¯ã¼ã¯ã«ã¯ãé¢æ°åããã°ã©ãã³ã°ããã¡ã¤ã³é§åè¨è¨ã®ãã©ãã¤ã ãåãå ¥ãããã¦ãããã¨ãå°ãªããªãã®ã§ãç´ç²ãªé¢æ°åããã°ã©ãã³ã°ããã¡ã¤ã³é§åè¨è¨ãæåããªãã¨ããæ¬æ¸ã«ã¦ç´¹ä»ãããã¨ãã»ã³ã¹ãç¾å ´ã®ã½ããã¦ã§ã¢éçºã§å°å ¥ã§ããã®ã§ã¯ãªãã§ããããã
å¤ãã®ç¤ºåã«å¯ãã æ¬ã¨æ¸ãã¾ããããå人çã«æå¿ããã®ã¯ãã¯ã¼ã¯ããã¼ãåã§è¡¨ç¾ããç¹ããã¨ãã°ã顧客ãã注æãããããã®æ³¨æã®å 容ãæ¤è¨¼ããã¨ããã¯ã¼ã¯ããã¼ããã£ãã¨ãã¾ãããã®ã¯ã¼ã¯ããã¼ã§ã¯æ³¨æä¼ç¥¨ã®è£½åã³ã¼ãããã§ãã¯ãããã¨ã顧客ä½æããã§ãã¯ããå ´åãæ¬æ¸ã®ããããã«ã®ã£ã¨ãã°ãã¾ã次ã®ãããªé¢æ°åãå®ç¾©ãã¾ãã
type ValidateOrder = CheckProductCodeExists // ä¾åé¢ä¿ -> CheckAddressExists // ä¾åé¢ä¿ -> UnvalidatedOrder // å ¥å -> ValidatedOrder
ãã®ãã¨ããã®é¢æ°åãæºããé¢æ°ãå®è£ ãã¾ãã
let validateOrder : ValidateOrder = fun checkProductCodeExists checkAddressExists unvalidatedOrder -> ...
ãã®ããæ¹ã®ããã¨ããã¯ãå宣è¨ãè¦ãã°ã¯ã¼ã¯ããã¼ã§ä½ãããã®ããä¸ç®ã§ããããã¨ãããã¦ä»æ§å¤æ´ã«å¼·ããã¨ã§ãããã¨ãã°ãä»æ§å¤æ´ãçºçãã¦ã注æã®å 容ãæ¤è¨¼ããéã«ã顧客ã®ã¡ã¼ã«ã¢ãã¬ã¹ããã§ãã¯ããå¿ è¦ãå¢ããã¨ãã¾ãããã®å ´åãã¾ãå宣è¨ãä¿®æ£ãã¾ãã
type ValidateOrder = CheckProductCodeExists // ä¾åé¢ä¿ -> CheckAddressExists // ä¾åé¢ä¿ -> CheckEmailExists // ä¾åé¢ä¿ -> UnvalidatedOrder // å ¥å -> ValidatedOrder
ããã¨ããã®é¢æ°åã®å®è£
é¢æ°ã§ããvalidateOrder
é¢æ°ã¯ã³ã³ãã¤ã«ã¨ã©ã¼ã«ãªãã¾ããããã¯ã¤ã¾ãä»æ§ã¨å®è£
ã«å·®ç°ããããã¨ãã³ã³ãã¤ã©ã«ãã£ã¦æ©æ¢°çã«æ¤åºã§ãã¦ããã¨ããã¾ããèªåã®ä»äºæãExcelä»æ§æ¸ã®ä¸èº«ã¨ã½ã¼ã¹ã³ã¼ãã®å®è£
ãéã£ã¦å°ããã¨ãããã¨ãå¤ã
ããã®ã§ãããããä»æ§ã¨å®è£
ã®ä¸è´ãå¼·å¶ã§ããä»çµã¿ã«ã¯æ¬å½ã«æåãã¾ããã
ãã以å¤ã«ãæ¬æ¸ã«ã¯ã½ããã¦ã§ã¢è¨è¨ã«å½¹ç«ã¤ãã¾ãã¾ãªã¢ã¤ãã£ã¢ãç´¹ä»ããã¦ãã¾ããå ¨293ãã¼ã¸ã¨åéã¯ã»ã©ã»ã©ãå³è¡¨ãå¤ãã¦ããããããããªã«ãã翻訳ãããªãã¦ãã¦ãé常ã«èªã¿ãããã®ã§ãèªåã®ã½ããã¦ã§ã¢è¨è¨ã®æã¡é§ãå¢ãããããæ°ããªé¢¨ãåãå ¥ããã人ã¯èªãã§ã¿ã¦æã¯ãªããã¨æãã¾ãã