0
$\begingroup$

On this page describing the precursor to the Scala language - the pizza language - they refer to it having both case classes and pattern matching - and then imply that these taken together provide algebraic types.

Is this the case? To provide algebraic types - do you combine case classes and pattern matching?

$\endgroup$
0
$\begingroup$

Scala provides algebraic types and pattern matching in a way that is compatible with classes, but this is not what algebraic types are – it is Scala's realisation of the concept. Technically, pattern matching is not even needed for algebraic types; it just makes them must more convenient to use. One could instead use functions the pull apart the types. Early scheme's approach to ADTs would do just this.

$\endgroup$
  • $\begingroup$ Thanks @Dave - could you provide a link to Early Scheme's approach to ADTs? $\endgroup$ – hawkeye Dec 7 '13 at 10:49
  • $\begingroup$ All I meant by the comment about early Scheme is that it didn't have pattern matching, but you could still construct ADTs. $\endgroup$ – Dave Clarke Dec 7 '13 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.