-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type classes for mapping, folding, and traversing monomorphic containers
--   
--   Monomorphic variants of the Functor, Foldable, and Traversable
--   typeclasses. Contains even more experimental code for abstracting
--   containers and sequences.
@package mono-traversable
@version 0.6.1


-- | Provides conversion functions between strict <tt>ByteString</tt>s and
--   storable <tt>Vector</tt>s.
module Data.ByteVector

-- | Convert a <tt>ByteString</tt> into a storable <tt>Vector</tt>.
--   
--   Since 0.6.1
toByteVector :: ByteString -> Vector Word8

-- | Convert a storable <tt>Vector</tt> into a <tt>ByteString</tt>.
--   
--   Since 0.6.1
fromByteVector :: Vector Word8 -> ByteString


-- | Type classes mirroring standard typeclasses, but working with
--   monomorphic containers.
--   
--   The motivation is that some commonly used data types (i.e.,
--   <tt>ByteString</tt> and <tt>Text</tt>) do not allow for instances of
--   typeclasses like <tt>Functor</tt> and <tt>Foldable</tt>, since they
--   are monomorphic structures. This module allows both monomorphic and
--   polymorphic data types to be instances of the same typeclasses.
--   
--   All of the laws for the polymorphic typeclasses apply to their
--   monomorphic cousins. Thus, even though a <tt>MonoFunctor</tt> instance
--   for <tt>Set</tt> could theoretically be defined, it is omitted since
--   it could violate the functor law of <tt>omap f . omap g = omap (f .
--   g)</tt>.
--   
--   Note that all typeclasses have been prefixed with <tt>Mono</tt>, and
--   functions have been prefixed with <tt>o</tt>. The mnemonic for
--   <tt>o</tt> is "only one," or alternatively "it's mono, but m is
--   overused in Haskell, so we'll use the second letter instead." (Agreed,
--   it's not a great mangling scheme, input is welcome!)
module Data.MonoTraversable
class MonoFunctor mono where omap = fmap
omap :: MonoFunctor mono => (Element mono -> Element mono) -> mono -> mono
class MonoFoldable mono where ofoldMap = foldMap ofoldr = foldr ofoldl' = foldl' otoList t = build (\ mono n -> ofoldr mono n t) oall f = getAll . ofoldMap (All . f) oany f = getAny . ofoldMap (Any . f) onull = oall (const False) olength = ofoldl' (\ i _ -> i + 1) 0 olength64 = ofoldl' (\ i _ -> i + 1) 0 ocompareLength c0 i0 = olength c0 `compare` fromIntegral i0 otraverse_ f = ofoldr ((*>) . f) (pure ()) ofor_ = flip otraverse_ omapM_ f = ofoldr ((>>) . f) (return ()) oforM_ = flip omapM_ ofoldlM f z0 xs = ofoldr f' return xs z0 where f' x k z = f z x >>= k ofoldMap1Ex f = maybe (error "Data.MonoTraversable.ofoldMap1Ex") id . getOption . ofoldMap (Option . Just . f) ofoldr1Ex = foldr1 ofoldl1Ex' = foldl1 headEx = ofoldr const (error "Data.MonoTraversable.headEx: empty") lastEx = ofoldl1Ex' (flip const) unsafeHead = headEx unsafeLast = lastEx maximumByEx f = ofoldl1Ex' go where go x y = case f x y of { LT -> y _ -> x } minimumByEx f = ofoldl1Ex' go where go x y = case f x y of { GT -> y _ -> x }
ofoldMap :: (MonoFoldable mono, Monoid m) => (Element mono -> m) -> mono -> m
ofoldr :: MonoFoldable mono => (Element mono -> b -> b) -> b -> mono -> b
ofoldl' :: MonoFoldable mono => (a -> Element mono -> a) -> a -> mono -> a
otoList :: MonoFoldable mono => mono -> [Element mono]
oall :: MonoFoldable mono => (Element mono -> Bool) -> mono -> Bool
oany :: MonoFoldable mono => (Element mono -> Bool) -> mono -> Bool
onull :: MonoFoldable mono => mono -> Bool
olength :: MonoFoldable mono => mono -> Int
olength64 :: MonoFoldable mono => mono -> Int64
ocompareLength :: (MonoFoldable mono, Integral i) => mono -> i -> Ordering
otraverse_ :: (MonoFoldable mono, MonoFoldable mono, Applicative f) => (Element mono -> f b) -> mono -> f ()
ofor_ :: (MonoFoldable mono, MonoFoldable mono, Applicative f) => mono -> (Element mono -> f b) -> f ()
omapM_ :: (MonoFoldable mono, MonoFoldable mono, Monad m) => (Element mono -> m ()) -> mono -> m ()
oforM_ :: (MonoFoldable mono, MonoFoldable mono, Monad m) => mono -> (Element mono -> m ()) -> m ()
ofoldlM :: (MonoFoldable mono, MonoFoldable mono, Monad m) => (a -> Element mono -> m a) -> a -> mono -> m a
ofoldMap1Ex :: (MonoFoldable mono, Semigroup m) => (Element mono -> m) -> mono -> m
ofoldr1Ex :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> mono -> Element mono
ofoldl1Ex' :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> mono -> Element mono
headEx :: MonoFoldable mono => mono -> Element mono
lastEx :: MonoFoldable mono => mono -> Element mono
unsafeHead :: MonoFoldable mono => mono -> Element mono
unsafeLast :: MonoFoldable mono => mono -> Element mono
maximumByEx :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Element mono
minimumByEx :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Element mono

