Table of Contents
| {-- | |
| Some informal notes on the talk Cubical Agda: A Dependently Typed Programming | |
| Language with Univalence and Higher Inductive Types by Andrea Vezzosi. | |
| Link: https://youtu.be/AZ8wMIar-_c | |
| --} | |
| --- Equality in dependently typed languages like Agda is defined as an inductive | |
| --- family: | |
| data _≡_ {A : Set} (x : A) : A → Set where |
Note that this is meant to be a common subset of useful types, not an exhaustive list.
Box<T>, casually referred to as a 'box', provides the simplest form of heap allocation in Rust. Boxes provide ownership for this allocation, and drop their contents when they go out of scope. Boxes also ensure that they never allocate more thanisize::MAXbytes.
Arc: Atomically Reference-Counted pointer, which can be used in multithreaded environments to prolong the lifetime of some data until all the threads have finished using it.Barrier: Ensures multiple threads will wait for each other to reach a point in the program, before continuing execution all together.Condvar: Condition Variable, providing the ability to block a thread while waiting for an event to occur.mpsc: Multi-producer, single-consumer queues (channels), used for message-based communication. Can provide a lightweight inter-thread synchronisation mechanism, at the cost of some extra memory.
"Higher-kinded types" is a vague term, conflating multiple language features under a single banner, which can be inaccurate.
As background, this RFC includes a brief overview of the notion of kinds and kindedness. Kinds are often called 'the type of a type,' the exact sort of unhelpful description that only makes sense to someone who already understands what is being explained. Instead, let's try to understand kinds by analogy to types.
In a well-typed language, every expression has a type. Many expressions have what are sometimes called 'base types,' types which are primitive to the language and which cannot be described in terms of other types. In Rust, the types bool, i64, usize, and char are all prominent examples of base types.
In contrast, there are types which are formed by arranging other types - functions are a good example of this. Consider this simple function:
fn not(x: bool) -> bool {| import Foundation | |
| extension String { | |
| /// Returns the minimum number of bits required to encode the given string | |
| func bitFloor() -> Int { Int(entropy().rounded(.up)) } | |
| /// Returns the metric entropy of the given string, as a measure of randomness | |
| func randomness() -> Double { entropy() / Double(self.count)} | |
| /// Returns the approximate Shannon entropy of the given string |
| interface Trait { | |
| // some props | |
| } | |
| export default class Foo implements Trait { | |
| private static foo: Foo | |
| private constructor() { } | |
| static instance(): Foo { | |
| if (this.foo == null) this.foo = new Foo() |
| /* | |
| * This code is taken from Ian Lance Taylor's Gophercon 2019 talk on | |
| * a proposed syntax/semantics for generics in Go. As such, it won't | |
| * compile on any released Go compiler as of this posting (early 2020). | |
| */ | |
| // Tree is a generic binary tree | |
| type Tree (type E) struct { | |
| root *node(E) | |
| compare func(E, E) int |
This simple bash/zsh function automates a make-based Go project that uses modules (No GOPATH muckery required).
Copy the goproject file somewhere on your $PATH and chmod +x it, or copy the function definition into your own bash/zsh script.
This is little more than a wrapper around running go mod init <etc>, writing a few files so you don't have to think about it. Expected outputs are shown in comments following each command.
| name: Rust | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: |
| use std::collections::HashMap; | |
| pub fn str_is_unique(s: &str) -> bool { | |
| let mut map: HashMap<char, i32> = HashMap::new(); | |
| for c in s.chars() { | |
| *map.entry(c).or_insert(0) += 1; | |
| } | |
| !map.iter().any(|(_, &v)| v > 1) | |
| } |