Coder Social home page Coder Social logo

cacco's Introduction

cacco

cacco
Important
Cacco is still in the design stage. It’s not working yet.

Introduction

Comment

;; This is inline comment (to the end of the line).

(; (1)
  This is block comment.
  block comment is keeping until the terminator -> ;) ;; (2)

(;
  (; These block comments can be nested. ;)
;)
  1. (; is the start of block comment

  2. ;) is the end of block comment

Literals

0     ;; Fuzzy Numeric.  (default: Natural)
-1 +1 ;; Fuzzy Integer.  (default: Integer)
0.0   ;; Fuzzy Decimal.  (default: Decimal)
1/2   ;; Rational.
'a'   ;; Character.      (same as Uint32)
""    ;; Fuzzy Text.     (default: String_UTF8)
:key  ;; Keyword.
[]    ;; Fuzzy Sequence. (default: List)
{}    ;; Key-Value Map.
Fuzzy Types Include Types

Fuzzy-Numeric

Uint8, Uint16, Uint32, Uint64, Natural, and Fuzzy-Integer

Fuzzy-Integer

Int8, Int16, Int32, Int64, Integer, and Fuzzy-Decimal

Fuzzy-Decimal

Float16, Float32, Float64, Flonum

Fuzzy-Text

Bytes, String-UTF8, String-UTF16, String-UTF32

Fuzzy-Sequence

List, Vector, Array, Sequence

Declaration and Reassign

;; Declare procedure or constant value or variable value.
(: x Integer)

;; Declare a constant value once.
(= x 1000)

;; Declare a mutable variable value.
(:= y 0)

;; Strictly typing with literal.
(= z (: 0 Uint8))
(:= w (: "something" Bytes))

;; Reassign
(=! y 1000)    ;; OK
(=! y "hello") ;; Can't. `y` has been declared as Number type.
(=! x 10)      ;; Can't. `x` has been declared as immutable.

Calling procedure

;; Simply calling a procedure.
(foo a b c)

;; Calling closure.
((|a| (* a a)) 10) ;; returns 100

Define procedure

;; Declare a procedure
(: cubic (-> Number Number)) ;;(1)

;; Define the procedure
(= (cubic x) (* x x x))
  1. (→ T1 T2 …​ Tn) is Function type receive T1, T2 …​ then return value as Tn type.

Development

Prerequisites

  • Haskell Stack

Build and Testing

Simply building libraries and application

stack build

Clean

stack clean

Run Tests

# simply run test-suites
stack test

# run test-suites and generate coverage-report
stack test --coverage

# open coverage-report in your browser
open $(stack path --local-hpc-root)/index.html

Check Haddock

stack haddock

open $(stack path --local-doc-root)/index.html

cacco's People

Contributors

hsjoihs avatar voqn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

hsjoihs

cacco's Issues

Tokenize strict typed floating point number literal

Spec

digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";

sign = "+" | "-";

decimal float =
    digit, {digit}
    [".", digit, {digit} ]
    ["e", [sign], digit, {digit}]
;

natural float = decimal float;
signed float = [sign], natural float;

float16 = signed float, "_f16";
float32 = signed float, "_f32";
float64 = signed float, "_f64";

Tokenize strict typed integer literals

Spec

binary digit = "0" | "1";
octal digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7";
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
hex alphabet =  "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F";
hex digit = digit | hex alphabet;
sign = "+" | "-";

decimal = digit, {digit};
binary = "0b", binary digit, binary digit;
octal = "0o", octal digit, {octal digit};
hexadecimal = "0x", hex digit, {hex digit};
natural integer = decimal | binary | octal | hexadecimal;
signed integer = [sign], natural integer;

int8 = signed integer, "_i8";
int16 = signed integer, "_i16";
int32 = signed integer, "_i32";
int64 = signed integer, "_i64";

uint8 = natural integer, "_u8";
uint16 = natural integer, "_u16";
uint32 = natural integer, "_u32";
uint64 = natural integer, "_u64";

Tokenize hexadecimal floating point number literal

digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
hex alphabet =
    "a" | "b" | "c" | "d" | "e" | "f" |
    "A" | "B" | "C" | "D" | "E" | "F"
;
hex digit = digit | hex alphabet;
sign = "+" | "-";

decimal float =
    digit, {digit}
    [".", digit, {digit} ]
    ["e", [sign], digit, {digit}]
;
hexadecimal float =
    "0x", hex digit, {hex digit}
    [".", hex digit, {hex digit}]
    ["p", [sign], digit, {digit}]
;
natural float = decimal float | hexadecimal float ;
signed float = [sign], natural float;

float16 = signed float, "_f16";
float32 = signed float, "_f32";
float64 = signed float, "_f64";

List up Builtin functions

Task

  • prepare document
  • write document about builtin functions

Builtin Function

Equality

  • eq? (: a Eq) (-> a a ... Bool)/==
  • unique? (: a Eq) (-> a a ... Bool)/!=

Ordering

  • greater? (: a Ord) (-> a a ... Bool)/>
  • less? (: a Ord) (-> a a ... Bool)/<
  • greater-or-equal? (: a Ord) (-> a a ... Bool)/<=
  • less-or-equal? (: a Ord) (-> a a ... Bool)/>=
  • compare (: a Ord) (-> a a Ordering)

Numeric operation

  • sum (: a Addible) (-> a a ... a)/+
  • product (: a Multiply) (-> a a ... a)/*
  • sub (-> a a ... a)/-
  • div (-> a a ... a)//
  • negate (-> a a)

List operation

  • list
  • head
  • tail
  • cons/unshift/::
  • length
  • nth

I/O

  • open-input-file
  • close-input-file
  • open-output-file
  • close-output-file
  • print
  • read
  • write

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.