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

M Farkas-Dyck strake888 at gmail.com
Thu Jul 30 15:31:42 UTC 2015


On 30/07/2015 at 17:00:54 +0200, Silvio Frischknecht wrote:
> You have a library that has errors.
> 
> Error1, .. ErrorN.
> 
> Currently there are only two ways of making a function that can throw
> Error3 and Error8.
> 
> Use 'Dynamic' typed Exceptions or make a general Error type that is the
> sum of all Errors. In both cases it is not clear from the type of the
> function what Errors can occur.
> 
> With sumTuples you could just return (Result|Error3|Error8).

I doubt whether this would work so well for errors, as I think we would want to be able to combine the values of fallible terms such as to combine the possible errors associatively and commutatively, and these sum tuples would not. The non-associativity of product tuples sometimes bites me already in other use cases.

That said, I sometimes thought this myself, tho with other syntax: (a;b;c)


More information about the Haskell-Cafe mailing list