Agda-2.6.2.2: A dependently typed functional programming language and proof assistant
Safe HaskellNone
LanguageHaskell2010

Agda.Utils.List1

Description

Non-empty lists.

Better name List1 for non-empty lists, plus missing functionality.

Import: @

{-# LANGUAGE PatternSynonyms #-}

import Agda.Utils.List1 (List1, pattern (:|)) import qualified Agda.Utils.List1 as List1

@

Synopsis
  • type List1 = NonEmpty
  • initLast :: List1 a -> ([a], a)
  • singleton :: a -> List1 a
  • appendList :: List1 a -> [a] -> List1 a
  • prependList :: [a] -> List1 a -> List1 a
  • snoc :: [a] -> a -> List1 a
  • groupBy' :: forall a. (a -> a -> Bool) -> [a] -> [List1 a]
  • breakAfter :: (a -> Bool) -> List1 a -> (List1 a, [a])
  • concat :: [List1 a] -> [a]
  • union :: Eq a => List1 a -> List1 a -> List1 a
  • ifNull :: [a] -> b -> (List1 a -> b) -> b
  • ifNotNull :: [a] -> (List1 a -> b) -> b -> b
  • unlessNull :: Null m => [a] -> (List1 a -> m) -> m
  • allEqual :: Eq a => List1 a -> Bool
  • catMaybes :: List1 (Maybe a) -> [a]
  • mapMaybe :: (a -> Maybe b) -> List1 a -> [b]
  • partitionEithers :: List1 (Either a b) -> ([a], [b])
  • lefts :: List1 (Either a b) -> [a]
  • rights :: List1 (Either a b) -> [b]
  • nubM :: Monad m => (a -> a -> m Bool) -> List1 a -> m (List1 a)
  • zipWithM :: Applicative m => (a -> b -> m c) -> List1 a -> List1 b -> m (List1 c)
  • zipWithM_ :: Applicative m => (a -> b -> m c) -> List1 a -> List1 b -> m ()
  • pattern (:|) :: a -> [a] -> NonEmpty a
  • (!!) :: NonEmpty a -> Int -> a
  • (<|) :: a -> NonEmpty a -> NonEmpty a
  • break :: (a -> Bool) -> NonEmpty a -> ([a], [a])
  • cons :: a -> NonEmpty a -> NonEmpty a
  • cycle :: NonEmpty a -> NonEmpty a
  • drop :: Int -> NonEmpty a -> [a]
  • dropWhile :: (a -> Bool) -> NonEmpty a -> [a]
  • filter :: (a -> Bool) -> NonEmpty a -> [a]
  • fromList :: [a] -> NonEmpty a
  • group :: (Foldable f, Eq a) => f a -> [NonEmpty a]
  • group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a)
  • groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a]
  • groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
  • groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a]
  • groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a)
  • groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a]
  • groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
  • head :: NonEmpty a -> a
  • init :: NonEmpty a -> [a]
  • inits :: Foldable f => f a -> NonEmpty [a]
  • insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a
  • intersperse :: a -> NonEmpty a -> NonEmpty a
  • isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool
  • iterate :: (a -> a) -> a -> NonEmpty a
  • last :: NonEmpty a -> a
  • length :: NonEmpty a -> Int
  • map :: (a -> b) -> NonEmpty a -> NonEmpty b
  • nonEmpty :: [a] -> Maybe (NonEmpty a)
  • nub :: Eq a => NonEmpty a -> NonEmpty a
  • nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a
  • partition :: (a -> Bool) -> NonEmpty a -> ([a], [a])
  • repeat :: a -> NonEmpty a
  • reverse :: NonEmpty a -> NonEmpty a
  • scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b
  • scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
  • scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b
  • scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
  • some1 :: Alternative f => f a -> f (NonEmpty a)
  • sort :: Ord a => NonEmpty a -> NonEmpty a
  • sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a
  • sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a
  • span :: (a -> Bool) -> NonEmpty a -> ([a], [a])
  • splitAt :: Int -> NonEmpty a -> ([a], [a])
  • tail :: NonEmpty a -> [a]
  • tails :: Foldable f => f a -> NonEmpty [a]
  • take :: Int -> NonEmpty a -> [a]
  • takeWhile :: (a -> Bool) -> NonEmpty a -> [a]
  • toList :: NonEmpty a -> [a]
  • transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a)
  • uncons :: NonEmpty a -> (a, Maybe (NonEmpty a))
  • unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b
  • unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b
  • unzip :: Functor f => f (a, b) -> (f a, f b)
  • xor :: NonEmpty Bool -> Bool
  • zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)
  • zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c

Documentation

type List1 = NonEmpty Source #

initLast :: List1 a -> ([a], a) Source #

