Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

peach-lang

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peach-lang

A tiny functional language

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

peach

Build

A statically typed functional language.

fib =
  0 => 1
  1 => 1
  x => (+ (fib (- x 1)) (fib (- x 2)))

(map fib [0 1 2 3 4 5 6 7 8 9 10])
# [ 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 ]

Syntax

Peach is inspired by JavaScript, Elm, Clojure and @bodil's BODOL, which I learned about from this awesome talk.

# assignment
x = 2 # 2

# equality
(== x 2) # true

# maths and stuff
(* x 2) # 4

# conditionals
if ((< x 10))
  `little`
else if ((< x 20))
  `medium`
else
  `large`

# functions
double = (x => (* x 2))
(map x (x => (pow x 2))) # [2 4 8 16]

# currying
double-all = (map double)
(double-all [1 2 3 4]) # (2 4 6 8)

# pattern matching
(fn fib
  0 => 1
  1 => 1
  x => (+ (fib x - 2) (fib x - 1))
)

(fn starts-with-one
  [1|_] => true
  _  => false
)

# tail call optimisation
# n: the accumulating factorial
# x: a decrementing iteration count
factorial =
  (n, 1) => n
  (n, x) => (factorial (* n x) (- x 1))

(factorial 1 32768) # Infinity, because JavaScript. Better than a stack overflow!

Semantics

Features

  • Minimal syntax
  • A tree-based JavaScript interpreter
  • REPL
  • Proper tails calls

Plans

Coming soon:

  • Type hint syntax
  • More stdlib
  • Algebraic data types

And then:

  • JavaScript interop
  • JavaScript code generation
  • Lazy sequences
  • IO

One day:

  • Efficient bytecode interpreter
  • Interactive debugger
  • Immutable data structures with structural sharing
  • Self-hosting

Develop

Use Node 6+.

npm install
npm test

Keywords

FAQs

Package last updated on 02 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc