Releases: pixilcode/tego-lang
Releases · pixilcode/tego-lang
v0.5.0
v0.4.3
Added
- Commands
- Also known as IO Monads
doexpressions- Used to chain together commands
do <expr> in <match> then <expr>- Performs the Command resulting from the first expression
- Uses match pattern to assign result
- Performs the Command resulting from the second expression
- Both expressions must evaluate to a Command
in <match>is optional- If skipped,
_is used as the match pattern
- Internal functions
- Internal functions are functions built in to the compiler
- Helps with constructing Commands
- Prelude
- Contains predefined functions
return acreates a Command froma(type:a -> Command a)println aprints outa, then prints a line (type:a -> Command ())readLinereads a line from standard input (Command) (type:Command String)readIntreads an integer from standard input (not perfect yet) (type:Command Int)
.operator- Applies the first operand to the second operand
a . b===b a1 . id==id 11 . const 2==const 2 1- For more details, see
tego/feature-tests/dotOperator.tgo
Charcomparison<,>,<=,>=work withChars
Fixed
- Matching on
()actually matches on()- The following code didn't work as expected
foo t = match t to | head, () -> head | head, tail -> head + 1, foo tail - The first match (
head, ()) would always match - In a regular value
(head, ()) == head - Match patterns were originally treated the same way
- Therefore, the match
head, ()would be treated ashead headis an identifier pattern, which would catch all values- Now,
()actually matches()
- The following code didn't work as expected
v0.4.2
Added
- Differentiation between string and generic tuple storage
- Strings are now stored as strings for as long as they only contain characters
- Helps to conserve space and utilize the internal string representation
Charjoined withCharresults in a String
CharandStringvalue pattern matching'a'matches the character'a'"string"matches the string"string"
- Positive integers can be used to index a tuple
- Tuples are 0-indexed
- Trying to access past the end results in
() 0 (1, true, 'a') == 11 (1, true, 'a') == true2 (1, true, 'a') == 'a'3 (1, true, 'a') == ()
- Boxed values
[and]can be used to create boxed values (ex.[1, 2])- Boxed values are treated as a single value in tuple matching
[and]can also be used to match boxed values- The
,,operator flat joins tuples (it unwraps one layer of boxed values) - Strings are boxed tuples
- To access the character tuple, unbox the string
- For more details, see 'feature-tests/boxedTuple.tgo'
Fixed
- A non-tuple value joined with
()now evaluates to that same value- Previously, the above action would produce a single-value tuple, which doesn't make sense
- An identifier starting with a keyword (ex.
matchStr) isn't parsed as a keyword- Previously, the above identifier would be parsed as
matchStr
- Previously, the above identifier would be parsed as
v0.4.1
Added
- Support for comments
--starts a single line comment{-and-}wrap a multi-line comment
- Improved parsing errors, so the user actually understands what went wrong
Changed
:option removed from if expressions- Only
if ... then ... else ...andif ... ? ... else ...are allowed now
- Only
Fixed
- A match expression declaration couldn't be followed by any code
-
foo a = match a to | () -> () | h, t -> foo t bar b = ... - The above code produced a 'missing newline' error
- Now, it works
- Error came from having an optional newline after the match arm, which consumed all whitespace up to the next token; then, at the end of the declaration, a newline was expected, but all newlines had already been consumed
-
v0.4.0
Added
Chartype- Syntax:
'c'
- Syntax:
Stringtype- Syntax:
"this is string" - Represented as a tuple of chars
"abc" : (Char, Char, Char)- Therefore, can be concatenated using the
,operator
- Syntax:
Changed
- Using a tuple match pattern works differently
- Any unfilled spaces in tuples are filled with unit (
()) - Matching
a, b, cto1results ina = 1,b = (), andc = () - Matching
a, b, cto1, 2results ina = 1,b = 2, andc = () - Previously, the above two would produce errors
- This feature allows for optional parameters and more (more on this later)
- Any unfilled spaces in tuples are filled with unit (
Fixed
- Optional newline wasn't allowed after the equal sign in a declaration
- Subtraction error caused by trying to print out empty tuple/type of empty tuple
- When printing a tuple or the type of a tuple, an extra
,was added on the end - This was solved by removing the last two characters of the string
- However, when the tuple was empty, an empty string was returned
- Therefore, the length of the string was 0 (usize)
- Subtracting
2from unsized0led to an overflow - Added guard around this subtraction
- When printing a tuple or the type of a tuple, an extra
v0.3.2
v0.3.1
Added
- Delay expressions
- Delay the evaluation of an expression until later
delay <ident> = <expr> in <expr>- Only accepts identifiers, no other match expressions
- Expression is evaluated when the variable is used
Changed
- Declarations are not evaluated until needed
- Any declarations referencing future declarations now work
- Checks made for keywords are now done in identifier parser
- Identifier parser fails if the identifier is a keyword
Release of v0.3.0: Age of Declarations
Added
- Pattern-matching over values
- Can now match integers and bools
let 1 = 1 in ...let true = true in ...
- Pattern-match catch-all/ignore
_pattern discards the valuelet _ = 1 in ...- Useful in match expressions
- Match expression
- Syntax:
match <expr> to | <match> -> <expr> | <match> -> <expr> | ...
- Syntax:
- Expression Declarations
<ident> <match>* = <expr>- Defines
<ident>before expression is evaluated - Currently, declarations are evaluated in order; that will change
- If there are any match expressions,
<ident>will be treated as a function - Declarations can be used in the REPL
- (Soon to come, file read and evaluate)
Changed
- Unit (
()) is now (completely) a zero-element tuple instead of a first-class type - While it was changed in some places so that it functioned like that, the vestigal parts of code were completely removed
v0.2.1
Added
- Pattern-matching over tuples
let a, b = 1, 2 in ...- Parentheses in matching and/or expression are optional
let (a, b) = 1, 2 in ...let a, b = (1, 2) in ...let (a, b) = (1, 2) in ...
- Note that grouping doesn't create tuples in tuples
a, (b, c)==(a, b), c==a, b, c
- Lambda function expressions
fn <match> -> <expr>- Lambda functions can only take 1 argument
- Function application
- Arguments can now be applied to functions to get results
(fn a -> a + 1) 1==2 : Int(fn a, b -> a + b) (1 , 2)==3 : Int- Function application has high precedence
fn a -> a 1is a function that takes a function as an argument and applies 1 as an argument; it can be read asfn a -> (a 1)(fn a, b -> a + b) 1, 2is an error because the argument, which is only1, can't be unwrapped into a tuple; it can be read as((fn a, b -> a + b) 1), 2
v0.2.0
Added
- If expression
if <expr> then <expr> else <expr>if <expr> ? <expr> : <expr>
- Let expression
let <match> = <expr> in <expr>
- Variables in interpreter
- Match expressions
- Currently only implemented for a simple identifier
- Identifiers are composed only of the alphabet (a-z, A-Z)
- Plan is to add other destructuring identifiers
Removed
- Type checker
- Type checker was getting complicated to maintain
- Also, it wasn't being used in the actual project
- In the future, the goal is to make type inference
- New line allowance before tokens
- New lines will be used to signify the end of an expression
- Therefore, can't allow code such as
3 + 2