[Haskell-cafe] One-element tuple

Brent Yorgey byorgey at seas.upenn.edu
Fri Aug 16 16:56:49 CEST 2013


On Fri, Aug 16, 2013 at 01:35:22AM +0000, AntC wrote:
> There's an annoying inconsistency:
> 
>     (CustId 47, CustName "Fred", Gender Male)  -- threeple
>     (CustId 47, CustName "Fred)                -- twople
> --  (CustId 47)                                -- oneple not!
>     ()                                         -- nople
> 
> (That is, it's annoying if you're trying to make typeclass instances for 
> extensible/contractable tuples. Yes, I know I could use HLists.)
> 
> I'm not happy with either approach I've tried:
> 
>     data Oneple a = Oneple a                   -- (or newtype)
>     (Oneple $ CustId 47)                       -- too verbose
> 
>     type Oneple a = [a]
>     [CustId 47]                  -- at least looks bracket-y
> 
> What do you do?

This is what the OneTuple package is for:

  http://hackage.haskell.org/package/OneTuple

-Brent




More information about the Haskell-Cafe mailing list