-- | like Data.List.head, but not partial
headMay :: MonoFoldable mono => mono -> Maybe (Element mono)

-- | like Data.List.last, but not partial
lastMay :: MonoFoldable mono => mono -> Maybe (Element mono)

-- | The <tt>sum</tt> function computes the sum of the numbers of a
--   structure.
osum :: (MonoFoldable mono, Num (Element mono)) => mono -> Element mono

-- | The <tt>product</tt> function computes the product of the numbers of a
--   structure.
oproduct :: (MonoFoldable mono, Num (Element mono)) => mono -> Element mono

-- | Are all of the values <tt>True</tt>?
--   
--   Since 0.6.0
oand :: (Element mono ~ Bool, MonoFoldable mono) => mono -> Bool

-- | Are any of the values <tt>True</tt>?
--   
--   Since 0.6.0
oor :: (Element mono ~ Bool, MonoFoldable mono) => mono -> Bool
class (MonoFoldable mono, Monoid mono) => MonoFoldableMonoid mono where oconcatMap = ofoldMap
oconcatMap :: MonoFoldableMonoid mono => (Element mono -> mono) -> mono -> mono

-- | A typeclass for <tt>MonoFoldable</tt>s containing elements which are
--   an instance of <tt>Ord</tt>.
class (MonoFoldable mono, Ord (Element mono)) => MonoFoldableOrd mono where maximumEx = maximumByEx compare minimumEx = minimumByEx compare
maximumEx :: MonoFoldableOrd mono => mono -> Element mono
minimumEx :: MonoFoldableOrd mono => mono -> Element mono
maximumMay :: MonoFoldableOrd mono => mono -> Maybe (Element mono)
maximumByMay :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Maybe (Element mono)
minimumMay :: MonoFoldableOrd mono => mono -> Maybe (Element mono)
minimumByMay :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> mono -> Maybe (Element mono)
class (MonoFunctor mono, MonoFoldable mono) => MonoTraversable mono where otraverse = traverse omapM = mapM
otraverse :: (MonoTraversable mono, Applicative f) => (Element mono -> f (Element mono)) -> mono -> f mono
omapM :: (MonoTraversable mono, Monad m) => (Element mono -> m (Element mono)) -> mono -> m mono
ofor :: (MonoTraversable mono, Applicative f) => mono -> (Element mono -> f (Element mono)) -> f mono
oforM :: (MonoTraversable mono, Monad f) => mono -> (Element mono -> f (Element mono)) -> f mono

-- | A strict left fold, together with an unwrap function.
--   
--   This is convenient when the accumulator value is not the same as the
--   final expected type. It is provided mainly for integration with the
--   <tt>foldl</tt> package, to be used in conjunction with
--   <tt>purely</tt>.
--   
--   Since 0.3.1
ofoldlUnwrap :: MonoFoldable mono => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b

-- | A monadic strict left fold, together with an unwrap function.
--   
--   Similar to <tt>foldlUnwrap</tt>, but allows monadic actions. To be
--   used with <tt>impurely</tt> from <tt>foldl</tt>.
--   
--   Since 0.3.1
ofoldMUnwrap :: (Monad m, MonoFoldable mono) => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b

