-
Easy chaining of monadic actions.
Ie. separating two monadic actions should chain them together with
bind(a, |_| b)
. -
Simple bind of a value to an ident.
This should probably also allow any monadic action and not just calls to functions, eg. something like:
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
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs | |
index 61e81d7..69328e8 100644 | |
--- a/src/librustc_trans/trans/base.rs | |
+++ b/src/librustc_trans/trans/base.rs | |
@@ -2343,6 +2343,8 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { | |
let val = match item { | |
ast_map::NodeItem(i) => { | |
let ty = ccx.tcx().node_id_to_type(i.id); | |
+ let ty = monomorphize::normalize_associated_type(ccx.tcx(), &ty); | |
+ |
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
error: internal compiler error: fictitious type impl Parser<u8, &'static [u8], error::Error<u8>> + Sized + 'static in sizing_type_of() | |
note: the compiler unexpectedly panicked. this is a bug. | |
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports | |
thread 'rustc' panicked at 'Box<Any>', src/libsyntax/diagnostic.rs:253 | |
stack backtrace: | |
1: 0x1080028f5 - sys::backtrace::write::ha0bc4a9bddc6a867Cxs | |
2: 0x10800b9fe - panicking::on_panic::ha9dfbe03b50c004akYw | |
3: 0x107fc53e2 - rt::unwind::begin_unwind_inner::hca93a9fd146d03e3vGw |
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
error: internal compiler error: fictitious type impl Parser<u8, &'static [u8], error::Error<u8>> + Sized + 'static in sizing_type_of() | |
note: the compiler unexpectedly panicked. this is a bug. | |
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports | |
thread 'rustc' panicked at 'Box<Any>', src/libsyntax/diagnostic.rs:253 | |
stack backtrace: | |
1: 0x1070328f5 - sys::backtrace::write::hbde7a04ac5266f40Cxs | |
2: 0x10703b9fe - panicking::on_panic::hebff0ba18b62efb1kYw | |
3: 0x106ff53e2 - rt::unwind::begin_unwind_inner::hda386695be757df8vGw | |
4: 0x104c6741f - rt::unwind::begin_unwind::h4700935743387377434 |
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
[package] | |
name = "test" | |
version = "0.1.0" | |
authors = ["Martin Wernstål <m4rw3r@gmail.com>"] | |
[dependencies.parser] | |
path = "/Users/m4rw3r/Projects/Self/rust_parser" |
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
#![crate_name = "parser"] | |
#![crate_type = "lib"] | |
use std::ops::Add; | |
/// ``` | |
/// use parser::test; | |
/// | |
/// assert_eq!(test::<i32>(1)(2), 3); | |
/// ``` |
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
Running target/debug/parser-4592a6b517fc46f5 | |
running 5 tests | |
test mdo::test::mdo ... ok | |
test mdo::test::mdo_closure ... ok | |
test monad::test::associativity ... ok | |
test monad::test::right_identity ... ok | |
test monad::test::left_identity ... ok | |
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured |
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
extern crate combine; | |
use combine::*; | |
use combine::combinator::{take_while1, range}; | |
use combine::primitives::Error; | |
use std::fs::File; | |
use std::env; | |
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
extern crate combine; | |
use combine::*; | |
use std::fs::File; | |
use std::env; | |
// Seems like combine does not support any kind of zero-copy parsing | |
#[derive(Debug, Clone)] | |
struct Request { |
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
diff --git a/examples/http_parser.rs b/examples/http_parser.rs | |
index 5c31b35..196763e 100644 | |
--- a/examples/http_parser.rs | |
+++ b/examples/http_parser.rs | |
@@ -41,17 +41,17 @@ fn is_not_space(c: u8) -> bool { c != b' ' } | |
fn is_end_of_line(c: u8) -> bool { c == b'\r' || c == b'\n' } | |
fn is_http_version(c: u8) -> bool { c >= b'0' && c <= b'9' || c == b'.' } | |
-fn end_of_line<'a>(p: Empty<'a, u8>) -> Parser<'a, u8, u8, Error<u8>> { | |
- or(mdo!{p, |