<div dir="ltr">Hi,<div>I think the problem is that when you give functions in where clauses type signatures, type parameters like "a" are bound by forall. So the "a" in h is a different one to in "g".</div><div>You might have more luck if you enable <span style="line-height:1.5">-XScopedTypeVariables , and give a top-level type signature explicitly binding a and b: "forall a b. Stream a -> …"</span></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 15 Aug 2016 at 13:04 David Banas <<a href="mailto:capn.freako@gmail.com">capn.freako@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all,<div><br></div><div>I wonder if anyone can help me find my error, in this code:</div><div><br></div><div>It’s note clear to me why x :: a is an error, except that maybe the type of f is not being correctly inferred?</div><div>Am I, maybe, not allowed to use pattern matching, on the right side of ‘=‘?</div><div><br></div><div>Thanks,</div><div>-db</div><div><br></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="Menlo" size="1">data Stream a = Cons a (Stream a)</font></div></div><div><div><font face="Menlo" size="1"><br></font></div></div><div><div><font face="Menlo" size="1">newtype StreamMap a b = SM (Stream a -> Stream b)</font></div></div><div><div><font face="Menlo" size="1"><br></font></div></div><div><div><font face="Menlo" size="1">instance Arrow StreamMap where</font></div></div><div><div><font face="Menlo" size="1"> pure f = SM g</font></div></div><div><div><font face="Menlo" size="1"> where g (Cons x xs) = Cons (f x) (g xs)</font></div></div><div><div><font face="Menlo" size="1"> SM f >>> SM g = SM (g . f)</font></div></div><div><div><font face="Menlo" size="1"> first (SM g) = SM h -- h :: Stream (a, c) -> Stream (b, c)</font></div></div><div><div><font face="Menlo" size="1"> where h :: Stream (a, c) -> Stream (b, c)</font></div></div><div><div><font face="Menlo" size="1"> h (Cons (x, y) zs) = Cons ((f x), y) (h zs)</font></div></div><div><div><font face="Menlo" size="1"> g :: Stream a -> Stream b</font></div></div><div><div><font face="Menlo" size="1"> g (Cons x xs) = Cons (f x) (g xs)</font></div></div></blockquote><div><div> </div></div><div><span style="color:rgb(255,0,0);font-family:monospace;font-size:14.40000057220459px;font-style:italic;white-space:pre-wrap;background-color:rgb(255,255,255)">Couldn't match expected type ‘b1’ with actual type ‘a’</span><br style="color:rgb(255,0,0);font-family:monospace;font-size:14.40000057220459px;font-style:italic;white-space:pre-wrap"><span style="color:rgb(255,0,0);font-family:monospace;font-size:14.40000057220459px;font-style:italic;white-space:pre-wrap;background-color:rgb(255,255,255)"> ‘a’ is a rigid type variable bound by the type signature for g :: interactive:IHaskell152.Stream a -> interactive:IHaskell152.Stream b1 at </span><u></u>:10:17<br> ‘b1’ is a rigid type variable bound by the type signature for g :: interactive:IHaskell152.Stream a -> interactive:IHaskell152.Stream b1 at <u></u>:10:17<br>Relevant bindings include<br> xs :: interactive:IHaskell152.Stream a (bound at <u></u>:11:27)<br> x :: a (bound at <u></u>:11:20)<br> g :: interactive:IHaskell152.Stream a -> interactive:IHaskell152.Stream b1 (bound at <u></u>:11:12)<br>In the first argument of ‘f’, namely ‘x’<br>In the first argument of ‘IHaskell152.Cons’, namely ‘(f x)’<br><u></u><u></u><u></u><u></u><u></u></div><div><br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>