gsp

command module
v0.0.0-...-8032aab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2015 License: MIT Imports: 13 Imported by: 0

README

Gsp

Gsp is a compiler built on top of Joseph Adams' Gisp. Gsp provides a more complete language environment, including Golang bindings and the Gsp Prelude.

Install

go get github.com/gsp-lang/gsp
cd <GOPATH>/src/github.com/gsp-lang/gsp
go build
echo 'export PATH=$PATH:"${pwd}"' >> ~/.profile
. ~/.bashrc # . ~/.zshrc

Build Prelude

cd <GOPATH>/src/github.com/gsp-lang/stdlib/prelude
gsp prelude.gsp > prelude.go

Example

; Copy into example.gsp
(ns main
    "/fmt"
    "/net/http")

(def hello (fn [w r]
    (fmt/fprintf w "hello")
    ()))

(def main (fn []
    (http/handle-func "/" hello)
    (http/listen-and-serve ":9090" nil)))

To compile & run

gspc example.gsp
./bin/main

Using the Prelude

(ns main
	"/fmt")

(def main (fn []
    (let [[m (/cons 2 (/cons 1 /null))]]
        (fmt/println (/car (/cons 1 /null)))
        (fmt/println (/len (/cons 1 /null)))
        (fmt/println (/car (/map (fn [x] (+ x 20)) m)) (/car m))
        (fmt/println (/len m))
        (fmt/println (/car (/cons 17 m)))
        (fmt/println [1 2 3 4])
        (fmt/println (/car (/cdr (/cdr (/append m (/cdr m))))))
        ())))

More examples

Check out the Prelude. It is written in Gsp.

License

Originally licensed code can be found at https://github.com/jcla1/gisp.

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL