[Haskell-cafe] Why is the no tuple syntax for sum types

Silvio Frischknecht silvio.frischi at gmail.com
Wed Aug 5 09:13:17 UTC 2015

@Scott Turner
This actually works surprisingly well with Either

showError :: (Result `Either` Error3 `Either` Error) -> String
showError = `mapSum3`
    (result -> "no error"
    ,error3 -> "error3: " ++ show error3
    ,error3 -> "error8: " ++ show error8

mapSum3 :: (x `Either` y `Either` z) -> (x->a,y->a,z->a) -> a

But sum tuples would look cooler still :)

> I'm a little puzzled by all of this, having learned ML before there
> was such a thing as Standard ML. Anonymous sums, with inl, inr, outl,
> outr and so on are one thing I was very happy to see the back of. 
> This sudden enthusiasm for them strikes me as being like a sudden
> enthusiasm for punched cards, paper tape, or PL/I.

Either (and to some lesser extent Maybe) are an anonymous sum type and
it is used all the time. I'm just saying it does not have the ideal syntax.

P.S. The (a||) really conflicts with operators but (a;;) might actually
still be possible.

More information about the Haskell-Cafe mailing list