æ¨æ¥ã®ç¶ãã§ããè¨æ³ãããã¨ãMonadã¿ããã«å¯ä½ç¨ãæ±ããã¨ãè¨ã£ãã¡ãªãããã¯ããã«è¶ããArrowã®ç´ æ´ãããã«ã¤ãã¦ç´¹ä»ãã¾ãã reverse.reverse == id ã? èªåãæåã«Arrowã£ã¦ãããã¨æ°ã¥ããåé¡ãããã§ãã大å¦ã§åç´çã¨è©±ãã¦ããæã«æ°ã¥ãã¾ããã大ãã¦å½¹ã«ç«ã¤ä¾ã§ã¯ç¡ãã§ãããArrowã®æ°ããå´é¢ãè¦ãã¦ããä¾ã§ãã æ¨æºå ¥åã«å¯¾ãã¦reverse,reverse,headãé ã«å®è¡ãã¦çµæãåºåããã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãã¾ããå¾ã®æ¯è¼ã®çºã«æ¢ãã¦Arrowã§æ¸ãã¦ãã¾ãã import Control.Arrow main :: IO () main = getContents >>= print. (reverse >>> reverse >>> head) ãªã¹ããï¼åã²ã£ããè¿ãããå ã«æ»ãã ããªã®ã§ããã®headãã¨ãã¨ããè¨ç®ã¯ä¸
ããã¯ãã³ãã¼ Arrowåpipeã¯FRPã®å¤¢ãè¦ããï¼ æ¬è¨äºãå¼ãç¶ããArrowè¨æ³å¯¾å¿ã®pipeç³»(ãªããã¯Iterateeç³»)èªä½ã©ã¤ãã©ãªmachinecellã®ç´¹ä»ã§ãã machinecell: Arrow based stream transducers ä»åã¯ã¤ã³ãã¯ãéè¦ã®ãã¢ã¨ãã¦ãå°ããªGUIããã°ã©ã ãæ«é²ãã¾ãã ãã®åã«ã¤ã³ããã¨ãã¦ããªãIterateeç³»ã®ã©ã¤ãã©ãªãArrowåããããã¨ããã¢ããã¼ã·ã§ã³ã®é¨åã«ã¤ãã¦ãååã®è¨äºããå°ãçªã£è¾¼ãã§è§¦ãã¦ã¿ããã¨æãã¾ãã ã¤ã³ããï¼Arrowåã®ã¢ããã¼ã·ã§ã³ Iterateeç³»ã©ã¤ãã©ãªã¨ã¯ããã¼ã¿ãèªã¿ãæ¸ããå¯ä½ç¨ãå®è¡ããå°ããªé¨åããããããUnixã®ãã¤ãã®ãã¨ããé£ãã¦ãä¸é£ã®å¦çãè¡ãäºãã§ãããæ©è½ããæä¾ãããã®ã§ããã Arrowã¨ã¯Categoryã®æ¡å¼µã§ãããããããã¤ãã®
Haskell Advent Calendar 13æ¥ç®ã®è¨äºã§ãã ããããããã ä»å¹´ãé³æ¥½ã®å¬ããã£ã¦ã¾ããã¾ãããHaskellããé³æ¥½ã®ã»ãã«åã注ãã§ããæ°ããããã®é ã§ããããµã¨ããæãã¾ããââãHaskellã§ã·ã³ã»ãµã¤ã¶ã¼ãä½ããã¨ã¦ã楽ããã®ã§ã¯ãªããï¼ã ã·ã³ã»ãµã¤ã¶ã¼ã®ä»çµã¿ã¯ããã¨ãã°FMã»æ¸ç®å¼ãªããããªãã¾ã: ãããããããå®è£ åºæ¥ã¦ããã¾ãå¬ãããªããã¨ããã®ã¯ããã£ã¦ããã ããã®ã§ã¯ãªãã§ããããââããããã ã®ã·ã³ã»ãµã¤ã¶ã¼ã§ã¯ãªãã©ããªã·ã³ã»ãµã¤ã¶ã¼ã§ãä½ãããã¬ã¼ã ã¯ã¼ã¯ã欲ããã®ã§ãã é¨åãä½ãé¨åã-Artery- ã¾ããç§ã¯ãé¨åå士ããé ç·ãã§ããããã«ãããããarteryã¨ããããã±ã¼ã¸ãä½ãã¾ããã Arteryã¯Arrowã¨ãã¦ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ãæã£ã¦ãã¾ããArrowã¯ããç°¡åã«è¡¨ç¾ããã¨ã以ä¸ã®ãããªã¯ã©ã¹ã§è¡¨ç¾ããã¾ã(
ã¨ã©ãã¹ããã¹ã®ç¯©ã®åã«, éä¹ãArrowã§ããã¾ã. çç±ã¯ããããåããã¾ã. éä¹ãæ®éã« fact n = if n == 0 then 1 else n * fact (n - 1) main = print $ fact 10 3628800 æµç³ã«ããã¯ããã§ãã. ã¯ã. Arrowã«æ¥ãåã«, ã¾ãfixã使ã£ã¦æ¸ãã¾ããã. è²ã èãã¾ããã, fixãä»ãã¦Arrowã«è¡ãã®ãä¸çªè¿éã§ã. fix f = f (fix f) fact = fix fact' fact' f n = if n == 0 then 1 else n * f (n - 1) main = print $ fact 10 3628800 ãã£ãã®factã, 第ä¸å¼æ°ã§é¢æ°ãåãããã«ãã¦ããã ãã§ãã. éä¹ãArrowLoop㧠ãã¦, fixã§æ¸ããããããæã®ç©ã§ã. ã¨ããã®ã
Arrow.hsãèªããã30åã§èªããç¯å²ã ãã ãã³ãã¯30åã§Arrowã使ã£ã¦30åã§ä½ãä½ãããã£ã¦ã®ããããããã ãã©ãã¾ã ããã°ã©ã ãæ¸ããã»ã©ç解ãã¦ããªãã ãããããªãããã³ã¼ããªã¼ãã£ã³ã°ããããã ã©ãã«ããã®? http://darcs.haskell.org/packages/base/Control/ æ¹é ã¨ããããArrowã®ã¤ã³ã¹ã¿ã³ã¹ã§ãã->ã«é¢ããã³ã¼ãã ããèªããKleisli(..)ã¨doè¨æ³ã¯ç¡è¦ã é¢é£ãã¦ãããªã㤠ã¢ã¸ã¥ã¼ã«ããã¨ã¯ã¹ãã¼ãããã¦ãããã¤ã Arrow(..) ArrowChoice(..) ArrowApply(..) ArrowMonad(..) leftApp ArrowLoop(..) (>>>), (<<<) (>>>), (<<<) Arrowã¨ããã°(>>>)ã ãã©ãå®ã¯Category.hsã§å®ç¾©ããã¦ã
ã¾ãæåã«ArrowLoopã«ã¤ãã¦èª¬æãã¾ããæ°å¦çãªè©±ã¯ä¸åãã¾ãã(ã§ãã¾ãã)ã ArrowLoopã®ä»çµã¿ ArrowLoopã¨ããã¯ã©ã¹ã«ã¯loopã¨ããé¢æ°ãä¸ã¤ã ãå±ãã¦ãã¾ãããã®loopã¯Arrowããæ°ããArrowãä½ãåºãã¦ãããé¢æ°ã§ãã ã¾ãloopã«å ¥ããArrowã¯ãããªå½¢ããã¦ãã¾ãã å ¥åã2ã¤ãããåºåã2ã¤ããã¾ãããã ããArrowã¯å ¥åã¨åºåãã©ã¡ããï¼ã¤ãã¤ã§ãªããã°ãªããªãã®ã§å®éã¯ã¿ãã«ã¨ãã¦å ¥åºåãã¾ããæ¨æºã©ã¤ãã©ãªã§å®ç¾©ããã¦ããArrowLoopã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã«ã¯æ®éã®é¢æ°ã¨ãã¢ãããArrowåããKleisliã¨ããArrowãããã¾ãã ããã§ã¯ä¾ã¨ãã¦æ¬¡ã®Arrowãèãã¾ãã swap_mul = \(x, y) -> (2 * y, 3* x) å®è¡ä¾ > swap_mul (3, 4) (8,9)ç°¡åãªé¢æ°ã§ã
http://www.nicovideo.jp/watch/sm5103132 ã§ãHaskell(ã¨ãããGHC?)ã®Control.Arrowã«é¢å¿ãæã£ãã®ã§ããããããã£ã¦ã¿ãã loop ãã®1 ã¾ããç解ãé£ããloopããããªããªããã©ããArrowã使ãã¨ãã«ã¯ããããã¦ã³ã§èããªãã¨ãããåãããªããªããããªã®ã§ãããã¦ãã¨ã§åºãä¾ãããã ãã©ãç¹°ãè¿ããããä»äºã¯ä¸çªä¸ãloopã«ãªãã®ã§ãloopã«ä½ãå ¥ããã¹ããªã®ãããèãã¯ããããã¨ã«ãªãã ã¨ããããã(->)å(é¢æ°ãã®ãã®ã®å)ã®loopã®å®ç¾©ã¯æ¬¡ã®ã¨ãã: class Arrow a => ArrowLoop a where loop :: a (b,d) (c,d) -> a b c instance ArrowLoop (->) where loop f b = let (c,d) = f (b,d)
We have permission to import material from the Haskell arrows page. See the talk page for details. Arrows, like monads, express computations that happen within a context. However, they are a more general abstraction than monads, and thus allow for contexts beyond what the Monad class makes possible. The essential difference between the abstractions can be summed up thus: Just as we think of a mona
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}