[Haskell-cafe] Announcing OneTuple-0.1.0

minh thu noteed at gmail.com
Thu Oct 2 16:56:43 EDT 2008

2008/10/2 John Dorsey <haskell at colquitt.org>:
> All,
> I'm bundling responses to save paper.
> ajb at spamcop.net wrote:
>> I hope it has a Monad instance.
> Naturally!
>> But more to the point: Can it send email?
> Can you give an example of a use case?  Do the Haskell-98 standard
> tuples have a correspondence feature?  I wasn't able to find one with
> Hoogle.
> Simon Brenner wrote:
>> You could always use this one-tuple instead and get Functor, Monad and
>> MonadFix for free:
> As Luke pointed out, that one seems to be too strict.  It may simplify
> the strict implementation, though.  The initial release did have Monad
> and Functor instances... I'll look into MonadFix (thanks!).
> Luke Palmer wrote:
>> Hmm, it looks like you forgot to write a Traversable instance.
> Oops... I included the instance statement but retained the default,
> mutually recursive methods.  Too bad GHC didn't warn me.  (Pesky
> halting problem.)  Your change is in 0.1.1 -- thanks!
> Benjamin L.Russell wrote:
>> Wonderful!  I'm intrigued....
> Thank you.
>> What is the syntax for the singleton tuple?  [...]  What is your
>> solution?
> Haskell has no such syntax, of course.  '(x)' is no good due to
> ambiguity with parens' usual associative use.  '(x,)' has been
> discussed, I think.  It's ugly; it's inconsistent with other tuples,
> which don't share its final comma; it looks a bit like a tuple section,
> which could cause confusion.
> My solution was to use a normal Algebraic Data Type:
>    data OneTuple a = OneTuple a
> I think the need for singleton tuples is rare enough that the
> syntactic inconsistency is tolerable.
> Jon Fairbairn suggests using unicode 0x27e8 and 0x27e0 in place of
> parentheses for tuples.  I like the idea, especially as an alternate
> syntax for the same tuple types, permitting the singleton.
> minh thu writes:
>> I thought to this idea in another way : parenthesis could be used for
>> s-expressions and [unicode 0x27e8 and 0x27e0] could be used for
>> regular grouping. This would allow to switch in the same code between
>> infix and s-expr (e.g. enabling SXML)...
> I don't think I fully understand your proposal, although it sounds
> interesting.

(It's not related to your tuple)
Here is an example, quite contrived:

With angle bracket:
f a b c d = a + (+ b ⟨c + d⟩) -- the + before the b is in prefix position

is equivalent to

Normal Haskell:
f a b c d = a + (b + (c + d))

With angle brackets, parenthesis mean "this is an s-expr" and
angle brackets mean "this is an standard (infix) expression".
In the s-expr, there is no precedence rules while they are kept in
the top level or in angle brackets.

Hope it's clearer,

More information about the Haskell-Cafe mailing list