-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliterate-p.rkt
executable file
·51 lines (38 loc) · 1.47 KB
/
literate-p.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/env racket
#lang scribble/lp2
@(require scribble/manual)
First steps in literate programming.
To generate scribble execute 'raco scribble literate-p.rkt'
@chunk[<xmain>
(module xmain typed/racket
(provide x)
(: x Integer)
(define x 2)
(printf "xmain - executed when called from command line\n")
(module+ test
(require typed/rackunit)
(check-equal? 1 1)))]
next chunk
@chunk[<ymain>
(module ymain typed/racket ;; define submodules to use own language (e.g. typed/racket)
(require (submod ".." xmain)) ;; import all from xmain
(provide y)
(: y Integer)
(define y 3)
(printf "ymain - executed when called from command line\n")
;; have a failing test (to see that it is actually executed
(module+ test
(require typed/rackunit)
(check-equal? x y)))]
@chunk[<*>
<xmain> ;; make sure to insert all chunks in the main (which is this)
<ymain>
;; execute something dependend on the previously defined chunks
(module main typed/racket
(require (submod ".." ymain))
(printf "main - executed when called from command line (~a)\n" y))
;; now include all test modules of the submodules
;; so that raco test ... works and C-c C-t from w/i emacs
(module test typed/racket
(require (submod ".." xmain test))
(require (submod ".." ymain test)))]