npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

patel

v0.40.0

Published

A Patrisika-based Example Language

Downloads

2,076

Readme

PatEL

The Patrisika Example Language.

Install

npm install patel

Syntax

PatEL's syntax is based on Lisp's S-expression but with two significant changes:

  • Supports infix operators, like (1 + 2).
  • Use indents to avoid too-deep nests.

There are three fundamental constructions in PatEL:

  • Invocation: [a b c]
  • Infix: (x + y)
  • Struct: {a b c} and {.a 1 .b 2}

For invocations you can replace [a b [c d [e f g]]] with [a b : c d : e f g] to eliminate deep nests.

Invocations and Infixes can be written in line-level like this:

f2 a b c : x y z
    d e f
    g h i
    j + k

This is identical to the form [f2 a b c [x y z [d e f] [g h i] (j + k)]], but much clearer.

Primitive Semantics

  • [if test consequent alternate] Evaluate test, then when it is true, evaluate and return consequent, otherwise evaluate and return alternate.

  • [if test consequent] Evaluate test, then when it is true, evaluate and return consequent, otherwise return nothing.

  • [piecewise [condition1 consequent1] [condition2 consequent2] ...] Evaluate condition1, when it is true, evaluate and return consequent1; otherwise, evaluate the rest condition-consequent pairs in the same manner. When all conditions are all false, return nothing.

  • [match term [pattern1 consequent1] [pattern2 consequent2] ... ] Evaluate term, and test whether it matches pattern1. When it matches, extract the parts mentioned in the pattern, evaluate and return consequent1. Otherwise, evaluate the rest pattern-consequent pairs in the same manner. When all patterns mismatch, return nothing.

    Sample:

    define [sum list] : match list
        {} 0                               # empty
        {head :: rear} : head + [sum rear] # cons
        otherwise : throw : new Error "Input is not a list." # everything else
  • [while test body] Assign temporary variable t to nothing. Evaluate test, then when it is true, evaluate body and set t to the value of body, then loop; otherwise return t.

  • [return e] Evaluate e, and immediately return the current function valued e.

  • [throw e] Evaluate e, and throw an exception valued e.

  • [yield e] Mark the current function as Generator Function. Evaluate and yield e.

    Sample:

    define [endless] : begin
        local x 0
        while true : begin
            yield x
            set x : x + 1
    
    define g : endless
    console.log [g.next].value # 0
    console.log [g.next].value # 1
  • [foreach [e range] body] Enumerate items in range using standard ES6 semantics, assign the current item to e and evaluate body.

  • [define e value] Define a local constant e and set its value to value.

  • [local e value] Define a local variable e and set its value to value.

  • [local x] Declare a local variable x and set it to nothing.

  • [define [f a b c] body] Define a local constant f, and set it to a function takes parameters a, b and c, and returns body.

  • [local [f a b c] body] Define a local variable f, and set it to a function takes parameters a, b and c, and returns body.

  • [define pattern value] Assign value to pattern, and declare all variables occurred in pattern as local constant. Function call patterns are not supported here. Function call patterns are not directly supported here, but can be used as sub-pattern.

  • [local pattern value] Assign value to pattern, and declare all variables occurred in pattern as local variable. Function call patterns are not directly supported here, but can be used as sub-pattern.

  • [lambda [a b c] body] Returns a function which takes parameters a, b and c, and returns body.

  • [set pattern value]: Set pattern value to value. Function call patterns are not directly supported here, but can be used as sub-pattern.

  • [begin a b ... z]: Evaluate a, b, ..., z in order and return z's value.