Skip to content

Instantly share code, notes, and snippets.

View jroesch's full-sized avatar

Jared Roesch jroesch

View GitHub Profile
λ 169-231-106-204 rust → λ git generalize-impl-bounds* → RUST_BACKTRACE=1 RUST_LOG=rustc_typeck::check::compare_method=debug x86_64-apple-darwin/stage1/bin/rustc src/test/compile-fail/regions-bound-missing-bound-in-impl.rs
DEBUG:rustc_typeck::check::compare_method: compare_impl_method(impl_trait_ref=TraitRef('aint, Foo<'a>))
DEBUG:rustc_typeck::check::compare_method: impl_trait_ref (liberated) = TraitRef('aint, Foo<'a>)
DEBUG:rustc_typeck::check::compare_method: compare_impl_method: trait_to_skol_substs=Substs[types=[[];[&'a int];[]], regions=[[ReFree(109, BrNamed(DefId { krate: 0, node: 179 }, 'a))];[];[ReFree(109, BrNamed(DefId { krate: 0, node: 97 }, 'b))]]]
DEBUG:rustc_typeck::check::compare_method: compare_impl_method: impl_bounds=GenericBounds([[];[];[Binder(OutlivesPredicate(ReFree(109, BrNamed(DefId { krate: 0, node: 97 }, 'b)), ReFree(109, BrNamed(DefId { krate: 0, node: 179 }, 'a))))]])
DEBUG:rustc_typeck::check::compare_method: compare_impl_method: trait_bounds=GenericBounds([[];[];[]])
DEBUG:rustc
trait Foo<T> {
fn meth(&self) where T: Copy {}
}
impl<T> Foo<T> for int {
fn meth(&self) where T: Eq {}
}
fn main() {
Foo::<int>::meth(&1);
@jroesch
jroesch / TypedLogic.idr
Created December 21, 2014 04:43
TypedLogic
module TypedLogic
import Data.SortedMap
data LType : Type where
FreshType : LType
Atom : String -> LType
DisjUnion : LType -> LType -> LType
Relation : (Vect n LType) -> LType
#![feature(associated_types)]
trait N {
type Repr;
}
trait SizedVec<A: N> {}
fn main() {}
@jroesch
jroesch / ex.hs
Created November 12, 2014 21:18
Using associated types to represent existentials
class Request where
data R
...
class Response where
data R
class (Request Req, Response Resp) => Http where
data Req
data Resp
@jroesch
jroesch / gist:3176f3631aab87f63db4
Created October 14, 2014 21:14
dynamic to static idris
module Main
listToVect : (n: Nat) -> List a -> Maybe (Vect n a)
listToVect Z Nil = Just Nil
listToVect n Nil = Nothing
listToVect (S n) (x :: xs) = map (x ::) (listToVect n xs)
import shapeless._
...
config.vm.provider :vmware_fusion do |vm|
vdiskmanager = '/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager'
dir = "#{ENV['HOME']}/vagrant-additional-disk"
unless File.directory?( dir )
Dir.mkdir dir
end
@jroesch
jroesch / nat.rs
Created August 28, 2014 10:09
Type level naturals in Rust
use std::fmt::{Formatter, Show, FormatError};
trait Nat {}
struct Z;
struct Succ<N> {
pred: Box<N>
}
impl Nat for Z {}
@jroesch
jroesch / hlist.rs
Last active August 29, 2015 14:05
use std::fmt::{Formatter, Show, FormatError};
trait HList {
fn cons<H>(self, xs: H) -> HCons<H, Self>;
}
struct HCons<H, T> {
head: H,
tail: Box<T>
}