[Haskell-cafe] Showing the 1 element tuple
Dan Weston
westondan at imageworks.com
Fri Dec 22 14:13:50 EST 2006
More generally, is there an operator version of dotted pair notation
(gasp, did I just lisp?) that works like:
data Tuple a b = () | Tuple a b
() == ()
( ) 1 == Tuple 1 ()
(2,'a',"hello") == Tuple 2 (Tuple 'a' (Tuple "hello" ()))
And is there anyway in Haskell to restrict the type definition above to
require that b be a type that can be constructed (possibly recursively)
with only () or Tuple, so the user doesn't do something stupid like
Tuple 1 'a', which is not a valid dotted pair?
Dan
John Meacham wrote:
> have it be
> ( ) 1
>
> with a space between the parens to denote that it is a single tuple
> rather than a nullary one.
>
> John
More information about the Haskell-Cafe
mailing list