This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Convert.List

Convert wrappers for list

attemptTail : List a -> List a -> List a

Try to return the tail of a list, returning default value if failed

attemptHead : a -> List a -> a

Try to return the head of a list, returning default value if failed

module Convert.List where
{-| Convert wrappers for list 

@docs attemptTail, attemptHead
-}

import Convert exposing (defaultMaybe)

import List exposing (head, tail)

{-|
  Try to return the tail of a list, returning default value if failed
-}
attemptTail : List a -> List a -> List a
attemptTail defaultList list  = defaultMaybe tail defaultList list

{-|
  Try to return the head of a list, returning default value if failed
-}
attemptHead : a -> List a -> a
attemptHead defaultItem list  = defaultMaybe head defaultItem list