Hi Stephen,<br><br>I&#39;m not sure I see the problem. You can do what you require with the function i supplied (minus the typo). This is in the module (where the Finite constructor is exposed)<br><br><span style="font-family: courier new,monospace;">finite :: b -&gt; (a -&gt; Finite s a -&gt; b) -&gt; Finite s a -&gt; b</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">finite b _ (Finite [])     = b</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">finite _ f (Finite (x:xs)) = f x (Finite xs)</span><br>
<br>Then viewl can be defined anywhere,<br><br><span style="font-family: courier new,monospace;">viewl :: Finite s a -&gt; Either () (a, Finite s a)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">viewl = finite (Left ()) (Right . (,))</span><br>
<br>Why would you ever decrease the Peano numbers? It&#39;s just an upper bound, not an exact size.<br><br>/J<br><br>2010/10/13 Stephen Tetley &lt;<a href="mailto:stephen.tetley@gmail.com">stephen.tetley@gmail.com</a>&gt;:<br>
&gt; Hi Jonas<br>&gt;<br>&gt; Thanks - I was meaning an equivalent to viewl on Data.Sequence, on plain lists:<br>&gt;<br>&gt; viewl :: [a] -&gt; Either () (a,[a])<br>&gt; viewl []     = Left ()<br>&gt; viewl (x:xs) = Right (x,xs)<br>
&gt;<br>&gt;<br>&gt; It was a trick question because I can&#39;t see how you can do it without<br>&gt; decrement on the Peano numbers.<br>&gt;<br>&gt; Best wishes<br>&gt;<br>&gt; Stephen<br>&gt;<br><br>