[Haskell-cafe] One-element tuple
eleventynine at gmail.com
Tue Aug 20 06:32:09 CEST 2013
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
On 20/08/2013 1:17 PM, "Ivan Lazar Miljenovic" <ivan.miljenovic at gmail.com>
> On 20 August 2013 11:07, AntC <anthony_clayden at clear.net.nz> wrote:
> >> Daniel F <difrumin <at> gmail.com> writes:
> >> Can you please elaborate why this inconsistency is annoying and what's
> > the use of OneTuple?
> >> Genuine question,
> > Hi Daniel, the main annoyance is the verbosity (of using a data type and
> > constructor), and that it no longer looks like a tuple.
> > The inconsistency is because a one-element tuple is just as cromulent as
> > n-element, or a zero-element. (And that a one-element tuple is a distinct
> > type from the element on its own/un-tupled.)
> Why is it as "cromulent" (especially as I'm not so sure we could
> really consider () to be merely a zero-element tuple)?
> I can see what you're trying to do here, but for general usage isn't a
> single element tuple isomorphic to just that element (which is what
> newtypes are for if you need that distinction)?
> > 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.
> > The use of OneTuple is that it comes with all Prelude instances pre-
> > declared (just like all other tuple constructors). I don't see that it
> > an advantage over declaring your own data type(?) I'd also be interested
> > to know who is using it, and why.
> As far as I'm aware, it's just a joke package, but two packages
> dealing with tuples seem to use it:
> > What I'm doing is building Type-Indexed Tuples  mentioned in HList
> > as an approach to extensible records , on the model of Trex  -- all
> > of which acknowledge one-element records/rows/tuples. And then I'm using
> > the tuples as a platform for relational algebra  with natural Join
> > ideas from Tropashko's 'Relational Lattice' ).
> > Is there anybody using OneTuple 'in anger'?
> > AntC
> >  M. Shields and E.Meijer. Type-indexed rows. In Proceedings
> > of the 28th ACM SIGPLAN-SIGACT symposium on Principles
> > of Programming Languages, pages 261–275. ACMPress, 2001.
> >  http://hackage.haskell.org/package/HList
> >  http://www.haskell.org/haskellwiki/Extensible_record
> >  http://web.cecs.pdx.edu/~mpj/pubs/polyrec.html
> >  http://en.wikipedia.org/wiki/Relational_algebra#Natural_join_
> >  http://vadimtropashko.wordpress.com/relational-lattice/
> >> On Fri, Aug 16, 2013 at 5:35 AM, AntC <anthony_clayden <at>
> > clear.net.nz> wrote:
> >> There's an annoying inconsistency:
> >> (CustId 47, CustName "Fred", Gender Male) -- threeple
> >> (CustId 47, CustName "Fred) -- twople
> >> -- (CustId 47) -- oneple not!
> >> () -- nople
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe