Skip to content

A modern scheme language variant with builtin supports for algebraic data type, polymorphism, referencial transparency and simple C-FFI.

Notifications You must be signed in to change notification settings

liangkun/schemer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

schemer

Introduction

A modern scheme language variant with following additional (different) features:

  1. Algebraic data type and pattern matching.
  2. Polymorphism.
  3. Referencial transparency.
  4. Simple C-FFI.

Examples

There are some code snippets of schemer.

; schemer inherits a lot of things from scheme, including comments.

; Following defines a Tree type.
(def Tree
    (data (element_type)
          (Leaf element_type)
          (Node (Tree element_type) (Treeelement_type))))

; Builtin List type.
(def List
    (data (element_type)
          (Cons element_type (List element_type))
          Null))

; pattern matching
(: height (-> (Tree t) Integer))
(def (height (Leaf _)) 0) ; `_' means we donot care what is that.
(def (height (Node left right))
     (+ 1 (max (height left)
               (height right))))

(: length (-> (List t) Integer))
(def (length Null) 0)
(def (length (Cons _ rest)) (+ 1 (length rest)))

Core Forms

Followings are the core forms of schemer.

  1. (data ...) : Create an algebric data type.
  2. (-> arg_types ... return_type) : Create a function type.
  3. (: name type) : Declare the type of a name (identifier)
  4. (lambda (pattern) body) : Create a closure.
  5. (case (test body)...) : Condition expression.
  6. (fn args ...) : Closure application.
  7. (reset ...) : reset operator in delimited continuation.
  8. (shift k body) : shift operator in delimited continuation.

Builtins

Followings are the schemer builtins.

Types

  1. Bool : True / False.
  2. Integer : integral numbers.
  3. Real : double of c.
  4. List[element_type] : list type.

Functions

        • / : arithmatic functions on all numeric types.
  1. % : mod on integral types.

Virtual Machine

This section gives a brief introduction to the schemer virtual machine.

Schemer virtual machine heavily depends on the LLVM infrastructure. In addition to the operations provided by LLVM, Schemer virtual machine provides the following intrinsic functions.

About

A modern scheme language variant with builtin supports for algebraic data type, polymorphism, referencial transparency and simple C-FFI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published