<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I wonder if anyone can help me find my error, in this code:</div><div class=""><br class=""></div><div class="">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 class="">Am I, maybe, not allowed to use pattern matching, on the right side of ‘=‘?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-db</div><div class=""><br class=""></div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Menlo" size="1" class="">data Stream a = Cons a (Stream a)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">newtype StreamMap a b = SM (Stream a -> Stream b)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">instance Arrow StreamMap where</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">    pure f        = SM g</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">     where g (Cons x xs) = Cons (f x) (g xs)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">    SM f >>> SM g = SM (g . f)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">    first (SM g)  = SM h  -- h :: Stream (a, c) -> Stream (b, c)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">     where h :: Stream (a, c) -> Stream (b, c)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">           h (Cons (x, y) zs) = Cons ((f x), y) (h zs)</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">           g :: Stream a -> Stream b</font></div></div><div class=""><div class=""><font face="Menlo" size="1" class="">           g (Cons x      xs) = Cons (f x) (g xs)</font></div></div></blockquote><div class=""><div class="">           </div></div><div class=""><span style="color: rgb(255, 0, 0); font-family: monospace; font-size: 14.40000057220459px; font-style: italic; white-space: pre; background-color: rgb(255, 255, 255);" class="">Couldn't match expected type ‘b1’ with actual type ‘a’</span><br style="box-sizing: border-box; color: rgb(255, 0, 0); font-family: monospace; font-size: 14.40000057220459px; font-style: italic; white-space: pre;" class=""><span style="color: rgb(255, 0, 0); font-family: monospace; font-size: 14.40000057220459px; font-style: italic; white-space: pre; background-color: rgb(255, 255, 255);" class="">  ‘a’ is a rigid type variable bound by the type signature for g :: interactive:IHaskell152.Stream a -> interactive:IHaskell152.Stream b1 at </span><interactive style="box-sizing: border-box; color: rgb(255, 0, 0); font-family: monospace; font-size: 14.40000057220459px; font-style: italic; white-space: pre;" class="">:10:17<br style="box-sizing: border-box;" class="">  ‘b1’ is a rigid type variable bound by the type signature for g :: interactive:IHaskell152.Stream a -> interactive:IHaskell152.Stream b1 at <interactive style="box-sizing: border-box;" class="">:10:17<br style="box-sizing: border-box;" class="">Relevant bindings include<br style="box-sizing: border-box;" class="">  xs :: interactive:IHaskell152.Stream a (bound at <interactive style="box-sizing: border-box;" class="">:11:27)<br style="box-sizing: border-box;" class="">  x :: a (bound at <interactive style="box-sizing: border-box;" class="">:11:20)<br style="box-sizing: border-box;" class="">  g :: interactive:IHaskell152.Stream a -> interactive:IHaskell152.Stream b1 (bound at <interactive style="box-sizing: border-box;" class="">:11:12)<br style="box-sizing: border-box;" class="">In the first argument of ‘f’, namely ‘x’<br style="box-sizing: border-box;" class="">In the first argument of ‘IHaskell152.Cons’, namely ‘(f x)’<br style="box-sizing: border-box;" class=""></interactive></interactive></interactive></interactive></interactive></div><div class=""><br class=""></div></body></html>