AI prompts
base on 🍭 A sweet, functional programming language that is robust, minimalistic, and expressive. # 🍭 Candy
> **🚧 Work in Progress!**
>
> Candy is still in its early stages.
> We are actively working on it, but it's not ready for production use yet.
> If you want to help, please join our [Discord server].
> See also: [The current state](#the-current-state).
A sweet, functional programming language that is robust, minimalistic, and expressive.
Many programming languages have a strict separation between compile-time and runtime errors.
Sometimes, this border can seem arbitrary:
Dividing by a string fails during compilation with a type error, while dividing by zero only fails during runtime.
In the mathematical sense, there's no fundamental difference between these cases – division is only defined for divisors that are non-zero numbers.
That's why we eliminate the border between compile-time and runtime errors – all errors are runtime errors.
By crafting high-quality tooling with dynamic analyses such as fuzzing, we try to still be able to show most errors while you're editing the code.
In fact, we try to show more errors than typical statically typed languages.
![Candy in VS Code](screenshot.png)
## Quick introduction
- **Values are at the center of your computations.**
Only a handful of predefined types of values exist:
```candy
3 # int
"Candy" # text
Green # tag (uppercase)
Error ListIsEmpty # tag with a value
(Foo, Bar) # list
[Name: "Candy"] # struct
{ it -> add it 2 } # function
```
- **Minimalistic syntax.**
Defining variables and functions works without braces or keywords cluttering up your code.
The syntax is indentation-aware.
```candy
# I'm a comment
foo = 42 # variable (lowercase)
println message = # function
print message # function call
print "\n"
println "Hello, world!"
```
- **Extensive compile-time evaluation.**
Many values can already be computed at compile-time.
In your editor, you'll see the results on the right side:
```candy
foo = double 2 # foo = 4
```
- **Fuzzing instead of traditional types.**
In Candy, functions have to specify their needs _exactly._
As you type, the tooling automatically tests your code with many inputs to see if one breaks the code:
```candy
foo a = # If you pass a = 0,
needs (isInt a)
math.logarithm a # then this panics: The `input` must be a positive number.
efficientTextReverse text =
needs (isText text)
needs (isPalindrome text) "Only palindromes can be efficiently reversed."
text
greetBackwards name = # If you pass name = "Test",
"Hello, {efficientTextReverse name}" # then this panics: Only palindromes can be efficiently reversed.
```
For more info, read:
- Marcel's blog post about Candy: https://marcelgarus.dev/candy
- the [language documentation](language.md)
- Marcel's blog post about Candy's compiler pipeline: https://marcelgarus.dev/candy-compiler-pipeline
## The current state
We are currently implementing a first version of Candy in Rust.
We already have a CLI, language server, and Visual Studio Code extension that provide some tooling.
The language is still in its early stages, and we are actively working on it.
There are still compiler bugs and performance improvements that need work before this language is ready for production use.
## Discussion
[Join our <img height="12" src="https://github.com/candy-lang/candy/assets/19330937/baf90ce0-1d0a-4279-92fa-1c360cd28b38"> Discord server.][Discord server]
## How to use Candy
1. Install [<img height="16" src="https://rust-lang.org/static/images/favicon.svg"> Rust](https://rust-lang.org): [rust-lang.org/tools/install](https://rust-lang.org/tools/install) (use Rustup since we use nightly features).
- Alternatively, use the provided [<img height="16" src="https://nixos.org/_astro/flake-blue.Bf2X2kC4_Z1yqDoT.svg"> Nix](https://nixos.org/) flake to install all required dependencies.
2. Clone this repo.
Then, you can use Candy in two ways:
### Use the VS Code Extension
1. Install [<img height="16" src="https://code.visualstudio.com/favicon.ico"> Visual Studio Code (VS Code)](https://code.visualstudio.com): [code.visualstudio.com/download](https://code.visualstudio.com/download).
2. Open the workspace (`compiler.code-workspace`) in VS Code.
3. Install the recommended VS Code extensions.
4. Run `npm install` inside `vscode_extension/`.
5. Run the launch config “Run Extension (VS Code Extension)”.
6. In the new VS Code window that opens, you can enjoy 🍭 Candy :)
If you are working on the Rust code itself, you might want to disable release mode for quicker compilation:
In `packages/candy.code-workspace`, in the `candy.languageServerCommand` setting, remove `--release`.
(But don't commit that change.)
### Use the CLI
From the root of this repository, you can run the Candy CLI by starting the Candy commands with `cargo run --release --`:
```sh
# Run a Candy file:
cargo run --release -- run ./packages/Examples/helloWorld.candy
# View all available commands:
cargo run --release -- help
```
(Everything after `--` is passed to Candy, everything before it to Cargo.)
## Environment Variables for Debugging the Compiler
```sh
# Don't normalize IDs (number them sequentially) after optimizing the MIR.
CANDY_MIR_NORMALIZE_IDS=false
# Generate a _large_ Markdown file that lists every single optimization step
# performed on the MIR.
CANDY_MIR_OPTIMIZATION_LOG=target/optimization-log.md
```
[Discord server]: https://discord.gg/5Vr4eAJ7gU
", Assign "at most 3 tags" to the expected json: {"id":"8104","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"