Skip to content

Instantly share code, notes, and snippets.

Kyle Headley kyleheadley

Block or report user

Report or block kyleheadley

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
kyleheadley /
Last active Feb 8, 2017
Prototype implementation of Monads in Rust
use std::fmt::Display;
trait Monadic {}
struct Monad<M:Monadic,T>(M,T);
struct Opt(bool);
impl Monadic for Opt {}
impl<T:Default> Monad<Opt,T> {
kyleheadley /
Last active Mar 20, 2017
CSCI 7000 Spring '17 -- Course Project Proposal

CSCI 7000 -- Course Project Proposal

Student name: Kyle Headley

Project Description:

  • Project kind: IC library implementation
  • Project details: Extend the rust implementation of the RAZ with additional incremental features.
use std::fmt::Debug;
struct Door<S: DoorState> {
state: S,
trait DoorState {}
kyleheadley /
Created Jul 10, 2017
Possible alternative for missing type equality in rust trait impl's
trait F<V,X> {}
struct D;
trait TheV2 {
type IsThis;
impl<V1,V2> TheV2 for F<V1,V2> {
type IsThis = V2;
kyleheadley /
Last active Jul 28, 2017
Show off type functions in rust with an example of 'type constructors'
// emulates the type of a function from types 'E' to sequence-like types
pub trait SeqTypeFn<E> { type Result : SeqLike<E>; }
// sequence-like interface
pub trait SeqLike<E>{
fn new() -> Self;
fn push(self,e:E) -> Self;
fn first(&self) -> Option<&E>;
kyleheadley /
Created Aug 1, 2017
Demonstrate searching a type-level list in rust
struct True;
struct False;
impl IsEqual<False> for True {type Out=False;}
impl IsEqual<False> for False {type Out=True;}
impl IsEqual<True> for True {type Out=True;}
impl IsEqual<True> for False {type Out=False;}
trait Nat {fn inst()->usize;}
struct Zero;
kyleheadley /
Created Aug 1, 2017
Playing around with type-level operations in rust
// #![feature(conservative_impl_trait)]
// basic nats, my knowledge
mod nat {
pub trait Nat { fn to_usize() -> usize; }
pub struct Zero;
impl Nat for Zero { fn to_usize() -> usize { 0 } }
pub struct Succ<N>(pub N);
kyleheadley /
Created Nov 11, 2017
Use pipes to communicate with z3 in rust
use std::error::Error;
use std::io::prelude::*;
use std::process::{Command, Stdio};
use std::str;
fn main() {
let process = match Command::new("z3")
// use any z3 language with another .arg() here
kyleheadley /
Last active Jan 2, 2018
Higher-order rust macro that assists in parsing by macro
/// Higher-order macro fold function for pre-parsing comma separated lists
/// The commas on KEYWORD lines can be changed to parse lists with any
/// separator.
/// run a macro on a list of lists after splitting the input at commas
macro_rules! split_comma {
// no defaults
{$fun:ident <= $($item:tt)*} => {
split_comma![$fun () () () <= $($item)*]
kyleheadley /
Last active Feb 21, 2018
An implementation in Rust of the examples from the OCaml manual chapter on modules and funtors
//! This file is a translation of the example code in the OCaml manual
//! chapter two,"The module system", into Rust code.
//! The intent is to translate as directly as possible, to show OCaml
//! users a way to implement their functionality. This means that
//! later, more complex sections are neither idiomatic Rust nor a
//! perfect translation of the OCaml. Further study would be required,
//! but hopefully this helps explain some of the concepts.
//! There are two constructs in Rust that might match OCaml modules,
You can’t perform that action at this time.