Open wongjiahau opened 5 years ago
[ | 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) ]