<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p>`return` is the initial value. So, `replicate x oveKnignt)` is a
list of functions. `foldr` folds them with initial value `return`
with the `<=<` between them: functions are folding with
(<=<). First folding value is `return` function. You can
check the types with :t something in the GHCi.</p>
<p>Result of folding is flow of functions or long functions circuit.
`return start` is the same as to pass `start` to this functions
circuit:</p>
<blockquote><tt>inMany x start = foldr (<=<) return (replicate
x oveKnight) $ start</tt></blockquote>
<p>Idea seems, to make from [KnighPos -> [KnighPos]] functions
list one function: KnighPos -> [KnighPos] performing those
functions step by step (<=<) and to pass `start` to it. Due
to `<=<` joining of functions is not "do", but "do for
each...", because <=< is in the list monad. Something like:</p>
<blockquote><tt>for x in f-last start:</tt><br>
<tt> for y in f-prelast x:</tt><br>
<tt> ...</tt><br>
</blockquote>
You can look at these types:<br>
<blockquote><tt>:t foldr</tt><br>
<tt>foldr :: Foldable t => (a -> b -> b) -> b -> t
a -> b</tt><br>
<tt> :t (<=<)</tt><br>
<tt>(<=<) :: Monad m => (b -> m c) -> (a -> m b)
-> a -> m c</tt><br>
</blockquote>
<br>
<br>
<div class="moz-cite-prefix">26.07.2018 04:44, Olumide wrotes:<br>
</div>
<blockquote type="cite"
cite="mid:8d3be724-8f53-0bdb-339f-b713140ae673@web.de">Dear List,
<br>
<br>
Chapter 13 of LYAH
(<a class="moz-txt-link-freetext" href="http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions">http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions</a>)
has the following code block
<br>
<br>
import Data.List
<br>
<br>
inMany :: Int -> KnightPos -> [KnightPos]
<br>
inMany x start = return start >>= foldr (<=<) return
(replicate x oveKnight)
<br>
<br>
What I'd like to know is where the accumulator of foldr is in this
example.
<br>
<br>
Regards,
<br>
<br>
- Olumide
<br>
<br>
<br>
<br>
<br>
_______________________________________________
<br>
Beginners mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
<br>
</blockquote>
<br>
</body>
</html>