-- | Instances must obey the laws:
--   
--   <ul>
--   <li><pre>otoList . mconcat . map opoint == id</pre></li>
--   </ul>
class MonoPointed mono
opoint :: MonoPointed mono => Element mono -> mono
instance MonoPointed (Either a b)
instance Storable a => MonoPointed (Vector a)
instance Unbox a => MonoPointed (Vector a)
instance Hashable a => MonoPointed (HashSet a)
instance MonoPointed (DList a)
instance MonoPointed (Set a)
instance MonoPointed (Vector a)
instance MonoPointed (Identity a)
instance MonoPointed (NonEmpty a)
instance MonoPointed (Option a)
instance MonoPointed (Seq a)
instance MonoPointed (Maybe a)
instance MonoPointed [a]
instance MonoPointed IntSet
instance MonoPointed Text
instance MonoPointed Text
instance MonoPointed ByteString
instance MonoPointed ByteString
instance MonoTraversable (Either a b)
instance Storable a => MonoTraversable (Vector a)
instance Unbox a => MonoTraversable (Vector a)
instance MonoTraversable (Vector a)
instance MonoTraversable (HashMap k v)
instance MonoTraversable (Map k v)
instance MonoTraversable (Identity a)
instance MonoTraversable (DList a)
instance MonoTraversable (NonEmpty a)
instance MonoTraversable (Option a)
instance MonoTraversable (IntMap a)
instance MonoTraversable (ViewR a)
instance MonoTraversable (ViewL a)
instance MonoTraversable (Seq a)
instance MonoTraversable (Tree a)
instance MonoTraversable (Maybe a)
instance MonoTraversable [a]
instance MonoTraversable Text
instance MonoTraversable Text
instance MonoTraversable ByteString
instance MonoTraversable ByteString
instance Ord b => MonoFoldableOrd (Either a b)
instance (Ord a, Storable a) => MonoFoldableOrd (Vector a)
instance (Unbox a, Ord a) => MonoFoldableOrd (Vector a)
instance Ord e => MonoFoldableOrd (HashSet e)
instance Ord e => MonoFoldableOrd (Set e)
instance Ord a => MonoFoldableOrd (Vector a)
instance Ord v => MonoFoldableOrd (HashMap k v)
instance Ord v => MonoFoldableOrd (Map k v)
instance Ord a => MonoFoldableOrd (Identity a)
instance Ord a => MonoFoldableOrd (NonEmpty a)
instance Ord a => MonoFoldableOrd (Option a)
instance Ord a => MonoFoldableOrd (IntMap a)
instance Ord a => MonoFoldableOrd (ViewR a)
instance Ord a => MonoFoldableOrd (ViewL a)
instance Ord a => MonoFoldableOrd (Seq a)
instance Ord a => MonoFoldableOrd (Tree a)
instance Ord a => MonoFoldableOrd (Maybe a)
instance Ord a => MonoFoldableOrd [a]
instance MonoFoldableOrd IntSet
instance MonoFoldableOrd Text
instance MonoFoldableOrd Text
instance MonoFoldableOrd ByteString
instance MonoFoldableOrd ByteString
instance MonoFoldableMonoid Text
instance MonoFoldableMonoid Text
instance MonoFoldableMonoid ByteString
instance MonoFoldableMonoid ByteString
instance (MonoFoldable (t a), Monoid (t a)) => MonoFoldableMonoid (t a)
instance MonoFoldable (Either a b)
instance Storable a => MonoFoldable (Vector a)
instance Unbox a => MonoFoldable (Vector a)
instance MonoFoldable (DList a)
instance MonoFoldable (HashSet e)
instance MonoFoldable (Set e)
instance MonoFoldable (Vector a)
instance MonoFoldable (HashMap k v)
instance MonoFoldable (Map k v)
instance MonoFoldable (Identity a)
instance MonoFoldable (NonEmpty a)
instance MonoFoldable (Option a)
instance MonoFoldable (IntMap a)
instance MonoFoldable (ViewR a)
instance MonoFoldable (ViewL a)
instance MonoFoldable (Seq a)
instance MonoFoldable (Tree a)
instance MonoFoldable (Maybe a)
instance MonoFoldable [a]
instance MonoFoldable IntSet
instance MonoFoldable Text
instance MonoFoldable Text
instance MonoFoldable ByteString
instance MonoFoldable ByteString
instance Storable a => MonoFunctor (Vector a)
instance Unbox a => MonoFunctor (Vector a)
instance Functor f => MonoFunctor (Static f a b)
instance (Functor f, Functor g) => MonoFunctor (Product f g a)
instance (Functor f, Functor g) => MonoFunctor (Compose f g a)
instance Functor m => MonoFunctor (ContT r m a)
instance Functor m => MonoFunctor (ErrorT e m a)
instance Functor m => MonoFunctor (ReaderT r m a)
instance Functor m => MonoFunctor (RWST r w s m a)
instance Functor m => MonoFunctor (RWST r w s m a)
instance Functor m => MonoFunctor (StateT s m a)
instance Functor m => MonoFunctor (StateT s m a)
instance Functor m => MonoFunctor (WriterT w m a)
instance Functor m => MonoFunctor (WriterT w m a)
instance Functor m => MonoFunctor (IdentityT m a)
instance Functor m => MonoFunctor (ListT m a)
instance Functor m => MonoFunctor (MaybeT m a)
instance MonoFunctor (Cokleisli w a b)
instance Functor f => MonoFunctor (WrappedApplicative f a)
instance Functor f => MonoFunctor (MaybeApply f a)
instance Arrow a => MonoFunctor (WrappedArrow a b c)
instance MonoFunctor (Vector a)
instance MonoFunctor (HashMap k v)
instance MonoFunctor (Map k v)
instance Monad m => MonoFunctor (WrappedMonad m a)
instance MonoFunctor (Const m a)
instance MonoFunctor (a, b)
instance MonoFunctor (Either a b)
instance MonoFunctor (r -> a)
instance MonoFunctor (Identity a)
instance MonoFunctor (NonEmpty a)
instance MonoFunctor (Option a)
instance MonoFunctor (IntMap a)
instance MonoFunctor (ViewR a)
instance MonoFunctor (ViewL a)
instance MonoFunctor (DList a)
instance MonoFunctor (Seq a)
instance MonoFunctor (Tree a)
instance MonoFunctor (Maybe a)
instance MonoFunctor (ZipList a)
instance MonoFunctor (IO a)
instance MonoFunctor [a]
instance MonoFunctor Text
instance MonoFunctor Text
instance MonoFunctor ByteString
instance MonoFunctor ByteString


