Thank you for your comment

Beau­tiful Racket / appendix

  1. #lang web-server/insta
    (define (start request)
      (response/xexpr
       '(html (body "Hello LOP World"))))
    1
    2
    3
    4
    #lang web-server/insta
    (define (start request)
      (response/xexpr
       '(html (body "Hello LOP World"))))
    
    copy to clipboard
    #lang txtadv

    ===VERBS===

    north, n
     "go north"

    south, s
     "go south"

    get _, grab _, take _
     "get"

    ===THINGS===

    ---cactus---
    get
      "Ouch!"


    ===PLACES===

    ---desert---
    "You're in a desert. There is nothing for miles around."
    [cactus, key]

    north
      meadow

    south
      desert
     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
    #lang txtadv
    
    ===VERBS===
    
    north, n
     "go north"
    
    south, s
     "go south"
    
    get _, grab _, take _
     "get"
    
    ===THINGS===
    
    ---cactus---
    get
      "Ouch!"
    
    
    ===PLACES===
    
    ---desert---
    "You're in a desert. There is nothing for miles around."
    [cactus, key]
    
    north
      meadow
    
    south
      desert
    
    copy to clipboard
  2. #lang pollen

    When you want to simplify the notation. Regular expressions are one example. Another example is my DSL ◊link["https://pollenpub.com"]{Pollen}, a language for making online books (including this one).
    1
    2
    3
    #lang pollen
    
    When you want to simplify the notation. Regular expressions are one example. Another example is my DSL ◊link["https://pollenpub.com"]{Pollen}, a language for making online books (including this one).
    
    copy to clipboard
    #lang racket/base
    (require lindenmayer/simple/compile)
    (define (finish val) (newline))
    (define (A value) (display 'A))
    (define (B value) (display 'B))
    (lindenmayer-system
     (void)
     finish
     3
     (A)
     (A -> A B)
     (B -> A))
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    #lang racket/base
    (require lindenmayer/simple/compile)
    (define (finish val) (newline))
    (define (A value) (display 'A))
    (define (B value) (display 'B))
    (lindenmayer-system
     (void)
     finish
     3
     (A)
     (A -> A B)
     (B -> A))
    
    copy to clipboard
    #lang lindenmayer/simple
    ## axiom ##
    A
    ## rules ##
    A -> AB
    B -> A
    ## variables ##
    n=3
    1
    2
    3
    4
    5
    6
    7
    8
    #lang lindenmayer/simple
    ## axiom ##
    A
    ## rules ##
    A -> AB
    B -> A
    ## variables ##
    n=3
    
    copy to clipboard
  3. #lang brag
    bf-program : (bf-op | bf-loop)*
    bf-op : ">" | "<" | "+" | "-" | "." | ","
    bf-loop : "[" (bf-op | bf-loop)* "]"
    1
    2
    3
    4
    #lang brag
    bf-program : (bf-op | bf-loop)*
    bf-op      : ">" | "<" | "+" | "-" | "." | ","
    bf-loop    : "[" (bf-op | bf-loop)* "]"
    
    copy to clipboard
    #lang pollen/markdown

    When you want to simplify the notation. Regular expressions are one example.
    My DSL [Pollen]("https://pollenpub.com") is a language for making online books.
    1
    2
    3
    4
    #lang pollen/markdown
    
    When you want to simplify the notation. Regular expressions are one example.
    My DSL [Pollen]("https://pollenpub.com") is a language for making online books.
    
    copy to clipboard
  4. #lang jsonic
    // a line comment
    [
      @$ 'null $@,
      @$ (* 6 7) $@,
      @$ (= 2 (+ 1 1)) $@,
      @$ (list "array" "of" "strings") $@,
      @$ (hash 'key-1 'null
               'key-2 (even? 3)
               'key-3 (hash 'subkey 21)) $@
    ]
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #lang jsonic
    // a line comment
    [
      @$ 'null $@,
      @$ (* 6 7) $@,
      @$ (= 2 (+ 1 1)) $@,
      @$ (list "array" "of" "strings") $@,
      @$ (hash 'key-1 'null
               'key-2 (even? 3)
               'key-3 (hash 'subkey 21)) $@
    ]
    
    copy to clipboard
    [
      null,
      42,
      true,
      ["array","of","strings"],
      {"key-1":null,"key-3":{"subkey":21},"key-2":false}
    ]
    1
    2
    3
    4
    5
    6
    7
    [
      null,
      42,
      true,
      ["array","of","strings"],
      {"key-1":null,"key-3":{"subkey":21},"key-2":false}
    ]
    
    copy to clipboard
  5. #lang riposte

    $productId := 41966
    $qty := 5
    $campaignId := 1

    $payload := {
      "product_id": $productId,
      "campaign_id": $campaignId,
      "qty": $qty
    }

    POST $payload cart/{uuid}/items responds with 200

    $itemId := /items/0/cart_item_id

    GET cart responds with 200
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    #lang riposte
    
    $productId := 41966
    $qty := 5
    $campaignId := 1
    
    $payload := {
      "product_id": $productId,
      "campaign_id": $campaignId,
      "qty": $qty
    }
    
    POST $payload cart/{uuid}/items responds with 200
    
    $itemId := /items/0/cart_item_id
    
    GET cart responds with 200
    
    copy to clipboard
  1. [One can try] to get permis­sion upfront to do some­thing in Racket. That’s less likely to succeed, I think, than just making some­thing great and explaining its bene­fits ... In my case, that meant talking with co-workers about their work and asking: “How can we model the proposed change in the API and be sure that we’ve really succeeded?” The implied answer being: “Write a Riposte script.” That’s the moment where it becomes clear that [the DSL] I made has real bene­fits. I don’t even “push” Racket. I just intro­duce the DSL and show them how it helps them.

← prev next →