Skip to content
/ ylang Public

Programming Language (Scheme like, but it is NOT "Lisp family")

License

Notifications You must be signed in to change notification settings

VoQn/ylang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ylang Build Status Coverage Status Gitter Apache 2 License

ylang is Programming Language. Scheme like, but it is NOT Lisp family

Motivation

Simplify to think "What is this?"

ylang aims to simplify design for programming.

Programming has many concepts easy to confuse, and too easy to bind self (regacy own code, uncontrollable dependency, language spec, etc ...)

ylang is designing to "Easy to Re-design own".

  • To be as possible as easy to rewrite own
  • To be as possible as easy to restruction own

Syntax Base

Foundation

TopLevel

; <- Comment

; Apply Function
(<FACTOR> <EXPR>)

; Eval Expression
(<EXPR>)

Literal (Atomic)

([])  ; Empty List
(1)   ; Integer
(0.5) ; Floating
(1/2) ; Rational
(yes) ; Boolean (true)
(no)  ; Boolean (false)
(:a)  ; Keyword
('a') ; Charactor
("a") ; String

Collection

(, 1 2) ; Pair

;; List
[]      ; Empty List

[1 2 3] ; = (, 1 2 3 [])

;; Examples
(, 1 []) ; [1]
(, [] 1) ; (, [] 1)
(, [1 2] []) ; [[1 2]]

Builtin Operator

Definition
(:) ; Declare Type Binding
(: x Int)

(=) ; Define [Value / Function]
(= x 10)
(+ x x) ; 20

(= (not x) (if x no yes))

(not yes) ; no
(not no)  ; yes

;; Arrow (Function-Type)
(->)

(: add (: t Addible) (-> t t))

(: VariadicType (-> Natural Set Set Set))
(= (VariadicType 0 A B) B)
(= (VariadicType (suc n) A B)
   (-> A (VariadicType n A B)))
Function
(\) ; Lambda
(= id (\ x x))

((\ x x) 1) ; => (1)

(.) ; Compose
((. f g) x) ; => (f (g x))
Collection
(,) ; Pair

;; Examples
(, x) ; (\ y (, x y))
(, x []) ; => [x]
(, [] x) ; => (, [] x)
Ordering
(>?) ; GT (>? 1 2) -> no
(<?) ; LT (<? 1 2) -> yes
(=?) ; EQ (=? 2 2) -> yes
Numeric
(+) ; Add (+ 1 1) -> (1)
(-) ; Sub (- 1 1) -> (0)
(*) ; Mul (* 2 2) -> (4)
(/) ; Div (/ 1 2) -> (1/2)
Boolean
(&) ; And (& yes no) -> (no)
(|) ; Or  (| no yes) -> (yes)
(~) ; Not (~ yes)    -> (no)

Let, Closure

(= (: x Int) 10)
(= y 20)

(+ x 1)
; (: 11 Int)

(+ x y)
; (: 30 Int)

((\ x (+ x x)) 1)
; (: 2 Int)
((\ x (+ x y)) 1)
; (: 21 Int)

Declare, Define, Apply

(: length (-> [a] Int))
(= (length []) 0)
(= (length (, x xs))
   (+ (length xs) 1))

(length [1 2 3 4 5])
; (: 5 Int)

License

See License file

About

Programming Language (Scheme like, but it is NOT "Lisp family")

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published