graydon/rust — Issue #1105: List: make "car"/"cdr"'s expectation of a non-empty list visible in the type system
Author: Lenny222
Created: 2011-10-31 13:53:08+00:00
State: open

Currently list::car/cdr call "fail" when the list is empty.

Haskell's "head"/"tail" do the same and it causes a lot of grieve: http://www.reddit.com/r/haskell/comments/lf71l/deprecate_preludehead_and_partial_functions/

I suggest to either
a) make the return type an "option"
b) add a "is_not_empty" predicate, similar to vec::head/tail

b) is probably more Rust-nic.