This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
head and tail without the Maybe
version 1.7.0
license BSD3
native-modules False
elm-version 0.15.0 <= v < 0.16.0
Tag 1.7.0
Committed At 2015-11-02 16:17:28 UTC
elm-lang/core 2.0.1 <= v < 3.0.0 2.1.0

Modules

README

List.Nonempty for Elm

A list that is known, at compile-time, to be nonempty. This means head and tail are guaranteed to succeed and you don't have to carry Maybes throughout your program.

import List.Nonempty exposing (..)
one = fromElement 2
two = 4 ::: one
toList two == [4, 2]
head two == 4
tail two == [2]
toList (reverse two) == [2, 4]
toList (dropTail two) == [4]
member 4 two == True
foldl1 (+) two == 6

For actual usage, I recommend import List.Nonempty as NE exposing (Nonempty, (:::)) to import the type and infix cons.

Testing

Run elm reactor in the test directory, open Test.elm, and wait a few seconds while libraries are downloaded. Thanks to all the work that went into property-based testing, even if it's overkill for this tiny library.