Return the last element and the rest.

singleton :: a -> List1 a Source #

Build a list with one element.

appendList :: List1 a -> [a] -> List1 a Source #

Append a list to a non-empty list.

prependList :: [a] -> List1 a -> List1 a Source #

Prepend a list to a non-empty list.

snoc :: [a] -> a -> List1 a Source #

More precise type for snoc.

groupBy' :: forall a. (a -> a -> Bool) -> [a] -> [List1 a] Source #

More precise type for groupBy'.

A variant of groupBy which applies the predicate to consecutive pairs. O(n).

breakAfter :: (a -> Bool) -> List1 a -> (List1 a, [a]) Source #

Breaks a list just after an element satisfying the predicate is found.

>>> breakAfter even [1,3,5,2,4,7,8]
([1,3,5,2],[4,7,8])

concat :: [List1 a] -> [a] Source #

Concatenate one or more non-empty lists.

union :: Eq a => List1 a -> List1 a -> List1 a Source #

Like union. Duplicates in the first list are not removed. O(nm).

ifNull :: [a] -> b -> (List1 a -> b) -> b Source #

ifNotNull :: [a] -> (List1 a -> b) -> b -> b Source #

unlessNull :: Null m => [a] -> (List1 a -> m) -> m Source #

allEqual :: Eq a => List1 a -> Bool Source #

Checks if all the elements in the list are equal. Assumes that the Eq instance stands for an equivalence relation. O(n).

catMaybes :: List1 (Maybe a) -> [a] Source #

Like catMaybes.

mapMaybe :: (a -> Maybe b) -> List1 a -> [b] Source #

Like filter.

partitionEithers :: List1 (Either a b) -> ([a], [b]) Source #

lefts :: List1 (Either a b) -> [a] Source #

Like lefts.

rights :: List1 (Either a b) -> [b] Source #

Like rights.

nubM :: Monad m => (a -> a -> m Bool) -> List1 a -> m (List1 a) Source #

Non-efficient, monadic nub. O(n²).

zipWithM :: Applicative m => (a -> b -> m c) -> List1 a -> List1 b -> m (List1 c) Source #

Like zipWithM.

zipWithM_ :: Applicative m => (a -> b -> m c) -> List1 a -> List1 b -> m () Source #

Like zipWithM.

pattern (:|) :: a -> [a] -> NonEmpty a #

(!!) :: NonEmpty a -> Int -> a #

(<|) :: a -> NonEmpty a -> NonEmpty a #

break :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #

cons :: a -> NonEmpty a -> NonEmpty a #

cycle :: NonEmpty a -> NonEmpty a #

drop :: Int -> NonEmpty a -> [a] #

dropWhile :: (a -> Bool) -> NonEmpty a -> [a] #

filter :: (a -> Bool) -> NonEmpty a -> [a] #

fromList :: [a] -> NonEmpty a #

group :: (Foldable f, Eq a) => f a -> [NonEmpty a] #

group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a) #

groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a] #

groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) #

groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a] #

groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a) #

groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a] #

groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a) #

head :: NonEmpty a -> a #

init :: NonEmpty a -> [a] #

inits :: Foldable f => f a -> NonEmpty [a] #

insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a #

intersperse :: a -> NonEmpty a -> NonEmpty a #

isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool #

iterate :: (a -> a) -> a -> NonEmpty a #

last :: NonEmpty a -> a #

length :: NonEmpty a -> Int #

map :: (a -> b) -> NonEmpty a -> NonEmpty b #

nonEmpty :: [a] -> Maybe (NonEmpty a) #

nub :: Eq a => NonEmpty a -> NonEmpty a #

nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a #

partition :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #

repeat :: a -> NonEmpty a #

reverse :: NonEmpty a -> NonEmpty a #

scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b #

scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a #

scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b #

scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a #

some1 :: Alternative f => f a -> f (NonEmpty a) #

sort :: Ord a => NonEmpty a -> NonEmpty a #

sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a #

sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a #

span :: (a -> Bool) -> NonEmpty a -> ([a], [a]) #

splitAt :: Int -> NonEmpty a -> ([a], [a]) #

tail :: NonEmpty a -> [a] #

tails :: Foldable f => f a -> NonEmpty [a] #

take :: Int -> NonEmpty a -> [a] #

takeWhile :: (a -> Bool) -> NonEmpty a -> [a] #

toList :: NonEmpty a -> [a] #

transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a) #

uncons :: NonEmpty a -> (a, Maybe (NonEmpty a)) #

unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b #

unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b #

unzip :: Functor f => f (a, b) -> (f a, f b) #

xor :: NonEmpty Bool -> Bool #

zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b) #

zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c #