<div dir="ltr">On Tue, Sep 13, 2011 at 00:08, Vasili I. Galchin <span dir="ltr"><<a href="mailto:vigalchin@gmail.com">vigalchin@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I am trying to model multigraphs ....but getting errors with ghci and can't figure out why.... I have a serious blind spot ....<br></blockquote><div><br></div><div>Why do you need to use classes for this? (Note: forget everything you know about classes from OOP. Haskell typeclasses have approximately nothing to do with OOP.)</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">junk1.hs:19:12:<br> Constructor `Arrow' should have 1 argument, but has been given 0<br> In the pattern: Arrow<br>
In the definition of `source': source Arrow = fst Arrow<br>
In the instance declaration for `Graph Arrow Int'<br></blockquote><div><br></div><div>It's asking "Arrow *what*?" You specified Arrow as taking a tuple argument; if you want to use it here, you need to provide that argument (or a placeholder, but in this case you clearly want the tuple).</div>
<div><br></div><div>> source (Arrow p) = fst p</div><div>> target (Arrow p) = snd p</div><div><br></div><div>Or you can use pattern matching to deconstruct the tuple as well:</div><div><br></div><div>> source (Arrow (f,_)) = f</div>
</div><div>> target (Arrow (_,t)) = t</div><div><br></div>-- <br>brandon s allbery <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a><br>wandering unix systems administrator (available) (412) 475-9364 vm/sms<br>
<br>
</div>