From 4a366fda30d6cea8419402b2a808c138891bf783 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 21 Oct 2021 01:31:31 -0700 Subject: [PATCH] Modified some of the syntax playground --- source_files/schala/syntax_playground.schala | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/source_files/schala/syntax_playground.schala b/source_files/schala/syntax_playground.schala index b65c4f2..9123962 100644 --- a/source_files/schala/syntax_playground.schala +++ b/source_files/schala/syntax_playground.schala @@ -6,36 +6,36 @@ fn main() { } -@annotations are with @- +@annotations use the @ sigil // variable expressions - var a: I32 = 20 - const b: String = 20 + //variable declaration works like Rust + let a: I32 = 20 + let mut b: String = 20 there(); can(); be(); multiple(); statements(); per_line(); //string interpolation - const yolo = "I have ${a + b} people in my house" + // maybe + let yolo = "I have ${a + b} people in my house" - // let expressions ??? not sure if I want this + // let expressions let a = 10, b = 20, c = 30 in a + b + c //list literal - const q = [1,2,3,4] + let q = [1,2,3,4] - //lambda literal - q.map({|item| item * 100 }) + //lambda literal - uses haskell-ish syntax + q.map(\(item) { item * 100 }) fn yolo(a: MyType, b: YourType): ReturnType { if a == 20 { return "early" } - var sex = 20 - sex } - /* for/while loop topics */ +//TODO I can probably get away with having one of `for`, `while` //infinite loop while { @@ -59,7 +59,7 @@ fn main() { //monadic decomposition for { a <- maybeInt(); - s <- foo() + s <- foo() } return { a + s } //return type is Monad @@ -70,7 +70,7 @@ fn main() { /* conditionals/pattern matching */ -// "is" operator for "does this pattern match" +// `is` functions as an operator asking "does this pattern match" x is Some(t) // type bool @@ -86,7 +86,7 @@ if x { //syntax is, I guess, for , where is a bool, or a // type level alises - typealias = #maybe thsi should be 'alias'? + type alias = #maybe thsi should be 'alias'? /* what if type A = B meant that you could had to create A's with A(B), but when you used A's the interface was exactly like B's? @@ -94,12 +94,12 @@ what if type A = B meant that you could had to create A's with A(B), but when yo */ //declaring types of all stripes - type MyData = { a: i32, b: String } + type MyData = { a: i32, b: String } // shorthand special-case for `type MyData = MyData { a: i32, b: String }` type MyType = MyType type Option = None | Some(a) type Signal = Absence | SimplePresence(i32) | ComplexPresence {a: i32, b: MyCustomData} - //traits + //traits TODO I probably want to rename this trait Bashable { } trait Luggable { @@ -108,7 +108,7 @@ what if type A = B meant that you could had to create A's with A(B), but when yo } - -// lambdas -// ruby-style not rust-style -const a: X -> Y -> Z = {|x,y| } +// lambdas - maybe I want to use ruby-style (not rust style) syntax +// e.g. +// Also TODO Nix uses `X: Y: Z` for in its value-level syntax, why can't I? +let a: X -> Y -> Z = {|x,y| }