[Haskell-cafe] One-element tuple

AntC anthony_clayden at clear.net.nz
Tue Aug 20 07:45:11 CEST 2013


> Mike Ledger <eleventynine <at> gmail.com> writes:
> 
> It seems to me that this is Identity given a different name. A bonus of 
using Identity is that it won't introduce any new packages to the majority 
of installations.
>
> On 20/08/2013 1:17 PM, "Ivan Lazar Miljenovic" wrote:
> ...
>  isn't a single element tuple isomorphic to just that element ...?
>

Hi Mike, and Ivan, I'm not sure you're 'getting' it.

A one-element tuple distinguishes at type level between a container vs 
contents. It's not identity/not isomorphic. Try those instances I gave.
(What's worse, `Identity` is no fewer chars than `OneTuple` ;-)

If your application is not working with tuples/"for general usage", then 
no need to "introduce any new packages". You won't want OneTuple's (or 
whatever they're called).

Since I am working with tuples, I want the code to be clear where it's 
dealing with tuples vs the Haskell type infrastructure.

Thanks Ivan for the dependencies list. No surprise that Hlist is using 
OneTuple <==> HCons a HNil. That need is exactly what I'm talking about, 
not a joke. Lennart's `tuple` package likewise (but no use to me because 
it's using positional access, not Type-Indexed).


AntC

> >
> > So if I have instances (as I do) like:
> >
> >     instance C (a, b) ...
> >     instance C ()     ...
> >
> > I can't usefully put either of these next two, because they're equiv to
> > the third:
> >
> >     instance C (( a )) ...
> >     instance C ( a )   ...
> >     instance C a       ...   -- overlaps every instance
> >
> > Similarly for patterns and expressions, the so-called superfluous 
parens
> > are just stripped away, so equivalent to the bare term.
> >






More information about the Haskell-Cafe mailing list