Proposal to extend JSON with sum types (variants)
Chris Done's Blog - Mon, 2 Feb 2026 00:00:00 GMT
https://chrisdone.com/posts/json-with-sum-types
Proposal to extend JSON with sum types (variants)
A small syntactical addition that I propose to add to JSON is variants. It looks like this:
I trust that the syntax is intuitive and follows norms that a hashtag is a way of labelling something.
The grammar is simply:
It would be more convenient without the quotes, but JSON is primarily a transfer format and secondarily a human readable format. The latter is what JSON5 is for. Additionally, it’s faster to crunch through JSON’s explicitly delimited string literals than more elaborate rules.
I think this syntax gives a good balance of intention and practicality. Sum types exist nicely in XML and static languages (Rust, Haskell), and this is always covered by convention in JSON. It seems about the right time to make this concept first-class.
[TABLE]
➤ @haskell_cast 98cda278a249
Chris Done's Blog - Mon, 2 Feb 2026 00:00:00 GMT
https://chrisdone.com/posts/json-with-sum-types
Proposal to extend JSON with sum types (variants)
A small syntactical addition that I propose to add to JSON is variants. It looks like this:
#"succeeded"
#"failed"("Problem flerbing the fobnicator.")
#"loading"({ "remaining": 3, "completed": 7 })
[ #"foo", #"bar"(1), #"boz"("Ok!") ]
I trust that the syntax is intuitive and follows norms that a hashtag is a way of labelling something.
The grammar is simply:
root ::= string | number | ... | object | variant
variant ::= "#" string variant-arg?
variant-arg ::= "(" root ")"
It would be more convenient without the quotes, but JSON is primarily a transfer format and secondarily a human readable format. The latter is what JSON5 is for. Additionally, it’s faster to crunch through JSON’s explicitly delimited string literals than more elaborate rules.
I think this syntax gives a good balance of intention and practicality. Sum types exist nicely in XML and static languages (Rust, Haskell), and this is always covered by convention in JSON. It seems about the right time to make this concept first-class.
[TABLE]
➤ @haskell_cast 98cda278a249
λ
After using 3 days of AI agents, understood that they can't take our jobs yet 🤣🤣🤣
Media is too big
VIEW IN TELEGRAM
if you tired of working, Emacs can help you, just
zone your project 😁😁1
Emacs is just beyond of the editors🙈
(use-package pulse
:ensure nil
:init
(defun pulse-line (&rest _)
"Pulse the current line."
(pulse-momentary-highlight-one-line (point)))
(defun pulse-copy (orig-fn &rest args)
"Pulse the region after copy/yank."
(apply orig-fn args)
(pulse-momentary-highlight-region (region-beginning) (region-end)))
(dolist (command '(scroll-up-command
scroll-down-command
windmove-left
windmove-right
windmove-up
windmove-down
move-to-window-line-top-bottom
recenter-top-bottom
other-window
))
(advice-add command :after #'pulse-line))
(advice-add 'kill-ring-save :around #'pulse-copy))
You've cancelled your subscription to GitHub Copilot Pro. This plan change will take effect on Mar 05, 2026.
once again cancelled my subscription. just useless completions and agents
This media is not supported in your browser
VIEW IN TELEGRAM
M-!vs
M-&
If you use the former command, Emacs will just hang and will not respond until your command ends.
The latter one is called async shell command and you don't need wait anything.
Me who doesn't know the last command till yesterday :)
And I want to note that nix installed Emacs version is not very compatible with MacOS, so I replaced my installation with emacs-plus using homebrew. It worked well without any lags and bugs
https://github.com/abdivasiyev/nix/commit/2c5bb6d6a99b56978a8601054be4121c546cbbfb
https://github.com/abdivasiyev/nix/commit/2c5bb6d6a99b56978a8601054be4121c546cbbfb
GitHub
remove nix based emacs and install homebrew based one · abdivasiyev/nix@2c5bb6d
My nix configuration. Contribute to abdivasiyev/nix development by creating an account on GitHub.
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
I now understand how important this kind of design. I am refactoring our codebase and there are only used primitive types instead of specific custom types. Each line which I am editing is risky and testing is insanely difficult. 😭
I now understand how important this kind of design. I am refactoring our codebase and there are only used primitive types instead of specific custom types. Each line which I am editing is risky and testing is insanely difficult. 😭