-- | Warning: This module should be considered highly experimental.
module Data.Sequences

-- | <a>SemiSequence</a> was created to share code between
--   <a>IsSequence</a> and <tt>NonNull</tt>. You should always use
--   <a>IsSequence</a> or <tt>NonNull</tt> rather than using
--   <a>SemiSequence</a> <a>SemiSequence</a> is exported so that you can
--   define new instances of <a>IsSequence</a> or <tt>NonNull</tt>
--   
--   <tt>Semi</tt> means <tt>SemiGroup</tt> A <a>SemiSequence</a> can
--   accomodate a <tt>SemiGroup</tt> such as <tt>NonEmpty</tt> A Monoid
--   should be able to fill out <a>IsSequence</a>
--   
--   As a base for <tt>NonNull</tt>, a <a>SemiSequence</a> keeps the same
--   type when increasing its number of elements. However, a decreasing
--   function such as filter may change a <tt>NonNull</tt> type. For
--   example, from <tt>NonEmpty</tt> to '[]' This exists on
--   <tt>NonNull</tt> as <tt>nfilter</tt>
--   
--   <a>filter</a> and other such functions are placed in <a>IsSequence</a>
class (Integral (Index seq), GrowingAppend seq) => SemiSequence seq where type family Index seq
intersperse :: SemiSequence seq => Element seq -> seq -> seq
reverse :: SemiSequence seq => seq -> seq
find :: SemiSequence seq => (Element seq -> Bool) -> seq -> Maybe (Element seq)
sortBy :: SemiSequence seq => (Element seq -> Element seq -> Ordering) -> seq -> seq
cons :: SemiSequence seq => Element seq -> seq -> seq
snoc :: SemiSequence seq => seq -> Element seq -> seq
singleton :: IsSequence seq => Element seq -> seq

-- | Sequence Laws:
--   
--   <pre>
--   fromList . otoList = id
--   fromList (x &lt;&gt; y) = fromList x &lt;&gt; fromList y
--   otoList (fromList x &lt;&gt; fromList y) = x &lt;&gt; y
--   </pre>
class (Monoid seq, MonoTraversable seq, SemiSequence seq, MonoPointed seq) => IsSequence seq where fromList = mconcat . fmap singleton break f = (fromList *** fromList) . break f . otoList span f = (fromList *** fromList) . span f . otoList dropWhile f = fromList . dropWhile f . otoList takeWhile f = fromList . takeWhile f . otoList splitAt i = (fromList *** fromList) . genericSplitAt i . otoList unsafeSplitAt i seq = (unsafeTake i seq, unsafeDrop i seq) take i = fst . splitAt i unsafeTake = take drop i = snd . splitAt i unsafeDrop = drop partition f = (fromList *** fromList) . partition f . otoList uncons = fmap (second fromList) . uncons . otoList unsnoc = fmap (first fromList) . unsnoc . otoList filter f = fromList . filter f . otoList filterM f = liftM fromList . filterM f . otoList replicate i = fromList . genericReplicate i replicateM i = liftM fromList . replicateM (fromIntegral i) groupBy f = fmap fromList . groupBy f . otoList groupAllOn f = fmap fromList . groupAllOn f . otoList subsequences = map fromList . subsequences . otoList permutations = map fromList . permutations . otoList tailEx = snd . maybe (error "Data.Sequences.tailEx") id . uncons initEx = fst . maybe (error "Data.Sequences.initEx") id . unsnoc unsafeTail = tailEx unsafeInit = initEx
fromList :: IsSequence seq => [Element seq] -> seq
break :: IsSequence seq => (Element seq -> Bool) -> seq -> (seq, seq)
span :: IsSequence seq => (Element seq -> Bool) -> seq -> (seq, seq)
dropWhile :: IsSequence seq => (Element seq -> Bool) -> seq -> seq
takeWhile :: IsSequence seq => (Element seq -> Bool) -> seq -> seq
splitAt :: IsSequence seq => Index seq -> seq -> (seq, seq)
unsafeSplitAt :: IsSequence seq => Index seq -> seq -> (seq, seq)
take :: IsSequence seq => Index seq -> seq -> seq
unsafeTake :: IsSequence seq => Index seq -> seq -> seq
drop :: IsSequence seq => Index seq -> seq -> seq
unsafeDrop :: IsSequence seq => Index seq -> seq -> seq
partition :: IsSequence seq => (Element seq -> Bool) -> seq -> (seq, seq)
uncons :: IsSequence seq => seq -> Maybe (Element seq, seq)
unsnoc :: IsSequence seq => seq -> Maybe (seq, Element seq)
filter :: IsSequence seq => (Element seq -> Bool) -> seq -> seq
filterM :: (IsSequence seq, Monad m) => (Element seq -> m Bool) -> seq -> m seq
replicate :: IsSequence seq => Index seq -> Element seq -> seq
replicateM :: (IsSequence seq, Monad m) => Index seq -> m (Element seq) -> m seq
groupBy :: IsSequence seq => (Element seq -> Element seq -> Bool) -> seq -> [seq]
groupAllOn :: (IsSequence seq, Eq b) => (Element seq -> b) -> seq -> [seq]
subsequences :: IsSequence seq => seq -> [seq]
permutations :: IsSequence seq => seq -> [seq]
tailEx :: IsSequence seq => seq -> seq
initEx :: IsSequence seq => seq -> seq
unsafeTail :: IsSequence seq => seq -> seq
unsafeInit :: IsSequence seq => seq -> seq
defaultFind :: MonoFoldable seq => (Element seq -> Bool) -> seq -> Maybe (Element seq)
defaultIntersperse :: IsSequence seq => Element seq -> seq -> seq
defaultReverse :: IsSequence seq => seq -> seq
defaultSortBy :: IsSequence seq => (Element seq -> Element seq -> Ordering) -> seq -> seq
vectorSortBy :: Vector v e => (e -> e -> Ordering) -> v e -> v e
vectorSort :: (Vector v e, Ord e) => v e -> v e
defaultCons :: IsSequence seq => Element seq -> seq -> seq
defaultSnoc :: IsSequence seq => seq -> Element seq -> seq

