Syntax  

Syntax sketch

Incomplete list of open issues

  • Do we need to use 'a 'b 'c for type variables like ML or can we design the grammar in a way so that type variables can be clearly discriminated from other identifiers.
  • Should we require capital letters at the beginning of type names or can we be flexible here too?
  • I think the most usable thing is what C# has done--uniform restrictions on type names, type variable names, or other identifiers, and lowercase aliases for the most common types like int, bool, and double.

Namespaces

namespace Foo.Bar.Baz
... proceeds to end of file

or

namespace Foo.Bar.Baz
    ... proceeds to end of indent

Declarations

Modules

module Foo
    [extends Constructor arg arg] 
    [with Trait]
    ... proceeds to end of indent

or

module Foo
    [extends Constructor arg arg] 
    [with Trait]
... proceeds to end of file

Types

All type declarations can be preceded with access modifiers:

  • public - globally visible
  • private - lexically scoped
  • internal - scoped to the nearest enclosing module
  • internal(modulename) - TODO: ??? fine grained scoping ???
// 
// Simple tagged union
//
variant Result = Success 'A
               | NetworkError
               | UnknownError

//
// GADT
//
variant Result = Success      : 'A -> Result 'A
               | NetworkError : Result _
               | UnknownError : Result _

//
// Record type
//
record Point : [RecordType]+
    def X : int
    def Y : int

//
// Transparent aliases
//
alias MyPoint    = Point
alias TuplePoint = (int,int)

//
// Class
//
class Foo arg arg : [Constructor arg arg]
    [with Trait]+
    [where constraint]

//
// Trait
//
trait Stream 'A
    [with Trait]
    [where constraint]

Concepts (typeclasses)

abstract concept Comparison 'A
    def cmp  (a:'A) (b:'A)

concept Comparison_Int : Comparison Int
    def cmp (a:'A) (b:'A) = a - b
 

Member values

These also support access controls.

def do_it (x:int) y(int) 
    ...
def x = 4

Simple bindings

These are always lexically scoped

var  x = 4
let  x = 4
lazy x = fib 4
Comments powered by Disqus