shakar
Sugar that's too sweet to be in the Nim standard library
Summary
| Latest Version | 0.1.3 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:27 |
Tags
Authors
- Trayambak Rai
Installation
nimble install shakar
choosenim install shakar
git clone https://github.com/ferus-web/shakar
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| shakar | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.0.0 | No |
| results >= | 0.5.1 | No |
Source
| Repository | https://github.com/ferus-web/shakar |
|---|---|
| Homepage | https://github.com/ferus-web/shakar |
| Registry Source | nimble_official |
README
shakar
Shakar (/ˈʃək.kəɾ/) is a library that contains a bunch of syntactic sugar for the Nim programming language. \ This package exists because a lot of these utilities apparently do not match Nim's safety guarantees (albeit it shouldn't really matter if you're paying attention). See this PR
Shakkar means "sugar" in Hindi. :^)
This library also aims to remove all the "sugar" files in all of the different Ferus projects and unify them under a single, easy-to-modify library.
basic usage
optional types
import std/options
import pkg/shakar
var nam = some("John")
assert *nam ## `*` is used to check if the optional has a value
var age = none(uint8)
assert !age ## `!` is used to check if the optional is empty
nam.applyThis:
## `applyThis` gives you a mutable `this` which is either
## the value of the optional if it has one, or the default
## value of that type (`default(T)`)
this &= " Doe"
age.applyThis:
assert this == 0 ## default initialized value since the optional is empty
this = 28
## Store `nam` into the `name` value. This operator returns true if the optional wasn't empty.
if nam ?= name:
echo "Name: " & name
if age ?= ayu:
echo "Age: " & $ayu