forked from sorawee/fmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
galaxy brain: use pretty printer to print the doc
- Loading branch information
Showing
5 changed files
with
52 additions
and
36 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#lang racket/base | ||
|
||
(provide define/record) | ||
(require syntax/parse/define | ||
(for-syntax racket/base)) | ||
|
||
(define-syntax-parse-rule (define/record head #:record x:id | ||
({~literal case} e | ||
[(s ...) body ...] ... | ||
[{~literal else} else-body ...])) | ||
(begin | ||
(define x (list {~@ s ...} ...)) | ||
(define head | ||
(case e | ||
[(s ...) body ...] ... | ||
[else else-body ...])))) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#lang racket/base | ||
|
||
(provide get-kws) | ||
|
||
(require racket/match | ||
pprint-compact | ||
(only-in fmt/conventions all-kws)) | ||
|
||
(define (flow xs) | ||
(match xs | ||
['() empty-doc] | ||
[(cons x xs) | ||
(let loop ([xs xs] [acc (text x)]) | ||
(match xs | ||
['() acc] | ||
[(list x xs ...) | ||
(define elem (text x)) | ||
(loop xs | ||
(alt (v-append acc elem) | ||
(hs-append acc elem)))]))])) | ||
|
||
(define (get-kws) | ||
(define xs (sort all-kws string<?)) | ||
(pretty-format (flow xs) #:width 64)) |