<div dir="ltr">Thanks, but I still don&#39;t know how to fix it.<div><br></div><div style>In the meantime, I&#39;m struggling with something more basic. I plan to write a basic monad that puts diagrams on top of each other, then I&#39;ll let State take care of pushing the origin and angle along (turtle style). But I&#39;m already stuck on that basic monad.</div>
<div style><br></div><div style>It&#39;s &gt;&gt;= has to explicitly use the fact that each monad has a journey there and a journey back. The thing on the right of &gt;&gt;= will be inserted in between them.  But I always get either &quot;something is a rigidly bound type variable&quot; or &quot;Monad should have kind * -&gt; *&quot; </div>
<div style><br></div><div style>I just don&#39;t know how this is supposed to work.</div><div style><br></div><div style>I want the monad to contain two trails, in the sense of the Diagrams module. If I bind two of them together, for the time being, I&#39;ll just stick them on top of each other (at least I think the State monad will rescue me from that.) I have no particular reason to tell the thing on the right of &gt;&gt;= about the thing on the left. Neither do I have a reason for &gt;&gt;= to be polymorphic. </div>
<div style><br></div><div style>Right now I&#39;m thinking that I&#39;ll have to define a class for things that provide a journey there and a journey back. I&#39;d rather not, because there&#39;s only one of them but I can&#39;t seem to restrict the game any other way, but this way isn&#39;t helping either.</div>
<div style><br></div><div style>Ideally I&#39;d be able to write something like this:</div><div style><br></div><div style><font face="courier new, monospace">data Sankey = Sankey {there, back :: Trail R2}</font></div><div style>
<font face="courier new, monospace"><br></font></div><div style><font face="courier new, monospace">instance Monad Sankey where</font></div><div style><font face="courier new, monospace">  return t b = Sankey t b</font></div>
<div style><font face="courier new, monospace">  l@(Sankey t b) &gt;&gt;= f = let (Sankey t&#39; b&#39;) = f l in</font></div><div style><font face="courier new, monospace">     Sankey (t &lt;&gt; t&#39;) (b &lt;&gt; b&#39;)</font></div>
<div style><font face="courier new, monospace"><br></font></div><div style>although I have no reason to pass l to f. But the compiler barfs anyway. I feel that Haskell is more complicated than what I&#39;m trying to do. Under duress I tried:</div>
<div style><br></div><div style><div><font face="courier new, monospace">class Pic a where </font></div><div><font face="courier new, monospace">  there :: a -&gt; Trail R2</font></div><div><font face="courier new, monospace">  back  :: a -&gt; Trail R2</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">data Trails p = Trails p   </font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">instance (Pic p) =&gt; Monad (Trails p) where </font></div>
<div><font face="courier new, monospace">  return = Trails </font></div><div><font face="courier new, monospace">  (Trails l) &gt;&gt;= f = let (Trails r) = f l in</font></div><div><font face="courier new, monospace">    ((there l &lt;&gt; there r),(back r &lt;&gt; back l)) </font></div>
<div><br></div></div><div style><br></div><div style>But it doesn&#39;t like that either. What am I missing?</div><div style><br></div><div style>Adrian.</div><div style><br></div><div style><br></div><div style><br></div>
<div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div><div style><br></div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On 31 May 2013 23:42, Brandon Allbery <span dir="ltr">&lt;<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="im">On Fri, May 31, 2013 at 11:06 AM, Adrian May <span dir="ltr">&lt;<a href="mailto:adrian.alexander.may@gmail.com" target="_blank">adrian.alexander.may@gmail.com</a>&gt;</span> wrote:<br></div>
<div class="gmail_extra">
<div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well I figured out that I should be using the State monad, but it seems not to be behaving like most of the tutorials on the web. Did the syntax change? ....</div>

</blockquote><div><br></div></div><div>mtl-2.x changed all the base monads (State, Reader, Writer, etc.) from standalone to being transformers atop an Identity monad; this cleans up the implementation considerably (since we don&#39;t have almost exactly the same code for both the standalone and transformer versions, but means that all uses of the standalone constructors must be replaced with functions that build the appropriate transformer. (e.g. State becomes state, unless you want to spell it out as StateT Identity.)</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>-- <br></div></font></span></div><span class="HOEnZb"><font color="#888888"><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>

<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</font></span></div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>