summaryrefslogtreecommitdiff
path: root/log-240211-1.gmi
blob: 2d151ab54e91ef44de52f7e228ed633f04fedacb (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
Time-stamp: <2024-02-11 12h13 UTC>

# Finally an APL for my flying saucer?

> Let's postpone the why and what of BQN, and address the how

Suppose that you're interested in using

=> https://mlochbaum.github.io/BQN/index.html BQN

but you're troubled by not having any. Well, if you're an Arch linux and using emacs, the following should see you through

## Building and installing

### CBQN

I found the AUR package for CBQN lacking, in that it didn't compile the shared libraries which i wanted for the LSP integration below. To that end, here's what i'm using

```
$ cat PKGBUILD
# Maintainer: Firegem <mrfiregem [at] protonail [dot] ch>
pkgname=cbqn-git
pkgver=r2743.8c18fddd
pkgrel=1
pkgdesc="A BQN implementation in C."
arch=('x86_64' 'i686' 'aarch64' 'arm')
url="https://github.com/dzaima/CBQN"
license=('Apache' 'Boost' 'GPL3' 'MIT')
depends=('glibc' 'libffi')
optdepends=('ttf-bqn386: BQN and APL compatible font')
makedepends=('git' 'clang')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=("${pkgname%-git}::git+${url}.git")
md5sums=('SKIP')

pkgver() {
  cd "${srcdir}/${pkgname%-git}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "${srcdir}/${pkgname%-git}"
  make PIE='-pie' o3n
  make PIE='-pie' shared-o3
}

package() {
  cd "${srcdir}/${pkgname%-git}"
  make PREFIX="${pkgdir}/usr/" install
}
```

the changes to build() and package() are minor, but appear to be necessary.

With that it should be possible to install a functioning BQN compiler and REPL.

#### BQN LSP

=> https://git.sr.ht/~detegr/bqnlsp

Cloning and building this should work now that the above PKGBUILD puts /usr/lib/libcbqn.so onto the file system. Not too much to say here, other than copy the resulting bqnlsp into your path somewhere

## Emacs integration

Fortunately for us, all of the hard work has already been done

```
(use-package bqn-mode
  :ensure t
  :defer
  :bind (:map bqn-mode-map
              ("M-TAB" . expand-abbrev)
              ("C-c r r" . bqn-comint-eval-dwim)
              ("C-c r b" . bqn-comint-eval-buffer))
  :hook (bqn-mode . (lambda () (eglot-ensure) (bqn-comint-buffer)))
  :config
  (require 'bqn-keymap-mode)
  (require 'bqn-glyph-mode))
```

Note that the first time this is run eglot may ask for the path of bqnlsp, simply provide it.

### Bonus round: abbrev-mode for entering symbols

At first when using BQN i found that while i could remember the names of the various glyphs in which i was interested, i could not recall where they were on the "BQN Keyboard"---a task not aided by the fact that i don't use QWERTY⁰. To that end i wrote some abbrev aliases so that i could type the names and press either space or whatever the favourite abbrev trigger was to replace the word with the glyph

```
(define-abbrev-table 'bqn-mode-abbrev-table
    '( ;; funtions
      ("abs" "│")
      ("assert" "!")
      ("ceiling" "⌈")
      ("classify" "⊐")
      ("conj" "∧")
      ("couple" "≍")
      ("deduplicate" "⍷")
      ("depth" "≡")
      ("deshape" "⥊")
      ("dgrade" "⍒")
      ("disj" "∨")
      ("divide" "÷")
      ("drop" "↓")
      ("dsort" "∧")
      ("enlist" "⋈")
      ("find" "⍷")
      ("floor" "⌊")
      ("group" "⊔")
      ("gt" ">")
      ("gte" "≥")
      ("indices" "/")
      ("join" "∾")
      ("left" "⊣")
      ("length" "≠")
      ("lshift" "«")
      ("lt" "<")
      ("lte" "≤")
      ("match" "≡")
      ("maximum" "⌈")
      ("member" "∊")
      ("minimum" "⌊")
      ("minus" "¯")
      ("modulus" "│")
      ("multiply" "×")
      ("neg" "¬")
      ("neq" "≠")
      ("nmatch" "≢")
      ("occurrence" "⊒")
      ("pair" "⋈")
      ("pick" "⊑")
      ("power" "⋆")
      ("prefix" "↑")
      ("range" "↕")
      ("recip" "÷")
      ("replicate" "/")
      ("reshape" "⥊")
      ("reverse" "⌽")
      ("right" "⊢")
      ("root" "√")
      ("rshift" "»")
      ("select" "⊏")
      ("shape" "≢")
      ("sign" "×")
      ("solo" "≍")
      ("span" "¬")
      ("sqrt" "√")
      ("suffix" "↓")
      ("take" "↑")
      ("transpose" "⍉")
      ("ugrade" "⍋")
      ("usort" "∨")
      ;; combinators
      ("atop" "∘")
      ("catch" "⎊")
      ("choose" "◶")
      ("constant" "˙")
      ("lhook" "⊸")
      ("over" "○")
      ("rhook" "⟜")
      ("self" "˜")
      ("swap" "˜")
      ("under" "⌾")
      ("valence" "⊘")
      ;; 1-modifiers
      ("cell" "˘")
      ("each" "¨")
      ("fold" "´")
      ("insert" "˝")
      ("scan" "`")
      ("table" "⌜")
      ("undo" "⁼")
      ;; 2-modifiers
      ("depth" "⚇")
      ("rank" "⎉")
      ("repeat" "⍟")
      ;; syntax
      ("define" "←")
      ("export" "⇐")
      ("change" "↩")
      ("nothing" "·")
      ("sep" "⋄")
      ;; constants
      ("pi" "π")
      ("infty" "∞")))
```

to make this not irritating i found myself also setting

```
(setq save-abbrevs 'silently)
```

and adding (abbrev-mode) to the bqn-mode hook.

Happy BQN'ing!

---

⁰ For the curious
=> https://git.sr.ht/~tslil/keyboard