Skip to content

Instantly share code, notes, and snippets.

bjorn3

  • Somewhere, Earth
Block or report user

Report or block bjorn3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@edmundsmith
edmundsmith / writeup.md
Created Jul 7, 2019
Method for Emulating Higher-Kinded Types in Rust
View writeup.md

Method for Emulating Higher-Kinded Types in Rust

Intro

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:

View rawtraitobjs.md

Raw Trait Objects 1.0

This is the sketch of a proposal for making it possible to manipulate some trait objects in stable rust.

Proposed new/stabilized API:

mod std::raw {
@johnhw
johnhw / umap_sparse.py
Last active Jul 18, 2019
1 million prime UMAP layout
View umap_sparse.py
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@mikeyhew
mikeyhew / deref_into.rs
Last active Jun 5, 2018
DerefMove and DerefInto
View deref_into.rs
#![feature(arbitrary_self_types, specialization)]
use std::{
mem::{self, ManuallyDrop},
ptr::{self, NonNull},
marker::PhantomData,
ops::{Deref, DerefMut},
};
struct Move<'a, T: 'a + ?Sized> {
@cessen
cessen / Rust2018_post.md
Last active Jan 26, 2018
#Rust2018 blog post
View Rust2018_post.md

#Rust2018

This is my contribution to the call for Rust blog posts.

I've been using Rust for various personal projects for quite a while now, and I confess that I have a lot to say about it! In fact, I've already said quite a bit about it before.

My experience with Rust has been overwhelmingly positive, and most of the things I still want (e.g. NLL, const functions, const generic parameters, SIMD intrinsics, etc.) are already well known and being worked on, so it seems silly to repeat them. Therefore, in this post I'm just going to highlight three small-ish things that have been mildly frustrating to me over the last year, but which I haven't seen mentioned recently.

BidirectionalIterator trait

@kyleheadley
kyleheadley / untyped_lambda.rs
Created Aug 2, 2017
Implement the untyped lambda calculus in the Rust type system.
View untyped_lambda.rs
#![allow(unused)]
//#![feature(optin_builtin_traits)]
// Booleans
struct True;
struct False;
trait BoolOr<B> {type BoolOr;}
impl<B> BoolOr<B> for True {type BoolOr=True;}
impl BoolOr<True> for False {type BoolOr=True;}
impl BoolOr<False> for False {type BoolOr=False;}
@suhr
suhr / monochord.md
Last active Jan 1, 2019
Monochord: implementing a musical tunings library
View monochord.md

First at all, falsehoods programmers believe about musical tuning:

  • C♯ and D♭ are the same notes
  • C𝄪 and D are the same notes
  • Semitone is 100 cents wide
  • There's only 12 notes in the octave
    • There's only 24 notes
    • Okay, 31 notes
    • Come on, 72 notes per octave is enough for everybody
    • You're kidding, right?
@kristovatlas
kristovatlas / cssbanner-beautified2.js
Last active Mar 9, 2018
cleaned up version of cssbanner.js
View cssbanner-beautified2.js
//beautified at http://jsbeautifier.org/ with default options
//and then manually modified
/*jslint bitwise: true */
self.onmessage = function (msg) {
var thecode = msg.data;
/**
* Ostensibly unused function
View rolling_sphere.txt
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform vec2 resolution;
#define FTIME_PERIOD 16.0
uniform float ftime;
uniform float subsecond;
You can’t perform that action at this time.