Racket ships in two sizes. Minimal Racket has the core and the raco pkg installer. The full Racket distribution adds the main collections, DrRacket and the documentation. The language libraries are loaded by module name, and a library is a module like any other: (require racket/list).
Two base languages
| Language | Is |
|---|---|
racket/base | the smaller language: the core forms and the procedures for data, I/O, threads, structs, the module system and macros. It loads fast, and is the usual choice for a library or a program that starts often. The libraries below are needed explicitly |
racket | all of racket/base plus the most-used libraries: racket/list, racket/string, racket/math, racket/function, racket/match, racket/class, racket/contract, racket/set, racket/dict, racket/port, racket/file, racket/system, racket/format, racket/vector and more. The default for scripts |
racket/kernel, '#%kernel | the primitive core under both; used to build languages and in the first modules that load |
The Racket Reference states for each library which one it comes from. A name from racket used in a racket/base module is an unbound identifier error; add the library or change the language.
Data
| Library | Provides |
|---|---|
racket/list | first … tenth, rest, last, take, drop, split-at, take-right, drop-right, takef, dropf, add-between, append*, flatten, remove-duplicates, filter-map, filter-not, partition, count, range, append-map, group-by, cartesian-product, permutations, in-permutations, argmin, argmax, shuffle, index-of, list-set, list-update, make-list, empty, empty?, cons? |
racket/vector | vector-map, vector-append, vector-copy, vector-take, vector-drop, vector-filter, vector-argmin, vector-sort, vector-sort!, vector-count, vector-member, vector-set*! |
racket/string | string-join, string-split, string-trim, string-replace, string-prefix?, string-suffix?, string-contains?, non-empty-string? – see Strings and regexps |
racket/format | ~a, ~s, ~v, ~e, ~r, ~.a and relatives: format a value as a string, with padding and alignment options |
racket/set | set, seteq, mutable-set, list->set, set-add, set-remove, set-member?, set-union, set-intersect, set-subtract, subset?, set-count, set-map, for/set |
racket/dict, racket/hash | one interface to hash tables, association lists and vectors: dict-ref, dict-set, dict-has-key?, dict-keys, dict-update; and hash-union, hash-filter and similar for hashes |
racket/stream, racket/sequence | lazy streams and generic sequences: stream-first, stream-map, sequence->list, in-slice |
racket/treelist | immutable lists with fast indexing, appending and updating in any position (a recent addition) |
racket/bytes, racket/bool, racket/symbol, racket/keyword, racket/box | small collections of helpers for those types; racket/bool has true, false, symbol=?, xor, implies |
racket/serialize, racket/fasl | write structures and data to a port and read them back (serialize, deserialize, s-exp->fasl) |
Numbers and maths
| Library | Provides |
|---|---|
racket/math | pi, nan?, infinite?, exact-round, exact-floor, exact-ceiling, exact-truncate, sqr, sgn, conjugate, sinh, cosh, tanh, euler, order-of-magnitude, positive-integer? |
racket/flonum, racket/fixnum, racket/extflonum, racket/unsafe/ops | operations specialised to flonums (fl+, flsqrt, flvector), fixnums (fx+, fxvector), extflonums, and unchecked fast versions (unsafe-fx+, unsafe-vector-ref) |
racket/random | random-ref, random-sample, crypto-random-bytes; the base random and make-pseudo-random-generator are in racket/base |
math (a separate collection) | number theory, matrices, statistics, special functions, arbitrary-precision floats (math/number-theory, math/matrix, math/statistics, math/bigfloat) |
Control, functions and syntax
| Library | Provides |
|---|---|
racket/function | identity, const, thunk, negate, conjoin, disjoin, curry, curryr, compose, compose1, arity-includes? |
racket/match, racket/contract, racket/class, racket/unit, racket/generic | covered on Pattern matching, Contracts, Classes and objects, Structs |
racket/control, racket/generator, racket/promise, racket/engine, racket/trace | delimited control; generators (generator, yield, in-generator); promises (delay, force, lazy); time-limited computations; trace and trace-define to print calls |
racket/local, racket/splicing, racket/stxparam, racket/syntax, racket/require, racket/provide, racket/performance-hint, racket/runtime-path | local; splicing-let and relatives; syntax parameters; format-id and with-syntax*; require and provide transformers; define-inline; paths relative to the source file (define-runtime-path) |
syntax/parse, syntax/parse/define, syntax/stx, syntax/srcloc, syntax/module-reader, syntax/readerr | macro and language-writing tools; see Macros |
Input, output and the system
| Library | Provides |
|---|---|
racket/port, racket/file, racket/path | port->string, port->lines, with-output-to-string, copy-port, make-pipe-with-specials; file->string, file->lines, display-to-file, write-to-file, make-temporary-file, delete-directory/files, find-files; path-only, file-name-from-path, path-get-extension, simple-form-path |
racket/system, racket/cmdline, racket/os, racket/date | system, process, system*; command-line for argument parsing; gethostname, getpid; current-date, date->string, date-display-format |
racket/tcp, racket/udp, net/url, net/http-client, net/uri-codec, net/base64, net/sendurl, openssl | sockets, URLs, HTTP clients, encodings and TLS |
json, xml, file/gzip, file/gunzip, file/zip, file/unzip, file/sha1, file/md5, racket/lazy-require, racket/format | JSON (read-json, write-json, jsexpr?), XML (read-xml, xexpr?), compression and hashing |
ffi/unsafe, ffi/vector | calling C libraries: ffi-lib, get-ffi-obj, _fun, _int, _string, malloc, cast, structures with define-cstruct |
racket/sandbox, racket/place, racket/future, racket/async-channel | run code with limits; places and futures; see Concurrency |
Testing, documentation and the larger libraries
| Library or collection | For |
|---|---|
rackunit | unit tests: check-equal?, check-true, check-pred, check-exn, check-=, test-case, test-suite; run by raco test |
scribble/… | documentation; see Scribble |
racket/gui, racket/draw, racket/snip, framework | windows, widgets, drawing, and the framework behind DrRacket |
pict, slideshow, 2htdp/image, 2htdp/universe, plot | pictures as values, slide shows, teaching-language images and animations, plots |
db, web-server, net, data, parser-tools, peg, racklog, datalog, csv-reading | databases (SQLite, PostgreSQL, MySQL), web applications and servlets, queues and heaps and other data structures, lexers and parsers, logic programming, CSV |
compiler/…, setup/…, pkg/…, raco/…, errortrace, profile, macro-debugger | tools: the compiler, raco and package management, error traces, profiling, macro stepping; see Packages and raco |
What the viewer colours
The viewer has a list of the procedures of racket/base and the common libraries above, and colours each as a function wherever it stands, including when it is passed as an argument. It also colours every name that begins in- or current-, every name ending % or /c, and the heads of calls. A name the program defines itself is coloured as a function when it is called, and as a variable where it is bound.
Not described
Known, not yet covered
- Reference: this is a tour, not a reference. Which libraries are in
racketand which only inracket/basewas taken from memory of the Racket Guide (the Reference chapters named for each library were not all read), and the tables list well-known names rather than all that a library exports. Collections of the main distribution (db,web-server,math,plot,pictand the rest) are named, not described, and the packages of the catalogue are not covered. - Viewer: the colour list of procedures holds about 1,300 names from
racket/base,racket/list,racket/string,racket/vector,racket/set,racket/dictand several others; a name from another library is coloured only as the head of a call. Procedure names were taken from memory and the downloaded Reference sections; the whole export list of each library was not checked.
See also
- Packages and raco – installing more libraries
- Modules – requiring libraries
- Scheme: standard libraries – the libraries of the Scheme reports