How to use `typed / racket` in` scribble / lp`

Is it possible to use others #langin #lang scribble/lpfor competent programming?

For example, I want to use #lang typed/racketin #lang scribble/lp. What does it mean?

+4
source share
2 answers

This is not the case, but you can use a typed / racket evaluator with scribble / eval.

    #lang scribble/manual
    @(require racket/sandbox
              scribble/eval)
    @(define my-evaluator
       (parameterize ([sandbox-output 'string]
                      [sandbox-error-output 'string])
         (make-evaluator 'typed/racket/base)))
    @interaction[#:eval my-evaluator

                 (: my-sqr (Real -> Real))
                 (define (my-sqr x)
                   (* x x))
                 (my-sqr 42)]

An example taken from here .

+1
source

TL; DR: . -, . -, scribble/lp2, .


- (begin …), , .

#lang scribble/lp2

@chunk[<*>
       (begin
         (module main typed/racket
           (define a : Number 1)
           (provide a)
           (module moo racket/base '…)
           (module+ test
             (require typed/rackunit)
             (check-equal? a (+ 1/2 1/2))))

         (require 'main)
         (provide (all-from-out 'main))

         (module test typed/racket
           (require (submod ".." main test))))]

, , test main, . (module+ test …) main, test . (module test , .

moo , (require (submod "myfile.lp2.typed.rkt" main moo)) "", test main.

, , / ( , ). / , / . , (begin-for-syntax (displayln 'executed)) , .

scribble/lp2, hyper-literate ( ) scribble/lp2 scribble .

, , chunk, .. stackoverflow-q-18877881, . master.

. test/test.hl.rkt:

#lang hyper-literate/typed typed/racket/base

@(require (for-label typed/racket/base
                     typed/rackunit))

@title{Title}

Hello world.

@chunk[<*>
       (require typed/rackunit)

       ;; Would give an error as typed/racket/base is used on the #lang line:
       ;curry

       (check-equal? ((make-predicate One) 1) #t)

       (define (f [x : 'e123]) x)

       (define ee (ann (f 'e123) 'e123))
       (provide ee)]
0

Source: https://habr.com/ru/post/1502865/


All Articles