Skip to content

List: make head/tail's expectation of a non-empty list visible in the type system #1105

Closed
@kud1ing

Description

@kud1ing

Currently list::head/tail call "fail" when the list is empty.

Haskell's head/tail do the same and it causes a lot of grief: 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions