Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucassouzamatos/chico.lang
:sparkles: :smiley_cat: a functional toy language
https://github.com/lucassouzamatos/chico.lang
erlang programming-language
Last synced: about 2 months ago
JSON representation
:sparkles: :smiley_cat: a functional toy language
- Host: GitHub
- URL: https://github.com/lucassouzamatos/chico.lang
- Owner: lucassouzamatos
- License: mit
- Archived: true
- Created: 2022-01-04T20:15:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-23T12:36:27.000Z (over 1 year ago)
- Last Synced: 2024-02-17T09:35:01.540Z (7 months ago)
- Topics: erlang, programming-language
- Language: Erlang
- Homepage:
- Size: 233 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a _toy_ functional language. **It is only an experiment. You can't use in production _yet_**.
## Overview
Using the shell, you can do basic operations, like this:```
$ chico> let a = 12
$ 12
$ chico> apply + a 1 done
$ 13
```Or create and use functions:
```
$ chico> fun T () -> 1 done done
$ #Fun
$ chico> apply T done
$ 1
```## Sections
- [Getting started](#getting-started)
- [Documentation](#documentation)
- [Comments](#comments)
- [Variable declarations](#variable-declarations)
- [Applications](#applications)
- [Function declarations](#function-declarations)## Getting started
First step for start is clone the project:
```
$ git clone https://github.com/lucassouzamatos/chico.lang.git
```After this, you should compile files:
```
$ make
```And install with:
```
$ make install
```In the next, you can compile single files or entire folder with:
```
$ chico --compile
```## Documentation
Below it's possible see some examples about features enabled in the lang.
### Comments
All lines with `#` in the start are considered a comment.
```
# The let specified is for a test
let T = 1
```### Variable declarations
The variables are declared as described in the example, and allow only integers and floats:
```
let A = 1
let B = 1.425
```### Applications
The `apply` term is used for call any function or operator:
```
let A = 12apply + 1 A done
```### Function declarations
The functions not has return expression declared, then the last expression is the return from the function.
```
fun sum(A B) ->
apply + A B done
done
```If you wanna return a closure function, you can return an another function directly:
```
fun builder(Self) ->
fun (N) ->
match N with
(1) -> 1 done
(_) ->
let X = apply - N 1 done
let Y = apply Self X doneapply * N Y done
done
done
done
```When you need export any function for uses in another codes, you can only:
```
# Filename: random.chicofun test () ->
1 done
doneexport test
```And import in another files, with just:
```
fun start () ->
apply random.test done
done
```