sergiotaborda / lense-lang

The Lense Language Compiler
1 stars 0 forks source link

Sum Types and Enums #26

Open sergiotaborda opened 8 years ago

sergiotaborda commented 8 years ago

Sum types allow for declarative specification of which sub classes are permited Example

abstract class Maybe is Some , None {} case class Some extends Maybe {} case object none extends Maybe{}

This is related to enums if we distinguish between classes and objects. Example

class Boolean is true , false {}

The compiler will automatically understand options are objects if no class with that name is defined

Syntax should be refined and maybe allow for inner class definition. The Maybe class is a good use case for this feature.