Agda-2.8.0: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Utils.List2

Description

Lists of length at least 2.

Import as: `import Agda.Utils.List2 (List2(List2)) import qualified Agda.Utils.List2 as List2`

Synopsis

- head :: List2 a -> a
- tail :: List2 a -> List1 a
- init :: List2 a -> List1 a
- break :: (a -> Bool) -> List2 a -> ([a], [a])
- cons :: a -> List1 a -> List2 a
- append :: List1 a -> List1 a -> List2 a
- appendList :: List2 a -> [a] -> List2 a
- snoc :: List1 a -> a -> List2 a
- data List2 a = List2 a a [a]
- fromList1 :: List1 a -> List2 a
- toList1 :: List2 a -> List1 a
- fromListMaybe :: [a] -> Maybe (List2 a)
- fromList1Maybe :: List1 a -> Maybe (List2 a)
- fromList1Either :: List1 a -> Either a (List2 a)
- toList1Either :: Either a (List2 a) -> List1 a
- concat21 :: List2 (List1 a) -> List2 a
- toList :: IsList l => l -> [Item l]

# Documentation

head :: List2 a -> a Source #

Safe. O(1).

tail :: List2 a -> List1 a Source #

Safe. O(1).

init :: List2 a -> List1 a Source #

Safe. O(n).

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

cons :: a -> List1 a -> List2 a Source #

O(1).

append :: List1 a -> List1 a -> List2 a Source #

O(length first list).

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

O(length first list).

snoc :: List1 a -> a -> List2 a Source #

O(n).

data List2 a Source #

Lists of length ≥2.

Constructors

List2 a a [a] |

#### Instances

Instances details

Functor List2 Source # |
Instance details Defined in Agda.Utils.List2 Methods fmap :: (a -> b) -> List2 a -> List2 b Source # (<$) :: a -> List2 b -> List2 a Source #
Foldable List2 Source # |

Instance details

Defined in Agda.Utils.List2

Methods

fold :: Monoid m => List2 m -> m Source #

foldMap :: Monoid m => (a -> m) -> List2 a -> m Source #

foldMap' :: Monoid m => (a -> m) -> List2 a -> m Source #

foldr :: (a -> b -> b) -> b -> List2 a -> b Source #

foldr' :: (a -> b -> b) -> b -> List2 a -> b Source #

foldl :: (b -> a -> b) -> b -> List2 a -> b Source #

foldl' :: (b -> a -> b) -> b -> List2 a -> b Source #

foldr1 :: (a -> a -> a) -> List2 a -> a Source #

foldl1 :: (a -> a -> a) -> List2 a -> a Source #

toList :: List2 a -> [a] Source #

null :: List2 a -> Bool Source #

length :: List2 a -> Int Source #

elem :: Eq a => a -> List2 a -> Bool Source #

maximum :: Ord a => List2 a -> a Source #

minimum :: Ord a => List2 a -> a Source #

sum :: Num a => List2 a -> a Source #

product :: Num a => List2 a -> a Source #

Traversable List2 Source # |
Instance details Defined in Agda.Utils.List2 Methods traverse :: Applicative f => (a -> f b) -> List2 a -> f (List2 b) Source # sequenceA :: Applicative f => List2 (f a) -> f (List2 a) Source # mapM :: Monad m => (a -> m b) -> List2 a -> m (List2 b) Source # sequence :: Monad m => List2 (m a) -> m (List2 a) Source #
ExprLike a => ExprLike (List2 a) Source # |
Instance details Defined in Agda.Syntax.Concrete.Generic Methods mapExpr :: (Expr -> Expr) -> List2 a -> List2 a Source # foldExpr :: Monoid m => (Expr -> m) -> List2 a -> m Source # traverseExpr :: Monad m => (Expr -> m Expr) -> List2 a -> m (List2 a) Source #
FoldDecl a => FoldDecl (List2 a) Source # |
Instance details Defined in Agda.Syntax.Concrete.Generic Methods foldDecl :: Monoid m => (Declaration -> m) -> List2 a -> m Source #
TraverseDecl a => TraverseDecl (List2 a) Source # |
Instance details Defined in Agda.Syntax.Concrete.Generic Methods preTraverseDecl :: Monad m => (Declaration -> m Declaration) -> List2 a -> m (List2 a) Source #
CPatternLike p => CPatternLike (List2 p) Source # |
Instance details Defined in Agda.Syntax.Concrete.Pattern Methods foldrCPattern :: Monoid m => (Pattern -> m -> m) -> List2 p -> m Source # traverseCPatternA :: (Applicative m, Functor m) => (Pattern -> m Pattern -> m Pattern) -> List2 p -> m (List2 p) Source # traverseCPatternM :: Monad m => (Pattern -> m Pattern) -> (Pattern -> m Pattern) -> List2 p -> m (List2 p) Source #
HasRange a => HasRange (List2 a) Source # |
Instance details Defined in Agda.Syntax.Position Methods getRange :: List2 a -> Range Source #
HasRangeWithoutFile a => HasRangeWithoutFile (List2 a) Source # |
Instance details Defined in Agda.Syntax.Position Methods getRangeWithoutFile :: List2 a -> RangeWithoutFile Source #
KillRange a => KillRange (List2 a) Source # |
Instance details Defined in Agda.Syntax.Position Methods killRange :: KillRangeT (List2 a) Source #
EmbPrj a => EmbPrj (List2 a) Source # |
Instance details Defined in Agda.TypeChecking.Serialise.Instances.Common Methods icode :: List2 a -> S Word32 Source # icod_ :: List2 a -> S Word32 Source # value :: Word32 -> R (List2 a) Source #
NFData a => NFData (List2 a) Source # |
Instance details Defined in Agda.Utils.List2 Methods rnf :: List2 a -> () Source #
IsList (List2 a) Source # | `fromList` is unsafe.

Instance details

Defined in Agda.Utils.List2

Associated Types

type Item (List2 a) |
Instance details Defined in Agda.Utils.List2 type Item (List2 a) = a

Methods

fromList :: [Item (List2 a)] -> List2 a Source #

fromListN :: Int -> [Item (List2 a)] -> List2 a Source #

toList :: List2 a -> [Item (List2 a)] Source #

Show a => Show (List2 a) Source # |
Instance details Defined in Agda.Utils.List2 Methods showsPrec :: Int -> List2 a -> ShowS Source # show :: List2 a -> String Source # showList :: [List2 a] -> ShowS Source #
Eq a => Eq (List2 a) Source # |
Instance details Defined in Agda.Utils.List2 Methods (==) :: List2 a -> List2 a -> Bool Source # (/=) :: List2 a -> List2 a -> Bool Source #
Ord a => Ord (List2 a) Source # |
Instance details Defined in Agda.Utils.List2 Methods compare :: List2 a -> List2 a -> Ordering Source # (<) :: List2 a -> List2 a -> Bool Source # (<=) :: List2 a -> List2 a -> Bool Source # (>) :: List2 a -> List2 a -> Bool Source # (>=) :: List2 a -> List2 a -> Bool Source # max :: List2 a -> List2 a -> List2 a Source # min :: List2 a -> List2 a -> List2 a Source #
type Item (List2 a) Source # |
Instance details Defined in Agda.Utils.List2 type Item (List2 a) = a

fromList1 :: List1 a -> List2 a Source #

Unsafe! O(1).

toList1 :: List2 a -> List1 a Source #

Safe. O(1).

fromListMaybe :: [a] -> Maybe (List2 a) Source #

Safe. O(1).

fromList1Maybe :: List1 a -> Maybe (List2 a) Source #

Safe. O(1).

fromList1Either :: List1 a -> Either a (List2 a) Source #

Any `List1` is either a singleton or a `List2`. O(1).

toList1Either :: Either a (List2 a) -> List1 a Source #

Inverse of `fromList1Either`. O(1).

concat21 :: List2 (List1 a) -> List2 a Source #

Concatenate at least 2 lists of length at least 1.

toList :: IsList l => l -> [Item l] Source #

The `toList` function extracts a list of `Item l` from the structure `l`. It should satisfy fromList . toList = id.