-
-
Save rightfold/74548416c100101b44cdeb0c4f1141d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(namespace FH | |
(defmodule F | |
(deffn id (T) () (=> T T) (fn (x) x)) | |
(deffn constant (TI TO) (x TO) (=> TI TO) (fn (y) x)) | |
) | |
#! This is a document. | |
#! It is written in **Markdown** and | |
#! describes what follows. | |
(defclass JSON () (value mixed) mixed () | |
(deffn encode () () string (json_encode value)) | |
) | |
(defmodule JSON | |
(deffn null () () JSON (new JSON #null)) | |
(deffn bool () (v bool) JSON (new JSON v)) | |
(deffn num () (v num) JSON (new JSON v)) | |
(deffn string () (v string) JSON (new JSON v)) | |
(deffn array_ () (vs (ImmVector JSON)) JSON | |
(new JSON (.to-array (.map vs (fn (v) (->value v))))) | |
) | |
(deffn object () (vs (ImmMap string JSON)) JSON | |
(new JSON (cast object (.to-array (.map vs (fn (v) (->value v)))))) | |
) | |
) | |
) | |
; (namespace & members) | |
; (defclass name type-parameters value-parameters base-class interfaces & body) | |
; (defmodule name & body) | |
; (deffn name type-parameters value-parameters return-type body) | |
; (.method object & arguments) | |
; (->property object) | |
; lisp-case translates to lispCase. Weird symbols translate to "__" followed by | |
; their USV in hexadecimal notation, e.g. "$" -> "__24". | |
; defmodule creates a class with static methods. defclass creates a class with | |
; instance methods. Having both defmodule and defclass with the same name in the | |
; same file merges these classes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment