In this article, I'll explain why implementing numbers with just algebraic datatypes is desirable. I'll then talk about common implementations of FFT (Fast Fourier Transform) and why they hide inherent inefficiencies. I'll then show how to implement integers and complex numbers with just algebraic datatypes, in a way that is extremely simple and elegant. I'll conclude by deriving a pure functional implementation of complex FFT with just datatypes, no floats.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// COMPUTATION RULES | |
// =================================================== | |
// APP | ((λx body) arg) | |
// X | --------------------------------------------- | |
// LAM | x ~ arg; body | |
// =================================================== | |
// APP | ({fst snd} arg) | |
// X | --------------------------------------------- | |
// SUP | dup #L{a,b} = arg; {(fst a) (snd b)} | |
// =================================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Rot (V z)) = (V (- 0.0 z)) | |
(Rot (G x y)) = (G (Rot y) x) | |
(Add (V z) (V w)) = (V (+ z w)) | |
(Add (G x y) (G w z)) = (G (Add x w) (Add y z)) | |
(Get (V x) f) = (f x) | |
(Get (G x y) f) = (f x y) | |
Nil = λm λx (m x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Flip (n: Nat) : Nat | |
Flip Nat.zero = 1n | |
Flip (Nat.succ Nat.zero) = 0n | |
Mod2 (n: Nat) : Nat | |
Mod2 Nat.zero = Nat.zero | |
Mod2 (Nat.succ n) = Flip (Mod2 n) | |
IsEven (n: Nat) : Type | |
IsEven Nat.zero = Unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Security audit | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
paths: | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
jobs: | |
security_audit: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// Delete Backward. | |
// Put this into your user packages folder. Can be found by navigating to Preferences > Browse Packages... in Sublime Text. | |
// Then add something like this to your user Key Bindings. | |
// { "keys": ["alt+backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/User/Delete Subword Backward.sublime-macro"} } | |
[ | |
{ | |
"args": | |
{ | |
"by": "subwords", | |
"extend": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const inquirer = require('inquirer'); | |
const uuidv4 = require('uuid/v4'); | |
const owasp = require('owasp-password-strength-test'); | |
const words = new Set([...require('wordlist-english')['english/10'], ...require('wordlist-english')['english/20']]); | |
const thingsIDontDoAnyMore = require("./thingsIDontDoAnyMore.json"); | |
const { items } = require('./bitwarden_export_file.json'); |
I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.
There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.
As an example, currently we can express this type:
NewerOlder