Mikan
Safe HaskellNone
LanguageHaskell2010

Mikan.Utils.List2

Description

Lists of length at least 2.

This module is meant to be imported qualified ala:

import Mikan.Utils.List2 (List2(List2))
import Mikan.Utils.List2 qualified as List2
Synopsis

Documentation

data List2 a Source #

Lists of length 2 or greater.

Constructors

List2 a a [a] 

Instances

Instances details
Functor List2 Source # 
Instance details

Defined in Mikan.Utils.List2

Methods

fmap :: (a -> b) -> List2 a -> List2 b #

(<$) :: a -> List2 b -> List2 a #

Foldable List2 Source # 
Instance details

Defined in Mikan.Utils.List2

Methods

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

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

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

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

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

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

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

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

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

toList :: List2 a -> [a] #

null :: List2 a -> Bool #

length :: List2 a -> Int #

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

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

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

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

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

Traversable List2 Source # 
Instance details

Defined in Mikan.Utils.List2

Methods

traverse :: Applicative f => (a -> f b) -> List2 a -> f (List2 b) #

sequenceA :: Applicative f => List2 (f a) -> f (List2 a) #

mapM :: Monad m => (a -> m b) -> List2 a -> m (List2 b) #

sequence :: Monad m => List2 (m a) -> m (List2 a) #

Zip List1 List2 List1 Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: List1 a -> List2 b -> List1 (a, b) Source #

zipWith :: (a -> b -> c) -> List1 a -> List2 b -> List1 c Source #

Zip List2 List1 List1 Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: List2 a -> List1 b -> List1 (a, b) Source #

zipWith :: (a -> b -> c) -> List2 a -> List1 b -> List1 c Source #

Zip List2 List2 List2 Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: List2 a -> List2 b -> List2 (a, b) Source #

zipWith :: (a -> b -> c) -> List2 a -> List2 b -> List2 c Source #

Zip List2 ListInf List2 Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: List2 a -> ListInf b -> List2 (a, b) Source #

zipWith :: (a -> b -> c) -> List2 a -> ListInf b -> List2 c Source #

Zip List2 [] [] Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: List2 a -> [b] -> [(a, b)] Source #

zipWith :: (a -> b -> c) -> List2 a -> [b] -> [c] Source #

Zip ListInf List2 List2 Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: ListInf a -> List2 b -> List2 (a, b) Source #

zipWith :: (a -> b -> c) -> ListInf a -> List2 b -> List2 c Source #

Zip [] List2 [] Source # 
Instance details

Defined in Mikan.Utils.Zip

Methods

zip :: [a] -> List2 b -> [(a, b)] Source #

zipWith :: (a -> b -> c) -> [a] -> List2 b -> [c] Source #

ExprLike a => ExprLike (List2 a) Source # 
Instance details

Defined in Mikan.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 Mikan.Syntax.Concrete.Generic

Methods

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

TraverseDecl a => TraverseDecl (List2 a) Source # 
Instance details

Defined in Mikan.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 Mikan.Syntax.Concrete.Pattern

Methods

foldrCPattern :: Monoid m => (Pattern -> m -> m) -> List2 p -> m Source #

traverseCPatternA :: Applicative 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 Mikan.Syntax.Position

Methods

getRange :: List2 a -> Range Source #

HasRangeWithoutFile a => HasRangeWithoutFile (List2 a) Source # 
Instance details

Defined in Mikan.Syntax.Position

KillRange a => KillRange (List2 a) Source # 
Instance details

Defined in Mikan.Syntax.Position

EmbPrj a => EmbPrj (List2 a) Source # 
Instance details

Defined in Mikan.TypeChecking.Serialise.Instances.General

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 Mikan.Utils.List2

Methods

rnf :: List2 a -> () #

IsList (List2 a) Source #

The fromList implementation for List2 is unsafe, and returns __IMPOSSIBLE__ when provided a list with less than two elements.

Instance details

Defined in Mikan.Utils.List2

Associated Types

type Item (List2 a) 
Instance details

Defined in Mikan.Utils.List2

type Item (List2 a) = a

Methods

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

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

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

Show a => Show (List2 a) Source # 
Instance details

Defined in Mikan.Utils.List2

Methods

showsPrec :: Int -> List2 a -> ShowS #

show :: List2 a -> String #

showList :: [List2 a] -> ShowS #

Eq a => Eq (List2 a) Source # 
Instance details

Defined in Mikan.Utils.List2

Methods

(==) :: List2 a -> List2 a -> Bool #

(/=) :: List2 a -> List2 a -> Bool #

Ord a => Ord (List2 a) Source # 
Instance details

Defined in Mikan.Utils.List2

Methods

compare :: List2 a -> List2 a -> Ordering #

(<) :: List2 a -> List2 a -> Bool #

(<=) :: List2 a -> List2 a -> Bool #

(>) :: List2 a -> List2 a -> Bool #

(>=) :: List2 a -> List2 a -> Bool #

max :: List2 a -> List2 a -> List2 a #

min :: List2 a -> List2 a -> List2 a #

type Item (List2 a) Source # 
Instance details

Defined in Mikan.Utils.List2

type Item (List2 a) = a

Conversions

fromList :: IsList l => [Item l] -> l #

The fromList function constructs the structure l from the given list of Item l

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

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

fromList1 :: List1 a -> List2 a Source #

\(\mathcal{O}(1)\). Convert a List1 to a List2.

This function is unsafe, and returns __IMPOSSIBLE__ on lists that have less than two elements.

toList1 :: List2 a -> List1 a Source #

\(\mathcal{O}(1)\). Convert a List2 to a List1.

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

\(\mathcal{O}(1)\). Try to convert a list to a List2.

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

\(\mathcal{O}(1)\). Try to convert a List1 to a List2.

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

\(\mathcal{O}(1)\). Any List1 is either a singleton or a List2.

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

\(\mathcal{O}(1)\). Inverse of fromList1Either.

Construction

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

\(\mathcal{O}(1)\). Cons an element onto the front of a List1.

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

\(\mathcal{O}(n)\). Snoc an element onto the end of a List1.

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

\(\mathcal{O}(n)\). Append two non-empty lists.

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

\(\mathcal{O}(n)\). Prepend a List2 onto a list.

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

Concatenate at least 2 lists of length at least 1.

Destruction

head :: List2 a -> a Source #

\(\mathcal{O}(1)\). Get the head of a List2.

Unlike head, this function is total.

tail :: List2 a -> List1 a Source #

\(\mathcal{O}(1)\). Get the tail of a List2.

Unlike tail, this function is total.

init :: List2 a -> List1 a Source #

\(\mathcal{O}(n)\). Get all but the last element of a List2.

Unlike init, this function is total.

Sublists

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

\(\mathcal{O}(n)\). A variant of break for List2.

Zips

zip :: List2 a -> List2 b -> List2 (a, b) Source #

\(\mathcal{O}(n)\). A variant of zip for List2.

zipWith :: (a -> b -> c) -> List2 a -> List2 b -> List2 c Source #

\(\mathcal{O}(n)\). A variant of zipWith for List2.