Skip to content

Major syntax rework #70

Description

@wongjiahau
[

| 123 

// tagged union
| Shape = (
	choice 
		Circle(# radius(Float))
		Square(# side(Float))
		Rectangle(# width(Float).height(Float))
)

// object alias
| Person = (# name(String).age(Float))

// object constsruction
| p = (Person name("Wong").age(123.0))

| p name

| Shape Rectangle(# width(12.0).height(14.0)) area

// case matching
| (Shape s) area = (
	s
		if(_ Circle(c)) then
			(c radius square *(3.14))
		
		if(_ Square(s)) then 
			(s side square)
			
		if(_ Rectangle(r)) then 
			(r width *(r height))
)


// Mono func
| (Int n) square -> (Int) = (n ^(2))

// 2-arg-func 
| (Int x) plus(Int y) = (x +(y))

// 3-arg-func 
| (Knight k) attack(Monster m).with(Weapon w) = (undefined) 

// 4-arg func
| [|A Type] => (List of(A) xs) replace(Int startIndex).to(Int endIndex).with(A value) ->(List of(A)) = (undefined)

]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions