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

Safe Haskell | Safe
Language | Haskell2010

Agda.Utils.NonemptyList

Description

Nonempty lists.

Synopsis

- data NonemptyList a = (:!) {
  - headNe :: a
  - tailNe :: [a]
  }
- toList :: NonemptyList a -> [a]
- fromList :: [a] -> Maybe (NonemptyList a)
- consNe :: a -> NonemptyList a -> NonemptyList a
- unionNe :: Eq a => NonemptyList a -> NonemptyList a -> NonemptyList a
- zipWithNe :: (a -> b -> c) -> NonemptyList a -> NonemptyList b -> NonemptyList c
- zipNe :: NonemptyList a -> NonemptyList b -> NonemptyList (a, b)
- caseListNe :: [a] -> b -> (NonemptyList a -> b) -> b
- listCaseNe :: b -> (NonemptyList a -> b) -> [a] -> b
- elemNe :: Eq a => a -> NonemptyList a -> Bool

# Documentation

data NonemptyList a Source #

Constructors

(:!) infixr 5 |

Fields

- headNe :: a
- tailNe :: [a]

Instances

Monad NonemptyList Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods (>>=) :: NonemptyList a -> (a -> NonemptyList b) -> NonemptyList b Source # (>>) :: NonemptyList a -> NonemptyList b -> NonemptyList b Source # return :: a -> NonemptyList a Source # fail :: String -> NonemptyList a Source #
Functor NonemptyList Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods fmap :: (a -> b) -> NonemptyList a -> NonemptyList b Source # (<$) :: a -> NonemptyList b -> NonemptyList a Source #
Applicative NonemptyList Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods pure :: a -> NonemptyList a Source # (<*>) :: NonemptyList (a -> b) -> NonemptyList a -> NonemptyList b Source # liftA2 :: (a -> b -> c) -> NonemptyList a -> NonemptyList b -> NonemptyList c Source # (*>) :: NonemptyList a -> NonemptyList b -> NonemptyList b Source # (<*) :: NonemptyList a -> NonemptyList b -> NonemptyList a Source #
Foldable NonemptyList Source # |

Instance details

Defined in Agda.Utils.NonemptyList

Methods

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

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

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

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

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

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

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

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

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

null :: NonemptyList a -> Bool Source #

length :: NonemptyList a -> Int Source #

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

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

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

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

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

Traversable NonemptyList Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods traverse :: Applicative f => (a -> f b) -> NonemptyList a -> f (NonemptyList b) Source # sequenceA :: Applicative f => NonemptyList (f a) -> f (NonemptyList a) Source # mapM :: Monad m => (a -> m b) -> NonemptyList a -> m (NonemptyList b) Source # sequence :: Monad m => NonemptyList (m a) -> m (NonemptyList a) Source #
Singleton a (NonemptyList a) Source # |
Instance details Defined in Agda.Utils.Singleton Methods singleton :: a -> NonemptyList a Source #
Eq a => Eq (NonemptyList a) Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods (==) :: NonemptyList a -> NonemptyList a -> Bool Source # (/=) :: NonemptyList a -> NonemptyList a -> Bool Source #
Data a => Data (NonemptyList a) Source # |

Instance details

Defined in Agda.Utils.NonemptyList

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NonemptyList a -> c (NonemptyList a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NonemptyList a) Source #

toConstr :: NonemptyList a -> Constr Source #

dataTypeOf :: NonemptyList a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NonemptyList a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NonemptyList a)) Source #

gmapT :: (forall b. Data b => b -> b) -> NonemptyList a -> NonemptyList a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NonemptyList a -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NonemptyList a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> NonemptyList a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> NonemptyList a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> NonemptyList a -> m (NonemptyList a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NonemptyList a -> m (NonemptyList a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NonemptyList a -> m (NonemptyList a) Source #

Ord a => Ord (NonemptyList a) Source # |

Instance details

Defined in Agda.Utils.NonemptyList

Methods

compare :: NonemptyList a -> NonemptyList a -> Ordering Source #

(<) :: NonemptyList a -> NonemptyList a -> Bool Source #

(<=) :: NonemptyList a -> NonemptyList a -> Bool Source #

(>) :: NonemptyList a -> NonemptyList a -> Bool Source #

(>=) :: NonemptyList a -> NonemptyList a -> Bool Source #

max :: NonemptyList a -> NonemptyList a -> NonemptyList a Source #

min :: NonemptyList a -> NonemptyList a -> NonemptyList a Source #

Show a => Show (NonemptyList a) Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods showsPrec :: Int -> NonemptyList a -> ShowS Source # show :: NonemptyList a -> String Source # showList :: [NonemptyList a] -> ShowS Source #
Semigroup (NonemptyList a) Source # |
Instance details Defined in Agda.Utils.NonemptyList Methods (<>) :: NonemptyList a -> NonemptyList a -> NonemptyList a Source # sconcat :: NonEmpty (NonemptyList a) -> NonemptyList a Source # stimes :: Integral b => b -> NonemptyList a -> NonemptyList a Source #
Pretty a => Pretty (NonemptyList a) Source # |
Instance details Defined in Agda.Utils.Pretty Methods pretty :: NonemptyList a -> Doc Source # prettyPrec :: Int -> NonemptyList a -> Doc Source # prettyList :: [NonemptyList a] -> Doc Source #
KillRange a => KillRange (NonemptyList a) Source # |
Instance details Defined in Agda.Syntax.Position Methods killRange :: KillRangeT (NonemptyList a) Source #
HasRange a => HasRange (NonemptyList a) Source # | Precondition: The ranges of the list elements must point to the same file (or be empty).
Instance details Defined in Agda.Syntax.Position Methods getRange :: NonemptyList a -> Range Source #
EmbPrj a => EmbPrj (NonemptyList a) Source # |
Instance details Defined in Agda.TypeChecking.Serialise.Instances.Common Methods icode :: NonemptyList a -> S Int32 Source # icod_ :: NonemptyList a -> S Int32 Source # value :: Int32 -> R (NonemptyList a) Source #
NamesIn a => NamesIn (NonemptyList a) Source # |
Instance details Defined in Agda.Syntax.Internal.Names Methods namesIn :: NonemptyList a -> Set QName Source #

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

Implementing conversion to list manually, since `Foldable.toList` might recurse over the tail and, thus, destroy sharing.

fromList :: [a] -> Maybe (NonemptyList a) Source #

Converting a list (safe).

consNe :: a -> NonemptyList a -> NonemptyList a Source #

Prepending an element.

unionNe :: Eq a => NonemptyList a -> NonemptyList a -> NonemptyList a Source #

Returns the union of the argument lists seen as sets. The order of the elements in the result is not specified. Precondition: arguments contain no duplicates.

zipWithNe :: (a -> b -> c) -> NonemptyList a -> NonemptyList b -> NonemptyList c Source #

Zip two nonempty lists.

zipNe :: NonemptyList a -> NonemptyList b -> NonemptyList (a, b) Source #

Zip two nonempty lists.

caseListNe :: [a] -> b -> (NonemptyList a -> b) -> b Source #

Case on a list, getting a nonempty list in the cons case.

listCaseNe :: b -> (NonemptyList a -> b) -> [a] -> b Source #

Case on a list, with list last.

elemNe :: Eq a => a -> NonemptyList a -> Bool Source #

Check if an element is present in a list.