-- | like Data.List.tail, but an input of <tt>mempty</tt> returns
--   <tt>mempty</tt>
tailDef :: IsSequence seq => seq -> seq

-- | like Data.List.init, but an input of <tt>mempty</tt> returns
--   <tt>mempty</tt>
initDef :: IsSequence seq => seq -> seq
class (IsSequence seq, Eq (Element seq)) => EqSequence seq where stripPrefix x y = fmap fromList (otoList x `stripPrefix` otoList y) isPrefixOf x y = otoList x `isPrefixOf` otoList y stripSuffix x y = fmap fromList (otoList x `stripSuffix` otoList y) isSuffixOf x y = otoList x `isSuffixOf` otoList y isInfixOf x y = otoList x `isInfixOf` otoList y group = groupBy (==) groupAll = groupAllOn id elem e = elem e . otoList notElem e = notElem e . otoList
stripPrefix :: EqSequence seq => seq -> seq -> Maybe seq
isPrefixOf :: EqSequence seq => seq -> seq -> Bool
stripSuffix :: EqSequence seq => seq -> seq -> Maybe seq
isSuffixOf :: EqSequence seq => seq -> seq -> Bool
isInfixOf :: EqSequence seq => seq -> seq -> Bool
group :: EqSequence seq => seq -> [seq]
groupAll :: EqSequence seq => seq -> [seq]
elem :: EqSequence seq => Element seq -> seq -> Bool
notElem :: EqSequence seq => Element seq -> seq -> Bool
class (EqSequence seq, MonoFoldableOrd seq) => OrdSequence seq where sort = fromList . sort . otoList
sort :: OrdSequence seq => seq -> seq
class (IsSequence t, IsString t, Element t ~ Char) => Textual t where breakWord = fmap (dropWhile isSpace) . break isSpace breakLine = (killCR *** drop 1) . break (== '\n') where killCR t = case unsnoc t of { Just (t', '\r') -> t' _ -> t }
words :: Textual t => t -> [t]
unwords :: Textual t => [t] -> t
lines :: Textual t => t -> [t]
unlines :: Textual t => [t] -> t
toLower :: Textual t => t -> t
toUpper :: Textual t => t -> t
toCaseFold :: Textual t => t -> t
breakWord :: Textual t => t -> (t, t)
breakLine :: Textual t => t -> (t, t)
instance Textual Text
instance Textual Text
instance c ~ Char => Textual [c]
instance (Ord a, Storable a) => OrdSequence (Vector a)
instance (Ord a, Unbox a) => OrdSequence (Vector a)
instance Ord a => OrdSequence (Vector a)
instance Ord a => OrdSequence (Seq a)
instance OrdSequence Text
instance OrdSequence Text
instance OrdSequence ByteString
instance OrdSequence ByteString
instance Ord a => OrdSequence [a]
instance (Eq a, Storable a) => EqSequence (Vector a)
instance (Eq a, Unbox a) => EqSequence (Vector a)
instance Eq a => EqSequence (Vector a)
instance Eq a => EqSequence (Seq a)
instance EqSequence Text
instance EqSequence Text
instance EqSequence ByteString
instance EqSequence ByteString
instance Eq a => EqSequence [a]
instance Storable a => IsSequence (Vector a)
instance Storable a => SemiSequence (Vector a)
instance Unbox a => IsSequence (Vector a)
instance Unbox a => SemiSequence (Vector a)
instance IsSequence (Vector a)
instance SemiSequence (Vector a)
instance IsSequence (DList a)
instance SemiSequence (DList a)
instance IsSequence (Seq a)
instance SemiSequence (Seq a)
instance IsSequence Text
instance SemiSequence Text
instance IsSequence ByteString
instance SemiSequence ByteString
instance IsSequence Text
instance SemiSequence Text
instance IsSequence ByteString
instance SemiSequence ByteString
instance SemiSequence (NonEmpty a)
instance IsSequence [a]
instance SemiSequence [a]

module Data.MinLen
data Zero
Zero :: Zero
data Succ nat
Succ :: nat -> Succ nat
class TypeNat nat
toValueNat :: (TypeNat nat, Num i) => nat -> i
typeNat :: TypeNat nat => nat
data MinLen nat mono
unMinLen :: MinLen nat mono -> mono
toMinLenZero :: mono -> MinLen Zero mono
toMinLen :: (MonoFoldable mono, TypeNat nat) => mono -> Maybe (MinLen nat mono)

-- | Although this function itself cannot cause a segfault, it breaks the
--   safety guarantees of <tt>MinLen</tt> and can lead to a segfault when
--   using otherwise safe functions.
unsafeToMinLen :: mono -> MinLen nat mono
mlcons :: IsSequence seq => Element seq -> MinLen nat seq -> MinLen (Succ nat) seq
mlappend :: IsSequence seq => MinLen x seq -> MinLen y seq -> MinLen (AddNat x y) seq
mlunion :: GrowingAppend mono => MinLen x mono -> MinLen y mono -> MinLen (MaxNat x y) mono
head :: MonoTraversable mono => MinLen (Succ nat) mono -> Element mono
last :: MonoTraversable mono => MinLen (Succ nat) mono -> Element mono
tailML :: IsSequence seq => MinLen (Succ nat) seq -> MinLen nat seq
initML :: IsSequence seq => MinLen (Succ nat) seq -> MinLen nat seq

-- | olength (x <a></a> y) &gt;= olength x + olength y
class (Semigroup mono, MonoFoldable mono) => GrowingAppend mono
ofoldMap1 :: (MonoFoldable mono, Semigroup m) => (Element mono -> m) -> MinLen (Succ nat) mono -> m
ofold1 :: (MonoFoldable mono, Semigroup (Element mono)) => MinLen (Succ nat) mono -> Element mono
ofoldr1 :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> MinLen (Succ nat) mono -> Element mono

-- | A variant of 'ofoldl\'' that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   <pre>
--   'foldl1\'' f = <a>foldl1</a> f . <a>otoList</a>
--   </pre>
ofoldl1' :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
maximum :: MonoFoldableOrd mono => MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
minimum :: MonoFoldableOrd mono => MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
maximumBy :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
minimumBy :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> MinLen (Succ nat) mono -> Element mono
instance Typeable2 MinLen
instance GrowingAppend mono => GrowingAppend (MinLen nat mono)
instance MonoFoldableOrd mono => MonoFoldableOrd (MinLen nat mono)
instance MonoFoldable mono => MonoFoldable (MinLen nat mono)
instance MonoFunctor mono => MonoFunctor (MinLen nat mono)
instance Eq mono => Eq (MinLen nat mono)
instance Ord mono => Ord (MinLen nat mono)
instance Read mono => Read (MinLen nat mono)
instance Show mono => Show (MinLen nat mono)
instance (Data nat, Data mono) => Data (MinLen nat mono)
instance Functor (MinLen nat)
instance MonoPointed mono => MonoPointed (MinLen (Succ Zero) mono)
instance MonoPointed mono => MonoPointed (MinLen Zero mono)
instance SemiSequence seq => SemiSequence (MinLen nat seq)
instance GrowingAppend mono => Semigroup (MinLen nat mono)
instance MonoTraversable mono => MonoTraversable (MinLen nat mono)
instance TypeNat nat => TypeNat (Succ nat)
instance TypeNat Zero


-- | Warning, this is Experimental!
--   
--   Data.NonNull attempts to extend the concepts from
--   <a>Data.List.NonEmpty</a> to any <a>MonoFoldable</a>.
--   
--   <a>NonNull</a> is a typeclass for a container with 1 or more elements.
--   <a>Data.List.NonEmpty</a> and 'NotEmpty a' are members of the
--   typeclass
module Data.NonNull
type NonNull mono = MinLen (Succ Zero) mono

-- | safely convert a <tt>Nullable</tt> to a <a>NonNull</a>
fromNullable :: MonoFoldable mono => mono -> Maybe (NonNull mono)

-- | convert a <tt>Nullable</tt> with elements to a <a>NonNull</a> throw an
--   exception if the <tt>Nullable</tt> is empty. do not use this unless
--   you have proved your structure is non-null
nonNull :: MonoFoldable mono => mono -> NonNull mono

-- | convert a <a>NonNull</a> to a <tt>Nullable</tt>
toNullable :: NonNull mono -> mono

-- | safely construct a <a>NonNull</a> from a <tt>NonEmpty</tt> list
fromNonEmpty :: IsSequence seq => NonEmpty (Element seq) -> NonNull seq

-- | Like cons, prepends an element. However, the prepend is to a Nullable,
--   creating a <a>NonNull</a>
--   
--   Generally this uses cons underneath. cons is not efficient for most
--   data structures.
--   
--   Alternatives: * if you don't need to cons, use <a>fromNullable</a> or
--   <a>nonNull</a> if you can create your structure in one go. * if you
--   need to cons, you might be able to start off with an efficient data
--   structure such as a <tt>NonEmpty</tt> List. <tt>fronNonEmpty</tt> will
--   convert that to your data structure using the structure's fromList
--   function.
ncons :: SemiSequence seq => Element seq -> seq -> NonNull seq

-- | like <a>uncons</a> of <a>SemiSequence</a>
nuncons :: IsSequence seq => NonNull seq -> (Element seq, Maybe (NonNull seq))

-- | like <a>uncons</a> of <a>SemiSequence</a>
splitFirst :: IsSequence seq => NonNull seq -> (Element seq, seq)

-- | like <a>filter</a>, but starts with a NonNull
nfilter :: IsSequence seq => (Element seq -> Bool) -> NonNull seq -> seq

-- | like <a>filterM</a>, but starts with a NonNull
nfilterM :: (Monad m, IsSequence seq) => (Element seq -> m Bool) -> NonNull seq -> m seq

-- | i must be &gt; 0. like <a>replicate</a>
--   
--   i &lt;= 0 is treated the same as providing 1
nReplicate :: IsSequence seq => Index seq -> Element seq -> NonNull seq
head :: MonoTraversable mono => MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a NonEmpty
tail :: IsSequence seq => NonNull seq -> seq
last :: MonoTraversable mono => MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a NonEmpty
init :: IsSequence seq => NonNull seq -> seq
ofoldMap1 :: (MonoFoldable mono, Semigroup m) => (Element mono -> m) -> MinLen (Succ nat) mono -> m
ofold1 :: (MonoFoldable mono, Semigroup (Element mono)) => MinLen (Succ nat) mono -> Element mono
ofoldr1 :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> MinLen (Succ nat) mono -> Element mono

-- | A variant of 'ofoldl\'' that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   <pre>
--   'foldl1\'' f = <a>foldl1</a> f . <a>otoList</a>
--   </pre>
ofoldl1' :: MonoFoldable mono => (Element mono -> Element mono -> Element mono) -> MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
maximum :: MonoFoldableOrd mono => MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
maximumBy :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
minimum :: MonoFoldableOrd mono => MinLen (Succ nat) mono -> Element mono

-- | like Data.List, but not partial on a MonoFoldable
minimumBy :: MonoFoldable mono => (Element mono -> Element mono -> Ordering) -> MinLen (Succ nat) mono -> Element mono

-- | Prepend an element to a NonNull
(<|) :: SemiSequence seq => Element seq -> NonNull seq -> NonNull seq
instance Typeable NullError
instance Show NullError
instance Exception NullError


-- | Warning: This module should be considered highly experimental.
module Data.Containers
class (Monoid set, Semigroup set, MonoFoldable set, Eq (ContainerKey set), GrowingAppend set) => SetContainer set where type family ContainerKey set
member :: SetContainer set => ContainerKey set -> set -> Bool
notMember :: SetContainer set => ContainerKey set -> set -> Bool
union :: SetContainer set => set -> set -> set
difference :: SetContainer set => set -> set -> set
intersection :: SetContainer set => set -> set -> set

-- | A guaranteed-polymorphic <tt>Map</tt>, which allows for more
--   polymorphic versions of functions.
class PolyMap map
differenceMap :: PolyMap map => map value1 -> map value2 -> map value1
intersectionMap :: PolyMap map => map value1 -> map value2 -> map value1
intersectionWithMap :: PolyMap map => (value1 -> value2 -> value3) -> map value1 -> map value2 -> map value3
class (MonoTraversable map, SetContainer map) => IsMap map where type family MapValue map findWithDefault def key = fromMaybe def . lookup key insertWith f k v m = v' `seq` insertMap k v' m where v' = case lookup k m of { Nothing -> v Just vold -> f v vold } insertWithKey f k v m = v' `seq` insertMap k v' m where v' = case lookup k m of { Nothing -> v Just vold -> f k v vold } insertLookupWithKey f k v m = v' `seq` (mold, insertMap k v' m) where (mold, v') = case lookup k m of { Nothing -> (Nothing, v) Just vold -> (Just vold, f k v vold) } adjustMap f k m = case lookup k m of { Nothing -> m Just v -> let v' = f v in v' `seq` insertMap k v' m } adjustWithKey f k m = case lookup k m of { Nothing -> m Just v -> let v' = f k v in v' `seq` insertMap k v' m } updateMap f k m = case lookup k m of { Nothing -> m Just v -> case f v of { Nothing -> deleteMap k m Just v' -> v' `seq` insertMap k v' m } } updateWithKey f k m = case lookup k m of { Nothing -> m Just v -> case f k v of { Nothing -> deleteMap k m Just v' -> v' `seq` insertMap k v' m } } updateLookupWithKey f k m = case lookup k m of { Nothing -> (Nothing, m) Just v -> case f k v of { Nothing -> (Just v, deleteMap k m) Just v' -> v' `seq` (Just v', insertMap k v' m) } } alterMap f k m = case f mold of { Nothing -> case mold of { Nothing -> m Just _ -> deleteMap k m } Just v -> insertMap k v m } where mold = lookup k m unionWith f x y = mapFromList $ loop $ mapToList x ++ mapToList y where loop [] = [] loop ((k, v) : rest) = case lookup k rest of { Nothing -> (k, v) : loop rest Just v' -> (k, f v v') : loop (deleteMap k rest) } unionWithKey f x y = mapFromList $ loop $ mapToList x ++ mapToList y where loop [] = [] loop ((k, v) : rest) = case lookup k rest of { Nothing -> (k, v) : loop rest Just v' -> (k, f k v v') : loop (deleteMap k rest) } unionsWith _ [] = mempty unionsWith _ [x] = x unionsWith f (x : y : z) = unionsWith f (unionWith f x y : z) mapWithKey f = mapFromList . map go . mapToList where go (k, v) = (k, f k v) mapKeysWith g f = mapFromList . unionsWith g . map go . mapToList where go (k, v) = [(f k, v)]
lookup :: IsMap map => ContainerKey map -> map -> Maybe (MapValue map)
insertMap :: IsMap map => ContainerKey map -> MapValue map -> map -> map
deleteMap :: IsMap map => ContainerKey map -> map -> map
singletonMap :: IsMap map => ContainerKey map -> MapValue map -> map
mapFromList :: IsMap map => [(ContainerKey map, MapValue map)] -> map
mapToList :: IsMap map => map -> [(ContainerKey map, MapValue map)]
findWithDefault :: IsMap map => MapValue map -> ContainerKey map -> map -> MapValue map
insertWith :: IsMap map => (MapValue map -> MapValue map -> MapValue map) -> ContainerKey map -> MapValue map -> map -> map
insertWithKey :: IsMap map => (ContainerKey map -> MapValue map -> MapValue map -> MapValue map) -> ContainerKey map -> MapValue map -> map -> map
insertLookupWithKey :: IsMap map => (ContainerKey map -> MapValue map -> MapValue map -> MapValue map) -> ContainerKey map -> MapValue map -> map -> (Maybe (MapValue map), map)
adjustMap :: IsMap map => (MapValue map -> MapValue map) -> ContainerKey map -> map -> map
adjustWithKey :: IsMap map => (ContainerKey map -> MapValue map -> MapValue map) -> ContainerKey map -> map -> map
updateMap :: IsMap map => (MapValue map -> Maybe (MapValue map)) -> ContainerKey map -> map -> map
updateWithKey :: IsMap map => (ContainerKey map -> MapValue map -> Maybe (MapValue map)) -> ContainerKey map -> map -> map
updateLookupWithKey :: IsMap map => (ContainerKey map -> MapValue map -> Maybe (MapValue map)) -> ContainerKey map -> map -> (Maybe (MapValue map), map)
alterMap :: IsMap map => (Maybe (MapValue map) -> Maybe (MapValue map)) -> ContainerKey map -> map -> map
unionWith :: IsMap map => (MapValue map -> MapValue map -> MapValue map) -> map -> map -> map
unionWithKey :: IsMap map => (ContainerKey map -> MapValue map -> MapValue map -> MapValue map) -> map -> map -> map
unionsWith :: IsMap map => (MapValue map -> MapValue map -> MapValue map) -> [map] -> map
mapWithKey :: IsMap map => (ContainerKey map -> MapValue map -> MapValue map) -> map -> map
mapKeysWith :: IsMap map => (MapValue map -> MapValue map -> MapValue map) -> (ContainerKey map -> ContainerKey map) -> map -> map
class (SetContainer set, Element set ~ ContainerKey set) => IsSet set
insertSet :: IsSet set => Element set -> set -> set
deleteSet :: IsSet set => Element set -> set -> set
singletonSet :: IsSet set => Element set -> set
setFromList :: IsSet set => [Element set] -> set
setToList :: IsSet set => set -> [Element set]

-- | zip operations on MonoFunctors.
class MonoFunctor mono => MonoZip mono
ozipWith :: MonoZip mono => (Element mono -> Element mono -> Element mono) -> mono -> mono -> mono
ozip :: MonoZip mono => mono -> mono -> [(Element mono, Element mono)]
ounzip :: MonoZip mono => [(Element mono, Element mono)] -> (mono, mono)
instance MonoZip Text
instance MonoZip Text
instance MonoZip ByteString
instance MonoZip ByteString
instance IsSet IntSet
instance (Eq element, Hashable element) => IsSet (HashSet element)
instance Ord element => IsSet (Set element)
instance Eq key => IsMap [(key, value)]
instance IsMap (IntMap value)
instance (Eq key, Hashable key) => IsMap (HashMap key value)
instance Ord key => IsMap (Map key value)
instance PolyMap IntMap
instance (Eq key, Hashable key) => PolyMap (HashMap key)
instance Ord key => PolyMap (Map key)
instance Eq key => SetContainer [(key, value)]
instance SetContainer IntSet
instance (Eq element, Hashable element) => SetContainer (HashSet element)
instance Ord element => SetContainer (Set element)
instance SetContainer (IntMap value)
instance (Eq key, Hashable key) => SetContainer (HashMap key value)
instance Ord k => SetContainer (Map k v)
