> Nice, but how about a list destructor<br><br><div>I'm not sure what you mean by destructor, if you mean an eliminator for case analysis then you can make a function</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">finite :: b -> (a -> Finite s1 a -> b) -> Finite s2 a -> b</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">finite b _ (Finite []) = b</font></div><div><font class="Apple-style-span" face="'courier new', monospace">finite _ f (Finite (x:xs)) = f x xs</font></div>
<div><br></div><div>If you men functions that possibly remove elements from lists, then you can add definitions like these to the module:</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">filter = onList . Prelude.filter<br>
tail = onList Prelude.tail<br><br></font><div><font class="Apple-style-span" face="'courier new', monospace">onList :: ([a] -> [b]) -> Finite s a -> Finite s b</font></div><div><font class="Apple-style-span" face="'courier new', monospace">onList f = Finite . f . infinite</font></div>
<br>Don't export onList though! filter and map should be enough to define any list function you want outside the module.</div><div><br></div><div>Note that the size-type doesn't correspond exactly to the size of the list, but that's not really a problem as long as you only want to guarantee finiteness.<br>
<br></div><div>/J</div><div><br><div class="gmail_quote">On 13 October 2010 16:41, Stephen Tetley <span dir="ltr"><<a href="mailto:stephen.tetley@gmail.com">stephen.tetley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Jonas<br>
<br>
Nice, but how about a list destructor?<br>
<br>
;-)<br>
<div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>