Yes, I wish Haskell had a 1-tuple. The obvious syntax is already taken, but I could accept something different, like 'One a'.<br><br><div class="gmail_quote">On Mon, Mar 10, 2008 at 11:17 PM, Dan Weston <<a href="mailto:westondan@imageworks.com">westondan@imageworks.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I understand the lack of distinction between a unit type and a 0-tuple,<br>
since they are isomorphic. But it is strange that there is no 1-tuple,<br>
since _|_ and the 1-tuple (_|_) would be different things entirely, no?<br>
<br>
Dan<br>
<div class="Ih2E3d"><br>
Rodrigo Queiro wrote:<br>
> You're looking for mapM_<br>
> mapM_ :: (Monad m) => (a -> m b) -> [a] -> m ()<br>
> (see also sequence_ :: (Monad m) => [m a] -> m () )<br>
><br>
> I don't think that it is possible to have a 1-tuples, just 2 and up. ()<br>
> is a unit rather than a 0-tuple, apparently:<br>
> <a href="http://www.haskell.org/onlinereport/basic.html#sect6.1.4" target="_blank">http://www.haskell.org/onlinereport/basic.html#sect6.1.4</a><br>
><br>
> On 10/03/2008, *Paulo J. Matos* <<a href="mailto:pocm@soton.ac.uk">pocm@soton.ac.uk</a><br>
</div><div class="Ih2E3d">> <mailto:<a href="mailto:pocm@soton.ac.uk">pocm@soton.ac.uk</a>>> wrote:<br>
><br>
> Hello all,<br>
><br>
> I find it funny that IO () is different from IO [()].<br>
> For example, if I define a function to output some lines with mapT,<br>
> I would do:<br>
> outputLines :: Int -> IO ()<br>
> outputLines i = mapM (putStrLn . show) (take i $ iterate ((+) 1) 1)<br>
><br>
> However, this is in fact<br>
> outputLines :: Int -> IO [()]<br>
><br>
> I would like to know if in fact there's any difference in practice<br>
> between (), [()], i.e. if in practice the difference matters.<br>
> My first guess is that this is just a consequence of the Haskell type<br>
> system and so that everything fits this really needs to be like this.<br>
> Because<br>
> mapM :: (Monad m) => (a -> m b) -> [a] -> m [b]<br>
><br>
> So I guess that it makes sense that you get IO [()] instead of IO (),<br>
> and adding an exception just to say that [()] == () isn't good.<br>
> By the way, as a consequence can you possibly get IO (()) or IO ([()])<br>
> and are these all different from each other?<br>
><br>
> Cheers,<br>
><br>
> --<br>
</div>> Paulo Jorge Matos - pocm at <a href="http://soton.ac.uk" target="_blank">soton.ac.uk</a> <<a href="http://soton.ac.uk" target="_blank">http://soton.ac.uk</a>><br>
<div class="Ih2E3d">> <a href="http://www.personal.soton.ac.uk/pocm" target="_blank">http://www.personal.soton.ac.uk/pocm</a><br>
> PhD Student @ ECS<br>
> University of Southampton, UK<br>
> Sponsor ECS runners - Action against Hunger:<br>
> <a href="http://www.justgiving.com/ecsrunslikethewind" target="_blank">http://www.justgiving.com/ecsrunslikethewind</a><br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
</div>> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a> <mailto:<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>><br>
<div class="Ih2E3d">> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
><br>
><br>
><br>
</div>> ------------------------------------------------------------------------<br>
<div><div></div><div class="Wj3C7c">><br>
> _______________________________________________<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>
<br>
<br>
_______________________________________________<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>