[Haskell-cafe] Musings on type systems

Ketil Malde ketil at malde.org
Sat Nov 20 06:33:28 EST 2010


Andrew Coppin <andrewcoppin at btinternet.com> writes:

> Now here's an interesting thought. Haskell has "algebraic data
> types". "Algebraic" because they are sum types of product types (or,
> equivilently, product types of sum types). Now I don't actually know
> what those terms mean,

The quick rule to remember this that the size of the resulting types
correspond to the arithmetic names.  I.e.

 data Sum a b = A a | B b -- values = values in a + values in b
 data Prod a b = P a b    -- values = values in a * values in b

I guess this makes [X] an exponential type, although I don't remember
seeing that term :-)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list