From 1b4ea6954867fdde4308df74257937348aa28d57 Mon Sep 17 00:00:00 2001 From: "William J. Bowman" Date: Tue, 10 Nov 2015 13:41:43 -0500 Subject: [PATCH] Documented bools --- scribblings/defs.rkt | 15 +++++++++- scribblings/stdlib/bool.scrbl | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 scribblings/stdlib/bool.scrbl diff --git a/scribblings/defs.rkt b/scribblings/defs.rkt index 59927bd..39c6b73 100644 --- a/scribblings/defs.rkt +++ b/scribblings/defs.rkt @@ -1,6 +1,10 @@ #lang racket/base -(require scribble/base scribble/manual) +(require + scribble/base + scribble/manual + racket/sandbox + scribble/eval) (provide (all-defined-out)) (define (todo . ls) @@ -8,3 +12,12 @@ (define (gtech . x) (apply tech x #:doc '(lib "scribblings/guide/guide.scrbl"))) + +(define (curnel-sandbox init-string) + (parameterize ([sandbox-output 'string] + [sandbox-error-output 'string] + ;; TODO: Probs a bad idea + [sandbox-eval-limits #f] + [sandbox-memory-limit #f]) + (make-module-evaluator + (format "#lang cur~n~a" init-string)))) diff --git a/scribblings/stdlib/bool.scrbl b/scribblings/stdlib/bool.scrbl new file mode 100644 index 0000000..28ce96d --- /dev/null +++ b/scribblings/stdlib/bool.scrbl @@ -0,0 +1,52 @@ +#lang scribble/manual + +@(require "../defs.rkt") + +@(define curnel-eval "(require cur/stdlib/bool cur/stdlib/sugar)") + +@title{Bool} +@defmodule[cur/stdlib/bool] +This library defines the datatype @racket[Bool] and several functions and forms for using them. + +@; TODO: Define a @defdata macro for Cur +@deftogether[(@defthing[Bool Type] + @defthing[true Bool] + @defthing[false Bool])]{ +The boolean datatype. +} + +@defform[(if test-expr c-expr alt-expr)]{ +A syntactic form that expands to the inductive eliminator for @racket[Bool]. This form is currently non-dependent---the branches do not know that @racket[test-expr] is equal to @racket[true] or @racket[false]. + +@examples[#:eval curnel-eval + (if true false true) + (elim Bool Type (λ (x : Bool) Bool) false true true)] +} + +@defproc[(not [x Bool]) + Bool]{ +Negates the boolean @racket[x]. + +@examples[#:eval curnel-eval + (not true) + (not false)] +} + +@defproc[(and [x Bool] [y Bool]) + Bool]{ +The boolean @racket[and]. True if and only if @racket[x] and @racket[y] are both either @racket[true] or @racket[false]. + +@examples[#:eval curnel-eval + (and true true) + (and false true)] +} + +@defproc[(or [x Bool] [y Bool]) + Bool]{ +The boolean @racket[or]. True if and only if either @racket[x] or @racket[y] is @racket[true]. + +@examples[#:eval curnel-eval + (or true true) + (or false true) + (or false false)] +} \ No newline at end of file