è¦ç´ï¼Free ã¢ããã¯ä½ãå¬ããã®ããè°è«ããããã®ãããå°ã以ä¸ã®2ã¤ã®è«æã«è¼ã£ã¦ããä¾ã3ã¤ã®æ¹æ³ã§å®è£ ããã
- Janis Voigtlander, "Asymptotic Improvement of Computations over Free Monads"
- Wouter Swierstra and Thorsten Altenkirch, "Beauty in the Beast -- A Functional Semantics for the Awkward Squad"
ã¢ãã
æè¿ãåã¯ã¢ããã次ã®ããã«èª¬æããããã«ãã¦ããããã¢ããã¨ã¯è¨èªå DSLãå®è£ ããããã® API (ãããã¯ãã¬ã¼ã ã¯ã¼ã¯)ã
ã ãããä½ãè¨èªå DSLãä½ããªãããããã¢ããã®ã¤ã³ã¹ã¿ã³ã¹ã«ãã¹ãã ãããã§ã¯ãgetChar 㨠putChar ã¨ãã API ãæã¤ç°¡å㪠DSL ãèããããã® DSL ã CharIO ã¨å¼ã¼ãã
å½ç¶ãå
¥åºåãªã®ã§ IO ã®ä¸ã§èµ°ãã¹ãã ãã表ç¾ã¨è§£éã¯åé¢ãããã
ã¤ã¾ã getChar/putChar ã¨ãã表ç¾ã¨ã解éç³»ãåé¢ããã解éç³»ã«ã¯
- å®éã« IO ã®ä¸ã§èµ°ããã
- å¯ä½ç¨ãçºçãããã«èµ°ããã
ã®2ã¤ãèãããå¾è ã¯ç´ç²ã ãããQuickCheck ã§ãã¹ãããã
2ã¤ã®ç¹ã«æ³¨æï¼
åã¯ã©ã¹
Real World Haskell ã® 15 ç« ã«ã¯ãåã¯ã©ã¹ã§å®è£ ããæ¹æ³ãè¼ã£ã¦ãããCharIO ã¨ããåã¯ã©ã¹ã®ã¡ã½ããã getChar/putChar ã¨ãã訳ã ãIO ã CharIO ã®ã¤ã³ã¹ã¿ã³ã¹ã«ããã°ãIO ã®ä¸ã§èµ°ãããç´ç²ãªã¢ããã CharIO ã®ã¤ã³ã¹ã¿ã³ã¹ã«ããã°ãç´ç²ã«å®è¡ã§ããããããå®è£ ããã®ãこのコードã
ææ³ï¼
- IO ã CharIO ã®ã¤ã³ã¹ã¿ã³ã¹ã«ããã®ã¯ç°¡åã
- RWS ã¢ããã« ErrorT ãç©ãã¨ãé¢åã§ãã£ã¦ãããªãã
ç´æ¥ã®ã¢ãã
ãã¯ãä½ããã®ãã¼ã¿æ§é ãå®ç¾©ãã¦ããããã¢ããã«ãããããã®å®è£ ãこれã
ææ³ï¼
- ãã¼ã¿åã«æ¬è³ªã§ãªã Pure ã¨ããæ§æåãå¿ è¦ãªã®ã§ã¡ãã£ã¨å«ã
- ç´ç²ã«èµ°ãããæ¹ã¯ãç°¡åã«æ¸ããã