packages feed

papa 0.5.0 → 0.7.0

raw patch · 133 files changed

+21409/−839 lines, 133 filesdep +asyncdep +bytestringdep +criteriondep ~basedep ~containersdep ~deepseqPVP ok

version bump matches the API change (PVP)

Dependencies added: async, bytestring, criterion, directory, exceptions, filepath, hashable, hedgehog, hedgehog-fn, inspection-testing, primitive, stm, tagged, text, time, unordered-containers, vector

Dependency ranges changed: base, containers, deepseq, lens, transformers

API changes (from Hackage documentation)

- Papa.Adjunctions.Renamed: ($dmtabulate) :: (Representable f, Generic1 f, GRep f ~ Rep f, GTabulate (Rep1 f)) => (Rep f -> a) -> f a
- Papa.Adjunctions.Renamed: -- | If no definition is provided, this will default to <a>GRep</a>.
- Papa.Adjunctions.Renamed: Co :: f a -> Co (f :: Type -> Type) a
- Papa.Adjunctions.Renamed: WrapRep :: Rep f -> WrappedRep (f :: Type -> Type)
- Papa.Adjunctions.Renamed: [unCo] :: Co (f :: Type -> Type) a -> f a
- Papa.Adjunctions.Renamed: [unwrapRep] :: WrappedRep (f :: Type -> Type) -> Rep f
- Papa.Adjunctions.Renamed: apRep :: Representable f => f (a -> b) -> f a -> f b
- Papa.Adjunctions.Renamed: askRep :: Representable f => f (Rep f)
- Papa.Adjunctions.Renamed: bindRep :: Representable f => f a -> (a -> f b) -> f b
- Papa.Adjunctions.Renamed: class Distributive f => Representable (f :: Type -> Type) where {
- Papa.Adjunctions.Renamed: collectRep :: (Representable f, Functor w) => (a -> f b) -> w a -> f (w b)
- Papa.Adjunctions.Renamed: distributeRep :: (Representable f, Functor w) => w (f a) -> f (w a)
- Papa.Adjunctions.Renamed: duplicateRep :: (Representable f, Monoid (Rep f)) => f a -> f (f a)
- Papa.Adjunctions.Renamed: duplicateRepBy :: Representable f => (Rep f -> Rep f -> Rep f) -> f a -> f (f a)
- Papa.Adjunctions.Renamed: duplicatedRep :: (Representable f, Semigroup (Rep f)) => f a -> f (f a)
- Papa.Adjunctions.Renamed: extendRep :: (Representable f, Monoid (Rep f)) => (f a -> b) -> f a -> f b
- Papa.Adjunctions.Renamed: extendRepBy :: Representable f => (Rep f -> Rep f -> Rep f) -> (f a -> b) -> f a -> f b
- Papa.Adjunctions.Renamed: extendedRep :: (Representable f, Semigroup (Rep f)) => (f a -> b) -> f a -> f b
- Papa.Adjunctions.Renamed: extractRep :: (Representable f, Monoid (Rep f)) => f a -> a
- Papa.Adjunctions.Renamed: extractRepBy :: Representable f => Rep f -> f a -> a
- Papa.Adjunctions.Renamed: fmapRep :: Representable f => (a -> b) -> f a -> f b
- Papa.Adjunctions.Renamed: gindex :: (Generic1 f, GRep f ~ Rep f, GIndex (Rep1 f)) => f a -> Rep f -> a
- Papa.Adjunctions.Renamed: gtabulate :: (Generic1 f, GRep f ~ Rep f, GTabulate (Rep1 f)) => (Rep f -> a) -> f a
- Papa.Adjunctions.Renamed: ifoldMapRep :: (Representable r, Foldable r, Monoid m) => (Rep r -> a -> m) -> r a -> m
- Papa.Adjunctions.Renamed: imapRep :: Representable r => (Rep r -> a -> a') -> r a -> r a'
- Papa.Adjunctions.Renamed: itraverseRep :: (Representable r, Traversable r, Applicative f) => (Rep r -> a -> f a') -> r a -> f (r a')
- Papa.Adjunctions.Renamed: liftR2 :: Representable f => (a -> b -> c) -> f a -> f b -> f c
- Papa.Adjunctions.Renamed: liftR3 :: Representable f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- Papa.Adjunctions.Renamed: localRep :: Representable f => (Rep f -> Rep f) -> f a -> f a
- Papa.Adjunctions.Renamed: mfixRep :: Representable f => (a -> f a) -> f a
- Papa.Adjunctions.Renamed: mzipRep :: Representable f => f a -> f b -> f (a, b)
- Papa.Adjunctions.Renamed: mzipWithRep :: Representable f => (a -> b -> c) -> f a -> f b -> f c
- Papa.Adjunctions.Renamed: newtype Co (f :: Type -> Type) a
- Papa.Adjunctions.Renamed: newtype WrappedRep (f :: Type -> Type)
- Papa.Adjunctions.Renamed: pureRep :: Representable f => a -> f a
- Papa.Adjunctions.Renamed: tabulate :: Representable f => (Rep f -> a) -> f a
- Papa.Adjunctions.Renamed: tabulated :: (Representable f, Representable g, Profunctor p, Functor h) => p (f a) (h (g b)) -> p (Rep f -> a) (h (Rep g -> b))
- Papa.Adjunctions.Renamed: type GRep (f :: Type -> Type) = GRep' Rep1 f
- Papa.Adjunctions.Renamed: type Rep f :: Type -> Type = GRep f;
- Papa.Adjunctions.Renamed: type family Rep (f :: Type -> Type)
- Papa.Adjunctions.Renamed: }
- Papa.Base: lines :: String -> [String]
- Papa.Base: unlines :: [String] -> String
- Papa.Base: unwords :: [String] -> String
- Papa.Base: words :: String -> [String]
- Papa.Base.Control.Applicative: data WrappedArrow (a :: Type -> Type -> Type) b c
- Papa.Base.Control.Applicative: data WrappedMonad (m :: Type -> Type) a
- Papa.Base.Control.Applicative: data ZipList a
- Papa.Base.Control.Arrow: first :: Arrow a => a b c -> a (b, d) (c, d)
- Papa.Base.Control.Arrow: left :: ArrowChoice a => a b c -> a (Either b d) (Either c d)
- Papa.Base.Control.Arrow: right :: ArrowChoice a => a b c -> a (Either d b) (Either d c)
- Papa.Base.Control.Arrow: second :: Arrow a => a b c -> a (d, b) (d, c)
- Papa.Base.Control.DeepSeq: ($dmrnf) :: (NFData a, Generic a, GNFData Zero (Rep a)) => a -> ()
- Papa.Base.Control.Monad: fail :: MonadFail m => String -> m a
- Papa.Base.Control.Monad: mfix :: MonadFix m => (a -> m a) -> m a
- Papa.Base.Data.Eq: ($dmliftEq) :: forall (f' :: Type -> Type -> Type) c a b. (Eq1 f, f ~ f' c, Eq2 f', Eq c) => (a -> b -> Bool) -> f a -> f b -> Bool
- Papa.Base.Data.List: uncons :: [a] -> Maybe (a, [a])
- Papa.Base.Data.List: unsnoc :: [a] -> Maybe ([a], a)
- Papa.Base.Data.Ord: ($dmliftCompare) :: forall (f' :: Type -> Type -> Type) c a b. (Ord1 f, f ~ f' c, Ord2 f', Ord c) => (a -> b -> Ordering) -> f a -> f b -> Ordering
- Papa.Base.Data.Semigroup: data All
- Papa.Base.Data.Semigroup: data Any
- Papa.Base.Data.Semigroup: data Dual a
- Papa.Base.Data.Semigroup: data Endo a
- Papa.Base.Data.Semigroup: data First a
- Papa.Base.Data.Semigroup: data Last a
- Papa.Base.Data.Semigroup: data Max a
- Papa.Base.Data.Semigroup: data Min a
- Papa.Base.Data.Semigroup: data Product a
- Papa.Base.Data.Semigroup: data Sum a
- Papa.Base.Data.Semigroup: data WrappedMonoid m
- Papa.Base.Data.Show: ($dmliftShowsPrec) :: forall (f' :: Type -> Type -> Type) b a. (Show1 f, f ~ f' b, Show2 f', Show b) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
- Papa.Base.Prelude: (/) :: Fractional a => a -> a -> a
- Papa.Base.Prelude: (^) :: (Num a, Integral b) => a -> b -> a
- Papa.Base.Prelude: (^^) :: (Fractional a, Integral b) => a -> b -> a
- Papa.Base.Prelude: appendFile :: FilePath -> String -> IO ()
- Papa.Base.Prelude: ceiling :: (RealFrac a, Integral b) => a -> b
- Papa.Base.Prelude: cycle :: HasCallStack => [a] -> [a]
- Papa.Base.Prelude: divMod :: Integral a => a -> a -> (a, a)
- Papa.Base.Prelude: floor :: (RealFrac a, Integral b) => a -> b
- Papa.Base.Prelude: fromInteger :: Num a => Integer -> a
- Papa.Base.Prelude: fromIntegral :: (Integral a, Num b) => a -> b
- Papa.Base.Prelude: getContents :: IO String
- Papa.Base.Prelude: getLine :: IO String
- Papa.Base.Prelude: interact :: (String -> String) -> IO ()
- Papa.Base.Prelude: mod :: Integral a => a -> a -> a
- Papa.Base.Prelude: properFraction :: (RealFrac a, Integral b) => a -> (b, a)
- Papa.Base.Prelude: putChar :: Char -> IO ()
- Papa.Base.Prelude: putStr :: String -> IO ()
- Papa.Base.Prelude: putStrLn :: String -> IO ()
- Papa.Base.Prelude: quot :: Integral a => a -> a -> a
- Papa.Base.Prelude: quotRem :: Integral a => a -> a -> (a, a)
- Papa.Base.Prelude: readFile :: FilePath -> IO String
- Papa.Base.Prelude: readIO :: Read a => String -> IO a
- Papa.Base.Prelude: realToFrac :: (Real a, Fractional b) => a -> b
- Papa.Base.Prelude: recip :: Fractional a => a -> a
- Papa.Base.Prelude: rem :: Integral a => a -> a -> a
- Papa.Base.Prelude: round :: (RealFrac a, Integral b) => a -> b
- Papa.Base.Prelude: toRational :: Real a => a -> Rational
- Papa.Base.Prelude: truncate :: (RealFrac a, Integral b) => a -> b
- Papa.Base.Prelude: writeFile :: FilePath -> String -> IO ()
- Papa.Lens: ($dm_1) :: (Field1 s t a b, Generic s, Generic t, GIxed N0 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_10) :: (Field10 s t a b, Generic s, Generic t, GIxed N9 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_11) :: (Field11 s t a b, Generic s, Generic t, GIxed N10 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_12) :: (Field12 s t a b, Generic s, Generic t, GIxed N11 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_13) :: (Field13 s t a b, Generic s, Generic t, GIxed N12 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_14) :: (Field14 s t a b, Generic s, Generic t, GIxed N13 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_15) :: (Field15 s t a b, Generic s, Generic t, GIxed N14 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_16) :: (Field16 s t a b, Generic s, Generic t, GIxed N15 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_17) :: (Field17 s t a b, Generic s, Generic t, GIxed N16 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_18) :: (Field18 s t a b, Generic s, Generic t, GIxed N17 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_19) :: (Field19 s t a b, Generic s, Generic t, GIxed N18 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_2) :: (Field2 s t a b, Generic s, Generic t, GIxed N1 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_3) :: (Field3 s t a b, Generic s, Generic t, GIxed N2 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_4) :: (Field4 s t a b, Generic s, Generic t, GIxed N3 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_5) :: (Field5 s t a b, Generic s, Generic t, GIxed N4 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_6) :: (Field6 s t a b, Generic s, Generic t, GIxed N5 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_7) :: (Field7 s t a b, Generic s, Generic t, GIxed N6 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_8) :: (Field8 s t a b, Generic s, Generic t, GIxed N7 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_9) :: (Field9 s t a b, Generic s, Generic t, GIxed N8 (Rep s) (Rep t) a b) => Lens s t a b
- Papa.Lens: ($dm_Empty) :: (AsEmpty a, Monoid a, Eq a) => Prism' a ()
- Papa.Lens: ($dm_Wrapped') :: forall (d :: Meta) (c :: Meta) (s' :: Meta) a. (Wrapped s, Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s)
- Papa.Lens: ($dmeach) :: forall (g :: Type -> Type). (Each s t a b, Traversable g, s ~ g a, t ~ g b) => Traversal s t a b
- Papa.Lens: ($dmifoldMap) :: (FoldableWithIndex i f, TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
- Papa.Lens: ($dmimap) :: (FunctorWithIndex i f, TraversableWithIndex i f) => (i -> a -> b) -> f a -> f b
- Papa.Lens: ($dmitraverse) :: (TraversableWithIndex i t, i ~ Int, Applicative f) => (i -> a -> f b) -> t a -> f (t b)
- Papa.Lens: ($dmix) :: (Ixed m, At m) => Index m -> Traversal' m (IxValue m)
- Papa.Lens: ($dmplate) :: (Plated a, Data a) => Traversal' a a
- Papa.Lens: (^?!) :: HasCallStack => s -> Getting (Endo a) s a -> a
- Papa.Lens: (^@?!) :: HasCallStack => s -> IndexedGetting i (Endo (i, a)) s a -> (i, a)
- Papa.Lens: foldl1Of :: HasCallStack => Getting (Dual (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a
- Papa.Lens: foldl1Of' :: HasCallStack => Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> a) -> s -> a
- Papa.Lens: foldr1Of :: HasCallStack => Getting (Endo (Maybe a)) s a -> (a -> a -> a) -> s -> a
- Papa.Lens: foldr1Of' :: HasCallStack => Getting (Dual (Endo (Endo (Maybe a)))) s a -> (a -> a -> a) -> s -> a
- Papa.Lens: iunsafePartsOf :: (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a b -> Over p f s t [a] [b]
- Papa.Lens: iunsafePartsOf' :: forall i s t a b. Over (Indexed i) (Bazaar (Indexed i) a b) s t a b -> IndexedLens [i] s t [a] [b]
- Papa.Lens: singular :: (HasCallStack, Conjoined p, Functor f) => Traversing p f s t a a -> Over p f s t a a
- Papa.Lens: unsafePartsOf :: Functor f => Traversing (->) f s t a b -> LensLike f s t [a] [b]
- Papa.Lens: unsafePartsOf' :: ATraversal s t a b -> Lens s t [a] [b]
- Papa.Lens: unsafeSingular :: (HasCallStack, Conjoined p, Functor f) => Traversing p f s t a b -> Over p f s t a b
- Papa.One.Renamed: ($dm_One) :: AsOne x f a t => Prism' x (One f a t)
- Papa.One.Renamed: ($dm_OneItem) :: (AsOneItem x, ReviewOneItemElement x ~ AsOneItemElement x) => Prism' x (AsOneItemElement x)
- Papa.One.Renamed: ($dmone) :: HasOne x f a t => Lens' x (One f a t)
- Papa.One.Renamed: ($dmoneItem) :: (HasOneItem x, GetterOneItemElement x ~ HasOneItemElement x) => Lens' x (HasOneItemElement x)
- Papa.One.Renamed: type AsOneItemElement x;
- Papa.One.Renamed: type GetterOneItemElement x;
- Papa.One.Renamed: type HasOneItemElement x;
- Papa.One.Renamed: type ReviewOneItemElement x;
- Papa.Polytree.Renamed: Tree :: a -> TreeForest f a b -> Tree (f :: Type -> Type) a b
- Papa.Polytree.Renamed: TreeForest :: f (Either b (Tree f a b)) -> TreeForest (f :: Type -> Type) a b
- Papa.Polytree.Renamed: _Tree :: AsTree x f a b => Prism' x (Tree f a b)
- Papa.Polytree.Renamed: _TreeForest :: AsTreeForest x f a b => Prism' x (TreeForest f a b)
- Papa.Polytree.Renamed: baseTree :: forall a p f. (Profunctor p, Functor f) => p (Tree a) (f (Tree a)) -> p (TreeList' a) (f (TreeList' a))
- Papa.Polytree.Renamed: bfs :: forall (f :: Type -> Type) a b. Foldable f => Tree f a b -> NonEmpty (Either a b)
- Papa.Polytree.Renamed: class ReviewTree x f a b => AsTree x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class ReviewTreeForest x f a b => AsTreeForest x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class GetTree x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class GetTreeForest x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class GetTree x f a b => HasTree x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class GetTreeForest x f a b => HasTreeForest x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class ReviewTree x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: class ReviewTreeForest x (f :: Type -> Type) a b | x -> f a b
- Papa.Polytree.Renamed: countLeaves :: forall (f :: Type -> Type) a b. Foldable f => Tree f a b -> Int
- Papa.Polytree.Renamed: countNodes :: forall (f :: Type -> Type) a b. Foldable f => Tree f a b -> Int
- Papa.Polytree.Renamed: data Tree (f :: Type -> Type) a b
- Papa.Polytree.Renamed: dfs :: forall (f :: Type -> Type) a b. Foldable f => Tree f a b -> NonEmpty (Either a b)
- Papa.Polytree.Renamed: getTree :: GetTree x f a b => Getter x (Tree f a b)
- Papa.Polytree.Renamed: getTreeForest :: GetTreeForest x f a b => Getter x (TreeForest f a b)
- Papa.Polytree.Renamed: getTreeLabel :: GetTree x f a b => Getter x a
- Papa.Polytree.Renamed: makeChild :: a -> f (Either b (Tree f a b)) -> Either x (Tree f a b)
- Papa.Polytree.Renamed: makeChildren :: Functor f => a -> f (Tree f a b) -> Tree f a b
- Papa.Polytree.Renamed: makeLeaves :: Functor f => a -> f b -> Tree f a b
- Papa.Polytree.Renamed: makeTree :: a -> f (Either b (Tree f a b)) -> Tree f a b
- Papa.Polytree.Renamed: newtype TreeForest (f :: Type -> Type) a b
- Papa.Polytree.Renamed: pruneLeaves :: forall (f :: Type -> Type) b a. (Traversable f, Applicative f, Monoid (f (Either b (Tree f a b)))) => (b -> Bool) -> Tree f a b -> Tree f a b
- Papa.Polytree.Renamed: reviewTree :: ReviewTree x f a b => Review x (Tree f a b)
- Papa.Polytree.Renamed: reviewTreeForest :: ReviewTreeForest x f a b => Review x (TreeForest f a b)
- Papa.Polytree.Renamed: singleton :: forall (f :: Type -> Type) b a. Monoid (f (Either b (Tree f a b))) => a -> Tree f a b
- Papa.Polytree.Renamed: tree :: HasTree x f a b => Lens' x (Tree f a b)
- Papa.Polytree.Renamed: treeForest :: HasTreeForest x f a b => Lens' x (TreeForest f a b)
- Papa.Polytree.Renamed: treeForest' :: forall (f1 :: Type -> Type) a b (f' :: Type -> Type) b' f2. Functor f2 => (TreeForest f1 a b -> f2 (TreeForest f' a b')) -> Tree f1 a b -> f2 (Tree f' a b')
- Papa.Polytree.Renamed: treeForestChildren :: forall (f :: Type -> Type) a b. Traversable f => Traversal' (Tree f a b) (Tree f a b)
- Papa.Polytree.Renamed: treeLabel :: HasTree x f a b => Lens' x a
- Papa.Polytree.Renamed: treeLeaves :: forall (f :: Type -> Type) a b. Traversable f => Traversal' (Tree f a b) b
- Papa.Polytree.Renamed: treeSubForest :: forall (f :: Type -> Type) a b b'. Traversable f => Traversal (Tree f a b) (Tree f a b') (Either b (Tree f a b)) (Either b' (Tree f a b'))
- Papa.Polytree.Renamed: type Tree' (f :: Type -> Type) a = Tree f a a
- Papa.Polytree.Renamed: type Tree1 a b = Tree Identity a b
- Papa.Polytree.Renamed: type Tree1' a = Tree1 a a
- Papa.Polytree.Renamed: type TreeForest' (f :: Type -> Type) a = TreeForest f a a
- Papa.Polytree.Renamed: type TreeList a b = Tree [] a b
- Papa.Polytree.Renamed: type TreeList' a = TreeList a a
- Papa.Polytree.Renamed: unfoldTree :: Functor f => (a -> (a, f (Either b a))) -> a -> Tree f a b
- Papa.Polytree.Renamed: unfoldTreeM :: (Monad m, Traversable f) => (a -> m (a, f (Either b a))) -> a -> m (Tree f a b)
- Papa.Selective.Renamed: (<&&>) :: Selective f => f Bool -> f Bool -> f Bool
- Papa.Selective.Renamed: (<*?) :: Selective f => f (Either a b) -> f (a -> b) -> f b
- Papa.Selective.Renamed: (<||>) :: Selective f => f Bool -> f Bool -> f Bool
- Papa.Selective.Renamed: ComposeEither :: f (Either e a) -> ComposeEither (f :: Type -> Type) e a
- Papa.Selective.Renamed: ComposeTraversable :: f (g a) -> ComposeTraversable (f :: Type -> Type) (g :: Type -> Type) a
- Papa.Selective.Renamed: Failure :: e -> Validation e a
- Papa.Selective.Renamed: SelectA :: f a -> SelectA (f :: Type -> Type) a
- Papa.Selective.Renamed: SelectM :: f a -> SelectM (f :: Type -> Type) a
- Papa.Selective.Renamed: Success :: a -> Validation e a
- Papa.Selective.Renamed: Under :: m -> Under m a
- Papa.Selective.Renamed: [getSelectA] :: SelectA (f :: Type -> Type) a -> f a
- Papa.Selective.Renamed: [getSelectM] :: SelectM (f :: Type -> Type) a -> f a
- Papa.Selective.Renamed: [getUnder] :: Under m a -> m
- Papa.Selective.Renamed: allS :: Selective f => (a -> f Bool) -> [a] -> f Bool
- Papa.Selective.Renamed: andAlso :: (Selective f, Semigroup a) => f (Either e a) -> f (Either e a) -> f (Either e a)
- Papa.Selective.Renamed: anyS :: Selective f => (a -> f Bool) -> [a] -> f Bool
- Papa.Selective.Renamed: apS :: Selective f => f (a -> b) -> f a -> f b
- Papa.Selective.Renamed: bindS :: (Bounded a, Enum a, Eq a, Selective f) => f a -> (a -> f b) -> f b
- Papa.Selective.Renamed: branch :: Selective f => f (Either a b) -> f (a -> c) -> f (b -> c) -> f c
- Papa.Selective.Renamed: cases :: Eq a => [a] -> Cases a
- Papa.Selective.Renamed: casesEnum :: (Bounded a, Enum a) => Cases a
- Papa.Selective.Renamed: class Applicative f => Selective (f :: Type -> Type)
- Papa.Selective.Renamed: data Cases a
- Papa.Selective.Renamed: data Validation e a
- Papa.Selective.Renamed: foldS :: (Selective f, Foldable t, Monoid a) => t (f (Either e a)) -> f (Either e a)
- Papa.Selective.Renamed: fromMaybeS :: Selective f => f a -> f (Maybe a) -> f a
- Papa.Selective.Renamed: getOver :: Over m a -> m
- Papa.Selective.Renamed: ifS :: Selective f => f Bool -> f a -> f a -> f a
- Papa.Selective.Renamed: infixl 4 <*?
- Papa.Selective.Renamed: matchM :: Monad m => Cases a -> m a -> (a -> m b) -> m (Either a b)
- Papa.Selective.Renamed: matchS :: (Eq a, Selective f) => Cases a -> f a -> (a -> f b) -> f (Either a b)
- Papa.Selective.Renamed: newtype ComposeEither (f :: Type -> Type) e a
- Papa.Selective.Renamed: newtype ComposeTraversable (f :: Type -> Type) (g :: Type -> Type) a
- Papa.Selective.Renamed: newtype SelectA (f :: Type -> Type) a
- Papa.Selective.Renamed: newtype SelectM (f :: Type -> Type) a
- Papa.Selective.Renamed: newtype Under m a
- Papa.Selective.Renamed: orElse :: (Selective f, Semigroup e) => f (Either e a) -> f (Either e a) -> f (Either e a)
- Papa.Selective.Renamed: select :: Selective f => f (Either a b) -> f (a -> b) -> f b
- Papa.Selective.Renamed: selectA :: Applicative f => f (Either a b) -> f (a -> b) -> f b
- Papa.Selective.Renamed: selectM :: Monad f => f (Either a b) -> f (a -> b) -> f b
- Papa.Selective.Renamed: selectT :: Traversable f => f (Either a b) -> f (a -> b) -> f b
- Papa.Selective.Renamed: swapEither :: Either a b -> Either b a
- Papa.Selective.Renamed: untilRight :: (Monoid a, Selective f) => f (Either a b) -> f (a, b)
- Papa.Selective.Renamed: whenS :: Selective f => f Bool -> f () -> f ()
- Papa.Selective.Renamed: whileS :: Selective f => f Bool -> f ()
- Papa.Semigroupoids: concat :: Bind f => f (f a) -> f a
- Papa.Semigroupoids: concatMap :: Bind f => (a -> f b) -> f a -> f b
- Papa.Semigroupoids: maximum :: (Ord a, Foldable1 f) => f a -> a
- Papa.Semigroupoids: minimum :: (Ord a, Foldable1 f) => f a -> a
- Papa.Semigroupoids: zero :: Plus f => f a
- Papa.Semigroupoids.Data.Functor.Bind: concat :: Bind f => f (f a) -> f a
- Papa.Semigroupoids.Data.Functor.Bind: concatMap :: Bind f => (a -> f b) -> f a -> f b
- Papa.Semigroupoids.Data.Semigroup.Foldable: maximum :: (Ord a, Foldable1 f) => f a -> a
- Papa.Semigroupoids.Data.Semigroup.Foldable: minimum :: (Ord a, Foldable1 f) => f a -> a
+ Papa: (!?) :: [a] -> Int -> Maybe a
+ Papa: ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
+ Papa: ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
+ Papa: ($>) :: Functor f => f a -> b -> f b
+ Papa: (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
+ Papa: (&&) :: Bool -> Bool -> Bool
+ Papa: (&) :: a -> (a -> b) -> b
+ Papa: (*) :: Num a => a -> a -> a
+ Papa: (**) :: Floating a => a -> a -> a
+ Papa: (*>) :: Applicative f => f a -> f b -> f b
+ Papa: (+) :: Num a => a -> a -> a
+ Papa: (++) :: Semigroup a => a -> a -> a
+ Papa: (-) :: Num a => a -> a -> a
+ Papa: (.) :: forall (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c
+ Papa: (/=) :: Eq a => a -> a -> Bool
+ Papa: (:|) :: a -> [a] -> NonEmpty a
+ Papa: (<$!>) :: Monad m => (a -> b) -> m a -> m b
+ Papa: (<$) :: Functor f => a -> f b -> f a
+ Papa: (<$>) :: Functor f => (a -> b) -> f a -> f b
+ Papa: (<&>) :: Functor f => f a -> (a -> b) -> f b
+ Papa: (<) :: Ord a => a -> a -> Bool
+ Papa: (<*) :: Applicative f => f a -> f b -> f a
+ Papa: (<**>) :: Applicative f => f a -> f (a -> b) -> f b
+ Papa: (<*>) :: Applicative f => f (a -> b) -> f a -> f b
+ Papa: (<=) :: Ord a => a -> a -> Bool
+ Papa: (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
+ Papa: (<>) :: Semigroup a => a -> a -> a
+ Papa: (<|>) :: Alternative f => f a -> f a -> f a
+ Papa: (==) :: Eq a => a -> a -> Bool
+ Papa: (>) :: Ord a => a -> a -> Bool
+ Papa: (>=) :: Ord a => a -> a -> Bool
+ Papa: (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
+ Papa: (>>) :: Monad m => m a -> m b -> m b
+ Papa: (>>=) :: Monad m => m a -> (a -> m b) -> m b
+ Papa: (\\) :: Eq a => [a] -> [a] -> [a]
+ Papa: (||) :: Bool -> Bool -> Bool
+ Papa: All :: Bool -> All
+ Papa: Any :: Bool -> Any
+ Papa: AppendMode :: IOMode
+ Papa: Arg :: a -> b -> Arg a b
+ Papa: BlockBuffering :: Maybe Int -> BufferMode
+ Papa: ClosePunctuation :: GeneralCategory
+ Papa: Compose :: f (g a) -> Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1)
+ Papa: ConnectorPunctuation :: GeneralCategory
+ Papa: Const :: a -> Const a (b :: k)
+ Papa: Control :: GeneralCategory
+ Papa: CurrencySymbol :: GeneralCategory
+ Papa: DashPunctuation :: GeneralCategory
+ Papa: DecimalNumber :: GeneralCategory
+ Papa: DecodeFailed :: Either Handle FilePath -> UnicodeException -> IOFailure
+ Papa: Denormal :: ArithException
+ Papa: DivideByZero :: ArithException
+ Papa: Down :: a -> Down a
+ Papa: Dual :: a -> Dual a
+ Papa: EQ :: Ordering
+ Papa: EnclosingMark :: GeneralCategory
+ Papa: Endo :: (a -> a) -> Endo a
+ Papa: ExceptT :: m (Either e a) -> ExceptT e (m :: Type -> Type) a
+ Papa: ExitFailure :: Int -> ExitCode
+ Papa: ExitSuccess :: ExitCode
+ Papa: False :: Bool
+ Papa: FinalQuote :: GeneralCategory
+ Papa: First :: a -> First a
+ Papa: Format :: GeneralCategory
+ Papa: GT :: Ordering
+ Papa: HeapOverflow :: AsyncException
+ Papa: IOFailed :: IOException -> IOFailure
+ Papa: Identity :: a -> Identity a
+ Papa: IndexOutOfBounds :: String -> ArrayException
+ Papa: InitialQuote :: GeneralCategory
+ Papa: Just :: a -> Maybe a
+ Papa: LT :: Ordering
+ Papa: Last :: a -> Last a
+ Papa: Left :: a -> Either a b
+ Papa: LetterNumber :: GeneralCategory
+ Papa: LineBuffering :: BufferMode
+ Papa: LineSeparator :: GeneralCategory
+ Papa: LossOfPrecision :: ArithException
+ Papa: LowercaseLetter :: GeneralCategory
+ Papa: MaskedInterruptible :: MaskingState
+ Papa: MaskedUninterruptible :: MaskingState
+ Papa: MathSymbol :: GeneralCategory
+ Papa: Max :: a -> Max a
+ Papa: Min :: a -> Min a
+ Papa: ModifierLetter :: GeneralCategory
+ Papa: ModifierSymbol :: GeneralCategory
+ Papa: NoBuffering :: BufferMode
+ Papa: NonSpacingMark :: GeneralCategory
+ Papa: NotAssigned :: GeneralCategory
+ Papa: Nothing :: Maybe a
+ Papa: OpenPunctuation :: GeneralCategory
+ Papa: OtherLetter :: GeneralCategory
+ Papa: OtherNumber :: GeneralCategory
+ Papa: OtherPunctuation :: GeneralCategory
+ Papa: OtherSymbol :: GeneralCategory
+ Papa: Overflow :: ArithException
+ Papa: ParagraphSeparator :: GeneralCategory
+ Papa: PrivateUse :: GeneralCategory
+ Papa: Product :: a -> Product a
+ Papa: Proxy :: Proxy (t :: k)
+ Papa: RatioZeroDenominator :: ArithException
+ Papa: ReadMode :: IOMode
+ Papa: ReadWriteMode :: IOMode
+ Papa: ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a
+ Papa: Right :: b -> Either a b
+ Papa: SomeAsyncException :: e -> SomeAsyncException
+ Papa: Space :: GeneralCategory
+ Papa: SpacingCombiningMark :: GeneralCategory
+ Papa: StackOverflow :: AsyncException
+ Papa: StateT :: (s -> m (a, s)) -> StateT s (m :: Type -> Type) a
+ Papa: Sum :: a -> Sum a
+ Papa: Surrogate :: GeneralCategory
+ Papa: ThreadKilled :: AsyncException
+ Papa: TitlecaseLetter :: GeneralCategory
+ Papa: True :: Bool
+ Papa: UndefinedElement :: String -> ArrayException
+ Papa: Underflow :: ArithException
+ Papa: Unmasked :: MaskingState
+ Papa: UppercaseLetter :: GeneralCategory
+ Papa: UserInterrupt :: AsyncException
+ Papa: WrapArrow :: a b c -> WrappedArrow (a :: Type -> Type -> Type) b c
+ Papa: WrapMonad :: m a -> WrappedMonad (m :: Type -> Type) a
+ Papa: WrapMonoid :: m -> WrappedMonoid m
+ Papa: WriteMode :: IOMode
+ Papa: ZipList :: [a] -> ZipList a
+ Papa: [appEndo] :: Endo a -> a -> a
+ Papa: [getAll] :: All -> Bool
+ Papa: [getAny] :: Any -> Bool
+ Papa: [getCompose] :: Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1) -> f (g a)
+ Papa: [getConst] :: Const a (b :: k) -> a
+ Papa: [getDual] :: Dual a -> a
+ Papa: [getFirst] :: First a -> a
+ Papa: [getLast] :: Last a -> a
+ Papa: [getMax] :: Max a -> a
+ Papa: [getMin] :: Min a -> a
+ Papa: [getProduct] :: Product a -> a
+ Papa: [getSum] :: Sum a -> a
+ Papa: [getZipList] :: ZipList a -> [a]
+ Papa: [runIdentity] :: Identity a -> a
+ Papa: [runReaderT] :: ReaderT r (m :: Type -> Type) a -> r -> m a
+ Papa: [runStateT] :: StateT s (m :: Type -> Type) a -> s -> m (a, s)
+ Papa: [unwrapArrow] :: WrappedArrow (a :: Type -> Type -> Type) b c -> a b c
+ Papa: [unwrapMonad] :: WrappedMonad (m :: Type -> Type) a -> m a
+ Papa: [unwrapMonoid] :: WrappedMonoid m -> m
+ Papa: _DecodeFailed :: Prism' IOFailure (Either Handle FilePath, UnicodeException)
+ Papa: _IOFailed :: Prism' IOFailure IOException
+ Papa: _IOFailure :: AsIOFailure t => Prism' t IOFailure
+ Papa: abs :: Num a => a -> a
+ Papa: absurd :: Void -> a
+ Papa: acos :: Floating a => a -> a
+ Papa: acosh :: Floating a => a -> a
+ Papa: all :: Foldable t => (a -> Bool) -> t a -> Bool
+ Papa: allM :: Monad m => (a -> m Bool) -> [a] -> m Bool
+ Papa: and :: Foldable t => t Bool -> Bool
+ Papa: any :: Foldable t => (a -> Bool) -> t a -> Bool
+ Papa: anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool
+ Papa: ap :: Monad m => m (a -> b) -> m a -> m b
+ Papa: appendFile :: FilePath -> Text -> IOExcept ()
+ Papa: approxRationalMaybe :: RealFrac a => a -> a -> Maybe Rational
+ Papa: asin :: Floating a => a -> a
+ Papa: asinh :: Floating a => a -> a
+ Papa: ask :: MonadReader r m => m r
+ Papa: asks :: MonadReader r m => (r -> a) -> m a
+ Papa: asum :: (Foldable t, Alternative f) => t (f a) -> f a
+ Papa: asyncExceptionFromException :: Exception e => SomeException -> Maybe e
+ Papa: asyncExceptionToException :: Exception e => e -> SomeException
+ Papa: atan :: Floating a => a -> a
+ Papa: atan2 :: RealFloat a => a -> a -> a
+ Papa: atanh :: Floating a => a -> a
+ Papa: atomicModifyIORef' :: IORef a -> (a -> (a, b)) -> IO b
+ Papa: atomicWriteIORef :: IORef a -> a -> IO ()
+ Papa: bool :: a -> a -> Bool -> a
+ Papa: bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
+ Papa: bracketOnError :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
+ Papa: bracket_ :: IO a -> IO b -> IO c -> IO c
+ Papa: break :: (a -> Bool) -> [a] -> ([a], [a])
+ Papa: catMaybes :: [Maybe a] -> [a]
+ Papa: catch :: Exception e => IO a -> (e -> IO a) -> IO a
+ Papa: catchError :: MonadError e m => m a -> (e -> m a) -> m a
+ Papa: ceilingFloating :: RealFloat a => a -> a
+ Papa: ceilingMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa: chr :: Int -> Maybe Char
+ Papa: class a ~# b => (a :: k) ~ (b :: k)
+ Papa: class Applicative f => Alternative (f :: Type -> Type)
+ Papa: class Functor f => Applicative (f :: Type -> Type)
+ Papa: class (ReviewIOFailure t) => AsIOFailure t
+ Papa: class Eq a => Bits a
+ Papa: class () => Bounded a
+ Papa: class () => Category (cat :: k -> k -> Type)
+ Papa: class a ~R# b => Coercible (a :: k) (b :: k)
+ Papa: class Typeable a => Data a
+ Papa: class DivisorLike p f x x' a a' | x -> a
+ Papa: class () => Enum a
+ Papa: class () => Eq a
+ Papa: class forall a. Eq a => Eq f a => Eq1 (f :: Type -> Type)
+ Papa: class forall a. Eq a => Eq1 f a => Eq2 (f :: Type -> Type -> Type)
+ Papa: class (Typeable e, Show e) => Exception e
+ Papa: class Fractional a => Floating a
+ Papa: class () => Foldable (t :: Type -> Type)
+ Papa: class Foldable t => Foldable1 (t :: Type -> Type)
+ Papa: class Num a => Fractional a
+ Papa: class () => Functor (f :: Type -> Type)
+ Papa: class () => Generic a
+ Papa: class () => Generic1 (f :: k -> Type)
+ Papa: class GetIOFailure s
+ Papa: class (GetIOFailure s) => HasIOFailure s
+ Papa: class Eq a => Hashable a
+ Papa: class (Real a, Enum a) => Integral a
+ Papa: class () => IsString a
+ Papa: class LeftLike p f x x' a a' | x -> a
+ Papa: class Applicative m => Monad (m :: Type -> Type)
+ Papa: class Monad m => MonadError e (m :: Type -> Type) | m -> e
+ Papa: class Monad m => MonadFail (m :: Type -> Type)
+ Papa: class Monad m => MonadFix (m :: Type -> Type)
+ Papa: class Monad m => MonadIO (m :: Type -> Type)
+ Papa: class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type)
+ Papa: class Monad m => MonadReader r (m :: Type -> Type) | m -> r
+ Papa: class Monad m => MonadState s (m :: Type -> Type) | m -> s
+ Papa: class forall (m :: Type -> Type). Monad m => Monad t m => MonadTrans (t :: Type -> Type -> Type -> Type)
+ Papa: class Monad m => MonadZip (m :: Type -> Type)
+ Papa: class Semigroup a => Monoid a
+ Papa: class () => NFData a
+ Papa: class NonZeroLike p f x x' a a' | x -> a
+ Papa: class () => Num a
+ Papa: class Eq a => Ord a
+ Papa: class (Eq1 f, forall a. Ord a => Ord f a) => Ord1 (f :: Type -> Type)
+ Papa: class (Eq2 f, forall a. Ord a => Ord1 f a) => Ord2 (f :: Type -> Type -> Type)
+ Papa: class () => Read a
+ Papa: class (Num a, Ord a) => Real a
+ Papa: class (RealFrac a, Floating a) => RealFloat a
+ Papa: class (Real a, Fractional a) => RealFrac a
+ Papa: class ReviewIOFailure t
+ Papa: class RightLike p f x x' a a' | x -> a
+ Papa: class () => Semigroup a
+ Papa: class () => Show a
+ Papa: class forall a. Show a => Show f a => Show1 (f :: Type -> Type)
+ Papa: class forall a. Show a => Show1 f a => Show2 (f :: Type -> Type -> Type)
+ Papa: class (Functor t, Foldable t) => Traversable (t :: Type -> Type)
+ Papa: class () => Typeable (a :: k)
+ Papa: coerce :: forall {k :: RuntimeRep} (a :: TYPE k) (b :: TYPE k). Coercible a b => a -> b
+ Papa: compare :: Ord a => a -> a -> Ordering
+ Papa: comparing :: Ord a => (b -> a) -> b -> b -> Ordering
+ Papa: concat :: Foldable t => t [a] -> [a]
+ Papa: concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
+ Papa: const :: Applicative f => a -> f a
+ Papa: cos :: Floating a => a -> a
+ Papa: cosh :: Floating a => a -> a
+ Papa: curry :: ((a, b) -> c) -> a -> b -> c
+ Papa: cycle :: [a] -> Maybe [a]
+ Papa: cycle1 :: Semigroup m => m -> m
+ Papa: data () => Arg a b
+ Papa: data () => ArithException
+ Papa: data () => ArrayException
+ Papa: data () => AsyncException
+ Papa: data () => Bool
+ Papa: data () => BufferMode
+ Papa: data () => ByteString
+ Papa: data () => Char
+ Papa: data () => Double
+ Papa: data () => Either a b
+ Papa: data () => ErrorCall
+ Papa: data () => ExitCode
+ Papa: data () => Float
+ Papa: data () => GeneralCategory
+ Papa: data () => Handle
+ Papa: data () => HashMap k v
+ Papa: data () => HashSet a
+ Papa: data () => IO a
+ Papa: data () => IOException
+ Papa: data IOFailure
+ Papa: data () => IOMode
+ Papa: data () => IORef a
+ Papa: data () => Int
+ Papa: data () => Int16
+ Papa: data () => Int32
+ Papa: data () => Int64
+ Papa: data () => Int8
+ Papa: data () => Integer
+ Papa: data () => MVar a
+ Papa: data () => MaskingState
+ Papa: data () => Maybe a
+ Papa: data () => NonEmpty a
+ Papa: data NonZero a
+ Papa: data () => Ordering
+ Papa: data () => Proxy (t :: k)
+ Papa: data () => SomeAsyncException
+ Papa: data () => SomeException
+ Papa: data () => Text
+ Papa: data () => ThreadId
+ Papa: data () => Vector a
+ Papa: data () => Void
+ Papa: data () => Word
+ Papa: data () => Word16
+ Papa: data () => Word32
+ Papa: data () => Word64
+ Papa: data () => Word8
+ Papa: decodeFloat :: RealFloat a => a -> (Integer, Int)
+ Papa: decodeUtf8' :: ByteString -> Either UnicodeException Text
+ Papa: deepseq :: NFData a => a -> b -> b
+ Papa: delete :: Eq a => a -> [a] -> [a]
+ Papa: deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
+ Papa: deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
+ Papa: denominator :: Ratio a -> a
+ Papa: die :: Text -> IO a
+ Papa: diff :: Semigroup m => m -> Endo m
+ Papa: display :: Show a => a -> Text
+ Papa: displayException :: Exception e => e -> String
+ Papa: displayExponent :: RealFloat a => Word -> a -> Text
+ Papa: displayFixed :: RealFloat a => Word -> a -> Text
+ Papa: divModNonZero :: Integral a => a -> NonZero a -> (a, a)
+ Papa: divNonZero :: Integral a => a -> NonZero a -> a
+ Papa: divideFloating :: RealFloat a => a -> a -> a
+ Papa: divideNonZero :: Fractional a => a -> NonZero a -> a
+ Papa: divisor :: DivisorLike p f x x' a a' => Optic p f x x' a a'
+ Papa: doubleToFloat :: Double -> Float
+ Papa: drop :: Int -> [a] -> [a]
+ Papa: dropWhile :: (a -> Bool) -> [a] -> [a]
+ Papa: dropWhileEnd :: (a -> Bool) -> [a] -> [a]
+ Papa: either :: (a -> c) -> (b -> c) -> Either a b -> c
+ Papa: elem :: (Foldable t, Eq a) => a -> t a -> Bool
+ Papa: empty :: Alternative f => f a
+ Papa: encodeFloat :: RealFloat a => Integer -> Int -> a
+ Papa: encodeUtf8 :: Text -> ByteString
+ Papa: evalState :: State s a -> s -> a
+ Papa: evalStateT :: Monad m => StateT s m a -> s -> m a
+ Papa: evaluate :: a -> IO a
+ Papa: even :: Integral a => a -> Bool
+ Papa: except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a
+ Papa: exceptIO :: IO a -> IOExcept a
+ Papa: execState :: State s a -> s -> s
+ Papa: execStateT :: Monad m => StateT s m a -> s -> m s
+ Papa: exitFailure :: IO a
+ Papa: exitSuccess :: IO a
+ Papa: exitWith :: ExitCode -> Maybe (IO a)
+ Papa: exp :: Floating a => a -> a
+ Papa: exponent :: RealFloat a => a -> Int
+ Papa: filter :: (a -> Bool) -> [a] -> [a]
+ Papa: filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
+ Papa: finally :: IO a -> IO b -> IO a
+ Papa: find :: Foldable t => (a -> Bool) -> t a -> Maybe a
+ Papa: findM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a)
+ Papa: fix :: (a -> a) -> a
+ Papa: flip :: Functor f => f (a -> b) -> a -> f b
+ Papa: floatDigits :: RealFloat a => a -> Int
+ Papa: floatRadix :: RealFloat a => a -> Integer
+ Papa: floatRange :: RealFloat a => a -> (Int, Int)
+ Papa: floatToDouble :: Float -> Double
+ Papa: floorFloating :: RealFloat a => a -> a
+ Papa: floorMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa: fmap :: Functor f => (a -> b) -> f a -> f b
+ Papa: fmapDefault :: Traversable t => (a -> b) -> t a -> t b
+ Papa: fold :: (Foldable t, Monoid m) => t m -> m
+ Papa: foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
+ Papa: foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()
+ Papa: foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
+ Papa: foldMap' :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
+ Papa: foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m
+ Papa: foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
+ Papa: foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b
+ Papa: foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
+ Papa: foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
+ Papa: foldr' :: Foldable t => (a -> b -> b) -> b -> t a -> b
+ Papa: foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
+ Papa: for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
+ Papa: forM :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
+ Papa: forM_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
+ Papa: for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
+ Papa: force :: NFData a => a -> a
+ Papa: forever :: Applicative f => f a -> f b
+ Papa: forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
+ Papa: forkIO :: IO () -> IO ThreadId
+ Papa: fromException :: Exception e => SomeException -> Maybe e
+ Papa: fromLeft :: LeftLike (->) (Const (First a)) s s a a => a -> s -> a
+ Papa: fromMaybe :: a -> Maybe a -> a
+ Papa: fromRational :: Fractional a => Rational -> a
+ Papa: fromRight :: RightLike (->) (Const (First b)) s s b b => b -> s -> b
+ Papa: fromString :: IsString a => String -> a
+ Papa: gcd :: Integral a => a -> a -> a
+ Papa: genericDrop :: Integral i => i -> [a] -> [a]
+ Papa: genericLength :: Num i => [a] -> i
+ Papa: genericReplicate :: Integral i => i -> a -> [a]
+ Papa: genericSplitAt :: Integral i => i -> [a] -> ([a], [a])
+ Papa: genericTake :: Integral i => i -> [a] -> [a]
+ Papa: get :: MonadState s m => m s
+ Papa: getArgs :: IO [String]
+ Papa: getChar :: IO Char
+ Papa: getContents :: IOExcept Text
+ Papa: getEnvironment :: IO [(String, String)]
+ Papa: getIOFailure :: GetIOFailure s => Getter s IOFailure
+ Papa: getLine :: IOExcept Text
+ Papa: getMaskingState :: IO MaskingState
+ Papa: getProgName :: IO String
+ Papa: gets :: MonadState s m => (s -> a) -> m a
+ Papa: group :: (Foldable f, Eq a) => f a -> [NonEmpty a]
+ Papa: group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a)
+ Papa: groupAllWith :: Ord b => (a -> b) -> [a] -> [NonEmpty a]
+ Papa: groupAllWith1 :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
+ Papa: groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a]
+ Papa: groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a)
+ Papa: groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a]
+ Papa: groupWith1 :: Eq b => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)
+ Papa: guard :: Alternative f => Bool -> f ()
+ Papa: hClose :: Handle -> IOExcept ()
+ Papa: hFlush :: Handle -> IOExcept ()
+ Papa: hGetContents :: Handle -> IOExcept Text
+ Papa: hGetLine :: Handle -> IOExcept Text
+ Papa: hIsEOF :: Handle -> IOExcept Bool
+ Papa: hPrint :: Show a => Handle -> a -> IOExcept ()
+ Papa: hPutStr :: Handle -> Text -> IOExcept ()
+ Papa: hPutStrLn :: Handle -> Text -> IOExcept ()
+ Papa: hSetBuffering :: Handle -> BufferMode -> IOExcept ()
+ Papa: handle :: Exception e => (e -> IO a) -> IO a -> IO a
+ Papa: head :: Lens' (NonEmpty a) a
+ Papa: id :: forall (a :: k). Category cat => cat a a
+ Papa: infix 4 `notElem`
+ Papa: infix 5 \\
+ Papa: infixl 0 `on`
+ Papa: infixl 1 &
+ Papa: infixl 3 <|>
+ Papa: infixl 4 <$!>
+ Papa: infixl 6 +
+ Papa: infixl 7 *
+ Papa: infixl 9 !?
+ Papa: infixr 0 $!
+ Papa: infixr 1 <=<
+ Papa: infixr 2 ||
+ Papa: infixr 3 &&&
+ Papa: infixr 5 ++
+ Papa: infixr 6 <>
+ Papa: infixr 8 **
+ Papa: infixr 9 .
+ Papa: inheritNonZero :: InheritNonZero s a => proxy s -> ()
+ Papa: init :: Lens' (NonEmpty a) [a]
+ Papa: inits :: Foldable f => f a -> NonEmpty [a]
+ Papa: insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a
+ Papa: insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
+ Papa: intCast :: (Integral a, Num b, IntCast a b) => a -> b
+ Papa: integralToFloating :: (Integral a, RealFloat b) => a -> b
+ Papa: interact :: (Text -> Text) -> IOExcept ()
+ Papa: intercalate :: [a] -> [[a]] -> [a]
+ Papa: intersect :: Eq a => [a] -> [a] -> [a]
+ Papa: intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
+ Papa: intersperse :: a -> [a] -> [a]
+ Papa: ioError :: IOError -> IO a
+ Papa: ioFailure :: HasIOFailure s => Lens' s IOFailure
+ Papa: isAlpha :: Char -> Bool
+ Papa: isAlphaNum :: Char -> Bool
+ Papa: isAscii :: Char -> Bool
+ Papa: isAsciiLower :: Char -> Bool
+ Papa: isAsciiUpper :: Char -> Bool
+ Papa: isControl :: Char -> Bool
+ Papa: isDenormalized :: RealFloat a => a -> Bool
+ Papa: isDigit :: Char -> Bool
+ Papa: isHexDigit :: Char -> Bool
+ Papa: isIEEE :: RealFloat a => a -> Bool
+ Papa: isInfinite :: RealFloat a => a -> Bool
+ Papa: isInfixOf :: Eq a => [a] -> [a] -> Bool
+ Papa: isJust :: Maybe a -> Bool
+ Papa: isLatin1 :: Char -> Bool
+ Papa: isLeft :: Either a b -> Bool
+ Papa: isLetter :: Char -> Bool
+ Papa: isLower :: Char -> Bool
+ Papa: isMark :: Char -> Bool
+ Papa: isNaN :: RealFloat a => a -> Bool
+ Papa: isNegativeZero :: RealFloat a => a -> Bool
+ Papa: isNothing :: Maybe a -> Bool
+ Papa: isNumber :: Char -> Bool
+ Papa: isOctDigit :: Char -> Bool
+ Papa: isPrefixOf :: Eq a => [a] -> [a] -> Bool
+ Papa: isPrint :: Char -> Bool
+ Papa: isPunctuation :: Char -> Bool
+ Papa: isRight :: Either a b -> Bool
+ Papa: isSeparator :: Char -> Bool
+ Papa: isSpace :: Char -> Bool
+ Papa: isSubsequenceOf :: Eq a => [a] -> [a] -> Bool
+ Papa: isSuffixOf :: Eq a => [a] -> [a] -> Bool
+ Papa: isSymbol :: Char -> Bool
+ Papa: isUpper :: Char -> Bool
+ Papa: iterate :: (a -> a) -> a -> NonEmpty a
+ Papa: killThread :: ThreadId -> IO ()
+ Papa: last :: Lens' (NonEmpty a) a
+ Papa: lawNamesNonZero :: NonZeroLike (->) (Const (First (NonZero a))) a a a a => NonZero a -> Maybe (NonZero a)
+ Papa: lcm :: Integral a => a -> a -> a
+ Papa: left :: LeftLike p f x x' a a' => Optic p f x x' a a'
+ Papa: lefts :: Traversable f => Traversal (f (Either a b)) (f (Either a' b)) a a'
+ Papa: length :: Foldable t => t a -> Int
+ Papa: lift :: (MonadTrans t, Monad m) => m a -> t m a
+ Papa: liftA :: Applicative f => (a -> b) -> f a -> f b
+ Papa: liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
+ Papa: liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
+ Papa: liftCompare :: Ord1 f => (a -> b -> Ordering) -> f a -> f b -> Ordering
+ Papa: liftCompare2 :: Ord2 f => (a -> b -> Ordering) -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
+ Papa: liftEither :: MonadError e m => Either e a -> m a
+ Papa: liftEq :: Eq1 f => (a -> b -> Bool) -> f a -> f b -> Bool
+ Papa: liftEq2 :: Eq2 f => (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
+ Papa: liftIO :: MonadIO m => IO a -> m a
+ Papa: liftM :: Monad m => (a1 -> r) -> m a1 -> m r
+ Papa: liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
+ Papa: liftShowsPrec :: Show1 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
+ Papa: liftShowsPrec2 :: Show2 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> f a b -> ShowS
+ Papa: lines :: Text -> [Text]
+ Papa: listToMaybe :: [a] -> Maybe a
+ Papa: local :: MonadReader r m => (r -> r) -> m a -> m a
+ Papa: log :: Floating a => a -> a
+ Papa: logBase :: Floating a => a -> a -> a
+ Papa: lookup :: (Eq a, Foldable f) => a -> f (a, b) -> Maybe b
+ Papa: lookupEnv :: String -> IO (Maybe String)
+ Papa: many :: Alternative f => f a -> f [a]
+ Papa: map :: Functor f => (a -> b) -> f a -> f b
+ Papa: mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
+ Papa: mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
+ Papa: mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
+ Papa: mapM :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
+ Papa: mapM_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
+ Papa: mapMaybe :: (a -> Maybe b) -> [a] -> [b]
+ Papa: mappend :: Monoid a => a -> a -> a
+ Papa: mask :: ((forall a. () => IO a -> IO a) -> IO b) -> IO b
+ Papa: mask_ :: IO a -> IO a
+ Papa: matchIOFailure :: AsIOFailure t => t -> Maybe IOFailure
+ Papa: max :: Ord a => a -> a -> a
+ Papa: maxBound :: Bounded a => a
+ Papa: maximum :: (Foldable1 t, Ord a) => t a -> a
+ Papa: maximumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
+ Papa: maybe :: b -> (a -> b) -> Maybe a -> b
+ Papa: maybeToList :: Maybe a -> [a]
+ Papa: mconcat :: (Foldable f, Monoid a) => f a -> a
+ Papa: mempty :: Monoid a => a
+ Papa: mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
+ Papa: min :: Ord a => a -> a -> a
+ Papa: minBound :: Bounded a => a
+ Papa: minimum :: (Foldable1 t, Ord a) => t a -> a
+ Papa: minimumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
+ Papa: modFloating :: RealFloat a => a -> a -> a
+ Papa: modNonZero :: Integral a => a -> NonZero a -> a
+ Papa: modify :: MonadState s m => (s -> s) -> m ()
+ Papa: modify' :: MonadState s m => (s -> s) -> m ()
+ Papa: modifyIORef' :: IORef a -> (a -> a) -> IO ()
+ Papa: modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b
+ Papa: modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
+ Papa: mplus :: MonadPlus m => m a -> m a -> m a
+ Papa: msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
+ Papa: mtimesDefault :: (Integral b, Monoid a) => b -> a -> Maybe a
+ Papa: munzip :: MonadZip m => m (a, b) -> (m a, m b)
+ Papa: myThreadId :: IO ThreadId
+ Papa: mzero :: MonadPlus m => m a
+ Papa: mzip :: MonadZip m => m a -> m b -> m (a, b)
+ Papa: mzipWith :: MonadZip m => (a -> b -> c) -> m a -> m b -> m c
+ Papa: negate :: Num a => a -> a
+ Papa: newEmptyMVar :: IO (MVar a)
+ Papa: newIORef :: a -> IO (IORef a)
+ Papa: newMVar :: a -> IO (MVar a)
+ Papa: newtype () => All
+ Papa: newtype () => Any
+ Papa: newtype () => Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1)
+ Papa: newtype () => Const a (b :: k)
+ Papa: newtype () => Down a
+ Papa: newtype () => Dual a
+ Papa: newtype () => Endo a
+ Papa: newtype () => ExceptT e (m :: Type -> Type) a
+ Papa: newtype () => First a
+ Papa: newtype () => Identity a
+ Papa: newtype () => Last a
+ Papa: newtype () => Max a
+ Papa: newtype () => Min a
+ Papa: newtype () => Product a
+ Papa: newtype () => ReaderT r (m :: Type -> Type) a
+ Papa: newtype () => StateT s (m :: Type -> Type) a
+ Papa: newtype () => Sum a
+ Papa: newtype () => WrappedArrow (a :: Type -> Type -> Type) b c
+ Papa: newtype () => WrappedMonad (m :: Type -> Type) a
+ Papa: newtype () => WrappedMonoid m
+ Papa: newtype () => ZipList a
+ Papa: nonEmpty :: [a] -> Maybe (NonEmpty a)
+ Papa: nonZero :: NonZeroLike p f x x' a a' => Optic p f x x' (NonZero a) (NonZero a')
+ Papa: not :: Bool -> Bool
+ Papa: notElem :: (Foldable t, Eq a) => a -> t a -> Bool
+ Papa: nub :: Eq a => [a] -> [a]
+ Papa: nubBy :: (a -> a -> Bool) -> [a] -> [a]
+ Papa: null :: Foldable t => t a -> Bool
+ Papa: numerator :: Ratio a -> a
+ Papa: odd :: Integral a => a -> Bool
+ Papa: on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
+ Papa: onException :: IO a -> IO b -> IO a
+ Papa: openFile :: FilePath -> IOMode -> IOExcept Handle
+ Papa: optional :: Alternative f => f a -> f (Maybe a)
+ Papa: or :: Foldable t => t Bool -> Bool
+ Papa: ord :: Char -> Int
+ Papa: otherwise :: Bool
+ Papa: pack :: String -> Text
+ Papa: partition :: (a -> Bool) -> [a] -> ([a], [a])
+ Papa: partitionEithers :: Foldable f => f (Either a b) -> ([a], [b])
+ Papa: permutations :: [a] -> [[a]]
+ Papa: pi :: Floating a => a
+ Papa: pow :: Num a => a -> Word -> a
+ Papa: powNonZero :: (Fractional a, Integral b) => NonZero a -> b -> a
+ Papa: pred :: (Bounded a, Enum a, Eq a) => a -> Maybe a
+ Papa: previewNonZero :: (Eq a, Num a) => a -> Maybe (NonZero a)
+ Papa: print :: Show a => a -> IOExcept ()
+ Papa: product :: (Foldable t, Num a) => t a -> a
+ Papa: properFractionMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe (b, a)
+ Papa: pure :: Applicative f => a -> f a
+ Papa: put :: MonadState s m => s -> m ()
+ Papa: putMVar :: MVar a -> a -> IO ()
+ Papa: putStr :: Text -> IOExcept ()
+ Papa: putStrLn :: Text -> IOExcept ()
+ Papa: quotNonZero :: Integral a => a -> NonZero a -> a
+ Papa: quotRemNonZero :: Integral a => a -> NonZero a -> (a, a)
+ Papa: ratioNonZero :: Integer -> NonZero Integer -> Rational
+ Papa: readEither :: Read a => Text -> Either Text a
+ Papa: readFile :: FilePath -> IOExcept Text
+ Papa: readIO :: Read a => Text -> IO (Maybe a)
+ Papa: readIORef :: IORef a -> IO a
+ Papa: readMVar :: MVar a -> IO a
+ Papa: readMaybe :: Read a => Text -> Maybe a
+ Papa: reader :: MonadReader r m => (r -> a) -> m a
+ Papa: reads :: Read a => ReadS a
+ Papa: recipFloating :: RealFloat a => a -> a
+ Papa: recipNonZero :: Fractional a => NonZero a -> a
+ Papa: remNonZero :: Integral a => a -> NonZero a -> a
+ Papa: repeat :: a -> NonEmpty a
+ Papa: replicate :: Int -> a -> [a]
+ Papa: replicateA :: Applicative f => Int -> f a -> f [a]
+ Papa: replicateA_ :: Applicative f => Int -> f a -> f ()
+ Papa: replicateM :: Applicative m => Int -> m a -> m [a]
+ Papa: replicateM_ :: Applicative m => Int -> m a -> m ()
+ Papa: return :: Monad m => a -> m a
+ Papa: reverse :: [a] -> [a]
+ Papa: reviewIOFailure :: ReviewIOFailure t => Review t IOFailure
+ Papa: right :: RightLike p f x x' a a' => Optic p f x x' a a'
+ Papa: rights :: Traversable f => Traversal (f (Either a b)) (f (Either a b')) b b'
+ Papa: rnf :: NFData a => a -> ()
+ Papa: roundFloating :: RealFloat a => a -> a
+ Papa: roundMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa: runExcept :: Except e a -> Either e a
+ Papa: runExceptT :: ExceptT e m a -> m (Either e a)
+ Papa: runReader :: Reader r a -> r -> a
+ Papa: runState :: State s a -> s -> (a, s)
+ Papa: scaleFloat :: RealFloat a => Int -> a -> a
+ Papa: scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b
+ Papa: scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
+ Papa: scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b
+ Papa: scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a
+ Papa: sconcat :: Semigroup a => NonEmpty a -> a
+ Papa: seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
+ Papa: sequence :: (Traversable t, Applicative f) => t (f a) -> f (t a)
+ Papa: sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
+ Papa: sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
+ Papa: sequence_ :: (Foldable t, Applicative f) => t (f a) -> f ()
+ Papa: setIOFailure :: HasIOFailure s => IOFailure -> s -> s
+ Papa: show :: Show a => a -> String
+ Papa: showList :: Show a => [a] -> ShowS
+ Papa: showParen :: Bool -> ShowS -> ShowS
+ Papa: showString :: String -> ShowS
+ Papa: shows :: Show a => a -> ShowS
+ Papa: showsPrec :: Show a => Int -> a -> ShowS
+ Papa: significand :: RealFloat a => a -> a
+ Papa: signum :: Num a => a -> a
+ Papa: sin :: Floating a => a -> a
+ Papa: singleton :: a -> [a]
+ Papa: sinh :: Floating a => a -> a
+ Papa: some :: Alternative f => f a -> f [a]
+ Papa: some1 :: Alternative f => f a -> f (NonEmpty a)
+ Papa: sort :: Ord a => [a] -> [a]
+ Papa: sortBy :: (a -> a -> Ordering) -> [a] -> [a]
+ Papa: sortOn :: Ord b => (a -> b) -> [a] -> [a]
+ Papa: span :: (a -> Bool) -> [a] -> ([a], [a])
+ Papa: splitAt :: Int -> [a] -> ([a], [a])
+ Papa: sqrt :: Floating a => a -> a
+ Papa: state :: MonadState s m => (s -> (a, s)) -> m a
+ Papa: stderr :: Handle
+ Papa: stdin :: Handle
+ Papa: stdout :: Handle
+ Papa: stimes :: (Integral b, Semigroup a) => b -> a -> Maybe a
+ Papa: stimesIdempotent :: Integral b => b -> a -> Maybe a
+ Papa: stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> Maybe a
+ Papa: stimesMonoid :: (Integral b, Monoid a) => b -> a -> Maybe a
+ Papa: stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]
+ Papa: subsequences :: [a] -> [[a]]
+ Papa: subtract :: Num a => a -> a -> a
+ Papa: succ :: Enum a => a -> Maybe a
+ Papa: sum :: (Foldable t, Num a) => t a -> a
+ Papa: swap :: (a, b) -> (b, a)
+ Papa: tail :: Lens' (NonEmpty a) [a]
+ Papa: tails :: Foldable f => f a -> NonEmpty [a]
+ Papa: take :: Int -> [a] -> [a]
+ Papa: takeMVar :: MVar a -> IO a
+ Papa: takeWhile :: (a -> Bool) -> [a] -> [a]
+ Papa: tan :: Floating a => a -> a
+ Papa: tanh :: Floating a => a -> a
+ Papa: threadDelay :: Int -> IO ()
+ Papa: throwError :: MonadError e m => e -> m a
+ Papa: throwIO :: Exception e => e -> IO a
+ Papa: throwTo :: Exception e => ThreadId -> e -> IO ()
+ Papa: toException :: Exception e => e -> SomeException
+ Papa: toInteger :: Integral a => a -> Integer
+ Papa: toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
+ Papa: toList :: Foldable t => t a -> [a]
+ Papa: toLower :: Char -> Char
+ Papa: toNonEmpty :: Foldable1 t => t a -> NonEmpty a
+ Papa: toRationalMaybe :: Real a => a -> Maybe Rational
+ Papa: toTitle :: Char -> Char
+ Papa: toUpper :: Char -> Char
+ Papa: transpose :: [[a]] -> [[a]]
+ Papa: traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
+ Papa: traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
+ Papa: truncateFloating :: RealFloat a => a -> a
+ Papa: truncateMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa: try :: Exception e => IO a -> IO (Either e a)
+ Papa: tryReadMVar :: MVar a -> IO (Maybe a)
+ Papa: tryTakeMVar :: MVar a -> IO (Maybe a)
+ Papa: type ArgMax a b = Max Arg a b
+ Papa: type ArgMin a b = Min Arg a b
+ Papa: type Except e = ExceptT e Identity
+ Papa: type FilePath = String
+ Papa: type HasCallStack = ?callStack :: CallStack
+ Papa: type IOError = IOException
+ Papa: type IOExcept = ExceptT IOFailure IO
+ Papa: type InheritNonZero s a = (NonZeroLike (->) (Const ()) s s a a, DivisorLike (->) (Const ()) s s a a)
+ Papa: type IntCast a b = IntCastCheck a b (IsIntSubType a b)
+ Papa: type Rational = Ratio Integer
+ Papa: type Reader r = ReaderT r Identity
+ Papa: type ShowS = String -> String
+ Papa: type State s = StateT s Identity
+ Papa: type String = [Char]
+ Papa: type family IsIntSubType a b :: Bool
+ Papa: uncurry :: (a -> b -> c) -> (a, b) -> c
+ Papa: unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b
+ Papa: uninterruptibleMask :: ((forall a. () => IO a -> IO a) -> IO b) -> IO b
+ Papa: uninterruptibleMask_ :: IO a -> IO a
+ Papa: union :: Eq a => [a] -> [a] -> [a]
+ Papa: unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
+ Papa: unless :: Applicative f => Bool -> f () -> f ()
+ Papa: unlines :: [Text] -> Text
+ Papa: unpack :: Text -> String
+ Papa: until :: (a -> Bool) -> (a -> a) -> a -> a
+ Papa: unwords :: [Text] -> Text
+ Papa: unzip :: [(a, b)] -> ([a], [b])
+ Papa: unzip3 :: [(a, b, c)] -> ([a], [b], [c])
+ Papa: userError :: String -> IOError
+ Papa: vacuous :: Functor f => f Void -> f a
+ Papa: validNonZero :: (Eq a, Num a) => a -> Bool
+ Papa: void :: Functor f => f a -> f ()
+ Papa: when :: Applicative f => Bool -> f () -> f ()
+ Papa: whenJust :: (a -> Maybe b) -> (b -> a) -> a -> a
+ Papa: whenJustM :: Monad f => (a -> f (Maybe b)) -> (b -> f a) -> a -> f a
+ Papa: withExcept :: (e -> e') -> Except e a -> Except e' a
+ Papa: withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
+ Papa: withFile :: FilePath -> IOMode -> (Handle -> IOExcept a) -> IOExcept a
+ Papa: words :: Text -> [Text]
+ Papa: writeFile :: FilePath -> Text -> IOExcept ()
+ Papa: writeIORef :: IORef a -> a -> IO ()
+ Papa: xor :: NonEmpty Bool -> Bool
+ Papa: zip :: [a] -> [b] -> [(a, b)]
+ Papa: zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
+ Papa: zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
+ Papa: zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
+ Papa: zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
+ Papa: zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
+ Papa.Associative.Renamed: op :: (a -> a -> b) -> SemigroupOp a b
+ Papa.Async.Control.Concurrent.Async: AsyncCancelled :: AsyncCancelled
+ Papa.Async.Control.Concurrent.Async: Concurrently :: IO a -> Concurrently a
+ Papa.Async.Control.Concurrent.Async: ConcurrentlyE :: IO (Either e a) -> ConcurrentlyE e a
+ Papa.Async.Control.Concurrent.Async: [runConcurrentlyE] :: ConcurrentlyE e a -> IO (Either e a)
+ Papa.Async.Control.Concurrent.Async: [runConcurrently] :: Concurrently a -> IO a
+ Papa.Async.Control.Concurrent.Async: async :: IO a -> IO (Async a)
+ Papa.Async.Control.Concurrent.Async: asyncBound :: IO a -> IO (Async a)
+ Papa.Async.Control.Concurrent.Async: asyncOn :: Int -> IO a -> IO (Async a)
+ Papa.Async.Control.Concurrent.Async: asyncOnWithUnmask :: Int -> ((forall b. () => IO b -> IO b) -> IO a) -> IO (Async a)
+ Papa.Async.Control.Concurrent.Async: asyncThreadId :: Async a -> ThreadId
+ Papa.Async.Control.Concurrent.Async: asyncWithUnmask :: ((forall b. () => IO b -> IO b) -> IO a) -> IO (Async a)
+ Papa.Async.Control.Concurrent.Async: cancel :: Async a -> IO ()
+ Papa.Async.Control.Concurrent.Async: cancelWith :: Exception e => Async a -> e -> IO ()
+ Papa.Async.Control.Concurrent.Async: compareAsyncs :: Async a -> Async b -> Ordering
+ Papa.Async.Control.Concurrent.Async: concurrently :: IO a -> IO b -> IO (a, b)
+ Papa.Async.Control.Concurrent.Async: concurrentlyE :: IO (Either e a) -> IO (Either e b) -> IO (Either e (a, b))
+ Papa.Async.Control.Concurrent.Async: concurrentlyExcept :: ExceptT e IO a -> ExceptT e IO b -> ExceptT e IO (a, b)
+ Papa.Async.Control.Concurrent.Async: concurrently_ :: IO a -> IO b -> IO ()
+ Papa.Async.Control.Concurrent.Async: data () => Async a
+ Papa.Async.Control.Concurrent.Async: data () => AsyncCancelled
+ Papa.Async.Control.Concurrent.Async: forConcurrently :: Traversable t => t a -> (a -> IO b) -> IO (t b)
+ Papa.Async.Control.Concurrent.Async: forConcurrently_ :: Foldable f => f a -> (a -> IO b) -> IO ()
+ Papa.Async.Control.Concurrent.Async: mapConcurrently :: Traversable t => (a -> IO b) -> t a -> IO (t b)
+ Papa.Async.Control.Concurrent.Async: mapConcurrently_ :: Foldable f => (a -> IO b) -> f a -> IO ()
+ Papa.Async.Control.Concurrent.Async: newtype () => Concurrently a
+ Papa.Async.Control.Concurrent.Async: newtype () => ConcurrentlyE e a
+ Papa.Async.Control.Concurrent.Async: poll :: Async a -> IO (Maybe (Either SomeException a))
+ Papa.Async.Control.Concurrent.Async: pollSTM :: Async a -> STM (Maybe (Either SomeException a))
+ Papa.Async.Control.Concurrent.Async: race :: IO a -> IO b -> IO (Either a b)
+ Papa.Async.Control.Concurrent.Async: raceExcept :: ExceptT e IO a -> ExceptT e IO b -> ExceptT e IO (Either a b)
+ Papa.Async.Control.Concurrent.Async: race_ :: IO a -> IO b -> IO ()
+ Papa.Async.Control.Concurrent.Async: replicateConcurrently :: Int -> IO a -> IO [a]
+ Papa.Async.Control.Concurrent.Async: replicateConcurrently_ :: Int -> IO a -> IO ()
+ Papa.Async.Control.Concurrent.Async: uninterruptibleCancel :: Async a -> IO ()
+ Papa.Async.Control.Concurrent.Async: waitAnyCatch :: NonEmpty (Async a) -> IO (Async a, Either SomeException a)
+ Papa.Async.Control.Concurrent.Async: waitAnyCatchCancel :: NonEmpty (Async a) -> IO (Async a, Either SomeException a)
+ Papa.Async.Control.Concurrent.Async: waitAnyCatchSTM :: NonEmpty (Async a) -> STM (Async a, Either SomeException a)
+ Papa.Async.Control.Concurrent.Async: waitCatch :: Async a -> IO (Either SomeException a)
+ Papa.Async.Control.Concurrent.Async: waitCatchSTM :: Async a -> STM (Either SomeException a)
+ Papa.Async.Control.Concurrent.Async: waitEitherCatch :: Async a -> Async b -> IO (Either (Either SomeException a) (Either SomeException b))
+ Papa.Async.Control.Concurrent.Async: waitEitherCatchCancel :: Async a -> Async b -> IO (Either (Either SomeException a) (Either SomeException b))
+ Papa.Async.Control.Concurrent.Async: waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b))
+ Papa.Async.Control.Concurrent.Async: waitExcept :: Async a -> ExceptT SomeException IO a
+ Papa.Async.Control.Concurrent.Async: withAsync :: IO a -> (Async a -> IO b) -> IO b
+ Papa.Async.Control.Concurrent.Async: withAsyncBound :: IO a -> (Async a -> IO b) -> IO b
+ Papa.Async.Control.Concurrent.Async: withAsyncOn :: Int -> IO a -> (Async a -> IO b) -> IO b
+ Papa.Async.Control.Concurrent.Async: withAsyncOnWithUnmask :: Int -> ((forall c. () => IO c -> IO c) -> IO a) -> (Async a -> IO b) -> IO b
+ Papa.Async.Control.Concurrent.Async: withAsyncWithUnmask :: ((forall c. () => IO c -> IO c) -> IO a) -> (Async a -> IO b) -> IO b
+ Papa.Base: ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
+ Papa.Base: ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
+ Papa.Base: (&&) :: Bool -> Bool -> Bool
+ Papa.Base: (*) :: Num a => a -> a -> a
+ Papa.Base: (**) :: Floating a => a -> a -> a
+ Papa.Base: (+) :: Num a => a -> a -> a
+ Papa.Base: (-) :: Num a => a -> a -> a
+ Papa.Base: (/=) :: Eq a => a -> a -> Bool
+ Papa.Base: (<$) :: Functor f => a -> f b -> f a
+ Papa.Base: (<$>) :: Functor f => (a -> b) -> f a -> f b
+ Papa.Base: (<) :: Ord a => a -> a -> Bool
+ Papa.Base: (<*>) :: Applicative f => f (a -> b) -> f a -> f b
+ Papa.Base: (<=) :: Ord a => a -> a -> Bool
+ Papa.Base: (==) :: Eq a => a -> a -> Bool
+ Papa.Base: (>) :: Ord a => a -> a -> Bool
+ Papa.Base: (>=) :: Ord a => a -> a -> Bool
+ Papa.Base: (||) :: Bool -> Bool -> Bool
+ Papa.Base: EQ :: Ordering
+ Papa.Base: False :: Bool
+ Papa.Base: GT :: Ordering
+ Papa.Base: Just :: a -> Maybe a
+ Papa.Base: LT :: Ordering
+ Papa.Base: Left :: a -> Either a b
+ Papa.Base: Nothing :: Maybe a
+ Papa.Base: Right :: b -> Either a b
+ Papa.Base: True :: Bool
+ Papa.Base: abs :: Num a => a -> a
+ Papa.Base: acos :: Floating a => a -> a
+ Papa.Base: acosh :: Floating a => a -> a
+ Papa.Base: asin :: Floating a => a -> a
+ Papa.Base: asinh :: Floating a => a -> a
+ Papa.Base: atan :: Floating a => a -> a
+ Papa.Base: atan2 :: RealFloat a => a -> a -> a
+ Papa.Base: atanh :: Floating a => a -> a
+ Papa.Base: class a ~# b => (a :: k) ~ (b :: k)
+ Papa.Base: class Functor f => Applicative (f :: Type -> Type)
+ Papa.Base: class () => Bounded a
+ Papa.Base: class () => Enum a
+ Papa.Base: class () => Eq a
+ Papa.Base: class Fractional a => Floating a
+ Papa.Base: class () => Foldable (t :: Type -> Type)
+ Papa.Base: class Num a => Fractional a
+ Papa.Base: class () => Functor (f :: Type -> Type)
+ Papa.Base: class (Real a, Enum a) => Integral a
+ Papa.Base: class () => IsString a
+ Papa.Base: class Applicative m => Monad (m :: Type -> Type)
+ Papa.Base: class Semigroup a => Monoid a
+ Papa.Base: class () => Num a
+ Papa.Base: class Eq a => Ord a
+ Papa.Base: class (Num a, Ord a) => Real a
+ Papa.Base: class (RealFrac a, Floating a) => RealFloat a
+ Papa.Base: class (Real a, Fractional a) => RealFrac a
+ Papa.Base: class () => Show a
+ Papa.Base: class (Functor t, Foldable t) => Traversable (t :: Type -> Type)
+ Papa.Base: compare :: Ord a => a -> a -> Ordering
+ Papa.Base: cos :: Floating a => a -> a
+ Papa.Base: cosh :: Floating a => a -> a
+ Papa.Base: curry :: ((a, b) -> c) -> a -> b -> c
+ Papa.Base: data () => Bool
+ Papa.Base: data () => Char
+ Papa.Base: data () => Double
+ Papa.Base: data () => Either a b
+ Papa.Base: data () => Float
+ Papa.Base: data () => IO a
+ Papa.Base: data () => Int
+ Papa.Base: data () => Integer
+ Papa.Base: data () => Maybe a
+ Papa.Base: data () => Ordering
+ Papa.Base: data () => Word
+ Papa.Base: decodeFloat :: RealFloat a => a -> (Integer, Int)
+ Papa.Base: either :: (a -> c) -> (b -> c) -> Either a b -> c
+ Papa.Base: encodeFloat :: RealFloat a => Integer -> Int -> a
+ Papa.Base: even :: Integral a => a -> Bool
+ Papa.Base: exp :: Floating a => a -> a
+ Papa.Base: exponent :: RealFloat a => a -> Int
+ Papa.Base: filter :: (a -> Bool) -> [a] -> [a]
+ Papa.Base: floatDigits :: RealFloat a => a -> Int
+ Papa.Base: floatRadix :: RealFloat a => a -> Integer
+ Papa.Base: floatRange :: RealFloat a => a -> (Int, Int)
+ Papa.Base: fmap :: Functor f => (a -> b) -> f a -> f b
+ Papa.Base: foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
+ Papa.Base: fromRational :: Fractional a => Rational -> a
+ Papa.Base: fromString :: IsString a => String -> a
+ Papa.Base: gcd :: Integral a => a -> a -> a
+ Papa.Base: getChar :: IO Char
+ Papa.Base: infixl 4 <$>
+ Papa.Base: infixl 6 +
+ Papa.Base: infixl 7 *
+ Papa.Base: infixr 0 $!
+ Papa.Base: infixr 2 ||
+ Papa.Base: infixr 3 &&
+ Papa.Base: infixr 5 ++
+ Papa.Base: infixr 8 **
+ Papa.Base: ioError :: IOError -> IO a
+ Papa.Base: isDenormalized :: RealFloat a => a -> Bool
+ Papa.Base: isIEEE :: RealFloat a => a -> Bool
+ Papa.Base: isInfinite :: RealFloat a => a -> Bool
+ Papa.Base: isNaN :: RealFloat a => a -> Bool
+ Papa.Base: isNegativeZero :: RealFloat a => a -> Bool
+ Papa.Base: lcm :: Integral a => a -> a -> a
+ Papa.Base: log :: Floating a => a -> a
+ Papa.Base: logBase :: Floating a => a -> a -> a
+ Papa.Base: max :: Ord a => a -> a -> a
+ Papa.Base: maxBound :: Bounded a => a
+ Papa.Base: maybe :: b -> (a -> b) -> Maybe a -> b
+ Papa.Base: mempty :: Monoid a => a
+ Papa.Base: min :: Ord a => a -> a -> a
+ Papa.Base: minBound :: Bounded a => a
+ Papa.Base: negate :: Num a => a -> a
+ Papa.Base: not :: Bool -> Bool
+ Papa.Base: odd :: Integral a => a -> Bool
+ Papa.Base: otherwise :: Bool
+ Papa.Base: pi :: Floating a => a
+ Papa.Base: pure :: Applicative f => a -> f a
+ Papa.Base: scaleFloat :: RealFloat a => Int -> a -> a
+ Papa.Base: seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
+ Papa.Base: sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
+ Papa.Base: show :: Show a => a -> String
+ Papa.Base: showParen :: Bool -> ShowS -> ShowS
+ Papa.Base: shows :: Show a => a -> ShowS
+ Papa.Base: showsPrec :: Show a => Int -> a -> ShowS
+ Papa.Base: significand :: RealFloat a => a -> a
+ Papa.Base: signum :: Num a => a -> a
+ Papa.Base: sin :: Floating a => a -> a
+ Papa.Base: sinh :: Floating a => a -> a
+ Papa.Base: sqrt :: Floating a => a -> a
+ Papa.Base: subtract :: Num a => a -> a -> a
+ Papa.Base: tan :: Floating a => a -> a
+ Papa.Base: tanh :: Floating a => a -> a
+ Papa.Base: toInteger :: Integral a => a -> Integer
+ Papa.Base: traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
+ Papa.Base: type FilePath = String
+ Papa.Base: type IOError = IOException
+ Papa.Base: type Rational = Ratio Integer
+ Papa.Base: type ShowS = String -> String
+ Papa.Base: type String = [Char]
+ Papa.Base: uncurry :: (a -> b -> c) -> (a, b) -> c
+ Papa.Base: until :: (a -> Bool) -> (a -> a) -> a -> a
+ Papa.Base: unzip :: [(a, b)] -> ([a], [b])
+ Papa.Base: unzip3 :: [(a, b, c)] -> ([a], [b], [c])
+ Papa.Base: userError :: String -> IOError
+ Papa.Base: zip :: [a] -> [b] -> [(a, b)]
+ Papa.Base: zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
+ Papa.Base: zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
+ Papa.Base: zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
+ Papa.Base.Control.Applicative: WrapArrow :: a b c -> WrappedArrow (a :: Type -> Type -> Type) b c
+ Papa.Base.Control.Applicative: WrapMonad :: m a -> WrappedMonad (m :: Type -> Type) a
+ Papa.Base.Control.Applicative: ZipList :: [a] -> ZipList a
+ Papa.Base.Control.Applicative: [getZipList] :: ZipList a -> [a]
+ Papa.Base.Control.Applicative: [unwrapArrow] :: WrappedArrow (a :: Type -> Type -> Type) b c -> a b c
+ Papa.Base.Control.Applicative: [unwrapMonad] :: WrappedMonad (m :: Type -> Type) a -> m a
+ Papa.Base.Control.Applicative: newtype () => WrappedArrow (a :: Type -> Type -> Type) b c
+ Papa.Base.Control.Applicative: newtype () => WrappedMonad (m :: Type -> Type) a
+ Papa.Base.Control.Applicative: newtype () => ZipList a
+ Papa.Base.Control.Arrow: Kleisli :: (a -> m b) -> Kleisli (m :: Type -> Type) a b
+ Papa.Base.Control.Arrow: [runKleisli] :: Kleisli (m :: Type -> Type) a b -> a -> m b
+ Papa.Base.Control.Arrow: firstA :: Arrow a => a b c -> a (b, d) (c, d)
+ Papa.Base.Control.Arrow: leftA :: ArrowChoice a => a b c -> a (Either b d) (Either c d)
+ Papa.Base.Control.Arrow: newtype () => Kleisli (m :: Type -> Type) a b
+ Papa.Base.Control.Arrow: rightA :: ArrowChoice a => a b c -> a (Either d b) (Either d c)
+ Papa.Base.Control.Arrow: secondA :: Arrow a => a b c -> a (d, b) (d, c)
+ Papa.Base.Control.Concurrent: data () => MVar a
+ Papa.Base.Control.Concurrent: data () => ThreadId
+ Papa.Base.Control.Concurrent: forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
+ Papa.Base.Control.Concurrent: forkIO :: IO () -> IO ThreadId
+ Papa.Base.Control.Concurrent: killThread :: ThreadId -> IO ()
+ Papa.Base.Control.Concurrent: modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b
+ Papa.Base.Control.Concurrent: modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
+ Papa.Base.Control.Concurrent: myThreadId :: IO ThreadId
+ Papa.Base.Control.Concurrent: newEmptyMVar :: IO (MVar a)
+ Papa.Base.Control.Concurrent: newMVar :: a -> IO (MVar a)
+ Papa.Base.Control.Concurrent: putMVar :: MVar a -> a -> IO ()
+ Papa.Base.Control.Concurrent: readMVar :: MVar a -> IO a
+ Papa.Base.Control.Concurrent: takeMVar :: MVar a -> IO a
+ Papa.Base.Control.Concurrent: threadDelay :: Int -> IO ()
+ Papa.Base.Control.Concurrent: tryReadMVar :: MVar a -> IO (Maybe a)
+ Papa.Base.Control.Concurrent: tryTakeMVar :: MVar a -> IO (Maybe a)
+ Papa.Base.Control.Exception: Denormal :: ArithException
+ Papa.Base.Control.Exception: DivideByZero :: ArithException
+ Papa.Base.Control.Exception: HeapOverflow :: AsyncException
+ Papa.Base.Control.Exception: IndexOutOfBounds :: String -> ArrayException
+ Papa.Base.Control.Exception: LossOfPrecision :: ArithException
+ Papa.Base.Control.Exception: MaskedInterruptible :: MaskingState
+ Papa.Base.Control.Exception: MaskedUninterruptible :: MaskingState
+ Papa.Base.Control.Exception: Overflow :: ArithException
+ Papa.Base.Control.Exception: RatioZeroDenominator :: ArithException
+ Papa.Base.Control.Exception: SomeAsyncException :: e -> SomeAsyncException
+ Papa.Base.Control.Exception: StackOverflow :: AsyncException
+ Papa.Base.Control.Exception: ThreadKilled :: AsyncException
+ Papa.Base.Control.Exception: UndefinedElement :: String -> ArrayException
+ Papa.Base.Control.Exception: Underflow :: ArithException
+ Papa.Base.Control.Exception: Unmasked :: MaskingState
+ Papa.Base.Control.Exception: UserInterrupt :: AsyncException
+ Papa.Base.Control.Exception: asyncExceptionFromException :: Exception e => SomeException -> Maybe e
+ Papa.Base.Control.Exception: asyncExceptionToException :: Exception e => e -> SomeException
+ Papa.Base.Control.Exception: bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
+ Papa.Base.Control.Exception: bracketOnError :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
+ Papa.Base.Control.Exception: bracket_ :: IO a -> IO b -> IO c -> IO c
+ Papa.Base.Control.Exception: catch :: Exception e => IO a -> (e -> IO a) -> IO a
+ Papa.Base.Control.Exception: class (Typeable e, Show e) => Exception e
+ Papa.Base.Control.Exception: data () => ArithException
+ Papa.Base.Control.Exception: data () => ArrayException
+ Papa.Base.Control.Exception: data () => AsyncException
+ Papa.Base.Control.Exception: data () => ErrorCall
+ Papa.Base.Control.Exception: data () => IOException
+ Papa.Base.Control.Exception: data () => MaskingState
+ Papa.Base.Control.Exception: data () => SomeAsyncException
+ Papa.Base.Control.Exception: data () => SomeException
+ Papa.Base.Control.Exception: displayException :: Exception e => e -> String
+ Papa.Base.Control.Exception: evaluate :: a -> IO a
+ Papa.Base.Control.Exception: finally :: IO a -> IO b -> IO a
+ Papa.Base.Control.Exception: fromException :: Exception e => SomeException -> Maybe e
+ Papa.Base.Control.Exception: getMaskingState :: IO MaskingState
+ Papa.Base.Control.Exception: handle :: Exception e => (e -> IO a) -> IO a -> IO a
+ Papa.Base.Control.Exception: mask :: ((forall a. () => IO a -> IO a) -> IO b) -> IO b
+ Papa.Base.Control.Exception: mask_ :: IO a -> IO a
+ Papa.Base.Control.Exception: onException :: IO a -> IO b -> IO a
+ Papa.Base.Control.Exception: throwIO :: Exception e => e -> IO a
+ Papa.Base.Control.Exception: throwTo :: Exception e => ThreadId -> e -> IO ()
+ Papa.Base.Control.Exception: toException :: Exception e => e -> SomeException
+ Papa.Base.Control.Exception: try :: Exception e => IO a -> IO (Either e a)
+ Papa.Base.Control.Exception: uninterruptibleMask :: ((forall a. () => IO a -> IO a) -> IO b) -> IO b
+ Papa.Base.Control.Exception: uninterruptibleMask_ :: IO a -> IO a
+ Papa.Base.Control.Monad: (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
+ Papa.Base.Control.Monad: (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
+ Papa.Base.Control.Monad: ap :: Monad m => m (a -> b) -> m a -> m b
+ Papa.Base.Control.Monad: class Monad m => MonadIO (m :: Type -> Type)
+ Papa.Base.Control.Monad: class forall (m :: Type -> Type). Monad m => Monad t m => MonadTrans (t :: Type -> Type -> Type -> Type)
+ Papa.Base.Control.Monad: infixr 1 <=<
+ Papa.Base.Control.Monad: lift :: (MonadTrans t, Monad m) => m a -> t m a
+ Papa.Base.Control.Monad: liftIO :: MonadIO m => IO a -> m a
+ Papa.Base.Control.Monad: liftM :: Monad m => (a1 -> r) -> m a1 -> m r
+ Papa.Base.Control.Monad: liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
+ Papa.Base.Control.Monad: zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
+ Papa.Base.Control.Monad: zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
+ Papa.Base.Control.Monad.Error: ExceptT :: m (Either e a) -> ExceptT e (m :: Type -> Type) a
+ Papa.Base.Control.Monad.Error: except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a
+ Papa.Base.Control.Monad.Error: liftEither :: MonadError e m => Either e a -> m a
+ Papa.Base.Control.Monad.Error: mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
+ Papa.Base.Control.Monad.Error: newtype () => ExceptT e (m :: Type -> Type) a
+ Papa.Base.Control.Monad.Error: runExcept :: Except e a -> Either e a
+ Papa.Base.Control.Monad.Error: runExceptT :: ExceptT e m a -> m (Either e a)
+ Papa.Base.Control.Monad.Error: type Except e = ExceptT e Identity
+ Papa.Base.Control.Monad.Error: withExcept :: (e -> e') -> Except e a -> Except e' a
+ Papa.Base.Control.Monad.Error: withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
+ Papa.Base.Control.Monad.Reader: ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a
+ Papa.Base.Control.Monad.Reader: [runReaderT] :: ReaderT r (m :: Type -> Type) a -> r -> m a
+ Papa.Base.Control.Monad.Reader: asks :: MonadReader r m => (r -> a) -> m a
+ Papa.Base.Control.Monad.Reader: newtype () => ReaderT r (m :: Type -> Type) a
+ Papa.Base.Control.Monad.Reader: runReader :: Reader r a -> r -> a
+ Papa.Base.Control.Monad.Reader: type Reader r = ReaderT r Identity
+ Papa.Base.Control.Monad.State: StateT :: (s -> m (a, s)) -> StateT s (m :: Type -> Type) a
+ Papa.Base.Control.Monad.State: [runStateT] :: StateT s (m :: Type -> Type) a -> s -> m (a, s)
+ Papa.Base.Control.Monad.State: evalState :: State s a -> s -> a
+ Papa.Base.Control.Monad.State: evalStateT :: Monad m => StateT s m a -> s -> m a
+ Papa.Base.Control.Monad.State: execState :: State s a -> s -> s
+ Papa.Base.Control.Monad.State: execStateT :: Monad m => StateT s m a -> s -> m s
+ Papa.Base.Control.Monad.State: gets :: MonadState s m => (s -> a) -> m a
+ Papa.Base.Control.Monad.State: modify :: MonadState s m => (s -> s) -> m ()
+ Papa.Base.Control.Monad.State: modify' :: MonadState s m => (s -> s) -> m ()
+ Papa.Base.Control.Monad.State: newtype () => StateT s (m :: Type -> Type) a
+ Papa.Base.Control.Monad.State: runState :: State s a -> s -> (a, s)
+ Papa.Base.Control.Monad.State: type State s = StateT s Identity
+ Papa.Base.Control.Monad.Trans: class Monad m => MonadIO (m :: Type -> Type)
+ Papa.Base.Control.Monad.Trans: class forall (m :: Type -> Type). Monad m => Monad t m => MonadTrans (t :: Type -> Type -> Type -> Type)
+ Papa.Base.Control.Monad.Trans: lift :: (MonadTrans t, Monad m) => m a -> t m a
+ Papa.Base.Control.Monad.Trans: liftIO :: MonadIO m => IO a -> m a
+ Papa.Base.Data.Coerce: class a ~R# b => Coercible (a :: k) (b :: k)
+ Papa.Base.Data.Coerce: coerce :: forall {k :: RuntimeRep} (a :: TYPE k) (b :: TYPE k). Coercible a b => a -> b
+ Papa.Base.Data.Divisor: class DivisorLike p f x x' a a' | x -> a
+ Papa.Base.Data.Divisor: divisor :: DivisorLike p f x x' a a' => Optic p f x x' a a'
+ Papa.Base.Data.Either: class LeftLike p f x x' a a' | x -> a
+ Papa.Base.Data.Either: class RightLike p f x x' a a' | x -> a
+ Papa.Base.Data.Either: isLeft :: Either a b -> Bool
+ Papa.Base.Data.Either: isRight :: Either a b -> Bool
+ Papa.Base.Data.Either: left :: LeftLike p f x x' a a' => Optic p f x x' a a'
+ Papa.Base.Data.Either: right :: RightLike p f x x' a a' => Optic p f x x' a a'
+ Papa.Base.Data.Enum: class () => Bounded a
+ Papa.Base.Data.Enum: class () => Enum a
+ Papa.Base.Data.Enum: maxBound :: Bounded a => a
+ Papa.Base.Data.Enum: minBound :: Bounded a => a
+ Papa.Base.Data.Enum: pred :: (Bounded a, Enum a, Eq a) => a -> Maybe a
+ Papa.Base.Data.Enum: succ :: Enum a => a -> Maybe a
+ Papa.Base.Data.Eq: (/=) :: Eq a => a -> a -> Bool
+ Papa.Base.Data.Eq: (==) :: Eq a => a -> a -> Bool
+ Papa.Base.Data.Eq: class () => Eq a
+ Papa.Base.Data.Eq: infix 4 /=
+ Papa.Base.Data.Foldable: concat :: Foldable t => t [a] -> [a]
+ Papa.Base.Data.Foldable: concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
+ Papa.Base.Data.Foldable: foldMap' :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
+ Papa.Base.Data.Foldable: length :: Foldable t => t a -> Int
+ Papa.Base.Data.Foldable1: class Foldable t => Foldable1 (t :: Type -> Type)
+ Papa.Base.Data.Foldable1: maximum :: (Foldable1 t, Ord a) => t a -> a
+ Papa.Base.Data.Foldable1: maximumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
+ Papa.Base.Data.Foldable1: minimum :: (Foldable1 t, Ord a) => t a -> a
+ Papa.Base.Data.Foldable1: minimumBy :: Foldable1 t => (a -> a -> Ordering) -> t a -> a
+ Papa.Base.Data.Foldable1: toNonEmpty :: Foldable1 t => t a -> NonEmpty a
+ Papa.Base.Data.Fractional: divideNonZero :: Fractional a => a -> NonZero a -> a
+ Papa.Base.Data.Fractional: powNonZero :: (Fractional a, Integral b) => NonZero a -> b -> a
+ Papa.Base.Data.Fractional: recipNonZero :: Fractional a => NonZero a -> a
+ Papa.Base.Data.Function: (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
+ Papa.Base.Data.Function: infixr 3 &&&
+ Papa.Base.Data.Functor.Compose: Compose :: f (g a) -> Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1)
+ Papa.Base.Data.Functor.Compose: [getCompose] :: Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1) -> f (g a)
+ Papa.Base.Data.Functor.Compose: infixr 9 `Compose`
+ Papa.Base.Data.Functor.Compose: newtype () => Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1)
+ Papa.Base.Data.Functor.Identity: Identity :: a -> Identity a
+ Papa.Base.Data.Functor.Identity: [runIdentity] :: Identity a -> a
+ Papa.Base.Data.Functor.Identity: newtype () => Identity a
+ Papa.Base.Data.IORef: atomicModifyIORef' :: IORef a -> (a -> (a, b)) -> IO b
+ Papa.Base.Data.IORef: atomicWriteIORef :: IORef a -> a -> IO ()
+ Papa.Base.Data.IORef: data () => IORef a
+ Papa.Base.Data.IORef: modifyIORef' :: IORef a -> (a -> a) -> IO ()
+ Papa.Base.Data.IORef: newIORef :: a -> IO (IORef a)
+ Papa.Base.Data.IORef: readIORef :: IORef a -> IO a
+ Papa.Base.Data.IORef: writeIORef :: IORef a -> a -> IO ()
+ Papa.Base.Data.Int: data () => Int
+ Papa.Base.Data.Int: data () => Int16
+ Papa.Base.Data.Int: data () => Int32
+ Papa.Base.Data.Int: data () => Int64
+ Papa.Base.Data.Int: data () => Int8
+ Papa.Base.Data.IntCast: intCast :: (Integral a, Num b, IntCast a b) => a -> b
+ Papa.Base.Data.IntCast: type IntCast a b = IntCastCheck a b (IsIntSubType a b)
+ Papa.Base.Data.IntCast: type family IsIntSubType a b :: Bool
+ Papa.Base.Data.Integral: class Eq a => Bits a
+ Papa.Base.Data.Integral: divModNonZero :: Integral a => a -> NonZero a -> (a, a)
+ Papa.Base.Data.Integral: divNonZero :: Integral a => a -> NonZero a -> a
+ Papa.Base.Data.Integral: modNonZero :: Integral a => a -> NonZero a -> a
+ Papa.Base.Data.Integral: pow :: Num a => a -> Word -> a
+ Papa.Base.Data.Integral: quotNonZero :: Integral a => a -> NonZero a -> a
+ Papa.Base.Data.Integral: quotRemNonZero :: Integral a => a -> NonZero a -> (a, a)
+ Papa.Base.Data.Integral: remNonZero :: Integral a => a -> NonZero a -> a
+ Papa.Base.Data.Integral: toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
+ Papa.Base.Data.Left: class LeftLike p f x x' a a' | x -> a
+ Papa.Base.Data.Left: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ Data.Either.Either a' b) => Papa.Base.Data.Left.LeftLike p f (Data.Either.Either a b) x' a a'
+ Papa.Base.Data.Left: left :: LeftLike p f x x' a a' => Optic p f x x' a a'
+ Papa.Base.Data.List: infixr 5 ++
+ Papa.Base.Data.List: unzip :: [(a, b)] -> ([a], [b])
+ Papa.Base.Data.Maybe: catMaybes :: [Maybe a] -> [a]
+ Papa.Base.Data.Maybe: isJust :: Maybe a -> Bool
+ Papa.Base.Data.Maybe: isNothing :: Maybe a -> Bool
+ Papa.Base.Data.Maybe: listToMaybe :: [a] -> Maybe a
+ Papa.Base.Data.Maybe: mapMaybe :: (a -> Maybe b) -> [a] -> [b]
+ Papa.Base.Data.Maybe: maybeToList :: Maybe a -> [a]
+ Papa.Base.Data.Maybe: whenJust :: (a -> Maybe b) -> (b -> a) -> a -> a
+ Papa.Base.Data.Maybe: whenJustM :: Monad f => (a -> f (Maybe b)) -> (b -> f a) -> a -> f a
+ Papa.Base.Data.NonZero: class NonZeroLike p f x x' a a' | x -> a
+ Papa.Base.Data.NonZero: data NonZero a
+ Papa.Base.Data.NonZero: inheritNonZero :: InheritNonZero s a => proxy s -> ()
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, GHC.Real.Integral b, x' GHC.Types.~ GHC.Real.Ratio b, a' GHC.Types.~ GHC.Real.Ratio b) => Papa.Base.Data.NonZero.NonZeroLike p f (GHC.Real.Ratio b) x' (GHC.Real.Ratio b) a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Int.Int16, a' GHC.Types.~ GHC.Int.Int16) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Int.Int16 x' GHC.Int.Int16 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Int.Int32, a' GHC.Types.~ GHC.Int.Int32) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Int.Int32 x' GHC.Int.Int32 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Int.Int64, a' GHC.Types.~ GHC.Int.Int64) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Int.Int64 x' GHC.Int.Int64 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Int.Int8, a' GHC.Types.~ GHC.Int.Int8) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Int.Int8 x' GHC.Int.Int8 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Num.Integer.Integer, a' GHC.Types.~ GHC.Num.Integer.Integer) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Num.Integer.Integer x' GHC.Num.Integer.Integer a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Num.Natural.Natural, a' GHC.Types.~ GHC.Num.Natural.Natural) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Num.Natural.Natural x' GHC.Num.Natural.Natural a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Types.Double, a' GHC.Types.~ GHC.Types.Double) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Types.Double x' GHC.Types.Double a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Types.Float, a' GHC.Types.~ GHC.Types.Float) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Types.Float x' GHC.Types.Float a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Types.Int, a' GHC.Types.~ GHC.Types.Int) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Types.Int x' GHC.Types.Int a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Types.Word, a' GHC.Types.~ GHC.Types.Word) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Types.Word x' GHC.Types.Word a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Word.Word16, a' GHC.Types.~ GHC.Word.Word16) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Word.Word16 x' GHC.Word.Word16 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Word.Word32, a' GHC.Types.~ GHC.Word.Word32) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Word.Word32 x' GHC.Word.Word32 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Word.Word64, a' GHC.Types.~ GHC.Word.Word64) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Word.Word64 x' GHC.Word.Word64 a'
+ Papa.Base.Data.NonZero: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ GHC.Word.Word8, a' GHC.Types.~ GHC.Word.Word8) => Papa.Base.Data.NonZero.NonZeroLike p f GHC.Word.Word8 x' GHC.Word.Word8 a'
+ Papa.Base.Data.NonZero: instance (p GHC.Types.~ (->), Data.Functor.Contravariant.Contravariant f, GHC.Base.Functor f, x' GHC.Types.~ Papa.Base.Data.NonZero.NonZero a, a' GHC.Types.~ a) => Papa.Base.Data.Divisor.DivisorLike p f (Papa.Base.Data.NonZero.NonZero a) x' a a'
+ Papa.Base.Data.NonZero: instance (x' GHC.Types.~ Papa.Base.Data.NonZero.NonZero a') => Papa.Base.Data.NonZero.NonZeroLike p f (Papa.Base.Data.NonZero.NonZero a) x' a a'
+ Papa.Base.Data.NonZero: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Papa.Base.Data.NonZero.NonZero a)
+ Papa.Base.Data.NonZero: instance Data.Foldable.Foldable Papa.Base.Data.NonZero.NonZero
+ Papa.Base.Data.NonZero: instance Data.Foldable1.Foldable1 Papa.Base.Data.NonZero.NonZero
+ Papa.Base.Data.NonZero: instance Data.Functor.Classes.Eq1 Papa.Base.Data.NonZero.NonZero
+ Papa.Base.Data.NonZero: instance Data.Functor.Classes.Ord1 Papa.Base.Data.NonZero.NonZero
+ Papa.Base.Data.NonZero: instance Data.Functor.Classes.Show1 Papa.Base.Data.NonZero.NonZero
+ Papa.Base.Data.NonZero: instance GHC.Classes.Eq a => GHC.Classes.Eq (Papa.Base.Data.NonZero.NonZero a)
+ Papa.Base.Data.NonZero: instance GHC.Classes.Ord a => GHC.Classes.Ord (Papa.Base.Data.NonZero.NonZero a)
+ Papa.Base.Data.NonZero: instance GHC.Show.Show a => GHC.Show.Show (Papa.Base.Data.NonZero.NonZero a)
+ Papa.Base.Data.NonZero: lawNamesNonZero :: NonZeroLike (->) (Const (First (NonZero a))) a a a a => NonZero a -> Maybe (NonZero a)
+ Papa.Base.Data.NonZero: nonZero :: NonZeroLike p f x x' a a' => Optic p f x x' (NonZero a) (NonZero a')
+ Papa.Base.Data.NonZero: previewNonZero :: (Eq a, Num a) => a -> Maybe (NonZero a)
+ Papa.Base.Data.NonZero: type InheritNonZero s a = (NonZeroLike (->) (Const ()) s s a a, DivisorLike (->) (Const ()) s s a a)
+ Papa.Base.Data.NonZero: validNonZero :: (Eq a, Num a) => a -> Bool
+ Papa.Base.Data.Proxy: Proxy :: Proxy (t :: k)
+ Papa.Base.Data.Proxy: data () => Proxy (t :: k)
+ Papa.Base.Data.Ratio: denominator :: Ratio a -> a
+ Papa.Base.Data.Ratio: numerator :: Ratio a -> a
+ Papa.Base.Data.Ratio: ratioNonZero :: Integer -> NonZero Integer -> Rational
+ Papa.Base.Data.Ratio: type Rational = Ratio Integer
+ Papa.Base.Data.RealFloat: ceilingFloating :: RealFloat a => a -> a
+ Papa.Base.Data.RealFloat: divideFloating :: RealFloat a => a -> a -> a
+ Papa.Base.Data.RealFloat: floorFloating :: RealFloat a => a -> a
+ Papa.Base.Data.RealFloat: modFloating :: RealFloat a => a -> a -> a
+ Papa.Base.Data.RealFloat: recipFloating :: RealFloat a => a -> a
+ Papa.Base.Data.RealFloat: roundFloating :: RealFloat a => a -> a
+ Papa.Base.Data.RealFloat: truncateFloating :: RealFloat a => a -> a
+ Papa.Base.Data.RealFrac: approxRationalMaybe :: RealFrac a => a -> a -> Maybe Rational
+ Papa.Base.Data.RealFrac: ceilingMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa.Base.Data.RealFrac: doubleToFloat :: Double -> Float
+ Papa.Base.Data.RealFrac: floatToDouble :: Float -> Double
+ Papa.Base.Data.RealFrac: floorMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa.Base.Data.RealFrac: integralToFloating :: (Integral a, RealFloat b) => a -> b
+ Papa.Base.Data.RealFrac: properFractionMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe (b, a)
+ Papa.Base.Data.RealFrac: roundMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa.Base.Data.RealFrac: toRationalMaybe :: Real a => a -> Maybe Rational
+ Papa.Base.Data.RealFrac: truncateMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b
+ Papa.Base.Data.Right: class RightLike p f x x' a a' | x -> a
+ Papa.Base.Data.Right: instance (Data.Profunctor.Choice.Choice p, GHC.Base.Applicative f, x' GHC.Types.~ Data.Either.Either a b') => Papa.Base.Data.Right.RightLike p f (Data.Either.Either a b) x' b b'
+ Papa.Base.Data.Right: right :: RightLike p f x x' a a' => Optic p f x x' a a'
+ Papa.Base.Data.Semigroup: All :: Bool -> All
+ Papa.Base.Data.Semigroup: Any :: Bool -> Any
+ Papa.Base.Data.Semigroup: Dual :: a -> Dual a
+ Papa.Base.Data.Semigroup: Endo :: (a -> a) -> Endo a
+ Papa.Base.Data.Semigroup: First :: a -> First a
+ Papa.Base.Data.Semigroup: Last :: a -> Last a
+ Papa.Base.Data.Semigroup: Max :: a -> Max a
+ Papa.Base.Data.Semigroup: Min :: a -> Min a
+ Papa.Base.Data.Semigroup: Product :: a -> Product a
+ Papa.Base.Data.Semigroup: Sum :: a -> Sum a
+ Papa.Base.Data.Semigroup: WrapMonoid :: m -> WrappedMonoid m
+ Papa.Base.Data.Semigroup: [appEndo] :: Endo a -> a -> a
+ Papa.Base.Data.Semigroup: [getAll] :: All -> Bool
+ Papa.Base.Data.Semigroup: [getAny] :: Any -> Bool
+ Papa.Base.Data.Semigroup: [getDual] :: Dual a -> a
+ Papa.Base.Data.Semigroup: [getFirst] :: First a -> a
+ Papa.Base.Data.Semigroup: [getLast] :: Last a -> a
+ Papa.Base.Data.Semigroup: [getMax] :: Max a -> a
+ Papa.Base.Data.Semigroup: [getMin] :: Min a -> a
+ Papa.Base.Data.Semigroup: [getProduct] :: Product a -> a
+ Papa.Base.Data.Semigroup: [getSum] :: Sum a -> a
+ Papa.Base.Data.Semigroup: [unwrapMonoid] :: WrappedMonoid m -> m
+ Papa.Base.Data.Semigroup: newtype () => All
+ Papa.Base.Data.Semigroup: newtype () => Any
+ Papa.Base.Data.Semigroup: newtype () => Dual a
+ Papa.Base.Data.Semigroup: newtype () => Endo a
+ Papa.Base.Data.Semigroup: newtype () => First a
+ Papa.Base.Data.Semigroup: newtype () => Last a
+ Papa.Base.Data.Semigroup: newtype () => Max a
+ Papa.Base.Data.Semigroup: newtype () => Min a
+ Papa.Base.Data.Semigroup: newtype () => Product a
+ Papa.Base.Data.Semigroup: newtype () => Sum a
+ Papa.Base.Data.Semigroup: newtype () => WrappedMonoid m
+ Papa.Base.Data.Show: showList :: Show a => [a] -> ShowS
+ Papa.Base.Data.String: class () => IsString a
+ Papa.Base.Data.String: fromString :: IsString a => String -> a
+ Papa.Base.Data.Tuple: swap :: (a, b) -> (b, a)
+ Papa.Base.Data.Void: absurd :: Void -> a
+ Papa.Base.Data.Void: data () => Void
+ Papa.Base.Data.Void: vacuous :: Functor f => f Void -> f a
+ Papa.Base.Data.Word: data () => Word
+ Papa.Base.Data.Word: data () => Word16
+ Papa.Base.Data.Word: data () => Word32
+ Papa.Base.Data.Word: data () => Word64
+ Papa.Base.Data.Word: data () => Word8
+ Papa.Base.GHC.Stack: type HasCallStack = ?callStack :: CallStack
+ Papa.Base.Prelude: ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
+ Papa.Base.Prelude: class a ~# b => (a :: k) ~ (b :: k)
+ Papa.Base.Prelude: class () => Bounded a
+ Papa.Base.Prelude: class (Real a, Fractional a) => RealFrac a
+ Papa.Base.Prelude: maxBound :: Bounded a => a
+ Papa.Base.Prelude: minBound :: Bounded a => a
+ Papa.Base.Prelude: seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
+ Papa.Base.Prelude: userError :: String -> IOError
+ Papa.Base.System.Environment: getArgs :: IO [String]
+ Papa.Base.System.Environment: getEnvironment :: IO [(String, String)]
+ Papa.Base.System.Environment: getProgName :: IO String
+ Papa.Base.System.Environment: lookupEnv :: String -> IO (Maybe String)
+ Papa.Base.System.Exit: ExitFailure :: Int -> ExitCode
+ Papa.Base.System.Exit: ExitSuccess :: ExitCode
+ Papa.Base.System.Exit: data () => ExitCode
+ Papa.Base.System.Exit: die :: String -> IO a
+ Papa.Base.System.Exit: exitFailure :: IO a
+ Papa.Base.System.Exit: exitSuccess :: IO a
+ Papa.Base.System.Exit: exitWith :: ExitCode -> Maybe (IO a)
+ Papa.Base.System.IO: AppendMode :: IOMode
+ Papa.Base.System.IO: BlockBuffering :: Maybe Int -> BufferMode
+ Papa.Base.System.IO: LineBuffering :: BufferMode
+ Papa.Base.System.IO: NoBuffering :: BufferMode
+ Papa.Base.System.IO: ReadMode :: IOMode
+ Papa.Base.System.IO: ReadWriteMode :: IOMode
+ Papa.Base.System.IO: WriteMode :: IOMode
+ Papa.Base.System.IO: data () => BufferMode
+ Papa.Base.System.IO: data () => Handle
+ Papa.Base.System.IO: data () => IOMode
+ Papa.Base.System.IO: hClose :: Handle -> IOExcept ()
+ Papa.Base.System.IO: hFlush :: Handle -> IOExcept ()
+ Papa.Base.System.IO: hIsEOF :: Handle -> IOExcept Bool
+ Papa.Base.System.IO: hSetBuffering :: Handle -> BufferMode -> IOExcept ()
+ Papa.Base.System.IO: openFile :: FilePath -> IOMode -> IOExcept Handle
+ Papa.Base.System.IO: stderr :: Handle
+ Papa.Base.System.IO: stdin :: Handle
+ Papa.Base.System.IO: stdout :: Handle
+ Papa.Base.System.IO: type FilePath = String
+ Papa.Base.System.IO: withFile :: FilePath -> IOMode -> (Handle -> IOExcept a) -> IOExcept a
+ Papa.Base.System.IO.Except: DecodeFailed :: Either Handle FilePath -> UnicodeException -> IOFailure
+ Papa.Base.System.IO.Except: IOFailed :: IOException -> IOFailure
+ Papa.Base.System.IO.Except: _DecodeFailed :: Prism' IOFailure (Either Handle FilePath, UnicodeException)
+ Papa.Base.System.IO.Except: _IOFailed :: Prism' IOFailure IOException
+ Papa.Base.System.IO.Except: _IOFailure :: AsIOFailure t => Prism' t IOFailure
+ Papa.Base.System.IO.Except: class (ReviewIOFailure t) => AsIOFailure t
+ Papa.Base.System.IO.Except: class GetIOFailure s
+ Papa.Base.System.IO.Except: class (GetIOFailure s) => HasIOFailure s
+ Papa.Base.System.IO.Except: class ReviewIOFailure t
+ Papa.Base.System.IO.Except: data IOFailure
+ Papa.Base.System.IO.Except: exceptIO :: IO a -> IOExcept a
+ Papa.Base.System.IO.Except: getIOFailure :: GetIOFailure s => Getter s IOFailure
+ Papa.Base.System.IO.Except: instance Control.Exception.Lens.AsIOException Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance GHC.Classes.Eq Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance GHC.Exception.Type.Exception Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance GHC.Generics.Generic Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance GHC.Show.Show Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance Papa.Base.System.IO.Except.AsIOFailure GHC.Exception.Type.SomeException
+ Papa.Base.System.IO.Except: instance Papa.Base.System.IO.Except.AsIOFailure Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance Papa.Base.System.IO.Except.GetIOFailure Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance Papa.Base.System.IO.Except.HasIOFailure Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: instance Papa.Base.System.IO.Except.ReviewIOFailure GHC.Exception.Type.SomeException
+ Papa.Base.System.IO.Except: instance Papa.Base.System.IO.Except.ReviewIOFailure Papa.Base.System.IO.Except.IOFailure
+ Papa.Base.System.IO.Except: ioFailure :: HasIOFailure s => Lens' s IOFailure
+ Papa.Base.System.IO.Except: matchIOFailure :: AsIOFailure t => t -> Maybe IOFailure
+ Papa.Base.System.IO.Except: reviewIOFailure :: ReviewIOFailure t => Review t IOFailure
+ Papa.Base.System.IO.Except: setIOFailure :: HasIOFailure s => IOFailure -> s -> s
+ Papa.Base.System.IO.Except: type IOExcept = ExceptT IOFailure IO
+ Papa.Base.Text.Read: class () => Read a
+ Papa.Base.Text.Read: readEither :: Read a => String -> Either String a
+ Papa.Base.Text.Read: readIO :: Read a => String -> IO (Maybe a)
+ Papa.Base.Text.Read: readMaybe :: Read a => String -> Maybe a
+ Papa.Base.Text.Read: reads :: Read a => ReadS a
+ Papa.Bifunctors: Join :: p a a -> Join (p :: k -> k -> Type) (a :: k)
+ Papa.Bifunctors: Joker :: g b -> Joker (g :: k -> Type) (a :: k1) (b :: k)
+ Papa.Bifunctors: Tannen :: f (p a b) -> Tannen (f :: k -> Type) (p :: k1 -> k2 -> k) (a :: k1) (b :: k2)
+ Papa.Bifunctors: WrapBifunctor :: p a b -> WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1)
+ Papa.Bifunctors: [runJoin] :: Join (p :: k -> k -> Type) (a :: k) -> p a a
+ Papa.Bifunctors: [runJoker] :: Joker (g :: k -> Type) (a :: k1) (b :: k) -> g b
+ Papa.Bifunctors: [runTannen] :: Tannen (f :: k -> Type) (p :: k1 -> k2 -> k) (a :: k1) (b :: k2) -> f (p a b)
+ Papa.Bifunctors: [unwrapBifunctor] :: WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1) -> p a b
+ Papa.Bifunctors: bifoldMapDefault :: (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m
+ Papa.Bifunctors: bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)
+ Papa.Bifunctors: biforM :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)
+ Papa.Bifunctors: bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
+ Papa.Bifunctors: bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)
+ Papa.Bifunctors: bimapDefault :: Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d
+ Papa.Bifunctors: bimapM :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
+ Papa.Bifunctors: bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)
+ Papa.Bifunctors: bisequenceA :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)
+ Papa.Bifunctors: bitraverse :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
+ Papa.Bifunctors: class (Bifunctor t, Bifoldable t) => Bitraversable (t :: Type -> Type -> Type)
+ Papa.Bifunctors: newtype () => Join (p :: k -> k -> Type) (a :: k)
+ Papa.Bifunctors: newtype () => Joker (g :: k -> Type) (a :: k1) (b :: k)
+ Papa.Bifunctors: newtype () => Tannen (f :: k -> Type) (p :: k1 -> k2 -> k) (a :: k1) (b :: k2)
+ Papa.Bifunctors: newtype () => WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1)
+ Papa.Bytestring.Data.ByteString: (!?) :: ByteString -> Int -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: all :: (Word8 -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: any :: (Word8 -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: append :: ByteString -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: appendFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString: break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: breakEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: breakSubstring :: ByteString -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: concat :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString: concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: cons :: Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: copy :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: count :: Word8 -> ByteString -> Int
+ Papa.Bytestring.Data.ByteString: data () => ByteString
+ Papa.Bytestring.Data.ByteString: drop :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: dropEnd :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: dropWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: elem :: Word8 -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: elemIndex :: Word8 -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString: elemIndexEnd :: Word8 -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString: elemIndices :: Word8 -> ByteString -> [Int]
+ Papa.Bytestring.Data.ByteString: empty :: ByteString
+ Papa.Bytestring.Data.ByteString: filter :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: find :: (Word8 -> Bool) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString: findIndexEnd :: (Word8 -> Bool) -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString: findIndices :: (Word8 -> Bool) -> ByteString -> [Int]
+ Papa.Bytestring.Data.ByteString: foldl :: (a -> Word8 -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString: foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString: foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: foldl1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: foldr :: (Word8 -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString: foldr' :: (Word8 -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString: foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: foldr1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: fromFilePath :: FilePath -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: fromStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: getContents :: IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: getLine :: IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: group :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString: groupBy :: (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString: hGet :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: hGetContents :: Handle -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: hGetLine :: Handle -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: hGetNonBlocking :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: hGetSome :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: hPut :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString: hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: hPutStr :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString: head :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: index :: ByteString -> Int -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: indexMaybe :: ByteString -> Int -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: infixl 5 `snoc`
+ Papa.Bytestring.Data.ByteString: infixr 5 `cons`
+ Papa.Bytestring.Data.ByteString: init :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString: inits :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString: initsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString: interact :: (ByteString -> ByteString) -> IOExcept ()
+ Papa.Bytestring.Data.ByteString: intercalate :: ByteString -> [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString: intersperse :: Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: isInfixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: isPrefixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: isSuffixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: isValidUtf8 :: ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: last :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: length :: ByteString -> Int
+ Papa.Bytestring.Data.ByteString: map :: (Word8 -> Word8) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)
+ Papa.Bytestring.Data.ByteString: mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)
+ Papa.Bytestring.Data.ByteString: maximum :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: minimum :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString: notElem :: Word8 -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: null :: ByteString -> Bool
+ Papa.Bytestring.Data.ByteString: pack :: [Word8] -> ByteString
+ Papa.Bytestring.Data.ByteString: packCString :: CString -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: packCStringLen :: CStringLen -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: packZipWith :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: putStr :: ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString: readFile :: FilePath -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString: replicate :: Int -> Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString: reverse :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: scanl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: scanr :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: scanr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: singleton :: Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString: snoc :: ByteString -> Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString: sort :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: spanEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: split :: Word8 -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString: splitAt :: Int -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString: stripPrefix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString: stripSuffix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString: tail :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString: tails :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString: tailsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString: take :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: takeEnd :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: takeWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: toFilePath :: ByteString -> IOExcept FilePath
+ Papa.Bytestring.Data.ByteString: toStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString: transpose :: [ByteString] -> [ByteString]
+ Papa.Bytestring.Data.ByteString: type StrictByteString = ByteString
+ Papa.Bytestring.Data.ByteString: uncons :: ByteString -> Maybe (Word8, ByteString)
+ Papa.Bytestring.Data.ByteString: unfoldr :: (a -> Maybe (Word8, a)) -> a -> ByteString
+ Papa.Bytestring.Data.ByteString: unfoldrN :: Int -> (a -> Maybe (Word8, a)) -> a -> (ByteString, Maybe a)
+ Papa.Bytestring.Data.ByteString: unpack :: ByteString -> [Word8]
+ Papa.Bytestring.Data.ByteString: unsnoc :: ByteString -> Maybe (ByteString, Word8)
+ Papa.Bytestring.Data.ByteString: unzip :: [(Word8, Word8)] -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString: useAsCString :: ByteString -> (CString -> IO a) -> IO a
+ Papa.Bytestring.Data.ByteString: useAsCStringLen :: ByteString -> (CStringLen -> IO a) -> IO a
+ Papa.Bytestring.Data.ByteString: writeFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString: zip :: ByteString -> ByteString -> [(Word8, Word8)]
+ Papa.Bytestring.Data.ByteString: zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]
+ Papa.Bytestring.Data.ByteString.Builder: byteString :: ByteString -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: byteStringHex :: ByteString -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: char7 :: Char -> Maybe Builder
+ Papa.Bytestring.Data.ByteString.Builder: char8 :: Char -> Maybe Builder
+ Papa.Bytestring.Data.ByteString.Builder: charUtf8 :: Char -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: data () => Builder
+ Papa.Bytestring.Data.ByteString.Builder: data () => FloatFormat
+ Papa.Bytestring.Data.ByteString.Builder: doubleBE :: Double -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: doubleDec :: Double -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: doubleHexFixed :: Double -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: doubleLE :: Double -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: floatBE :: Float -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: floatDec :: Float -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: floatHexFixed :: Float -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: floatLE :: Float -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: formatDouble :: FloatFormat -> Double -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: formatFloat :: FloatFormat -> Float -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: generic :: FloatFormat
+ Papa.Bytestring.Data.ByteString.Builder: hPutBuilder :: Handle -> Builder -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Builder: int16BE :: Int16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int16Dec :: Int16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int16HexFixed :: Int16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int16LE :: Int16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int32BE :: Int32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int32Dec :: Int32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int32HexFixed :: Int32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int32LE :: Int32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int64BE :: Int64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int64Dec :: Int64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int64HexFixed :: Int64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int64LE :: Int64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int8 :: Int8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int8Dec :: Int8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: int8HexFixed :: Int8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: intDec :: Int -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: integerDec :: Integer -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: lazyByteString :: ByteString -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: lazyByteStringHex :: ByteString -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: scientific :: FloatFormat
+ Papa.Bytestring.Data.ByteString.Builder: shortByteString :: ShortByteString -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: standard :: Int -> FloatFormat
+ Papa.Bytestring.Data.ByteString.Builder: standardDefaultPrecision :: FloatFormat
+ Papa.Bytestring.Data.ByteString.Builder: string7 :: String -> Maybe Builder
+ Papa.Bytestring.Data.ByteString.Builder: string8 :: String -> Maybe Builder
+ Papa.Bytestring.Data.ByteString.Builder: stringUtf8 :: String -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: toLazyByteString :: Builder -> ByteString
+ Papa.Bytestring.Data.ByteString.Builder: word16BE :: Word16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word16Dec :: Word16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word16Hex :: Word16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word16HexFixed :: Word16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word16LE :: Word16 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word32BE :: Word32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word32Dec :: Word32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word32Hex :: Word32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word32HexFixed :: Word32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word32LE :: Word32 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word64BE :: Word64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word64Dec :: Word64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word64Hex :: Word64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word64HexFixed :: Word64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word64LE :: Word64 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word8 :: Word8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word8Dec :: Word8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word8Hex :: Word8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: word8HexFixed :: Word8 -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: wordDec :: Word -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: wordHex :: Word -> Builder
+ Papa.Bytestring.Data.ByteString.Builder: writeFile :: FilePath -> Builder -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: (!?) :: ByteString -> Int -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: all :: (Char -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: any :: (Char -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: append :: ByteString -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: appendFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: break :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: breakEnd :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: breakSubstring :: ByteString -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: concat :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: concatMap :: (Char -> ByteString) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: cons :: Char -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: copy :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: count :: Char -> ByteString -> Int
+ Papa.Bytestring.Data.ByteString.Char8: data () => ByteString
+ Papa.Bytestring.Data.ByteString.Char8: drop :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: dropEnd :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: dropSpace :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: dropWhile :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: dropWhileEnd :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: elem :: Char -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: elemIndex :: Char -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString.Char8: elemIndexEnd :: Char -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString.Char8: elemIndices :: Char -> ByteString -> [Int]
+ Papa.Bytestring.Data.ByteString.Char8: empty :: ByteString
+ Papa.Bytestring.Data.ByteString.Char8: filter :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: find :: (Char -> Bool) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: findIndex :: (Char -> Bool) -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString.Char8: findIndexEnd :: (Char -> Bool) -> ByteString -> Maybe Int
+ Papa.Bytestring.Data.ByteString.Char8: findIndices :: (Char -> Bool) -> ByteString -> [Int]
+ Papa.Bytestring.Data.ByteString.Char8: foldl :: (a -> Char -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Char8: foldl' :: (a -> Char -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Char8: foldl1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: foldl1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: foldr :: (Char -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Char8: foldr' :: (Char -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Char8: foldr1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: foldr1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: fromStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: getContents :: IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: getLine :: IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: group :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: groupBy :: (Char -> Char -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: hGet :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: hGetContents :: Handle -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: hGetLine :: Handle -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: hGetNonBlocking :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: hGetSome :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: hPut :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: hPutStr :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: hPutStrLn :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: head :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: index :: ByteString -> Int -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: indexMaybe :: ByteString -> Int -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: init :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: inits :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: initsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString.Char8: interact :: (ByteString -> ByteString) -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: intercalate :: ByteString -> [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: intersperse :: Char -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: isInfixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: isPrefixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: isSuffixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: last :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: length :: ByteString -> Int
+ Papa.Bytestring.Data.ByteString.Char8: lines :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: map :: (Char -> Char) -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: maximum :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: minimum :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Char8: notElem :: Char -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: null :: ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Char8: pack :: [Char] -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: packCString :: CString -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: packCStringLen :: CStringLen -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: partition :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: putStr :: ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: putStrLn :: ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: readFile :: FilePath -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Char8: readInt :: ByteString -> Maybe (Int, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: readInteger :: ByteString -> Maybe (Integer, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: replicate :: Int -> Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: reverse :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: singleton :: Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: snoc :: ByteString -> Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: sort :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: span :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: spanEnd :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: split :: Char -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: splitAt :: Int -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: splitWith :: (Char -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: strip :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: stripPrefix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: stripSuffix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: tail :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: tails :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: tailsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString.Char8: take :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: takeEnd :: Int -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: takeWhile :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: takeWhileEnd :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: toStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: transpose :: [ByteString] -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: uncons :: ByteString -> Maybe (Char, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: unfoldr :: (a -> Maybe (Char, a)) -> a -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Char8: unlines :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: unpack :: ByteString -> [Char]
+ Papa.Bytestring.Data.ByteString.Char8: unsnoc :: ByteString -> Maybe (ByteString, Char)
+ Papa.Bytestring.Data.ByteString.Char8: unwords :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Char8: unzip :: [(Char, Char)] -> Maybe (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Char8: useAsCString :: ByteString -> (CString -> IO a) -> IO a
+ Papa.Bytestring.Data.ByteString.Char8: useAsCStringLen :: ByteString -> (CStringLen -> IO a) -> IO a
+ Papa.Bytestring.Data.ByteString.Char8: words :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Char8: writeFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Char8: zip :: ByteString -> ByteString -> [(Char, Char)]
+ Papa.Bytestring.Data.ByteString.Char8: zipWith :: (Char -> Char -> a) -> ByteString -> ByteString -> [a]
+ Papa.Bytestring.Data.ByteString.Lazy: (!?) :: ByteString -> Int64 -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: all :: (Word8 -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: any :: (Word8 -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: append :: ByteString -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: appendFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy: break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: breakEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: compareLength :: ByteString -> Int64 -> Ordering
+ Papa.Bytestring.Data.ByteString.Lazy: concat :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: concatMap :: (Word8 -> ByteString) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: cons :: Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: cons' :: Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: copy :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: count :: Word8 -> ByteString -> Int64
+ Papa.Bytestring.Data.ByteString.Lazy: cycle :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: data () => ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: drop :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: dropEnd :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: dropWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: elem :: Word8 -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: elemIndex :: Word8 -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy: elemIndexEnd :: Word8 -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy: elemIndices :: Word8 -> ByteString -> [Int64]
+ Papa.Bytestring.Data.ByteString.Lazy: empty :: ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: filter :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: find :: (Word8 -> Bool) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: findIndex :: (Word8 -> Bool) -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy: findIndexEnd :: (Word8 -> Bool) -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy: findIndices :: (Word8 -> Bool) -> ByteString -> [Int64]
+ Papa.Bytestring.Data.ByteString.Lazy: foldl :: (a -> Word8 -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy: foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy: foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: foldl1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy: foldr :: (Word8 -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy: foldr' :: (Word8 -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy: foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: foldr1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy: fromChunks :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: fromStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: group :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: groupBy :: (Word8 -> Word8 -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: hGet :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: hGetNonBlocking :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: hPut :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy: hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: hPutStr :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy: head :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: index :: ByteString -> Int64 -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: indexMaybe :: ByteString -> Int64 -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: infixl 5 `snoc`
+ Papa.Bytestring.Data.ByteString.Lazy: infixr 5 `cons'`
+ Papa.Bytestring.Data.ByteString.Lazy: init :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: inits :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: initsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: intercalate :: ByteString -> [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: intersperse :: Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: isPrefixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: isSuffixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: iterate :: (Word8 -> Word8) -> Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: last :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: length :: ByteString -> Int64
+ Papa.Bytestring.Data.ByteString.Lazy: map :: (Word8 -> Word8) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: mapAccumL :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: mapAccumR :: (acc -> Word8 -> (acc, Word8)) -> acc -> ByteString -> (acc, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: maximum :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: minimum :: ByteString -> Maybe Word8
+ Papa.Bytestring.Data.ByteString.Lazy: notElem :: Word8 -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: null :: ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy: pack :: [Word8] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: packZipWith :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: partition :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: putStr :: ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy: repeat :: Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: replicate :: Int64 -> Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: reverse :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: scanl :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: scanl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: scanr :: (Word8 -> Word8 -> Word8) -> Word8 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: scanr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: singleton :: Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: snoc :: ByteString -> Word8 -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: span :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: spanEnd :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: split :: Word8 -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: splitAt :: Int64 -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: splitWith :: (Word8 -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: stripPrefix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: stripSuffix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: tail :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: tails :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: tailsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: take :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: takeEnd :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: takeWhileEnd :: (Word8 -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: toChunks :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: toStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: transpose :: [ByteString] -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy: type LazyByteString = ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: uncons :: ByteString -> Maybe (Word8, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: unfoldr :: (a -> Maybe (Word8, a)) -> a -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy: unpack :: ByteString -> [Word8]
+ Papa.Bytestring.Data.ByteString.Lazy: unsnoc :: ByteString -> Maybe (ByteString, Word8)
+ Papa.Bytestring.Data.ByteString.Lazy: unzip :: [(Word8, Word8)] -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy: writeFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy: zip :: ByteString -> ByteString -> [(Word8, Word8)]
+ Papa.Bytestring.Data.ByteString.Lazy: zipWith :: (Word8 -> Word8 -> a) -> ByteString -> ByteString -> [a]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: (!?) :: ByteString -> Int64 -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: all :: (Char -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: any :: (Char -> Bool) -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: append :: ByteString -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: appendFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: break :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: breakEnd :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: compareLength :: ByteString -> Int64 -> Ordering
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: concat :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: concatMap :: (Char -> ByteString) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: cons :: Char -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: cons' :: Char -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: copy :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: count :: Char -> ByteString -> Int64
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: cycle :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: data () => ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: drop :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: dropEnd :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: dropWhile :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: dropWhileEnd :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: elem :: Char -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: elemIndex :: Char -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: elemIndexEnd :: Char -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: elemIndices :: Char -> ByteString -> [Int64]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: empty :: ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: filter :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: find :: (Char -> Bool) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: findIndex :: (Char -> Bool) -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: findIndexEnd :: (Char -> Bool) -> ByteString -> Maybe Int64
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: findIndices :: (Char -> Bool) -> ByteString -> [Int64]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldl :: (a -> Char -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldl' :: (a -> Char -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldl1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldl1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldr :: (Char -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldr' :: (Char -> a -> a) -> a -> ByteString -> a
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldr1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: foldr1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: fromChunks :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: fromStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: group :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: groupBy :: (Char -> Char -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: hGet :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: hGetNonBlocking :: Handle -> Int -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: hPut :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: hPutStr :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: hPutStrLn :: Handle -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: head :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: index :: ByteString -> Int64 -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: indexMaybe :: ByteString -> Int64 -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: init :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: inits :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: initsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: intercalate :: ByteString -> [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: intersperse :: Char -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: isPrefixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: isSuffixOf :: ByteString -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: last :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: length :: ByteString -> Int64
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: lines :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: map :: (Char -> Char) -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: maximum :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: minimum :: ByteString -> Maybe Char
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: notElem :: Char -> ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: null :: ByteString -> Bool
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: pack :: [Char] -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: partition :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: putStr :: ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: putStrLn :: ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: readInt :: ByteString -> Maybe (Int, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: readInteger :: ByteString -> Maybe (Integer, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: repeat :: Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: replicate :: Int64 -> Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: reverse :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: singleton :: Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: snoc :: ByteString -> Char -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: span :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: spanEnd :: (Char -> Bool) -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: split :: Char -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: splitAt :: Int64 -> ByteString -> (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: splitWith :: (Char -> Bool) -> ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: stripPrefix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: stripSuffix :: ByteString -> ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: tail :: ByteString -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: tails :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: tailsNE :: ByteString -> NonEmpty ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: take :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: takeEnd :: Int64 -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: takeWhile :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: takeWhileEnd :: (Char -> Bool) -> ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: toChunks :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: toStrict :: ByteString -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: transpose :: [ByteString] -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: uncons :: ByteString -> Maybe (Char, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: unfoldr :: (a -> Maybe (Char, a)) -> a -> Maybe ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: unlines :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: unpack :: ByteString -> [Char]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: unsnoc :: ByteString -> Maybe (ByteString, Char)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: unwords :: [ByteString] -> ByteString
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: unzip :: [(Char, Char)] -> Maybe (ByteString, ByteString)
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: words :: ByteString -> [ByteString]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: writeFile :: FilePath -> ByteString -> IOExcept ()
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: zip :: ByteString -> ByteString -> [(Char, Char)]
+ Papa.Bytestring.Data.ByteString.Lazy.Char8: zipWith :: (Char -> Char -> a) -> ByteString -> ByteString -> [a]
+ Papa.Containers: data () => IntMap a
+ Papa.Containers: data () => IntSet
+ Papa.Containers: data () => Map k a
+ Papa.Containers: data () => Seq a
+ Papa.Containers: data () => Set a
+ Papa.Containers.Data.Containers.ListUtils: nubInt :: [Int] -> [Int]
+ Papa.Containers.Data.Containers.ListUtils: nubIntOn :: (a -> Int) -> [a] -> [a]
+ Papa.Containers.Data.Containers.ListUtils: nubOrd :: Ord a => [a] -> [a]
+ Papa.Containers.Data.Containers.ListUtils: nubOrdOn :: Ord b => (a -> b) -> [a] -> [a]
+ Papa.Containers.Data.IntMap: (!) :: IntMap a -> Int -> Maybe a
+ Papa.Containers.Data.IntMap: (!?) :: IntMap a -> Key -> Maybe a
+ Papa.Containers.Data.IntMap: (\\) :: IntMap a -> IntMap b -> IntMap a
+ Papa.Containers.Data.IntMap: adjust :: (a -> a) -> Key -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: adjustWithKey :: (Key -> a -> a) -> Key -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: alter :: (Maybe a -> Maybe a) -> Key -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: alterF :: Functor f => (Maybe a -> f (Maybe a)) -> Key -> IntMap a -> f (IntMap a)
+ Papa.Containers.Data.IntMap: assocs :: IntMap a -> [(Key, a)]
+ Papa.Containers.Data.IntMap: compose :: IntMap c -> IntMap Int -> IntMap c
+ Papa.Containers.Data.IntMap: data () => IntMap a
+ Papa.Containers.Data.IntMap: delete :: Key -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: deleteFindMax :: IntMap a -> Maybe ((Int, a), IntMap a)
+ Papa.Containers.Data.IntMap: deleteFindMin :: IntMap a -> Maybe ((Int, a), IntMap a)
+ Papa.Containers.Data.IntMap: deleteMax :: IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: deleteMin :: IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: difference :: IntMap a -> IntMap b -> IntMap a
+ Papa.Containers.Data.IntMap: differenceWith :: (a -> b -> Maybe a) -> IntMap a -> IntMap b -> IntMap a
+ Papa.Containers.Data.IntMap: differenceWithKey :: (Key -> a -> b -> Maybe a) -> IntMap a -> IntMap b -> IntMap a
+ Papa.Containers.Data.IntMap: disjoint :: IntMap a -> IntMap b -> Bool
+ Papa.Containers.Data.IntMap: dropWhileAntitone :: (Key -> Bool) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: elems :: IntMap a -> [a]
+ Papa.Containers.Data.IntMap: empty :: IntMap a
+ Papa.Containers.Data.IntMap: filter :: (a -> Bool) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: filterWithKey :: (Key -> a -> Bool) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: findMax :: IntMap a -> Maybe (Int, a)
+ Papa.Containers.Data.IntMap: findMin :: IntMap a -> Maybe (Int, a)
+ Papa.Containers.Data.IntMap: findWithDefault :: a -> Key -> IntMap a -> a
+ Papa.Containers.Data.IntMap: foldMapWithKey :: Monoid m => (Key -> a -> m) -> IntMap a -> m
+ Papa.Containers.Data.IntMap: foldl :: (a -> b -> a) -> a -> IntMap b -> a
+ Papa.Containers.Data.IntMap: foldl' :: (a -> b -> a) -> a -> IntMap b -> a
+ Papa.Containers.Data.IntMap: foldlWithKey :: (a -> Key -> b -> a) -> a -> IntMap b -> a
+ Papa.Containers.Data.IntMap: foldlWithKey' :: (a -> Key -> b -> a) -> a -> IntMap b -> a
+ Papa.Containers.Data.IntMap: foldr :: (a -> b -> b) -> b -> IntMap a -> b
+ Papa.Containers.Data.IntMap: foldr' :: (a -> b -> b) -> b -> IntMap a -> b
+ Papa.Containers.Data.IntMap: foldrWithKey :: (Key -> a -> b -> b) -> b -> IntMap a -> b
+ Papa.Containers.Data.IntMap: foldrWithKey' :: (Key -> a -> b -> b) -> b -> IntMap a -> b
+ Papa.Containers.Data.IntMap: fromAscList :: [(Int, a)] -> Maybe (IntMap a)
+ Papa.Containers.Data.IntMap: fromAscListWith :: (a -> a -> a) -> [(Int, a)] -> Maybe (IntMap a)
+ Papa.Containers.Data.IntMap: fromAscListWithKey :: (Int -> a -> a -> a) -> [(Int, a)] -> Maybe (IntMap a)
+ Papa.Containers.Data.IntMap: fromDescList :: [(Int, a)] -> Maybe (IntMap a)
+ Papa.Containers.Data.IntMap: fromDistinctAscList :: [(Int, a)] -> Maybe (IntMap a)
+ Papa.Containers.Data.IntMap: fromList :: [(Key, a)] -> IntMap a
+ Papa.Containers.Data.IntMap: fromListWith :: (a -> a -> a) -> [(Key, a)] -> IntMap a
+ Papa.Containers.Data.IntMap: fromListWithKey :: (Key -> a -> a -> a) -> [(Key, a)] -> IntMap a
+ Papa.Containers.Data.IntMap: fromSet :: (Key -> a) -> IntSet -> IntMap a
+ Papa.Containers.Data.IntMap: infixl 9 !
+ Papa.Containers.Data.IntMap: insert :: Key -> a -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: insertLookupWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> (Maybe a, IntMap a)
+ Papa.Containers.Data.IntMap: insertWith :: (a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: insertWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: intersection :: IntMap a -> IntMap b -> IntMap a
+ Papa.Containers.Data.IntMap: intersectionWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
+ Papa.Containers.Data.IntMap: intersectionWithKey :: (Key -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
+ Papa.Containers.Data.IntMap: isProperSubmapOf :: Eq a => IntMap a -> IntMap a -> Bool
+ Papa.Containers.Data.IntMap: isProperSubmapOfBy :: (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool
+ Papa.Containers.Data.IntMap: isSubmapOf :: Eq a => IntMap a -> IntMap a -> Bool
+ Papa.Containers.Data.IntMap: isSubmapOfBy :: (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool
+ Papa.Containers.Data.IntMap: keys :: IntMap a -> [Key]
+ Papa.Containers.Data.IntMap: keysSet :: IntMap a -> IntSet
+ Papa.Containers.Data.IntMap: lookup :: Key -> IntMap a -> Maybe a
+ Papa.Containers.Data.IntMap: lookupGE :: Key -> IntMap a -> Maybe (Key, a)
+ Papa.Containers.Data.IntMap: lookupGT :: Key -> IntMap a -> Maybe (Key, a)
+ Papa.Containers.Data.IntMap: lookupLE :: Key -> IntMap a -> Maybe (Key, a)
+ Papa.Containers.Data.IntMap: lookupLT :: Key -> IntMap a -> Maybe (Key, a)
+ Papa.Containers.Data.IntMap: lookupMax :: IntMap a -> Maybe (Key, a)
+ Papa.Containers.Data.IntMap: lookupMin :: IntMap a -> Maybe (Key, a)
+ Papa.Containers.Data.IntMap: map :: (a -> b) -> IntMap a -> IntMap b
+ Papa.Containers.Data.IntMap: mapAccum :: (a -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)
+ Papa.Containers.Data.IntMap: mapAccumRWithKey :: (a -> Key -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)
+ Papa.Containers.Data.IntMap: mapAccumWithKey :: (a -> Key -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)
+ Papa.Containers.Data.IntMap: mapEither :: (a -> Either b c) -> IntMap a -> (IntMap b, IntMap c)
+ Papa.Containers.Data.IntMap: mapEitherWithKey :: (Key -> a -> Either b c) -> IntMap a -> (IntMap b, IntMap c)
+ Papa.Containers.Data.IntMap: mapKeys :: (Key -> Key) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: mapKeysMonotonic :: (Int -> Int) -> IntMap a -> Maybe (IntMap a)
+ Papa.Containers.Data.IntMap: mapKeysWith :: (a -> a -> a) -> (Key -> Key) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: mapMaybe :: (a -> Maybe b) -> IntMap a -> IntMap b
+ Papa.Containers.Data.IntMap: mapMaybeWithKey :: (Key -> a -> Maybe b) -> IntMap a -> IntMap b
+ Papa.Containers.Data.IntMap: mapWithKey :: (Key -> a -> b) -> IntMap a -> IntMap b
+ Papa.Containers.Data.IntMap: maxView :: IntMap a -> Maybe (a, IntMap a)
+ Papa.Containers.Data.IntMap: maxViewWithKey :: IntMap a -> Maybe ((Key, a), IntMap a)
+ Papa.Containers.Data.IntMap: member :: Key -> IntMap a -> Bool
+ Papa.Containers.Data.IntMap: mergeWithKey :: (Key -> a -> b -> Maybe c) -> (IntMap a -> IntMap c) -> (IntMap b -> IntMap c) -> IntMap a -> IntMap b -> IntMap c
+ Papa.Containers.Data.IntMap: minView :: IntMap a -> Maybe (a, IntMap a)
+ Papa.Containers.Data.IntMap: minViewWithKey :: IntMap a -> Maybe ((Key, a), IntMap a)
+ Papa.Containers.Data.IntMap: notMember :: Key -> IntMap a -> Bool
+ Papa.Containers.Data.IntMap: null :: IntMap a -> Bool
+ Papa.Containers.Data.IntMap: partition :: (a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
+ Papa.Containers.Data.IntMap: partitionWithKey :: (Key -> a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
+ Papa.Containers.Data.IntMap: restrictKeys :: IntMap a -> IntSet -> IntMap a
+ Papa.Containers.Data.IntMap: showTree :: Whoops "Data.IntMap.showTree has moved to Data.IntMap.Internal.Debug.showTree" => IntMap a -> String
+ Papa.Containers.Data.IntMap: showTreeWith :: Whoops "Data.IntMap.showTreeWith has moved to Data.IntMap.Internal.Debug.showTreeWith" => Bool -> Bool -> IntMap a -> String
+ Papa.Containers.Data.IntMap: singleton :: Key -> a -> IntMap a
+ Papa.Containers.Data.IntMap: size :: IntMap a -> Int
+ Papa.Containers.Data.IntMap: spanAntitone :: (Key -> Bool) -> IntMap a -> (IntMap a, IntMap a)
+ Papa.Containers.Data.IntMap: split :: Key -> IntMap a -> (IntMap a, IntMap a)
+ Papa.Containers.Data.IntMap: splitLookup :: Key -> IntMap a -> (IntMap a, Maybe a, IntMap a)
+ Papa.Containers.Data.IntMap: splitRoot :: IntMap a -> [IntMap a]
+ Papa.Containers.Data.IntMap: takeWhileAntitone :: (Key -> Bool) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: toAscList :: IntMap a -> [(Key, a)]
+ Papa.Containers.Data.IntMap: toDescList :: IntMap a -> [(Key, a)]
+ Papa.Containers.Data.IntMap: toList :: IntMap a -> [(Key, a)]
+ Papa.Containers.Data.IntMap: traverseMaybeWithKey :: Applicative f => (Key -> a -> f (Maybe b)) -> IntMap a -> f (IntMap b)
+ Papa.Containers.Data.IntMap: traverseWithKey :: Applicative t => (Key -> a -> t b) -> IntMap a -> t (IntMap b)
+ Papa.Containers.Data.IntMap: type Key = Int
+ Papa.Containers.Data.IntMap: union :: IntMap a -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: unionWith :: (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: unionWithKey :: (Key -> a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: unions :: Foldable f => f (IntMap a) -> IntMap a
+ Papa.Containers.Data.IntMap: unionsWith :: Foldable f => (a -> a -> a) -> f (IntMap a) -> IntMap a
+ Papa.Containers.Data.IntMap: update :: (a -> Maybe a) -> Key -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: updateLookupWithKey :: (Key -> a -> Maybe a) -> Key -> IntMap a -> (Maybe a, IntMap a)
+ Papa.Containers.Data.IntMap: updateMax :: (a -> Maybe a) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: updateMaxWithKey :: (Key -> a -> Maybe a) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: updateMin :: (a -> Maybe a) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: updateMinWithKey :: (Key -> a -> Maybe a) -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: updateWithKey :: (Key -> a -> Maybe a) -> Key -> IntMap a -> IntMap a
+ Papa.Containers.Data.IntMap: withoutKeys :: IntMap a -> IntSet -> IntMap a
+ Papa.Containers.Data.IntSet: (\\) :: IntSet -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: alterF :: Functor f => (Bool -> f Bool) -> Key -> IntSet -> f IntSet
+ Papa.Containers.Data.IntSet: data () => IntSet
+ Papa.Containers.Data.IntSet: delete :: Key -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: deleteFindMax :: IntSet -> Maybe (Int, IntSet)
+ Papa.Containers.Data.IntSet: deleteFindMin :: IntSet -> Maybe (Int, IntSet)
+ Papa.Containers.Data.IntSet: deleteMax :: IntSet -> IntSet
+ Papa.Containers.Data.IntSet: deleteMin :: IntSet -> IntSet
+ Papa.Containers.Data.IntSet: difference :: IntSet -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: disjoint :: IntSet -> IntSet -> Bool
+ Papa.Containers.Data.IntSet: dropWhileAntitone :: (Key -> Bool) -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: elems :: IntSet -> [Key]
+ Papa.Containers.Data.IntSet: empty :: IntSet
+ Papa.Containers.Data.IntSet: filter :: (Key -> Bool) -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: findMax :: IntSet -> Maybe Int
+ Papa.Containers.Data.IntSet: findMin :: IntSet -> Maybe Int
+ Papa.Containers.Data.IntSet: fold :: (Key -> b -> b) -> b -> IntSet -> b
+ Papa.Containers.Data.IntSet: foldl :: (a -> Key -> a) -> a -> IntSet -> a
+ Papa.Containers.Data.IntSet: foldl' :: (a -> Key -> a) -> a -> IntSet -> a
+ Papa.Containers.Data.IntSet: foldr :: (Key -> b -> b) -> b -> IntSet -> b
+ Papa.Containers.Data.IntSet: foldr' :: (Key -> b -> b) -> b -> IntSet -> b
+ Papa.Containers.Data.IntSet: fromAscList :: [Int] -> Maybe IntSet
+ Papa.Containers.Data.IntSet: fromDescList :: [Int] -> Maybe IntSet
+ Papa.Containers.Data.IntSet: fromDistinctAscList :: [Int] -> Maybe IntSet
+ Papa.Containers.Data.IntSet: fromList :: [Key] -> IntSet
+ Papa.Containers.Data.IntSet: infixl 9 \\
+ Papa.Containers.Data.IntSet: insert :: Key -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: intersection :: IntSet -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: isProperSubsetOf :: IntSet -> IntSet -> Bool
+ Papa.Containers.Data.IntSet: isSubsetOf :: IntSet -> IntSet -> Bool
+ Papa.Containers.Data.IntSet: lookupGE :: Key -> IntSet -> Maybe Key
+ Papa.Containers.Data.IntSet: lookupGT :: Key -> IntSet -> Maybe Key
+ Papa.Containers.Data.IntSet: lookupLE :: Key -> IntSet -> Maybe Key
+ Papa.Containers.Data.IntSet: lookupLT :: Key -> IntSet -> Maybe Key
+ Papa.Containers.Data.IntSet: map :: (Key -> Key) -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: mapMonotonic :: (Int -> Int) -> IntSet -> Maybe IntSet
+ Papa.Containers.Data.IntSet: maxView :: IntSet -> Maybe (Key, IntSet)
+ Papa.Containers.Data.IntSet: member :: Key -> IntSet -> Bool
+ Papa.Containers.Data.IntSet: minView :: IntSet -> Maybe (Key, IntSet)
+ Papa.Containers.Data.IntSet: notMember :: Key -> IntSet -> Bool
+ Papa.Containers.Data.IntSet: null :: IntSet -> Bool
+ Papa.Containers.Data.IntSet: partition :: (Key -> Bool) -> IntSet -> (IntSet, IntSet)
+ Papa.Containers.Data.IntSet: showTree :: IntSet -> String
+ Papa.Containers.Data.IntSet: showTreeWith :: Bool -> Bool -> IntSet -> String
+ Papa.Containers.Data.IntSet: singleton :: Key -> IntSet
+ Papa.Containers.Data.IntSet: size :: IntSet -> Int
+ Papa.Containers.Data.IntSet: spanAntitone :: (Key -> Bool) -> IntSet -> (IntSet, IntSet)
+ Papa.Containers.Data.IntSet: split :: Key -> IntSet -> (IntSet, IntSet)
+ Papa.Containers.Data.IntSet: splitMember :: Key -> IntSet -> (IntSet, Bool, IntSet)
+ Papa.Containers.Data.IntSet: splitRoot :: IntSet -> [IntSet]
+ Papa.Containers.Data.IntSet: takeWhileAntitone :: (Key -> Bool) -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: toAscList :: IntSet -> [Key]
+ Papa.Containers.Data.IntSet: toDescList :: IntSet -> [Key]
+ Papa.Containers.Data.IntSet: toList :: IntSet -> [Key]
+ Papa.Containers.Data.IntSet: type Key = Int
+ Papa.Containers.Data.IntSet: union :: IntSet -> IntSet -> IntSet
+ Papa.Containers.Data.IntSet: unions :: Foldable f => f IntSet -> IntSet
+ Papa.Containers.Data.Map: (!) :: Ord k => Map k a -> k -> Maybe a
+ Papa.Containers.Data.Map: (!?) :: Ord k => Map k a -> k -> Maybe a
+ Papa.Containers.Data.Map: (\\) :: Ord k => Map k a -> Map k b -> Map k a
+ Papa.Containers.Data.Map: adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a
+ Papa.Containers.Data.Map: adjustWithKey :: Ord k => (k -> a -> a) -> k -> Map k a -> Map k a
+ Papa.Containers.Data.Map: alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a
+ Papa.Containers.Data.Map: alterF :: (Functor f, Ord k) => (Maybe a -> f (Maybe a)) -> k -> Map k a -> f (Map k a)
+ Papa.Containers.Data.Map: argSet :: Map k a -> Set (Arg k a)
+ Papa.Containers.Data.Map: assocs :: Map k a -> [(k, a)]
+ Papa.Containers.Data.Map: compose :: Ord b => Map b c -> Map a b -> Map a c
+ Papa.Containers.Data.Map: data () => Map k a
+ Papa.Containers.Data.Map: delete :: Ord k => k -> Map k a -> Map k a
+ Papa.Containers.Data.Map: deleteAt :: Int -> Map k a -> Maybe (Map k a)
+ Papa.Containers.Data.Map: deleteFindMax :: Map k a -> Maybe ((k, a), Map k a)
+ Papa.Containers.Data.Map: deleteFindMin :: Map k a -> Maybe ((k, a), Map k a)
+ Papa.Containers.Data.Map: deleteMax :: Map k a -> Map k a
+ Papa.Containers.Data.Map: deleteMin :: Map k a -> Map k a
+ Papa.Containers.Data.Map: difference :: Ord k => Map k a -> Map k b -> Map k a
+ Papa.Containers.Data.Map: differenceWith :: Ord k => (a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
+ Papa.Containers.Data.Map: differenceWithKey :: Ord k => (k -> a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
+ Papa.Containers.Data.Map: disjoint :: Ord k => Map k a -> Map k b -> Bool
+ Papa.Containers.Data.Map: drop :: Int -> Map k a -> Map k a
+ Papa.Containers.Data.Map: dropWhileAntitone :: (k -> Bool) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: elemAt :: Int -> Map k a -> Maybe (k, a)
+ Papa.Containers.Data.Map: elems :: Map k a -> [a]
+ Papa.Containers.Data.Map: empty :: Map k a
+ Papa.Containers.Data.Map: filter :: (a -> Bool) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: filterWithKey :: (k -> a -> Bool) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: findIndex :: Ord k => k -> Map k a -> Maybe Int
+ Papa.Containers.Data.Map: findMax :: Map k a -> Maybe (k, a)
+ Papa.Containers.Data.Map: findMin :: Map k a -> Maybe (k, a)
+ Papa.Containers.Data.Map: findWithDefault :: Ord k => a -> k -> Map k a -> a
+ Papa.Containers.Data.Map: foldMapWithKey :: Monoid m => (k -> a -> m) -> Map k a -> m
+ Papa.Containers.Data.Map: foldl :: (a -> b -> a) -> a -> Map k b -> a
+ Papa.Containers.Data.Map: foldl' :: (a -> b -> a) -> a -> Map k b -> a
+ Papa.Containers.Data.Map: foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a
+ Papa.Containers.Data.Map: foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> a
+ Papa.Containers.Data.Map: foldr :: (a -> b -> b) -> b -> Map k a -> b
+ Papa.Containers.Data.Map: foldr' :: (a -> b -> b) -> b -> Map k a -> b
+ Papa.Containers.Data.Map: foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b
+ Papa.Containers.Data.Map: foldrWithKey' :: (k -> a -> b -> b) -> b -> Map k a -> b
+ Papa.Containers.Data.Map: fromArgSet :: Set (Arg k a) -> Map k a
+ Papa.Containers.Data.Map: fromAscList :: Ord k => [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromAscListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromAscListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromDescList :: Ord k => [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromDescListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromDescListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromDistinctAscList :: Ord k => [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromDistinctDescList :: Ord k => [(k, a)] -> Maybe (Map k a)
+ Papa.Containers.Data.Map: fromList :: Ord k => [(k, a)] -> Map k a
+ Papa.Containers.Data.Map: fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
+ Papa.Containers.Data.Map: fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a
+ Papa.Containers.Data.Map: fromSet :: (k -> a) -> Set k -> Map k a
+ Papa.Containers.Data.Map: infixl 9 !
+ Papa.Containers.Data.Map: insert :: Ord k => k -> a -> Map k a -> Map k a
+ Papa.Containers.Data.Map: insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
+ Papa.Containers.Data.Map: insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
+ Papa.Containers.Data.Map: insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
+ Papa.Containers.Data.Map: intersection :: Ord k => Map k a -> Map k b -> Map k a
+ Papa.Containers.Data.Map: intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c
+ Papa.Containers.Data.Map: intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c
+ Papa.Containers.Data.Map: isProperSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
+ Papa.Containers.Data.Map: isProperSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool
+ Papa.Containers.Data.Map: isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
+ Papa.Containers.Data.Map: isSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool
+ Papa.Containers.Data.Map: keys :: Map k a -> [k]
+ Papa.Containers.Data.Map: keysSet :: Map k a -> Set k
+ Papa.Containers.Data.Map: lookup :: Ord k => k -> Map k a -> Maybe a
+ Papa.Containers.Data.Map: lookupGE :: Ord k => k -> Map k v -> Maybe (k, v)
+ Papa.Containers.Data.Map: lookupGT :: Ord k => k -> Map k v -> Maybe (k, v)
+ Papa.Containers.Data.Map: lookupIndex :: Ord k => k -> Map k a -> Maybe Int
+ Papa.Containers.Data.Map: lookupLE :: Ord k => k -> Map k v -> Maybe (k, v)
+ Papa.Containers.Data.Map: lookupLT :: Ord k => k -> Map k v -> Maybe (k, v)
+ Papa.Containers.Data.Map: lookupMax :: Map k a -> Maybe (k, a)
+ Papa.Containers.Data.Map: lookupMin :: Map k a -> Maybe (k, a)
+ Papa.Containers.Data.Map: map :: (a -> b) -> Map k a -> Map k b
+ Papa.Containers.Data.Map: mapAccum :: (a -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ Papa.Containers.Data.Map: mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ Papa.Containers.Data.Map: mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ Papa.Containers.Data.Map: mapEither :: (a -> Either b c) -> Map k a -> (Map k b, Map k c)
+ Papa.Containers.Data.Map: mapEitherWithKey :: (k -> a -> Either b c) -> Map k a -> (Map k b, Map k c)
+ Papa.Containers.Data.Map: mapKeys :: Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
+ Papa.Containers.Data.Map: mapKeysMonotonic :: Ord k2 => (k1 -> k2) -> Map k1 a -> Maybe (Map k2 a)
+ Papa.Containers.Data.Map: mapKeysWith :: Ord k2 => (a -> a -> a) -> (k1 -> k2) -> Map k1 a -> Map k2 a
+ Papa.Containers.Data.Map: mapMaybe :: (a -> Maybe b) -> Map k a -> Map k b
+ Papa.Containers.Data.Map: mapMaybeWithKey :: (k -> a -> Maybe b) -> Map k a -> Map k b
+ Papa.Containers.Data.Map: mapWithKey :: (k -> a -> b) -> Map k a -> Map k b
+ Papa.Containers.Data.Map: maxView :: Map k a -> Maybe (a, Map k a)
+ Papa.Containers.Data.Map: maxViewWithKey :: Map k a -> Maybe ((k, a), Map k a)
+ Papa.Containers.Data.Map: member :: Ord k => k -> Map k a -> Bool
+ Papa.Containers.Data.Map: mergeWithKey :: Ord k => (k -> a -> b -> Maybe c) -> (Map k a -> Map k c) -> (Map k b -> Map k c) -> Map k a -> Map k b -> Map k c
+ Papa.Containers.Data.Map: minView :: Map k a -> Maybe (a, Map k a)
+ Papa.Containers.Data.Map: minViewWithKey :: Map k a -> Maybe ((k, a), Map k a)
+ Papa.Containers.Data.Map: notMember :: Ord k => k -> Map k a -> Bool
+ Papa.Containers.Data.Map: null :: Map k a -> Bool
+ Papa.Containers.Data.Map: partition :: (a -> Bool) -> Map k a -> (Map k a, Map k a)
+ Papa.Containers.Data.Map: partitionWithKey :: (k -> a -> Bool) -> Map k a -> (Map k a, Map k a)
+ Papa.Containers.Data.Map: restrictKeys :: Ord k => Map k a -> Set k -> Map k a
+ Papa.Containers.Data.Map: showTree :: Whoops "showTree has moved to Data.Map.Internal.Debug.showTree." => Map k a -> String
+ Papa.Containers.Data.Map: showTreeWith :: Whoops "showTreeWith has moved to Data.Map.Internal.Debug.showTreeWith." => (k -> a -> String) -> Bool -> Bool -> Map k a -> String
+ Papa.Containers.Data.Map: singleton :: k -> a -> Map k a
+ Papa.Containers.Data.Map: size :: Map k a -> Int
+ Papa.Containers.Data.Map: spanAntitone :: (k -> Bool) -> Map k a -> (Map k a, Map k a)
+ Papa.Containers.Data.Map: split :: Ord k => k -> Map k a -> (Map k a, Map k a)
+ Papa.Containers.Data.Map: splitAt :: Int -> Map k a -> (Map k a, Map k a)
+ Papa.Containers.Data.Map: splitLookup :: Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)
+ Papa.Containers.Data.Map: splitRoot :: Map k b -> [Map k b]
+ Papa.Containers.Data.Map: take :: Int -> Map k a -> Map k a
+ Papa.Containers.Data.Map: takeWhileAntitone :: (k -> Bool) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: toAscList :: Map k a -> [(k, a)]
+ Papa.Containers.Data.Map: toDescList :: Map k a -> [(k, a)]
+ Papa.Containers.Data.Map: toList :: Map k a -> [(k, a)]
+ Papa.Containers.Data.Map: traverseMaybeWithKey :: Applicative f => (k -> a -> f (Maybe b)) -> Map k a -> f (Map k b)
+ Papa.Containers.Data.Map: traverseWithKey :: Applicative t => (k -> a -> t b) -> Map k a -> t (Map k b)
+ Papa.Containers.Data.Map: union :: Ord k => Map k a -> Map k a -> Map k a
+ Papa.Containers.Data.Map: unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
+ Papa.Containers.Data.Map: unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a
+ Papa.Containers.Data.Map: unions :: (Foldable f, Ord k) => f (Map k a) -> Map k a
+ Papa.Containers.Data.Map: unionsWith :: (Foldable f, Ord k) => (a -> a -> a) -> f (Map k a) -> Map k a
+ Papa.Containers.Data.Map: update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a
+ Papa.Containers.Data.Map: updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Maybe (Map k a)
+ Papa.Containers.Data.Map: updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a)
+ Papa.Containers.Data.Map: updateMax :: (a -> Maybe a) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: updateMaxWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: updateMin :: (a -> Maybe a) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: updateMinWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
+ Papa.Containers.Data.Map: updateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a
+ Papa.Containers.Data.Map: valid :: Ord k => Map k a -> Bool
+ Papa.Containers.Data.Map: withoutKeys :: Ord k => Map k a -> Set k -> Map k a
+ Papa.Containers.Data.Seq: (!?) :: Seq a -> Int -> Maybe a
+ Papa.Containers.Data.Seq: (:<) :: a -> Seq a -> ViewL a
+ Papa.Containers.Data.Seq: (:>) :: Seq a -> a -> ViewR a
+ Papa.Containers.Data.Seq: (<|) :: a -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: (><) :: Seq a -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: (|>) :: Seq a -> a -> Seq a
+ Papa.Containers.Data.Seq: EmptyL :: ViewL a
+ Papa.Containers.Data.Seq: EmptyR :: ViewR a
+ Papa.Containers.Data.Seq: adjust :: (a -> a) -> Int -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: adjust' :: (a -> a) -> Int -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: breakl :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
+ Papa.Containers.Data.Seq: breakr :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
+ Papa.Containers.Data.Seq: chunksOf :: Int -> Seq a -> Maybe (Seq (Seq a))
+ Papa.Containers.Data.Seq: cycleTaking :: Int -> Seq a -> Maybe (Seq a)
+ Papa.Containers.Data.Seq: data () => Seq a
+ Papa.Containers.Data.Seq: data () => ViewL a
+ Papa.Containers.Data.Seq: data () => ViewR a
+ Papa.Containers.Data.Seq: deleteAt :: Int -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: drop :: Int -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: dropWhileL :: (a -> Bool) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: dropWhileR :: (a -> Bool) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: elemIndexL :: Eq a => a -> Seq a -> Maybe Int
+ Papa.Containers.Data.Seq: elemIndexR :: Eq a => a -> Seq a -> Maybe Int
+ Papa.Containers.Data.Seq: elemIndicesL :: Eq a => a -> Seq a -> [Int]
+ Papa.Containers.Data.Seq: elemIndicesR :: Eq a => a -> Seq a -> [Int]
+ Papa.Containers.Data.Seq: empty :: Seq a
+ Papa.Containers.Data.Seq: filter :: (a -> Bool) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: findIndexL :: (a -> Bool) -> Seq a -> Maybe Int
+ Papa.Containers.Data.Seq: findIndexR :: (a -> Bool) -> Seq a -> Maybe Int
+ Papa.Containers.Data.Seq: findIndicesL :: (a -> Bool) -> Seq a -> [Int]
+ Papa.Containers.Data.Seq: findIndicesR :: (a -> Bool) -> Seq a -> [Int]
+ Papa.Containers.Data.Seq: foldMapWithIndex :: Monoid m => (Int -> a -> m) -> Seq a -> m
+ Papa.Containers.Data.Seq: foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> b
+ Papa.Containers.Data.Seq: foldrWithIndex :: (Int -> a -> b -> b) -> b -> Seq a -> b
+ Papa.Containers.Data.Seq: fromArray :: Ix i => Array i a -> Seq a
+ Papa.Containers.Data.Seq: fromFunction :: Int -> (Int -> a) -> Maybe (Seq a)
+ Papa.Containers.Data.Seq: fromList :: [a] -> Seq a
+ Papa.Containers.Data.Seq: index :: Seq a -> Int -> Maybe a
+ Papa.Containers.Data.Seq: infixl 5 |>
+ Papa.Containers.Data.Seq: infixr 5 ><
+ Papa.Containers.Data.Seq: inits :: Seq a -> Seq (Seq a)
+ Papa.Containers.Data.Seq: insertAt :: Int -> a -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: intersperse :: a -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: iterateN :: Int -> (a -> a) -> a -> Maybe (Seq a)
+ Papa.Containers.Data.Seq: length :: Seq a -> Int
+ Papa.Containers.Data.Seq: lookup :: Int -> Seq a -> Maybe a
+ Papa.Containers.Data.Seq: mapWithIndex :: (Int -> a -> b) -> Seq a -> Seq b
+ Papa.Containers.Data.Seq: null :: Seq a -> Bool
+ Papa.Containers.Data.Seq: partition :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
+ Papa.Containers.Data.Seq: pattern (:<|) :: a -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: pattern Empty :: Seq a
+ Papa.Containers.Data.Seq: replicate :: Int -> a -> Maybe (Seq a)
+ Papa.Containers.Data.Seq: replicateA :: Applicative f => Int -> f a -> Maybe (f (Seq a))
+ Papa.Containers.Data.Seq: replicateM :: Monad m => Int -> m a -> Maybe (m (Seq a))
+ Papa.Containers.Data.Seq: reverse :: Seq a -> Seq a
+ Papa.Containers.Data.Seq: scanl :: (a -> b -> a) -> a -> Seq b -> Seq a
+ Papa.Containers.Data.Seq: scanl1 :: (a -> a -> a) -> Seq a -> Maybe (Seq a)
+ Papa.Containers.Data.Seq: scanr :: (a -> b -> b) -> b -> Seq a -> Seq b
+ Papa.Containers.Data.Seq: scanr1 :: (a -> a -> a) -> Seq a -> Maybe (Seq a)
+ Papa.Containers.Data.Seq: singleton :: a -> Seq a
+ Papa.Containers.Data.Seq: sort :: Ord a => Seq a -> Seq a
+ Papa.Containers.Data.Seq: sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: sortOn :: Ord b => (a -> b) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: spanl :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
+ Papa.Containers.Data.Seq: spanr :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
+ Papa.Containers.Data.Seq: splitAt :: Int -> Seq a -> (Seq a, Seq a)
+ Papa.Containers.Data.Seq: tails :: Seq a -> Seq (Seq a)
+ Papa.Containers.Data.Seq: take :: Int -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: takeWhileL :: (a -> Bool) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: takeWhileR :: (a -> Bool) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: traverseWithIndex :: Applicative f => (Int -> a -> f b) -> Seq a -> f (Seq b)
+ Papa.Containers.Data.Seq: unfoldl :: (b -> Maybe (b, a)) -> b -> Seq a
+ Papa.Containers.Data.Seq: unfoldr :: (b -> Maybe (a, b)) -> b -> Seq a
+ Papa.Containers.Data.Seq: unstableSort :: Ord a => Seq a -> Seq a
+ Papa.Containers.Data.Seq: unstableSortBy :: (a -> a -> Ordering) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: unstableSortOn :: Ord b => (a -> b) -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: unzip :: Seq (a, b) -> (Seq a, Seq b)
+ Papa.Containers.Data.Seq: unzipWith :: (a -> (b, c)) -> Seq a -> (Seq b, Seq c)
+ Papa.Containers.Data.Seq: update :: Int -> a -> Seq a -> Seq a
+ Papa.Containers.Data.Seq: viewl :: Seq a -> ViewL a
+ Papa.Containers.Data.Seq: viewr :: Seq a -> ViewR a
+ Papa.Containers.Data.Seq: zip :: Seq a -> Seq b -> Seq (a, b)
+ Papa.Containers.Data.Seq: zip3 :: Seq a -> Seq b -> Seq c -> Seq (a, b, c)
+ Papa.Containers.Data.Seq: zip4 :: Seq a -> Seq b -> Seq c -> Seq d -> Seq (a, b, c, d)
+ Papa.Containers.Data.Seq: zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c
+ Papa.Containers.Data.Seq: zipWith3 :: (a -> b -> c -> d) -> Seq a -> Seq b -> Seq c -> Seq d
+ Papa.Containers.Data.Seq: zipWith4 :: (a -> b -> c -> d -> e) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e
+ Papa.Containers.Data.Set: (\\) :: Ord a => Set a -> Set a -> Set a
+ Papa.Containers.Data.Set: alterF :: (Ord a, Functor f) => (Bool -> f Bool) -> a -> Set a -> f (Set a)
+ Papa.Containers.Data.Set: cartesianProduct :: Set a -> Set b -> Set (a, b)
+ Papa.Containers.Data.Set: data () => Set a
+ Papa.Containers.Data.Set: delete :: Ord a => a -> Set a -> Set a
+ Papa.Containers.Data.Set: deleteAt :: Int -> Set a -> Maybe (Set a)
+ Papa.Containers.Data.Set: deleteFindMax :: Set a -> Maybe (a, Set a)
+ Papa.Containers.Data.Set: deleteFindMin :: Set a -> Maybe (a, Set a)
+ Papa.Containers.Data.Set: deleteMax :: Set a -> Set a
+ Papa.Containers.Data.Set: deleteMin :: Set a -> Set a
+ Papa.Containers.Data.Set: difference :: Ord a => Set a -> Set a -> Set a
+ Papa.Containers.Data.Set: disjoint :: Ord a => Set a -> Set a -> Bool
+ Papa.Containers.Data.Set: disjointUnion :: Set a -> Set b -> Set (Either a b)
+ Papa.Containers.Data.Set: drop :: Int -> Set a -> Set a
+ Papa.Containers.Data.Set: dropWhileAntitone :: (a -> Bool) -> Set a -> Set a
+ Papa.Containers.Data.Set: elemAt :: Int -> Set a -> Maybe a
+ Papa.Containers.Data.Set: elems :: Set a -> [a]
+ Papa.Containers.Data.Set: empty :: Set a
+ Papa.Containers.Data.Set: filter :: (a -> Bool) -> Set a -> Set a
+ Papa.Containers.Data.Set: findIndex :: Ord a => a -> Set a -> Maybe Int
+ Papa.Containers.Data.Set: findMax :: Set a -> Maybe a
+ Papa.Containers.Data.Set: findMin :: Set a -> Maybe a
+ Papa.Containers.Data.Set: fold :: (a -> b -> b) -> b -> Set a -> b
+ Papa.Containers.Data.Set: foldl :: (a -> b -> a) -> a -> Set b -> a
+ Papa.Containers.Data.Set: foldl' :: (a -> b -> a) -> a -> Set b -> a
+ Papa.Containers.Data.Set: foldr :: (a -> b -> b) -> b -> Set a -> b
+ Papa.Containers.Data.Set: foldr' :: (a -> b -> b) -> b -> Set a -> b
+ Papa.Containers.Data.Set: fromAscList :: Ord a => [a] -> Maybe (Set a)
+ Papa.Containers.Data.Set: fromDescList :: Ord a => [a] -> Maybe (Set a)
+ Papa.Containers.Data.Set: fromDistinctAscList :: Ord a => [a] -> Maybe (Set a)
+ Papa.Containers.Data.Set: fromDistinctDescList :: Ord a => [a] -> Maybe (Set a)
+ Papa.Containers.Data.Set: fromList :: Ord a => [a] -> Set a
+ Papa.Containers.Data.Set: infixl 9 \\
+ Papa.Containers.Data.Set: insert :: Ord a => a -> Set a -> Set a
+ Papa.Containers.Data.Set: intersection :: Ord a => Set a -> Set a -> Set a
+ Papa.Containers.Data.Set: isProperSubsetOf :: Ord a => Set a -> Set a -> Bool
+ Papa.Containers.Data.Set: isSubsetOf :: Ord a => Set a -> Set a -> Bool
+ Papa.Containers.Data.Set: lookupGE :: Ord a => a -> Set a -> Maybe a
+ Papa.Containers.Data.Set: lookupGT :: Ord a => a -> Set a -> Maybe a
+ Papa.Containers.Data.Set: lookupIndex :: Ord a => a -> Set a -> Maybe Int
+ Papa.Containers.Data.Set: lookupLE :: Ord a => a -> Set a -> Maybe a
+ Papa.Containers.Data.Set: lookupLT :: Ord a => a -> Set a -> Maybe a
+ Papa.Containers.Data.Set: lookupMax :: Set a -> Maybe a
+ Papa.Containers.Data.Set: lookupMin :: Set a -> Maybe a
+ Papa.Containers.Data.Set: map :: Ord b => (a -> b) -> Set a -> Set b
+ Papa.Containers.Data.Set: mapMonotonic :: Ord b => (a -> b) -> Set a -> Maybe (Set b)
+ Papa.Containers.Data.Set: maxView :: Set a -> Maybe (a, Set a)
+ Papa.Containers.Data.Set: member :: Ord a => a -> Set a -> Bool
+ Papa.Containers.Data.Set: minView :: Set a -> Maybe (a, Set a)
+ Papa.Containers.Data.Set: notMember :: Ord a => a -> Set a -> Bool
+ Papa.Containers.Data.Set: null :: Set a -> Bool
+ Papa.Containers.Data.Set: partition :: (a -> Bool) -> Set a -> (Set a, Set a)
+ Papa.Containers.Data.Set: powerSet :: Set a -> Set (Set a)
+ Papa.Containers.Data.Set: showTree :: Show a => Set a -> String
+ Papa.Containers.Data.Set: showTreeWith :: Show a => Bool -> Bool -> Set a -> String
+ Papa.Containers.Data.Set: singleton :: a -> Set a
+ Papa.Containers.Data.Set: size :: Set a -> Int
+ Papa.Containers.Data.Set: spanAntitone :: (a -> Bool) -> Set a -> (Set a, Set a)
+ Papa.Containers.Data.Set: split :: Ord a => a -> Set a -> (Set a, Set a)
+ Papa.Containers.Data.Set: splitAt :: Int -> Set a -> (Set a, Set a)
+ Papa.Containers.Data.Set: splitMember :: Ord a => a -> Set a -> (Set a, Bool, Set a)
+ Papa.Containers.Data.Set: splitRoot :: Set a -> [Set a]
+ Papa.Containers.Data.Set: take :: Int -> Set a -> Set a
+ Papa.Containers.Data.Set: takeWhileAntitone :: (a -> Bool) -> Set a -> Set a
+ Papa.Containers.Data.Set: toAscList :: Set a -> [a]
+ Papa.Containers.Data.Set: toDescList :: Set a -> [a]
+ Papa.Containers.Data.Set: toList :: Set a -> [a]
+ Papa.Containers.Data.Set: union :: Ord a => Set a -> Set a -> Set a
+ Papa.Containers.Data.Set: unions :: (Foldable f, Ord a) => f (Set a) -> Set a
+ Papa.Containers.Data.Set: valid :: Ord a => Set a -> Bool
+ Papa.Directory.System.Directory: XdgCache :: XdgDirectory
+ Papa.Directory.System.Directory: XdgConfig :: XdgDirectory
+ Papa.Directory.System.Directory: XdgConfigDirs :: XdgDirectoryList
+ Papa.Directory.System.Directory: XdgData :: XdgDirectory
+ Papa.Directory.System.Directory: XdgDataDirs :: XdgDirectoryList
+ Papa.Directory.System.Directory: XdgState :: XdgDirectory
+ Papa.Directory.System.Directory: canonicalizePath :: FilePath -> IOExcept FilePath
+ Papa.Directory.System.Directory: copyFile :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: copyFileWithMetadata :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: copyPermissions :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: createDirectory :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: createDirectoryIfMissing :: Bool -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: createDirectoryLink :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: createFileLink :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: data () => Permissions
+ Papa.Directory.System.Directory: data () => XdgDirectory
+ Papa.Directory.System.Directory: data () => XdgDirectoryList
+ Papa.Directory.System.Directory: doesDirectoryExist :: FilePath -> IOExcept Bool
+ Papa.Directory.System.Directory: doesFileExist :: FilePath -> IOExcept Bool
+ Papa.Directory.System.Directory: doesPathExist :: FilePath -> IOExcept Bool
+ Papa.Directory.System.Directory: emptyPermissions :: Permissions
+ Papa.Directory.System.Directory: exeExtension :: String
+ Papa.Directory.System.Directory: executable :: Permissions -> Bool
+ Papa.Directory.System.Directory: findExecutable :: String -> IOExcept (Maybe FilePath)
+ Papa.Directory.System.Directory: findExecutables :: String -> IOExcept [FilePath]
+ Papa.Directory.System.Directory: findExecutablesInDirectories :: [FilePath] -> String -> IOExcept [FilePath]
+ Papa.Directory.System.Directory: findFile :: [FilePath] -> String -> IOExcept (Maybe FilePath)
+ Papa.Directory.System.Directory: findFiles :: [FilePath] -> String -> IOExcept [FilePath]
+ Papa.Directory.System.Directory: getAccessTime :: FilePath -> IOExcept UTCTime
+ Papa.Directory.System.Directory: getAppUserDataDirectory :: FilePath -> IOExcept FilePath
+ Papa.Directory.System.Directory: getCurrentDirectory :: IOExcept FilePath
+ Papa.Directory.System.Directory: getFileSize :: FilePath -> IOExcept Integer
+ Papa.Directory.System.Directory: getHomeDirectory :: IOExcept FilePath
+ Papa.Directory.System.Directory: getModificationTime :: FilePath -> IOExcept UTCTime
+ Papa.Directory.System.Directory: getPermissions :: FilePath -> IOExcept Permissions
+ Papa.Directory.System.Directory: getSymbolicLinkTarget :: FilePath -> IOExcept FilePath
+ Papa.Directory.System.Directory: getTemporaryDirectory :: IOExcept FilePath
+ Papa.Directory.System.Directory: getUserDocumentsDirectory :: IOExcept FilePath
+ Papa.Directory.System.Directory: getXdgDirectory :: XdgDirectory -> FilePath -> IOExcept FilePath
+ Papa.Directory.System.Directory: getXdgDirectoryList :: XdgDirectoryList -> IOExcept [FilePath]
+ Papa.Directory.System.Directory: listDirectory :: FilePath -> IOExcept [FilePath]
+ Papa.Directory.System.Directory: makeAbsolute :: FilePath -> IOExcept FilePath
+ Papa.Directory.System.Directory: makeRelativeToCurrentDirectory :: FilePath -> IOExcept FilePath
+ Papa.Directory.System.Directory: pathIsSymbolicLink :: FilePath -> IOExcept Bool
+ Papa.Directory.System.Directory: readable :: Permissions -> Bool
+ Papa.Directory.System.Directory: removeDirectory :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: removeDirectoryLink :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: removeDirectoryRecursive :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: removeFile :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: removePathForcibly :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: renameDirectory :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: renameFile :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: renamePath :: FilePath -> FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: searchable :: Permissions -> Bool
+ Papa.Directory.System.Directory: setAccessTime :: FilePath -> UTCTime -> IOExcept ()
+ Papa.Directory.System.Directory: setCurrentDirectory :: FilePath -> IOExcept ()
+ Papa.Directory.System.Directory: setModificationTime :: FilePath -> UTCTime -> IOExcept ()
+ Papa.Directory.System.Directory: setOwnerExecutable :: Bool -> Permissions -> Permissions
+ Papa.Directory.System.Directory: setOwnerReadable :: Bool -> Permissions -> Permissions
+ Papa.Directory.System.Directory: setOwnerSearchable :: Bool -> Permissions -> Permissions
+ Papa.Directory.System.Directory: setOwnerWritable :: Bool -> Permissions -> Permissions
+ Papa.Directory.System.Directory: setPermissions :: FilePath -> Permissions -> IOExcept ()
+ Papa.Directory.System.Directory: withCurrentDirectory :: FilePath -> IOExcept a -> IOExcept a
+ Papa.Directory.System.Directory: writable :: Permissions -> Bool
+ Papa.Filepath.System.FilePath: (-<.>) :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: (</>) :: FilePath -> FilePath -> FilePath
+ Papa.Filepath.System.FilePath: addExtension :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: addTrailingPathSeparator :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: combine :: FilePath -> FilePath -> FilePath
+ Papa.Filepath.System.FilePath: dropDrive :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: dropExtension :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: dropExtensions :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: dropFileName :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: dropTrailingPathSeparator :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: equalFilePath :: FilePath -> FilePath -> Bool
+ Papa.Filepath.System.FilePath: extSeparator :: Char
+ Papa.Filepath.System.FilePath: getSearchPath :: IOExcept [FilePath]
+ Papa.Filepath.System.FilePath: hasDrive :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: hasExtension :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: hasTrailingPathSeparator :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: infixr 5 </>
+ Papa.Filepath.System.FilePath: infixr 7 -<.>
+ Papa.Filepath.System.FilePath: isAbsolute :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: isDrive :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: isExtSeparator :: Char -> Bool
+ Papa.Filepath.System.FilePath: isExtensionOf :: String -> FilePath -> Bool
+ Papa.Filepath.System.FilePath: isPathSeparator :: Char -> Bool
+ Papa.Filepath.System.FilePath: isRelative :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: isSearchPathSeparator :: Char -> Bool
+ Papa.Filepath.System.FilePath: isValid :: FilePath -> Bool
+ Papa.Filepath.System.FilePath: joinDrive :: FilePath -> FilePath -> FilePath
+ Papa.Filepath.System.FilePath: joinPath :: [FilePath] -> FilePath
+ Papa.Filepath.System.FilePath: makeRelative :: FilePath -> FilePath -> FilePath
+ Papa.Filepath.System.FilePath: makeValid :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: normalise :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: pathSeparator :: Char
+ Papa.Filepath.System.FilePath: pathSeparators :: [Char]
+ Papa.Filepath.System.FilePath: replaceBaseName :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: replaceDirectory :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: replaceExtension :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: replaceExtensions :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: replaceFileName :: FilePath -> String -> FilePath
+ Papa.Filepath.System.FilePath: searchPathSeparator :: Char
+ Papa.Filepath.System.FilePath: splitDirectories :: FilePath -> [FilePath]
+ Papa.Filepath.System.FilePath: splitDrive :: FilePath -> (FilePath, FilePath)
+ Papa.Filepath.System.FilePath: splitExtension :: FilePath -> (String, String)
+ Papa.Filepath.System.FilePath: splitExtensions :: FilePath -> (FilePath, String)
+ Papa.Filepath.System.FilePath: splitFileName :: FilePath -> (String, String)
+ Papa.Filepath.System.FilePath: splitPath :: FilePath -> [FilePath]
+ Papa.Filepath.System.FilePath: splitSearchPath :: String -> [FilePath]
+ Papa.Filepath.System.FilePath: stripExtension :: String -> FilePath -> Maybe FilePath
+ Papa.Filepath.System.FilePath: takeBaseName :: FilePath -> String
+ Papa.Filepath.System.FilePath: takeDirectory :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: takeDrive :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: takeExtension :: FilePath -> String
+ Papa.Filepath.System.FilePath: takeExtensions :: FilePath -> String
+ Papa.Filepath.System.FilePath: takeFileName :: FilePath -> FilePath
+ Papa.Filepath.System.FilePath: type FilePath = String
+ Papa.Hashable.Data.Hashable: class Eq a => Hashable a
+ Papa.Hashable.Data.Hashable: data () => Hashed a
+ Papa.Hashable.Data.Hashable: defaultHash :: Hashable a => a -> Int
+ Papa.Hashable.Data.Hashable: defaultHashWithSalt :: Hashable a => Int -> a -> Int
+ Papa.Hashable.Data.Hashable: hash :: Hashable a => a -> Int
+ Papa.Hashable.Data.Hashable: hashUsing :: Hashable b => (a -> b) -> Int -> a -> Int
+ Papa.Hashable.Data.Hashable: hashWithSalt :: Hashable a => Int -> a -> Int
+ Papa.Hashable.Data.Hashable: hashed :: Hashable a => a -> Hashed a
+ Papa.Hashable.Data.Hashable: hashedHash :: Hashed a -> Int
+ Papa.Hashable.Data.Hashable: infixl 0 `hashWithSalt`
+ Papa.Hashable.Data.Hashable: mapHashed :: Hashable b => (a -> b) -> Hashed a -> Hashed b
+ Papa.Hashable.Data.Hashable: traverseHashed :: (Hashable b, Functor f) => (a -> f b) -> Hashed a -> f (Hashed b)
+ Papa.Hashable.Data.Hashable: unhashed :: Hashed a -> a
+ Papa.Lens: biplate :: (Data s, Typeable a) => Traversal' s a
+ Papa.Lens: gtraverse :: (Applicative f, Data a) => (forall d. Data d => d -> f d) -> a -> f a
+ Papa.Lens: is :: APrism s t a b -> s -> Bool
+ Papa.Lens: onceUpon :: (Data s, Typeable a) => (s -> a) -> IndexedTraversal' Int s a
+ Papa.Lens: onceUpon' :: (Data s, Typeable a) => (s -> a) -> IndexedLens' Int s a
+ Papa.Lens: template :: (Data s, Typeable a) => Traversal' s a
+ Papa.Lens: tinplate :: (Data s, Typeable a) => Traversal' s a
+ Papa.Lens: uniplate :: Data a => Traversal' a a
+ Papa.Lens: upon :: (Indexable [Int] p, Applicative f, Data s, Data a) => (s -> a) -> p a (f a) -> s -> f s
+ Papa.Lens: upon' :: (Data s, Data a) => (s -> a) -> IndexedLens' [Int] s a
+ Papa.Lens.Control.Exception: _AllocationLimitExceeded :: AsAllocationLimitExceeded t => Prism' t ()
+ Papa.Lens.Control.Exception: _ArithException :: AsArithException t => Prism' t ArithException
+ Papa.Lens.Control.Exception: _ArrayException :: AsArrayException t => Prism' t ArrayException
+ Papa.Lens.Control.Exception: _AssertionFailed :: AsAssertionFailed t => Prism' t String
+ Papa.Lens.Control.Exception: _AsyncException :: AsAsyncException t => Prism' t AsyncException
+ Papa.Lens.Control.Exception: _BlockedIndefinitelyOnMVar :: AsBlockedIndefinitelyOnMVar t => Prism' t ()
+ Papa.Lens.Control.Exception: _BlockedIndefinitelyOnSTM :: AsBlockedIndefinitelyOnSTM t => Prism' t ()
+ Papa.Lens.Control.Exception: _CompactionFailed :: AsCompactionFailed t => Prism' t String
+ Papa.Lens.Control.Exception: _Deadlock :: AsDeadlock t => Prism' t ()
+ Papa.Lens.Control.Exception: _Denormal :: AsArithException t => Prism' t ()
+ Papa.Lens.Control.Exception: _DivideByZero :: AsArithException t => Prism' t ()
+ Papa.Lens.Control.Exception: _ErrorCall :: AsErrorCall t => Prism' t String
+ Papa.Lens.Control.Exception: _HandlingException :: AsHandlingException t => Prism' t ()
+ Papa.Lens.Control.Exception: _HeapOverflow :: AsAsyncException t => Prism' t ()
+ Papa.Lens.Control.Exception: _IOException :: AsIOException t => Prism' t IOException
+ Papa.Lens.Control.Exception: _IndexOutOfBounds :: AsArrayException t => Prism' t String
+ Papa.Lens.Control.Exception: _LossOfPrecision :: AsArithException t => Prism' t ()
+ Papa.Lens.Control.Exception: _NestedAtomically :: AsNestedAtomically t => Prism' t ()
+ Papa.Lens.Control.Exception: _NoMethodError :: AsNoMethodError t => Prism' t String
+ Papa.Lens.Control.Exception: _NonTermination :: AsNonTermination t => Prism' t ()
+ Papa.Lens.Control.Exception: _Overflow :: AsArithException t => Prism' t ()
+ Papa.Lens.Control.Exception: _PatternMatchFail :: AsPatternMatchFail t => Prism' t String
+ Papa.Lens.Control.Exception: _RatioZeroDenominator :: AsArithException t => Prism' t ()
+ Papa.Lens.Control.Exception: _RecConError :: AsRecConError t => Prism' t String
+ Papa.Lens.Control.Exception: _RecSelError :: AsRecSelError t => Prism' t String
+ Papa.Lens.Control.Exception: _RecUpdError :: AsRecUpdError t => Prism' t String
+ Papa.Lens.Control.Exception: _StackOverflow :: AsAsyncException t => Prism' t ()
+ Papa.Lens.Control.Exception: _ThreadKilled :: AsAsyncException t => Prism' t ()
+ Papa.Lens.Control.Exception: _TypeError :: AsTypeError t => Prism' t String
+ Papa.Lens.Control.Exception: _UndefinedElement :: AsArrayException t => Prism' t String
+ Papa.Lens.Control.Exception: _Underflow :: AsArithException t => Prism' t ()
+ Papa.Lens.Control.Exception: _UserInterrupt :: AsAsyncException t => Prism' t ()
+ Papa.Lens.Control.Exception: __AllocationLimitExceeded :: AsAllocationLimitExceeded t => Prism' t AllocationLimitExceeded
+ Papa.Lens.Control.Exception: __AssertionFailed :: AsAssertionFailed t => Prism' t AssertionFailed
+ Papa.Lens.Control.Exception: __BlockedIndefinitelyOnMVar :: AsBlockedIndefinitelyOnMVar t => Prism' t BlockedIndefinitelyOnMVar
+ Papa.Lens.Control.Exception: __BlockedIndefinitelyOnSTM :: AsBlockedIndefinitelyOnSTM t => Prism' t BlockedIndefinitelyOnSTM
+ Papa.Lens.Control.Exception: __CompactionFailed :: AsCompactionFailed t => Prism' t CompactionFailed
+ Papa.Lens.Control.Exception: __Deadlock :: AsDeadlock t => Prism' t Deadlock
+ Papa.Lens.Control.Exception: __ErrorCall :: AsErrorCall t => Prism' t ErrorCall
+ Papa.Lens.Control.Exception: __HandlingException :: AsHandlingException t => Prism' t HandlingException
+ Papa.Lens.Control.Exception: __NestedAtomically :: AsNestedAtomically t => Prism' t NestedAtomically
+ Papa.Lens.Control.Exception: __NoMethodError :: AsNoMethodError t => Prism' t NoMethodError
+ Papa.Lens.Control.Exception: __NonTermination :: AsNonTermination t => Prism' t NonTermination
+ Papa.Lens.Control.Exception: __PatternMatchFail :: AsPatternMatchFail t => Prism' t PatternMatchFail
+ Papa.Lens.Control.Exception: __RecConError :: AsRecConError t => Prism' t RecConError
+ Papa.Lens.Control.Exception: __RecSelError :: AsRecSelError t => Prism' t RecSelError
+ Papa.Lens.Control.Exception: __RecUpdError :: AsRecUpdError t => Prism' t RecUpdError
+ Papa.Lens.Control.Exception: __TypeError :: AsTypeError t => Prism' t TypeError
+ Papa.Lens.Control.Exception: catching :: MonadCatch m => Getting (First a) SomeException a -> m r -> (a -> m r) -> m r
+ Papa.Lens.Control.Exception: catching_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m r -> m r
+ Papa.Lens.Control.Exception: class () => AsAllocationLimitExceeded t
+ Papa.Lens.Control.Exception: class () => AsArithException t
+ Papa.Lens.Control.Exception: class () => AsArrayException t
+ Papa.Lens.Control.Exception: class () => AsAssertionFailed t
+ Papa.Lens.Control.Exception: class () => AsAsyncException t
+ Papa.Lens.Control.Exception: class () => AsBlockedIndefinitelyOnMVar t
+ Papa.Lens.Control.Exception: class () => AsBlockedIndefinitelyOnSTM t
+ Papa.Lens.Control.Exception: class () => AsCompactionFailed t
+ Papa.Lens.Control.Exception: class () => AsDeadlock t
+ Papa.Lens.Control.Exception: class () => AsErrorCall t
+ Papa.Lens.Control.Exception: class () => AsHandlingException t
+ Papa.Lens.Control.Exception: class () => AsIOException t
+ Papa.Lens.Control.Exception: class () => AsNestedAtomically t
+ Papa.Lens.Control.Exception: class () => AsNoMethodError t
+ Papa.Lens.Control.Exception: class () => AsNonTermination t
+ Papa.Lens.Control.Exception: class () => AsPatternMatchFail t
+ Papa.Lens.Control.Exception: class () => AsRecConError t
+ Papa.Lens.Control.Exception: class () => AsRecSelError t
+ Papa.Lens.Control.Exception: class () => AsRecUpdError t
+ Papa.Lens.Control.Exception: class () => AsTypeError t
+ Papa.Lens.Control.Exception: class () => Handleable e (m :: Type -> Type) (h :: Type -> Type) | h -> e m
+ Papa.Lens.Control.Exception: class MonadThrow m => MonadCatch (m :: Type -> Type)
+ Papa.Lens.Control.Exception: class MonadCatch m => MonadMask (m :: Type -> Type)
+ Papa.Lens.Control.Exception: class Monad m => MonadThrow (m :: Type -> Type)
+ Papa.Lens.Control.Exception: exception :: Exception a => Prism' SomeException a
+ Papa.Lens.Control.Exception: handler :: (Handleable e m h, Typeable a) => Getting (First a) e a -> (a -> m r) -> h r
+ Papa.Lens.Control.Exception: handler_ :: (Handleable e m h, Typeable a) => Getting (First a) e a -> m r -> h r
+ Papa.Lens.Control.Exception: handling :: MonadCatch m => Getting (First a) SomeException a -> (a -> m r) -> m r -> m r
+ Papa.Lens.Control.Exception: handling_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m r -> m r
+ Papa.Lens.Control.Exception: pattern AllocationLimitExceeded__ :: AsAllocationLimitExceeded s => AllocationLimitExceeded -> s
+ Papa.Lens.Control.Exception: pattern ArithException_ :: AsArithException s => ArithException -> s
+ Papa.Lens.Control.Exception: pattern ArrayException_ :: AsArrayException s => ArrayException -> s
+ Papa.Lens.Control.Exception: pattern AssertionFailed__ :: AsAssertionFailed s => AssertionFailed -> s
+ Papa.Lens.Control.Exception: pattern AsyncException_ :: AsAsyncException s => AsyncException -> s
+ Papa.Lens.Control.Exception: pattern BlockedIndefinitelyOnMVar__ :: AsBlockedIndefinitelyOnMVar s => BlockedIndefinitelyOnMVar -> s
+ Papa.Lens.Control.Exception: pattern BlockedIndefinitelyOnSTM__ :: AsBlockedIndefinitelyOnSTM s => BlockedIndefinitelyOnSTM -> s
+ Papa.Lens.Control.Exception: pattern CompactionFailed__ :: AsCompactionFailed s => CompactionFailed -> s
+ Papa.Lens.Control.Exception: pattern Deadlock__ :: AsDeadlock s => Deadlock -> s
+ Papa.Lens.Control.Exception: pattern ErrorCall__ :: AsErrorCall s => ErrorCall -> s
+ Papa.Lens.Control.Exception: pattern HandlingException__ :: AsHandlingException s => HandlingException -> s
+ Papa.Lens.Control.Exception: pattern IOException_ :: AsIOException s => IOException -> s
+ Papa.Lens.Control.Exception: pattern NestedAtomically__ :: AsNestedAtomically s => NestedAtomically -> s
+ Papa.Lens.Control.Exception: pattern NoMethodError__ :: AsNoMethodError s => NoMethodError -> s
+ Papa.Lens.Control.Exception: pattern NonTermination__ :: AsNonTermination s => NonTermination -> s
+ Papa.Lens.Control.Exception: pattern PatternMatchFail__ :: AsPatternMatchFail s => PatternMatchFail -> s
+ Papa.Lens.Control.Exception: pattern RecConError__ :: AsRecConError s => RecConError -> s
+ Papa.Lens.Control.Exception: pattern RecSelError__ :: AsRecSelError s => RecSelError -> s
+ Papa.Lens.Control.Exception: pattern RecUpdError__ :: AsRecUpdError s => RecUpdError -> s
+ Papa.Lens.Control.Exception: pattern IndexOutOfBounds_ :: AsArrayException s => String -> s
+ Papa.Lens.Control.Exception: pattern TypeError__ :: AsTypeError s => TypeError -> s
+ Papa.Lens.Control.Exception: pattern Exception :: Exception a => a -> SomeException
+ Papa.Lens.Control.Exception: pattern Overflow_ :: AsArithException s => s
+ Papa.Lens.Control.Exception: throwingM :: MonadThrow m => AReview SomeException b -> b -> m r
+ Papa.Lens.Control.Exception: throwingTo :: MonadIO m => ThreadId -> AReview SomeException b -> b -> m ()
+ Papa.Lens.Control.Exception: trying :: MonadCatch m => Getting (First a) SomeException a -> m r -> m (Either a r)
+ Papa.Lens.Control.Exception: trying_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m (Maybe r)
+ Papa.Lens.Core: (#) :: AReview t b -> b -> t
+ Papa.Lens.Core: (%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
+ Papa.Lens.Core: (%@~) :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t
+ Papa.Lens.Core: (%~) :: ASetter s t a b -> (a -> b) -> s -> t
+ Papa.Lens.Core: (&&~) :: ASetter s t Bool Bool -> Bool -> s -> t
+ Papa.Lens.Core: (*~) :: Num a => ASetter s t a a -> a -> s -> t
+ Papa.Lens.Core: (+=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()
+ Papa.Lens.Core: (+~) :: Num a => ASetter s t a a -> a -> s -> t
+ Papa.Lens.Core: (-=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m ()
+ Papa.Lens.Core: (-~) :: Num a => ASetter s t a a -> a -> s -> t
+ Papa.Lens.Core: (.=) :: MonadState s m => ASetter s s a b -> b -> m ()
+ Papa.Lens.Core: (.@~) :: AnIndexedSetter i s t a b -> (i -> b) -> s -> t
+ Papa.Lens.Core: (.~) :: ASetter s t a b -> b -> s -> t
+ Papa.Lens.Core: (<>=) :: (MonadState s m, Semigroup a) => ASetter' s a -> a -> m ()
+ Papa.Lens.Core: (<>~) :: Semigroup a => ASetter s t a a -> a -> s -> t
+ Papa.Lens.Core: (<|) :: Cons s s a a => a -> s -> s
+ Papa.Lens.Core: (>$) :: Contravariant f => b -> f b -> f a
+ Papa.Lens.Core: (?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m ()
+ Papa.Lens.Core: (?~) :: ASetter s t a (Maybe b) -> b -> s -> t
+ Papa.Lens.Core: (^.) :: s -> Getting a s a -> a
+ Papa.Lens.Core: (^..) :: s -> Getting (Endo [a]) s a -> [a]
+ Papa.Lens.Core: (^?) :: s -> Getting (First a) s a -> Maybe a
+ Papa.Lens.Core: (^@.) :: s -> IndexedGetting i (i, a) s a -> (i, a)
+ Papa.Lens.Core: (^@..) :: s -> IndexedGetting i (Endo [(i, a)]) s a -> [(i, a)]
+ Papa.Lens.Core: (^@?) :: s -> IndexedGetting i (Endo (Maybe (i, a))) s a -> Maybe (i, a)
+ Papa.Lens.Core: (|>) :: Snoc s s a a => s -> a -> s
+ Papa.Lens.Core: (||~) :: ASetter s t Bool Bool -> Bool -> s -> t
+ Papa.Lens.Core: Indexed :: (i -> a -> b) -> Indexed i a b
+ Papa.Lens.Core: [runIndexed] :: Indexed i a b -> i -> a -> b
+ Papa.Lens.Core: _1 :: Field1 s t a b => Lens s t a b
+ Papa.Lens.Core: _2 :: Field2 s t a b => Lens s t a b
+ Papa.Lens.Core: _3 :: Field3 s t a b => Lens s t a b
+ Papa.Lens.Core: _4 :: Field4 s t a b => Lens s t a b
+ Papa.Lens.Core: _5 :: Field5 s t a b => Lens s t a b
+ Papa.Lens.Core: _6 :: Field6 s t a b => Lens s t a b
+ Papa.Lens.Core: _7 :: Field7 s t a b => Lens s t a b
+ Papa.Lens.Core: _8 :: Field8 s t a b => Lens s t a b
+ Papa.Lens.Core: _9 :: Field9 s t a b => Lens s t a b
+ Papa.Lens.Core: _Cons :: Cons s t a b => Prism s t (a, s) (b, t)
+ Papa.Lens.Core: _Empty :: AsEmpty a => Prism' a ()
+ Papa.Lens.Core: _Just :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (Maybe a) (f (Maybe b))
+ Papa.Lens.Core: _Left :: forall a c b p f. (Choice p, Applicative f) => p a (f b) -> p (Either a c) (f (Either b c))
+ Papa.Lens.Core: _Nothing :: forall a p f. (Choice p, Applicative f) => p () (f ()) -> p (Maybe a) (f (Maybe a))
+ Papa.Lens.Core: _Right :: forall c a b p f. (Choice p, Applicative f) => p a (f b) -> p (Either c a) (f (Either c b))
+ Papa.Lens.Core: _Snoc :: Snoc s t a b => Prism s t (s, a) (t, b)
+ Papa.Lens.Core: _Unwrapped :: Rewrapping s t => Iso (Unwrapped t) (Unwrapped s) t s
+ Papa.Lens.Core: _Unwrapped' :: Wrapped s => Iso' (Unwrapped s) s
+ Papa.Lens.Core: _Unwrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso (Unwrapped t) (Unwrapped s) t s
+ Papa.Lens.Core: _Void :: forall s a p f. (Choice p, Applicative f) => p a (f Void) -> p s (f s)
+ Papa.Lens.Core: _Wrapped :: Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
+ Papa.Lens.Core: _Wrapped' :: Wrapped s => Iso' s (Unwrapped s)
+ Papa.Lens.Core: _Wrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
+ Papa.Lens.Core: _head :: Cons s s a a => Traversal' s a
+ Papa.Lens.Core: _init :: Snoc s s a a => Traversal' s s
+ Papa.Lens.Core: _last :: Snoc s s a a => Traversal' s a
+ Papa.Lens.Core: _tail :: Cons s s a a => Traversal' s s
+ Papa.Lens.Core: ala :: (Functor f, Rewrapping s t) => (Unwrapped s -> s) -> ((Unwrapped t -> t) -> f s) -> f (Unwrapped s)
+ Papa.Lens.Core: alaf :: (Functor f, Functor g, Rewrapping s t) => (Unwrapped s -> s) -> (f t -> g s) -> f (Unwrapped t) -> g (Unwrapped s)
+ Papa.Lens.Core: allOf :: Getting All s a -> (a -> Bool) -> s -> Bool
+ Papa.Lens.Core: alongside :: LensLike (AlongsideLeft f b') s t a b -> LensLike (AlongsideRight f t) s' t' a' b' -> LensLike f (s, s') (t, t') (a, a') (b, b')
+ Papa.Lens.Core: andOf :: Getting All s Bool -> s -> Bool
+ Papa.Lens.Core: anyOf :: Getting Any s a -> (a -> Bool) -> s -> Bool
+ Papa.Lens.Core: assign :: MonadState s m => ASetter s s a b -> b -> m ()
+ Papa.Lens.Core: at :: At m => Index m -> Lens' m (Maybe (IxValue m))
+ Papa.Lens.Core: au :: Functor f => AnIso s t a b -> ((b -> t) -> f s) -> f a
+ Papa.Lens.Core: auf :: (Functor f, Functor g) => AnIso s t a b -> (f t -> g s) -> f b -> g a
+ Papa.Lens.Core: beside :: (Representable q, Applicative (Rep q), Applicative f, Bitraversable r) => Optical p q f s t a b -> Optical p q f s' t' a b -> Optical p q f (r s s') (r t t') a b
+ Papa.Lens.Core: bimapping :: forall (f :: Type -> Type -> Type) (g :: Type -> Type -> Type) s t a b s' t' a' b'. (Bifunctor f, Bifunctor g) => AnIso s t a b -> AnIso s' t' a' b' -> Iso (f s s') (g t t') (f a a') (g b b')
+ Papa.Lens.Core: both :: forall (r :: Type -> Type -> Type) a b. Bitraversable r => Traversal (r a a) (r b b) a b
+ Papa.Lens.Core: both1 :: forall (r :: Type -> Type -> Type) a b. Bitraversable1 r => Traversal1 (r a a) (r b b) a b
+ Papa.Lens.Core: children :: Plated a => a -> [a]
+ Papa.Lens.Core: choosing :: Functor f => LensLike f s t a b -> LensLike f s' t' a b -> LensLike f (Either s s') (Either t t') a b
+ Papa.Lens.Core: chosen :: forall a b p f. (Conjoined p, Functor f) => p a (f b) -> p (Either a a) (f (Either b b))
+ Papa.Lens.Core: class () => AsEmpty a
+ Papa.Lens.Core: class Ixed m => At m
+ Papa.Lens.Core: class Profunctor p => Choice (p :: Type -> Type -> Type)
+ Papa.Lens.Core: class () => Cons s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Contains m
+ Papa.Lens.Core: class () => Contravariant (f :: Type -> Type)
+ Papa.Lens.Core: class () => Each s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class () => Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i
+ Papa.Lens.Core: class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i
+ Papa.Lens.Core: class Conjoined p => Indexable i (p :: Type -> Type -> Type)
+ Papa.Lens.Core: class () => Ixed m
+ Papa.Lens.Core: class () => Plated a
+ Papa.Lens.Core: class () => Prefixed t
+ Papa.Lens.Core: class () => Profunctor (p :: Type -> Type -> Type)
+ Papa.Lens.Core: class () => Reversing t
+ Papa.Lens.Core: class Wrapped s => Rewrapped s t
+ Papa.Lens.Core: class () => Snoc s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens.Core: class Profunctor p => Strong (p :: Type -> Type -> Type)
+ Papa.Lens.Core: class () => Suffixed t
+ Papa.Lens.Core: class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i
+ Papa.Lens.Core: class Ord k => TraverseMax k (m :: Type -> Type) | m -> k
+ Papa.Lens.Core: class Ord k => TraverseMin k (m :: Type -> Type) | m -> k
+ Papa.Lens.Core: class () => Wrapped s
+ Papa.Lens.Core: cloneIso :: AnIso s t a b -> Iso s t a b
+ Papa.Lens.Core: cloneLens :: ALens s t a b -> Lens s t a b
+ Papa.Lens.Core: clonePrism :: APrism s t a b -> Prism s t a b
+ Papa.Lens.Core: cloneTraversal :: ATraversal s t a b -> Traversal s t a b
+ Papa.Lens.Core: coerced :: forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
+ Papa.Lens.Core: concatMapOf :: Getting [r] s a -> (a -> [r]) -> s -> [r]
+ Papa.Lens.Core: concatOf :: Getting [r] s [r] -> s -> [r]
+ Papa.Lens.Core: cons :: Cons s s a a => a -> s -> s
+ Papa.Lens.Core: contains :: Contains m => Index m -> Lens' m Bool
+ Papa.Lens.Core: contramap :: Contravariant f => (a' -> a) -> f a -> f a'
+ Papa.Lens.Core: cosmos :: Plated a => Fold a a
+ Papa.Lens.Core: cosmosOf :: (Applicative f, Contravariant f) => LensLike' f a a -> LensLike' f a a
+ Papa.Lens.Core: devoid :: forall {k} p f (a :: k) b. Over p f Void Void a b
+ Papa.Lens.Core: dimap :: Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d
+ Papa.Lens.Core: dropping :: (Conjoined p, Applicative f) => Int -> Over p (Indexing f) s t a a -> Over p f s t a a
+ Papa.Lens.Core: droppingWhile :: (Conjoined p, Profunctor q, Applicative f) => (a -> Bool) -> Optical p q (Compose (State Bool) f) s t a a -> Optical p q f s t a a
+ Papa.Lens.Core: each :: Each s t a b => Traversal s t a b
+ Papa.Lens.Core: elemOf :: Eq a => Getting Any s a -> a -> s -> Bool
+ Papa.Lens.Core: filtered :: (Choice p, Applicative f) => (a -> Bool) -> Optic' p f a a
+ Papa.Lens.Core: filteredBy :: (Indexable i p, Applicative f) => Getting (First i) a i -> p a (f a) -> a -> f a
+ Papa.Lens.Core: findOf :: Getting (Endo (Maybe a)) s a -> (a -> Bool) -> s -> Maybe a
+ Papa.Lens.Core: first' :: Strong p => p a b -> p (a, c) (b, c)
+ Papa.Lens.Core: first1Of :: Getting (First a) s a -> s -> a
+ Papa.Lens.Core: firstOf :: Getting (Leftmost a) s a -> s -> Maybe a
+ Papa.Lens.Core: firsting :: forall (f :: Type -> Type -> Type) (g :: Type -> Type -> Type) s t a b x y. (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f s x) (g t y) (f a x) (g b y)
+ Papa.Lens.Core: foldMapOf :: Getting r s a -> (a -> r) -> s -> r
+ Papa.Lens.Core: foldOf :: Getting a s a -> s -> a
+ Papa.Lens.Core: folded :: forall (f :: Type -> Type) a. Foldable f => IndexedFold Int (f a) a
+ Papa.Lens.Core: folding :: Foldable f => (s -> f a) -> Fold s a
+ Papa.Lens.Core: foldlOf :: Getting (Dual (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
+ Papa.Lens.Core: foldlOf' :: Getting (Endo (Endo r)) s a -> (r -> a -> r) -> r -> s -> r
+ Papa.Lens.Core: foldrOf :: Getting (Endo r) s a -> (a -> r -> r) -> r -> s -> r
+ Papa.Lens.Core: foldrOf' :: Getting (Dual (Endo (Endo r))) s a -> (a -> r -> r) -> r -> s -> r
+ Papa.Lens.Core: forOf :: LensLike f s t a b -> s -> (a -> f b) -> f t
+ Papa.Lens.Core: forOf_ :: Functor f => Getting (Traversed r f) s a -> s -> (a -> f r) -> f ()
+ Papa.Lens.Core: from :: AnIso s t a b -> Iso b a t s
+ Papa.Lens.Core: has :: Getting Any s a -> s -> Bool
+ Papa.Lens.Core: hasn't :: Getting All s a -> s -> Bool
+ Papa.Lens.Core: holesOf :: Conjoined p => Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]
+ Papa.Lens.Core: iallOf :: IndexedGetting i All s a -> (i -> a -> Bool) -> s -> Bool
+ Papa.Lens.Core: ianyOf :: IndexedGetting i Any s a -> (i -> a -> Bool) -> s -> Bool
+ Papa.Lens.Core: ifindOf :: IndexedGetting i (Endo (Maybe a)) s a -> (i -> a -> Bool) -> s -> Maybe a
+ Papa.Lens.Core: ifoldMap :: (FoldableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m
+ Papa.Lens.Core: ifoldMapOf :: IndexedGetting i m s a -> (i -> a -> m) -> s -> m
+ Papa.Lens.Core: ifolded :: forall i (f :: Type -> Type) a. FoldableWithIndex i f => IndexedFold i (f a) a
+ Papa.Lens.Core: ifoldl :: FoldableWithIndex i f => (i -> b -> a -> b) -> b -> f a -> b
+ Papa.Lens.Core: ifoldlOf :: IndexedGetting i (Dual (Endo r)) s a -> (i -> r -> a -> r) -> r -> s -> r
+ Papa.Lens.Core: ifoldr :: FoldableWithIndex i f => (i -> a -> b -> b) -> b -> f a -> b
+ Papa.Lens.Core: ifoldrOf :: IndexedGetting i (Endo r) s a -> (i -> a -> r -> r) -> r -> s -> r
+ Papa.Lens.Core: iforOf :: (Indexed i a (f b) -> s -> f t) -> s -> (i -> a -> f b) -> f t
+ Papa.Lens.Core: iforOf_ :: Functor f => IndexedGetting i (Traversed r f) s a -> s -> (i -> a -> f r) -> f ()
+ Papa.Lens.Core: ignored :: Applicative f => pafb -> s -> f s
+ Papa.Lens.Core: imap :: FunctorWithIndex i f => (i -> a -> b) -> f a -> f b
+ Papa.Lens.Core: imapped :: forall i (f :: Type -> Type) a b. FunctorWithIndex i f => IndexedSetter i (f a) (f b) a b
+ Papa.Lens.Core: indexed :: Indexable i p => p a b -> i -> a -> b
+ Papa.Lens.Core: indices :: (Indexable i p, Applicative f) => (i -> Bool) -> Optical' p (Indexed i) f a a
+ Papa.Lens.Core: infix 4 -=
+ Papa.Lens.Core: infixl 4 >$
+ Papa.Lens.Core: infixl 5 |>
+ Papa.Lens.Core: infixl 8 ^@..
+ Papa.Lens.Core: infixr 2 `magnify`
+ Papa.Lens.Core: infixr 4 .@~
+ Papa.Lens.Core: infixr 5 <|
+ Papa.Lens.Core: infixr 8 #
+ Papa.Lens.Core: involuted :: (a -> a) -> Iso' a a
+ Papa.Lens.Core: iover :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t
+ Papa.Lens.Core: ipartsOf :: (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a a -> Over p f s t [a] [a]
+ Papa.Lens.Core: ipreview :: MonadReader s m => IndexedGetting i (First (i, a)) s a -> m (Maybe (i, a))
+ Papa.Lens.Core: iset :: AnIndexedSetter i s t a b -> (i -> b) -> s -> t
+ Papa.Lens.Core: isn't :: APrism s t a b -> s -> Bool
+ Papa.Lens.Core: iso :: (s -> a) -> (b -> t) -> Iso s t a b
+ Papa.Lens.Core: ito :: (Indexable i p, Contravariant f) => (s -> (i, a)) -> Over' p f s a
+ Papa.Lens.Core: itoListOf :: IndexedGetting i (Endo [(i, a)]) s a -> s -> [(i, a)]
+ Papa.Lens.Core: itraverse :: (TraversableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f (t b)
+ Papa.Lens.Core: itraverseOf :: (Indexed i a (f b) -> s -> f t) -> (i -> a -> f b) -> s -> f t
+ Papa.Lens.Core: itraverseOf_ :: Functor f => IndexedGetting i (Traversed r f) s a -> (i -> a -> f r) -> s -> f ()
+ Papa.Lens.Core: itraversed :: forall i (t :: Type -> Type) a b. TraversableWithIndex i t => IndexedTraversal i (t a) (t b) a b
+ Papa.Lens.Core: iview :: MonadReader s m => IndexedGetting i (i, a) s a -> m (i, a)
+ Papa.Lens.Core: ix :: Ixed m => Index m -> Traversal' m (IxValue m)
+ Papa.Lens.Core: last1Of :: Getting (Last a) s a -> s -> a
+ Papa.Lens.Core: lastOf :: Getting (Rightmost a) s a -> s -> Maybe a
+ Papa.Lens.Core: left' :: Choice p => p a b -> p (Either a c) (Either b c)
+ Papa.Lens.Core: lengthOf :: Getting (Endo (Endo Int)) s a -> s -> Int
+ Papa.Lens.Core: lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
+ Papa.Lens.Core: like :: (Profunctor p, Contravariant f, Functor f) => a -> Optic' p f s a
+ Papa.Lens.Core: lmap :: Profunctor p => (a -> b) -> p b c -> p a c
+ Papa.Lens.Core: locally :: MonadReader s m => ASetter s s a b -> (a -> b) -> m r -> m r
+ Papa.Lens.Core: lookupOf :: Eq k => Getting (Endo (Maybe v)) s (k, v) -> k -> s -> Maybe v
+ Papa.Lens.Core: magnify :: Magnify m n b a => ((Functor (Magnified m c), Contravariant (Magnified m c)) => LensLike' (Magnified m c) a b) -> m c -> n c
+ Papa.Lens.Core: mapAccumLOf :: LensLike (State acc) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
+ Papa.Lens.Core: mapAccumROf :: LensLike (Backwards (State acc)) s t a b -> (acc -> a -> (acc, b)) -> acc -> s -> (acc, t)
+ Papa.Lens.Core: mapped :: forall (f :: Type -> Type) a b. Functor f => Setter (f a) (f b) a b
+ Papa.Lens.Core: mapping :: forall (f :: Type -> Type) (g :: Type -> Type) s t a b. (Functor f, Functor g) => AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
+ Papa.Lens.Core: matching :: APrism s t a b -> s -> Either t a
+ Papa.Lens.Core: maximum1Of :: Ord a => Getting (Max a) s a -> s -> a
+ Papa.Lens.Core: maximumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a
+ Papa.Lens.Core: maximumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
+ Papa.Lens.Core: minimum1Of :: Ord a => Getting (Min a) s a -> s -> a
+ Papa.Lens.Core: minimumByOf :: Getting (Endo (Endo (Maybe a))) s a -> (a -> a -> Ordering) -> s -> Maybe a
+ Papa.Lens.Core: minimumOf :: Ord a => Getting (Endo (Endo (Maybe a))) s a -> s -> Maybe a
+ Papa.Lens.Core: modifying :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
+ Papa.Lens.Core: newtype () => Indexed i a b
+ Papa.Lens.Core: noneOf :: Getting Any s a -> (a -> Bool) -> s -> Bool
+ Papa.Lens.Core: notElemOf :: Eq a => Getting All s a -> a -> s -> Bool
+ Papa.Lens.Core: notNullOf :: Getting Any s a -> s -> Bool
+ Papa.Lens.Core: nullOf :: Getting All s a -> s -> Bool
+ Papa.Lens.Core: only :: Eq a => a -> Prism' a ()
+ Papa.Lens.Core: orOf :: Getting Any s Bool -> s -> Bool
+ Papa.Lens.Core: over :: ASetter s t a b -> (a -> b) -> s -> t
+ Papa.Lens.Core: partsOf :: Functor f => Traversing (->) f s t a a -> LensLike f s t [a] [a]
+ Papa.Lens.Core: partsOf' :: ATraversal s t a a -> Lens s t [a] [a]
+ Papa.Lens.Core: phantom :: (Functor f, Contravariant f) => f a -> f b
+ Papa.Lens.Core: plate :: Plated a => Traversal' a a
+ Papa.Lens.Core: prefixed :: Prefixed t => t -> Prism' t t
+ Papa.Lens.Core: preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)
+ Papa.Lens.Core: preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)
+ Papa.Lens.Core: previews :: MonadReader s m => Getting (First r) s a -> (a -> r) -> m (Maybe r)
+ Papa.Lens.Core: prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b
+ Papa.Lens.Core: prism' :: (b -> s) -> (s -> Maybe a) -> Prism s s a b
+ Papa.Lens.Core: productOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a
+ Papa.Lens.Core: re :: AReview t b -> Getter b t
+ Papa.Lens.Core: reversed :: Reversing a => Iso' a a
+ Papa.Lens.Core: reversing :: Reversing t => t -> t
+ Papa.Lens.Core: review :: MonadReader b m => AReview t b -> m t
+ Papa.Lens.Core: reviews :: MonadReader b m => AReview t b -> (t -> r) -> m r
+ Papa.Lens.Core: rewrite :: Plated a => (a -> Maybe a) -> a -> a
+ Papa.Lens.Core: rewriteOf :: ASetter a b a b -> (b -> Maybe a) -> a -> b
+ Papa.Lens.Core: right' :: Choice p => p a b -> p (Either c a) (Either c b)
+ Papa.Lens.Core: rmap :: Profunctor p => (b -> c) -> p a b -> p a c
+ Papa.Lens.Core: sans :: At m => Index m -> m -> m
+ Papa.Lens.Core: second' :: Strong p => p a b -> p (c, a) (c, b)
+ Papa.Lens.Core: seconding :: forall (f :: Type -> Type -> Type) (g :: Type -> Type -> Type) s t a b x y. (Bifunctor f, Bifunctor g) => AnIso s t a b -> Iso (f x s) (g y t) (f x a) (g y b)
+ Papa.Lens.Core: sequenceAOf :: LensLike f s t (f b) b -> s -> f t
+ Papa.Lens.Core: sequenceAOf_ :: Functor f => Getting (Traversed a f) s (f a) -> s -> f ()
+ Papa.Lens.Core: set :: ASetter s t a b -> b -> s -> t
+ Papa.Lens.Core: set' :: ASetter' s a -> a -> s -> s
+ Papa.Lens.Core: sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Optical p q f s t a b
+ Papa.Lens.Core: setting :: ((a -> b) -> s -> t) -> IndexPreservingSetter s t a b
+ Papa.Lens.Core: simple :: forall {k2} (a :: k2) k3 p (f :: k2 -> k3). p a (f a) -> p a (f a)
+ Papa.Lens.Core: snoc :: Snoc s s a a => s -> a -> s
+ Papa.Lens.Core: suffixed :: Suffixed t => t -> Prism' t t
+ Papa.Lens.Core: sumOf :: Num a => Getting (Endo (Endo a)) s a -> s -> a
+ Papa.Lens.Core: taking :: (Conjoined p, Applicative f) => Int -> Traversing p f s t a a -> Over p f s t a a
+ Papa.Lens.Core: takingWhile :: (Conjoined p, Applicative f) => (a -> Bool) -> Over p (TakingWhile p f a a) s t a a -> Over p f s t a a
+ Papa.Lens.Core: to :: (Profunctor p, Contravariant f) => (s -> a) -> Optic' p f s a
+ Papa.Lens.Core: toListOf :: Getting (Endo [a]) s a -> s -> [a]
+ Papa.Lens.Core: toNonEmptyOf :: Getting (NonEmptyDList a) s a -> s -> NonEmpty a
+ Papa.Lens.Core: transform :: Plated a => (a -> a) -> a -> a
+ Papa.Lens.Core: transformOf :: ASetter a b a b -> (b -> b) -> a -> b
+ Papa.Lens.Core: traverseMax :: TraverseMax k m => IndexedTraversal' k (m v) v
+ Papa.Lens.Core: traverseMin :: TraverseMin k m => IndexedTraversal' k (m v) v
+ Papa.Lens.Core: traverseOf :: LensLike f s t a b -> (a -> f b) -> s -> f t
+ Papa.Lens.Core: traverseOf_ :: Functor f => Getting (Traversed r f) s a -> (a -> f r) -> s -> f ()
+ Papa.Lens.Core: traversed :: forall (f :: Type -> Type) a b. Traversable f => IndexedTraversal Int (f a) (f b) a b
+ Papa.Lens.Core: traversed1 :: forall (f :: Type -> Type) a b. Traversable1 f => IndexedTraversal1 Int (f a) (f b) a b
+ Papa.Lens.Core: type ALens s t a b = LensLike Pretext (->) a b s t a b
+ Papa.Lens.Core: type ALens' s a = ALens s s a a
+ Papa.Lens.Core: type APrism s t a b = Market a b a Identity b -> Market a b s Identity t
+ Papa.Lens.Core: type APrism' s a = APrism s s a a
+ Papa.Lens.Core: type ASetter s t a b = a -> Identity b -> s -> Identity t
+ Papa.Lens.Core: type ASetter' s a = ASetter s s a a
+ Papa.Lens.Core: type ATraversal s t a b = LensLike Bazaar (->) a b s t a b
+ Papa.Lens.Core: type ATraversal' s a = ATraversal s s a a
+ Papa.Lens.Core: type AnIso s t a b = Exchange a b a Identity b -> Exchange a b s Identity t
+ Papa.Lens.Core: type AnIso' s a = AnIso s s a a
+ Papa.Lens.Core: type Getting r s a = a -> Const r a -> s -> Const r s
+ Papa.Lens.Core: type IndexedLens' i s a = IndexedLens i s s a a
+ Papa.Lens.Core: type IndexedTraversal' i s a = IndexedTraversal i s s a a
+ Papa.Lens.Core: type Iso' s a = Iso s s a a
+ Papa.Lens.Core: type Lens' s a = Lens s s a a
+ Papa.Lens.Core: type LensLike (f :: k -> Type) s (t :: k) a (b :: k) = a -> f b -> s -> f t
+ Papa.Lens.Core: type LensLike' (f :: Type -> Type) s a = LensLike f s s a a
+ Papa.Lens.Core: type Optic (p :: k -> k1 -> Type) (f :: k2 -> k1) (s :: k) (t :: k2) (a :: k) (b :: k2) = p a f b -> p s f t
+ Papa.Lens.Core: type Optic' (p :: k -> k1 -> Type) (f :: k -> k1) (s :: k) (a :: k) = Optic p f s s a a
+ Papa.Lens.Core: type Prism' s a = Prism s s a a
+ Papa.Lens.Core: type Setter' s a = Setter s s a a
+ Papa.Lens.Core: type Traversal' s a = Traversal s s a a
+ Papa.Lens.Core: type Traversal1' s a = Traversal1 s s a a
+ Papa.Lens.Core: type Setter s t a b = forall (f :: Type -> Type). Settable f => a -> f b -> s -> f t
+ Papa.Lens.Core: type family Unwrapped s
+ Papa.Lens.Core: type IndexedSetter i s t a b = forall (f :: Type -> Type) (p :: Type -> Type -> Type). (Indexable i p, Settable f) => p a f b -> s -> f t
+ Papa.Lens.Core: un :: (Profunctor p, Bifunctor p, Functor f) => Getting a s a -> Optic' p f a s
+ Papa.Lens.Core: uncons :: Cons s s a a => s -> Maybe (a, s)
+ Papa.Lens.Core: under :: AnIso s t a b -> (t -> s) -> b -> a
+ Papa.Lens.Core: united :: forall a f. Functor f => (() -> f ()) -> a -> f a
+ Papa.Lens.Core: universe :: Plated a => a -> [a]
+ Papa.Lens.Core: universeOf :: Getting (Endo [a]) a a -> a -> [a]
+ Papa.Lens.Core: unsnoc :: Snoc s s a a => s -> Maybe (s, a)
+ Papa.Lens.Core: unto :: (Profunctor p, Bifunctor p, Functor f) => (b -> t) -> Optic p f s t a b
+ Papa.Lens.Core: use :: MonadState s m => Getting a s a -> m a
+ Papa.Lens.Core: uses :: MonadState s m => LensLike' (Const r :: Type -> Type) s a -> (a -> r) -> m r
+ Papa.Lens.Core: view :: MonadReader s m => Getting a s a -> m a
+ Papa.Lens.Core: views :: MonadReader s m => LensLike' (Const r :: Type -> Type) s a -> (a -> r) -> m r
+ Papa.Lens.Core: withIso :: forall s t a b (rep :: RuntimeRep) (r :: TYPE rep). AnIso s t a b -> ((s -> a) -> (b -> t) -> r) -> r
+ Papa.Lens.Core: withPrism :: APrism s t a b -> ((b -> t) -> (s -> Either t a) -> r) -> r
+ Papa.Lens.Core: zoom :: Zoom m n s t => LensLike' (Zoomed m c) t s -> m c -> n c
+ Papa.Lens.Optic: the :: (forall f. (Contravariant f, Functor f) => LensLike' f s a) -> s -> a
+ Papa.Lens.System.IO.Error: _AlreadyExists :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _EOF :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _HardwareFault :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _IllegalOperation :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _InappropriateType :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _Interrupted :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _InvalidArgument :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _NoSuchThing :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _OtherError :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _PermissionDenied :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _ProtocolError :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _ResourceBusy :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _ResourceExhausted :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _ResourceVanished :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _SystemError :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _TimeExpired :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _UnsatisfiedConstraints :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _UnsupportedOperation :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: _UserError :: Prism' IOErrorType ()
+ Papa.Lens.System.IO.Error: description :: Lens' IOException String
+ Papa.Lens.System.IO.Error: errno :: Lens' IOException (Maybe CInt)
+ Papa.Lens.System.IO.Error: errorHandle :: Lens' IOException (Maybe Handle)
+ Papa.Lens.System.IO.Error: errorType :: Lens' IOException IOErrorType
+ Papa.Lens.System.IO.Error: fileName :: Lens' IOException (Maybe FilePath)
+ Papa.Lens.System.IO.Error: location :: Lens' IOException String
+ Papa.Semigroupoids: (.>>) :: Biapply p => p a b -> p c d -> p c d
+ Papa.Semigroupoids: (<<$>>) :: (a -> b) -> a -> b
+ Papa.Semigroupoids: (<<.) :: Biapply p => p a b -> p c d -> p a b
+ Papa.Semigroupoids: (<<..>>) :: Biapply p => p a c -> p (a -> b) (c -> d) -> p b d
+ Papa.Semigroupoids: (<<.>>) :: Biapply p => p (a -> b) (c -> d) -> p a c -> p b d
+ Papa.Semigroupoids: bifold1 :: (Bifoldable1 t, Semigroup m) => t m m -> m
+ Papa.Semigroupoids: bifoldMap1 :: (Bifoldable1 t, Semigroup m) => (a -> m) -> (b -> m) -> t a b -> m
+ Papa.Semigroupoids: bifoldMap1Default :: (Bitraversable1 t, Semigroup m) => (a -> m) -> (b -> m) -> t a b -> m
+ Papa.Semigroupoids: bifoldMapDefault1 :: (Bifoldable1 t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m
+ Papa.Semigroupoids: bifor1_ :: (Bifoldable1 t, Apply f) => t a c -> (a -> f b) -> (c -> f d) -> f ()
+ Papa.Semigroupoids: bilift2 :: Biapply w => (a -> b -> c) -> (d -> e -> f) -> w a d -> w b e -> w c f
+ Papa.Semigroupoids: bilift3 :: Biapply w => (a -> b -> c -> d) -> (e -> f -> g -> h) -> w a e -> w b f -> w c g -> w d h
+ Papa.Semigroupoids: bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
+ Papa.Semigroupoids: bisequence1 :: (Bitraversable1 t, Apply f) => t (f a) (f b) -> f (t a b)
+ Papa.Semigroupoids: bisequenceA1_ :: (Bifoldable1 t, Apply f) => t (f a) (f b) -> f ()
+ Papa.Semigroupoids: bitraverse1 :: (Bitraversable1 t, Apply f) => (a -> f b) -> (c -> f d) -> t a c -> f (t b d)
+ Papa.Semigroupoids: bitraverse1_ :: (Bifoldable1 t, Apply f) => (a -> f b) -> (c -> f d) -> t a c -> f ()
+ Papa.Semigroupoids: class Bifunctor p => Biapply (p :: Type -> Type -> Type)
+ Papa.Semigroupoids: class Bifoldable t => Bifoldable1 (t :: Type -> Type -> Type)
+ Papa.Semigroupoids: class forall a. () => Functor p a => Bifunctor (p :: Type -> Type -> Type)
+ Papa.Semigroupoids: class MonadTrans t => BindTrans (t :: Type -> Type -> Type -> Type)
+ Papa.Semigroupoids: class (Bifoldable1 t, Bitraversable t) => Bitraversable1 (t :: Type -> Type -> Type)
+ Papa.Semigroupoids: class Semigroupoid k1 => Groupoid (k1 :: k -> k -> Type)
+ Papa.Semigroupoids: class Semigroupoid k1 => Ob (k1 :: k -> k -> Type) (a :: k)
+ Papa.Semigroupoids: first :: Bifunctor p => (a -> b) -> p a c -> p b c
+ Papa.Semigroupoids: inv :: forall (a :: k) (b :: k). Groupoid k1 => k1 a b -> k1 b a
+ Papa.Semigroupoids: liftB :: (BindTrans t, Bind b) => b a -> t b a
+ Papa.Semigroupoids: second :: Bifunctor p => (b -> c) -> p a b -> p a c
+ Papa.Semigroupoids: semiid :: Ob k1 a => k1 a a
+ Papa.Stm.Control.Concurrent.STM: atomically :: STM a -> IO a
+ Papa.Stm.Control.Concurrent.STM: data () => STM a
+ Papa.Stm.Control.Concurrent.STM: data () => TVar a
+ Papa.Stm.Control.Concurrent.STM: modifyTVar' :: TVar a -> (a -> a) -> STM ()
+ Papa.Stm.Control.Concurrent.STM: newTVar :: a -> STM (TVar a)
+ Papa.Stm.Control.Concurrent.STM: newTVarIO :: a -> IO (TVar a)
+ Papa.Stm.Control.Concurrent.STM: orElse :: STM a -> STM a -> STM a
+ Papa.Stm.Control.Concurrent.STM: readTVar :: TVar a -> STM a
+ Papa.Stm.Control.Concurrent.STM: readTVarIO :: TVar a -> IO a
+ Papa.Stm.Control.Concurrent.STM: retry :: STM a
+ Papa.Stm.Control.Concurrent.STM: writeTVar :: TVar a -> a -> STM ()
+ Papa.Text.Data.Text: all :: (Char -> Bool) -> Text -> Bool
+ Papa.Text.Data.Text: any :: (Char -> Bool) -> Text -> Bool
+ Papa.Text.Data.Text: append :: Text -> Text -> Text
+ Papa.Text.Data.Text: break :: (Char -> Bool) -> Text -> (Text, Text)
+ Papa.Text.Data.Text: breakOn :: Text -> Text -> Maybe (Text, Text)
+ Papa.Text.Data.Text: breakOnAll :: Text -> Text -> Maybe [(Text, Text)]
+ Papa.Text.Data.Text: breakOnEnd :: Text -> Text -> Maybe (Text, Text)
+ Papa.Text.Data.Text: center :: Int -> Char -> Text -> Text
+ Papa.Text.Data.Text: chunksOf :: Int -> Text -> [Text]
+ Papa.Text.Data.Text: commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)
+ Papa.Text.Data.Text: compareLength :: Text -> Int -> Ordering
+ Papa.Text.Data.Text: concat :: [Text] -> Text
+ Papa.Text.Data.Text: concatMap :: (Char -> Text) -> Text -> Text
+ Papa.Text.Data.Text: cons :: Char -> Text -> Text
+ Papa.Text.Data.Text: copy :: Text -> Text
+ Papa.Text.Data.Text: count :: Text -> Text -> Maybe Int
+ Papa.Text.Data.Text: data () => Text
+ Papa.Text.Data.Text: display :: Show a => a -> Text
+ Papa.Text.Data.Text: displayExponent :: RealFloat a => Word -> a -> Text
+ Papa.Text.Data.Text: displayFixed :: RealFloat a => Word -> a -> Text
+ Papa.Text.Data.Text: drop :: Int -> Text -> Text
+ Papa.Text.Data.Text: dropAround :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text: dropEnd :: Int -> Text -> Text
+ Papa.Text.Data.Text: dropWhile :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text: dropWhileEnd :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text: elem :: Char -> Text -> Bool
+ Papa.Text.Data.Text: empty :: Text
+ Papa.Text.Data.Text: filter :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text: find :: (Char -> Bool) -> Text -> Maybe Char
+ Papa.Text.Data.Text: findIndex :: (Char -> Bool) -> Text -> Maybe Int
+ Papa.Text.Data.Text: foldl :: (a -> Char -> a) -> a -> Text -> a
+ Papa.Text.Data.Text: foldl' :: (a -> Char -> a) -> a -> Text -> a
+ Papa.Text.Data.Text: foldl1 :: (Char -> Char -> Char) -> Text -> Maybe Char
+ Papa.Text.Data.Text: foldl1' :: (Char -> Char -> Char) -> Text -> Maybe Char
+ Papa.Text.Data.Text: foldr :: (Char -> a -> a) -> a -> Text -> a
+ Papa.Text.Data.Text: foldr' :: (Char -> a -> a) -> a -> Text -> a
+ Papa.Text.Data.Text: foldr1 :: (Char -> Char -> Char) -> Text -> Maybe Char
+ Papa.Text.Data.Text: group :: Text -> [Text]
+ Papa.Text.Data.Text: groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
+ Papa.Text.Data.Text: head :: Text -> Maybe Char
+ Papa.Text.Data.Text: index :: Text -> Int -> Maybe Char
+ Papa.Text.Data.Text: infixr 5 `cons`
+ Papa.Text.Data.Text: init :: Text -> Maybe Text
+ Papa.Text.Data.Text: inits :: Text -> [Text]
+ Papa.Text.Data.Text: intercalate :: Text -> [Text] -> Text
+ Papa.Text.Data.Text: intersperse :: Char -> Text -> Text
+ Papa.Text.Data.Text: isAscii :: Text -> Bool
+ Papa.Text.Data.Text: isInfixOf :: Text -> Text -> Bool
+ Papa.Text.Data.Text: isPrefixOf :: Text -> Text -> Bool
+ Papa.Text.Data.Text: isSuffixOf :: Text -> Text -> Bool
+ Papa.Text.Data.Text: justifyLeft :: Int -> Char -> Text -> Text
+ Papa.Text.Data.Text: justifyRight :: Int -> Char -> Text -> Text
+ Papa.Text.Data.Text: last :: Text -> Maybe Char
+ Papa.Text.Data.Text: length :: Text -> Int
+ Papa.Text.Data.Text: lines :: Text -> [Text]
+ Papa.Text.Data.Text: map :: (Char -> Char) -> Text -> Text
+ Papa.Text.Data.Text: mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)
+ Papa.Text.Data.Text: mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)
+ Papa.Text.Data.Text: maximum :: Text -> Maybe Char
+ Papa.Text.Data.Text: measureOff :: Int -> Text -> Int
+ Papa.Text.Data.Text: minimum :: Text -> Maybe Char
+ Papa.Text.Data.Text: null :: Text -> Bool
+ Papa.Text.Data.Text: pack :: String -> Text
+ Papa.Text.Data.Text: partition :: (Char -> Bool) -> Text -> (Text, Text)
+ Papa.Text.Data.Text: readEither :: Read a => Text -> Either Text a
+ Papa.Text.Data.Text: readMaybe :: Read a => Text -> Maybe a
+ Papa.Text.Data.Text: replace :: Text -> Text -> Text -> Maybe Text
+ Papa.Text.Data.Text: replicate :: Int -> Text -> Text
+ Papa.Text.Data.Text: reverse :: Text -> Text
+ Papa.Text.Data.Text: scanl :: (Char -> Char -> Char) -> Char -> Text -> Text
+ Papa.Text.Data.Text: scanl1 :: (Char -> Char -> Char) -> Text -> Text
+ Papa.Text.Data.Text: scanr :: (Char -> Char -> Char) -> Char -> Text -> Text
+ Papa.Text.Data.Text: scanr1 :: (Char -> Char -> Char) -> Text -> Text
+ Papa.Text.Data.Text: singleton :: Char -> Text
+ Papa.Text.Data.Text: snoc :: Text -> Char -> Text
+ Papa.Text.Data.Text: span :: (Char -> Bool) -> Text -> (Text, Text)
+ Papa.Text.Data.Text: spanEndM :: Monad m => (Char -> m Bool) -> Text -> m (Text, Text)
+ Papa.Text.Data.Text: spanM :: Monad m => (Char -> m Bool) -> Text -> m (Text, Text)
+ Papa.Text.Data.Text: split :: (Char -> Bool) -> Text -> [Text]
+ Papa.Text.Data.Text: splitAt :: Int -> Text -> (Text, Text)
+ Papa.Text.Data.Text: splitOn :: Text -> Text -> Maybe [Text]
+ Papa.Text.Data.Text: strip :: Text -> Text
+ Papa.Text.Data.Text: stripEnd :: Text -> Text
+ Papa.Text.Data.Text: stripPrefix :: Text -> Text -> Maybe Text
+ Papa.Text.Data.Text: stripStart :: Text -> Text
+ Papa.Text.Data.Text: stripSuffix :: Text -> Text -> Maybe Text
+ Papa.Text.Data.Text: tail :: Text -> Maybe Text
+ Papa.Text.Data.Text: tails :: Text -> [Text]
+ Papa.Text.Data.Text: take :: Int -> Text -> Text
+ Papa.Text.Data.Text: takeEnd :: Int -> Text -> Text
+ Papa.Text.Data.Text: takeWhile :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text: takeWhileEnd :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text: toCaseFold :: Text -> Text
+ Papa.Text.Data.Text: toLower :: Text -> Text
+ Papa.Text.Data.Text: toTitle :: Text -> Text
+ Papa.Text.Data.Text: toUpper :: Text -> Text
+ Papa.Text.Data.Text: transpose :: [Text] -> [Text]
+ Papa.Text.Data.Text: uncons :: Text -> Maybe (Char, Text)
+ Papa.Text.Data.Text: unfoldr :: (a -> Maybe (Char, a)) -> a -> Text
+ Papa.Text.Data.Text: unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Text
+ Papa.Text.Data.Text: unlines :: [Text] -> Text
+ Papa.Text.Data.Text: unpack :: Text -> String
+ Papa.Text.Data.Text: unsnoc :: Text -> Maybe (Text, Char)
+ Papa.Text.Data.Text: unwords :: [Text] -> Text
+ Papa.Text.Data.Text: words :: Text -> [Text]
+ Papa.Text.Data.Text: zip :: Text -> Text -> [(Char, Char)]
+ Papa.Text.Data.Text: zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text
+ Papa.Text.Data.Text.Encoding: DecodeError :: String -> Maybe Word8 -> UnicodeException
+ Papa.Text.Data.Text.Encoding: Some :: !Text -> !ByteString -> (ByteString -> Decoding) -> Decoding
+ Papa.Text.Data.Text.Encoding: data () => Decoding
+ Papa.Text.Data.Text.Encoding: data () => StrictBuilder
+ Papa.Text.Data.Text.Encoding: data () => UnicodeException
+ Papa.Text.Data.Text.Encoding: data () => Utf8State
+ Papa.Text.Data.Text.Encoding: decodeASCII :: ByteString -> Maybe Text
+ Papa.Text.Data.Text.Encoding: decodeASCII' :: ByteString -> Maybe Text
+ Papa.Text.Data.Text.Encoding: decodeASCIIPrefix :: ByteString -> (Text, ByteString)
+ Papa.Text.Data.Text.Encoding: decodeLatin1 :: ByteString -> Text
+ Papa.Text.Data.Text.Encoding: decodeUtf16BE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Encoding: decodeUtf16BEWith :: OnDecodeError -> ByteString -> Text
+ Papa.Text.Data.Text.Encoding: decodeUtf16LE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Encoding: decodeUtf16LEWith :: OnDecodeError -> ByteString -> Text
+ Papa.Text.Data.Text.Encoding: decodeUtf32BE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Encoding: decodeUtf32BEWith :: OnDecodeError -> ByteString -> Text
+ Papa.Text.Data.Text.Encoding: decodeUtf32LE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Encoding: decodeUtf32LEWith :: OnDecodeError -> ByteString -> Text
+ Papa.Text.Data.Text.Encoding: decodeUtf8 :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Encoding: decodeUtf8' :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Encoding: decodeUtf8Chunk :: ByteString -> (StrictBuilder, ByteString, Maybe Utf8State)
+ Papa.Text.Data.Text.Encoding: decodeUtf8Lenient :: ByteString -> Text
+ Papa.Text.Data.Text.Encoding: decodeUtf8More :: Utf8State -> ByteString -> (StrictBuilder, ByteString, Maybe Utf8State)
+ Papa.Text.Data.Text.Encoding: decodeUtf8With :: OnDecodeError -> ByteString -> Text
+ Papa.Text.Data.Text.Encoding: encodeUtf16BE :: Text -> ByteString
+ Papa.Text.Data.Text.Encoding: encodeUtf16LE :: Text -> ByteString
+ Papa.Text.Data.Text.Encoding: encodeUtf32BE :: Text -> ByteString
+ Papa.Text.Data.Text.Encoding: encodeUtf32LE :: Text -> ByteString
+ Papa.Text.Data.Text.Encoding: encodeUtf8 :: Text -> ByteString
+ Papa.Text.Data.Text.Encoding: encodeUtf8Builder :: Text -> Builder
+ Papa.Text.Data.Text.Encoding: encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder
+ Papa.Text.Data.Text.Encoding: ignore :: OnError a b
+ Papa.Text.Data.Text.Encoding: lenientDecode :: OnDecodeError
+ Papa.Text.Data.Text.Encoding: replace :: b -> OnError a b
+ Papa.Text.Data.Text.Encoding: startUtf8State :: Utf8State
+ Papa.Text.Data.Text.Encoding: streamDecodeUtf8With :: OnDecodeError -> ByteString -> Decoding
+ Papa.Text.Data.Text.Encoding: strictBuilderToText :: StrictBuilder -> Text
+ Papa.Text.Data.Text.Encoding: textToStrictBuilder :: Text -> StrictBuilder
+ Papa.Text.Data.Text.Encoding: type OnDecodeError = OnError Word8 Char
+ Papa.Text.Data.Text.Encoding: type OnError a b = String -> Maybe a -> Maybe b
+ Papa.Text.Data.Text.Encoding: validateUtf8Chunk :: ByteString -> (Int, Maybe Utf8State)
+ Papa.Text.Data.Text.Encoding: validateUtf8More :: Utf8State -> ByteString -> (Int, Maybe Utf8State)
+ Papa.Text.Data.Text.IO: appendFile :: FilePath -> Text -> IOExcept ()
+ Papa.Text.Data.Text.IO: die :: Text -> IO a
+ Papa.Text.Data.Text.IO: getContents :: IOExcept Text
+ Papa.Text.Data.Text.IO: getLine :: IOExcept Text
+ Papa.Text.Data.Text.IO: hGetContents :: Handle -> IOExcept Text
+ Papa.Text.Data.Text.IO: hGetLine :: Handle -> IOExcept Text
+ Papa.Text.Data.Text.IO: hPrint :: Show a => Handle -> a -> IOExcept ()
+ Papa.Text.Data.Text.IO: hPutStr :: Handle -> Text -> IOExcept ()
+ Papa.Text.Data.Text.IO: hPutStrLn :: Handle -> Text -> IOExcept ()
+ Papa.Text.Data.Text.IO: interact :: (Text -> Text) -> IOExcept ()
+ Papa.Text.Data.Text.IO: print :: Show a => a -> IOExcept ()
+ Papa.Text.Data.Text.IO: putStr :: Text -> IOExcept ()
+ Papa.Text.Data.Text.IO: putStrLn :: Text -> IOExcept ()
+ Papa.Text.Data.Text.IO: readFile :: FilePath -> IOExcept Text
+ Papa.Text.Data.Text.IO: readIO :: Read a => Text -> IO (Maybe a)
+ Papa.Text.Data.Text.IO: writeFile :: FilePath -> Text -> IOExcept ()
+ Papa.Text.Data.Text.Lazy: all :: (Char -> Bool) -> Text -> Bool
+ Papa.Text.Data.Text.Lazy: any :: (Char -> Bool) -> Text -> Bool
+ Papa.Text.Data.Text.Lazy: append :: Text -> Text -> Text
+ Papa.Text.Data.Text.Lazy: break :: (Char -> Bool) -> Text -> (Text, Text)
+ Papa.Text.Data.Text.Lazy: breakOn :: Text -> Text -> Maybe (Text, Text)
+ Papa.Text.Data.Text.Lazy: breakOnAll :: Text -> Text -> Maybe [(Text, Text)]
+ Papa.Text.Data.Text.Lazy: breakOnEnd :: Text -> Text -> Maybe (Text, Text)
+ Papa.Text.Data.Text.Lazy: center :: Int64 -> Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: chunksOf :: Int64 -> Text -> [Text]
+ Papa.Text.Data.Text.Lazy: commonPrefixes :: Text -> Text -> Maybe (Text, Text, Text)
+ Papa.Text.Data.Text.Lazy: compareLength :: Text -> Int64 -> Ordering
+ Papa.Text.Data.Text.Lazy: concat :: [Text] -> Text
+ Papa.Text.Data.Text.Lazy: concatMap :: (Char -> Text) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: cons :: Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: count :: Text -> Text -> Maybe Int64
+ Papa.Text.Data.Text.Lazy: cycle :: Text -> Maybe Text
+ Papa.Text.Data.Text.Lazy: data () => Text
+ Papa.Text.Data.Text.Lazy: drop :: Int64 -> Text -> Text
+ Papa.Text.Data.Text.Lazy: dropAround :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: dropEnd :: Int64 -> Text -> Text
+ Papa.Text.Data.Text.Lazy: dropWhile :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: dropWhileEnd :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: elem :: Char -> Text -> Bool
+ Papa.Text.Data.Text.Lazy: empty :: Text
+ Papa.Text.Data.Text.Lazy: filter :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: find :: (Char -> Bool) -> Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: foldl :: (a -> Char -> a) -> a -> Text -> a
+ Papa.Text.Data.Text.Lazy: foldl' :: (a -> Char -> a) -> a -> Text -> a
+ Papa.Text.Data.Text.Lazy: foldl1 :: (Char -> Char -> Char) -> Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: foldl1' :: (Char -> Char -> Char) -> Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: foldlChunks :: (a -> Text -> a) -> a -> Text -> a
+ Papa.Text.Data.Text.Lazy: foldr :: (Char -> a -> a) -> a -> Text -> a
+ Papa.Text.Data.Text.Lazy: foldr1 :: (Char -> Char -> Char) -> Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: foldrChunks :: (Text -> a -> a) -> a -> Text -> a
+ Papa.Text.Data.Text.Lazy: fromChunks :: [Text] -> Text
+ Papa.Text.Data.Text.Lazy: fromStrict :: Text -> Text
+ Papa.Text.Data.Text.Lazy: group :: Text -> [Text]
+ Papa.Text.Data.Text.Lazy: groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
+ Papa.Text.Data.Text.Lazy: head :: Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: index :: Text -> Int64 -> Maybe Char
+ Papa.Text.Data.Text.Lazy: infixr 5 `cons`
+ Papa.Text.Data.Text.Lazy: init :: Text -> Maybe Text
+ Papa.Text.Data.Text.Lazy: inits :: Text -> [Text]
+ Papa.Text.Data.Text.Lazy: intercalate :: Text -> [Text] -> Text
+ Papa.Text.Data.Text.Lazy: intersperse :: Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: isAscii :: Text -> Bool
+ Papa.Text.Data.Text.Lazy: isInfixOf :: Text -> Text -> Bool
+ Papa.Text.Data.Text.Lazy: isPrefixOf :: Text -> Text -> Bool
+ Papa.Text.Data.Text.Lazy: isSuffixOf :: Text -> Text -> Bool
+ Papa.Text.Data.Text.Lazy: iterate :: (Char -> Char) -> Char -> Text
+ Papa.Text.Data.Text.Lazy: justifyLeft :: Int64 -> Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: justifyRight :: Int64 -> Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: last :: Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: length :: Text -> Int64
+ Papa.Text.Data.Text.Lazy: lines :: Text -> [Text]
+ Papa.Text.Data.Text.Lazy: map :: (Char -> Char) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: mapAccumL :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)
+ Papa.Text.Data.Text.Lazy: mapAccumR :: (a -> Char -> (a, Char)) -> a -> Text -> (a, Text)
+ Papa.Text.Data.Text.Lazy: maximum :: Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: minimum :: Text -> Maybe Char
+ Papa.Text.Data.Text.Lazy: null :: Text -> Bool
+ Papa.Text.Data.Text.Lazy: pack :: String -> Text
+ Papa.Text.Data.Text.Lazy: partition :: (Char -> Bool) -> Text -> (Text, Text)
+ Papa.Text.Data.Text.Lazy: repeat :: Char -> Text
+ Papa.Text.Data.Text.Lazy: replace :: Text -> Text -> Text -> Maybe Text
+ Papa.Text.Data.Text.Lazy: replicate :: Int64 -> Text -> Text
+ Papa.Text.Data.Text.Lazy: reverse :: Text -> Text
+ Papa.Text.Data.Text.Lazy: scanl :: (Char -> Char -> Char) -> Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: scanl1 :: (Char -> Char -> Char) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: scanr :: (Char -> Char -> Char) -> Char -> Text -> Text
+ Papa.Text.Data.Text.Lazy: scanr1 :: (Char -> Char -> Char) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: singleton :: Char -> Text
+ Papa.Text.Data.Text.Lazy: snoc :: Text -> Char -> Text
+ Papa.Text.Data.Text.Lazy: span :: (Char -> Bool) -> Text -> (Text, Text)
+ Papa.Text.Data.Text.Lazy: spanEndM :: Monad m => (Char -> m Bool) -> Text -> m (Text, Text)
+ Papa.Text.Data.Text.Lazy: spanM :: Monad m => (Char -> m Bool) -> Text -> m (Text, Text)
+ Papa.Text.Data.Text.Lazy: split :: (Char -> Bool) -> Text -> [Text]
+ Papa.Text.Data.Text.Lazy: splitAt :: Int64 -> Text -> (Text, Text)
+ Papa.Text.Data.Text.Lazy: splitOn :: Text -> Text -> Maybe [Text]
+ Papa.Text.Data.Text.Lazy: strip :: Text -> Text
+ Papa.Text.Data.Text.Lazy: stripEnd :: Text -> Text
+ Papa.Text.Data.Text.Lazy: stripPrefix :: Text -> Text -> Maybe Text
+ Papa.Text.Data.Text.Lazy: stripStart :: Text -> Text
+ Papa.Text.Data.Text.Lazy: stripSuffix :: Text -> Text -> Maybe Text
+ Papa.Text.Data.Text.Lazy: tail :: Text -> Maybe Text
+ Papa.Text.Data.Text.Lazy: tails :: Text -> [Text]
+ Papa.Text.Data.Text.Lazy: take :: Int64 -> Text -> Text
+ Papa.Text.Data.Text.Lazy: takeEnd :: Int64 -> Text -> Text
+ Papa.Text.Data.Text.Lazy: takeWhile :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: takeWhileEnd :: (Char -> Bool) -> Text -> Text
+ Papa.Text.Data.Text.Lazy: toCaseFold :: Text -> Text
+ Papa.Text.Data.Text.Lazy: toChunks :: Text -> [Text]
+ Papa.Text.Data.Text.Lazy: toLower :: Text -> Text
+ Papa.Text.Data.Text.Lazy: toStrict :: Text -> Text
+ Papa.Text.Data.Text.Lazy: toTitle :: Text -> Text
+ Papa.Text.Data.Text.Lazy: toUpper :: Text -> Text
+ Papa.Text.Data.Text.Lazy: transpose :: [Text] -> [Text]
+ Papa.Text.Data.Text.Lazy: uncons :: Text -> Maybe (Char, Text)
+ Papa.Text.Data.Text.Lazy: unfoldr :: (a -> Maybe (Char, a)) -> a -> Text
+ Papa.Text.Data.Text.Lazy: unfoldrN :: Int64 -> (a -> Maybe (Char, a)) -> a -> Text
+ Papa.Text.Data.Text.Lazy: unlines :: [Text] -> Text
+ Papa.Text.Data.Text.Lazy: unpack :: Text -> String
+ Papa.Text.Data.Text.Lazy: unsnoc :: Text -> Maybe (Text, Char)
+ Papa.Text.Data.Text.Lazy: unwords :: [Text] -> Text
+ Papa.Text.Data.Text.Lazy: words :: Text -> [Text]
+ Papa.Text.Data.Text.Lazy: zip :: Text -> Text -> [(Char, Char)]
+ Papa.Text.Data.Text.Lazy: zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text
+ Papa.Text.Data.Text.Lazy.Builder: data () => Builder
+ Papa.Text.Data.Text.Lazy.Builder: flush :: Builder
+ Papa.Text.Data.Text.Lazy.Builder: fromLazyText :: Text -> Builder
+ Papa.Text.Data.Text.Lazy.Builder: fromString :: String -> Builder
+ Papa.Text.Data.Text.Lazy.Builder: fromText :: Text -> Builder
+ Papa.Text.Data.Text.Lazy.Builder: singleton :: Char -> Builder
+ Papa.Text.Data.Text.Lazy.Builder: toLazyText :: Builder -> Text
+ Papa.Text.Data.Text.Lazy.Builder: toLazyTextWith :: Int -> Builder -> Text
+ Papa.Text.Data.Text.Lazy.Builder.Int: decimal :: Integral a => a -> Builder
+ Papa.Text.Data.Text.Lazy.Builder.Int: hexadecimal :: Integral a => a -> Maybe Builder
+ Papa.Text.Data.Text.Lazy.Encoding: decodeASCII :: ByteString -> Maybe Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeLatin1 :: ByteString -> Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf16BE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf16LE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf32BE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf32LE :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf8 :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf8' :: ByteString -> Either UnicodeException Text
+ Papa.Text.Data.Text.Lazy.Encoding: decodeUtf8With :: OnDecodeError -> ByteString -> Text
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf16BE :: Text -> ByteString
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf16LE :: Text -> ByteString
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf32BE :: Text -> ByteString
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf32LE :: Text -> ByteString
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf8 :: Text -> ByteString
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf8Builder :: Text -> Builder
+ Papa.Text.Data.Text.Lazy.Encoding: encodeUtf8BuilderEscaped :: BoundedPrim Word8 -> Text -> Builder
+ Papa.Text.Data.Text.Lazy.Read: decimal :: (Integral a, Bits a) => Reader a
+ Papa.Text.Data.Text.Lazy.Read: double :: Reader Double
+ Papa.Text.Data.Text.Lazy.Read: hexadecimal :: (Integral a, Bits a) => Reader a
+ Papa.Text.Data.Text.Lazy.Read: rational :: Fractional a => Reader a
+ Papa.Text.Data.Text.Lazy.Read: signed :: (Integral a, Bits a) => Reader Integer -> Reader a
+ Papa.Text.Data.Text.Lazy.Read: type Reader a = Text -> Either String (a, Text)
+ Papa.Text.Data.Text.Read: decimal :: (Integral a, Bits a) => Reader a
+ Papa.Text.Data.Text.Read: double :: Reader Double
+ Papa.Text.Data.Text.Read: hexadecimal :: (Integral a, Bits a) => Reader a
+ Papa.Text.Data.Text.Read: rational :: Fractional a => Reader a
+ Papa.Text.Data.Text.Read: signed :: (Integral a, Bits a) => Reader Integer -> Reader a
+ Papa.Text.Data.Text.Read: type Reader a = Text -> Either String (a, Text)
+ Papa.Time.Data.Time: addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime
+ Papa.Time.Data.Time: data () => Day
+ Papa.Time.Data.Time: data () => NominalDiffTime
+ Papa.Time.Data.Time: data () => UTCTime
+ Papa.Time.Data.Time: diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime
+ Papa.Time.Data.Time: getCurrentTime :: IO UTCTime
+ Papa.UnorderedContainers.Data.HashMap: (!?) :: Hashable k => HashMap k v -> k -> Maybe v
+ Papa.UnorderedContainers.Data.HashMap: adjust :: Hashable k => (v -> v) -> k -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: alter :: Hashable k => (Maybe v -> Maybe v) -> k -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: alterF :: (Functor f, Hashable k) => (Maybe v -> f (Maybe v)) -> k -> HashMap k v -> f (HashMap k v)
+ Papa.UnorderedContainers.Data.HashMap: compose :: Hashable b => HashMap b c -> HashMap a b -> HashMap a c
+ Papa.UnorderedContainers.Data.HashMap: data () => HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: delete :: Hashable k => k -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: difference :: Hashable k => HashMap k v -> HashMap k w -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: differenceWith :: Hashable k => (v -> w -> Maybe v) -> HashMap k v -> HashMap k w -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: differenceWithKey :: Eq k => (k -> v -> w -> Maybe v) -> HashMap k v -> HashMap k w -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: disjoint :: Eq k => HashMap k a -> HashMap k b -> Bool
+ Papa.UnorderedContainers.Data.HashMap: elems :: HashMap k v -> [v]
+ Papa.UnorderedContainers.Data.HashMap: empty :: HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: filter :: (v -> Bool) -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: filterWithKey :: (k -> v -> Bool) -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: findWithDefault :: Hashable k => v -> k -> HashMap k v -> v
+ Papa.UnorderedContainers.Data.HashMap: foldMapWithKey :: Monoid m => (k -> v -> m) -> HashMap k v -> m
+ Papa.UnorderedContainers.Data.HashMap: foldl :: (a -> v -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldl' :: (a -> v -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldlWithKey :: (a -> k -> v -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldlWithKey' :: (a -> k -> v -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldr :: (v -> a -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldr' :: (v -> a -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldrWithKey :: (k -> v -> a -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: foldrWithKey' :: (k -> v -> a -> a) -> a -> HashMap k v -> a
+ Papa.UnorderedContainers.Data.HashMap: fromList :: Hashable k => [(k, v)] -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: fromListWith :: Hashable k => (v -> v -> v) -> [(k, v)] -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: fromListWithKey :: Hashable k => (k -> v -> v -> v) -> [(k, v)] -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: insert :: Hashable k => k -> v -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: insertWith :: Hashable k => (v -> v -> v) -> k -> v -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: intersection :: Eq k => HashMap k v -> HashMap k w -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: intersectionWith :: Eq k => (v1 -> v2 -> v3) -> HashMap k v1 -> HashMap k v2 -> HashMap k v3
+ Papa.UnorderedContainers.Data.HashMap: intersectionWithKey :: Eq k => (k -> v1 -> v2 -> v3) -> HashMap k v1 -> HashMap k v2 -> HashMap k v3
+ Papa.UnorderedContainers.Data.HashMap: isSubmapOf :: (Hashable k, Eq v) => HashMap k v -> HashMap k v -> Bool
+ Papa.UnorderedContainers.Data.HashMap: isSubmapOfBy :: Hashable k => (v1 -> v2 -> Bool) -> HashMap k v1 -> HashMap k v2 -> Bool
+ Papa.UnorderedContainers.Data.HashMap: keys :: HashMap k v -> [k]
+ Papa.UnorderedContainers.Data.HashMap: keysSet :: HashMap k a -> HashSet k
+ Papa.UnorderedContainers.Data.HashMap: lookup :: Hashable k => k -> HashMap k v -> Maybe v
+ Papa.UnorderedContainers.Data.HashMap: lookupKey :: Hashable k => k -> HashMap k v -> Maybe k
+ Papa.UnorderedContainers.Data.HashMap: map :: (v1 -> v2) -> HashMap k v1 -> HashMap k v2
+ Papa.UnorderedContainers.Data.HashMap: mapKeys :: Hashable k2 => (k1 -> k2) -> HashMap k1 v -> HashMap k2 v
+ Papa.UnorderedContainers.Data.HashMap: mapMaybe :: (v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2
+ Papa.UnorderedContainers.Data.HashMap: mapMaybeWithKey :: (k -> v1 -> Maybe v2) -> HashMap k v1 -> HashMap k v2
+ Papa.UnorderedContainers.Data.HashMap: mapWithKey :: (k -> v1 -> v2) -> HashMap k v1 -> HashMap k v2
+ Papa.UnorderedContainers.Data.HashMap: member :: Hashable k => k -> HashMap k a -> Bool
+ Papa.UnorderedContainers.Data.HashMap: null :: HashMap k v -> Bool
+ Papa.UnorderedContainers.Data.HashMap: singleton :: Hashable k => k -> v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: size :: HashMap k v -> Int
+ Papa.UnorderedContainers.Data.HashMap: toList :: HashMap k v -> [(k, v)]
+ Papa.UnorderedContainers.Data.HashMap: traverseWithKey :: Applicative f => (k -> v1 -> f v2) -> HashMap k v1 -> f (HashMap k v2)
+ Papa.UnorderedContainers.Data.HashMap: union :: Eq k => HashMap k v -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: unionWith :: Eq k => (v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: unionWithKey :: Eq k => (k -> v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: unions :: Eq k => [HashMap k v] -> HashMap k v
+ Papa.UnorderedContainers.Data.HashMap: update :: Hashable k => (a -> Maybe a) -> k -> HashMap k a -> HashMap k a
+ Papa.Unsafe.Async: ExceptionInLinkedThread :: Async a -> SomeException -> ExceptionInLinkedThread
+ Papa.Unsafe.Async: data () => ExceptionInLinkedThread
+ Papa.Unsafe.Async: link :: Async a -> IO ()
+ Papa.Unsafe.Async: link2 :: Async a -> Async b -> IO ()
+ Papa.Unsafe.Async: link2Only :: (SomeException -> Bool) -> Async a -> Async b -> IO ()
+ Papa.Unsafe.Async: linkOnly :: (SomeException -> Bool) -> Async a -> IO ()
+ Papa.Unsafe.Async: wait :: Async a -> IO a
+ Papa.Unsafe.Async: waitAny :: [Async a] -> IO (Async a, a)
+ Papa.Unsafe.Async: waitAnyCancel :: [Async a] -> IO (Async a, a)
+ Papa.Unsafe.Async: waitAnySTM :: [Async a] -> STM (Async a, a)
+ Papa.Unsafe.Async: waitBoth :: Async a -> Async b -> IO (a, b)
+ Papa.Unsafe.Async: waitBothSTM :: Async a -> Async b -> STM (a, b)
+ Papa.Unsafe.Async: waitEither :: Async a -> Async b -> IO (Either a b)
+ Papa.Unsafe.Async: waitEitherCancel :: Async a -> Async b -> IO (Either a b)
+ Papa.Unsafe.Async: waitEitherSTM :: Async a -> Async b -> STM (Either a b)
+ Papa.Unsafe.Async: waitEitherSTM_ :: Async a -> Async b -> STM ()
+ Papa.Unsafe.Async: waitEither_ :: Async a -> Async b -> IO ()
+ Papa.Unsafe.Async: waitSTM :: Async a -> STM a
+ Papa.Unsafe.Exception: error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
+ Papa.Unsafe.Exception: errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a
+ Papa.Unsafe.Exception: throw :: forall (r :: RuntimeRep) (a :: TYPE r) e. Exception e => e -> a
+ Papa.Unsafe.Exception: throwing :: AReview SomeException b -> b -> r
+ Papa.Unsafe.Exception: throwing_ :: AReview SomeException () -> m x
+ Papa.Unsafe.Exception: undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
+ Papa.Unsafe.Format: hPrintf :: HPrintfType r => Handle -> String -> r
+ Papa.Unsafe.Format: printf :: PrintfType r => String -> r
+ Papa.Unsafe.Numeric: (%) :: Integral a => a -> a -> Ratio a
+ Papa.Unsafe.Numeric: (/) :: Fractional a => a -> a -> a
+ Papa.Unsafe.Numeric: (^) :: (Num a, Integral b) => a -> b -> a
+ Papa.Unsafe.Numeric: (^^) :: (Fractional a, Integral b) => a -> b -> a
+ Papa.Unsafe.Numeric: approxRational :: RealFrac a => a -> a -> Rational
+ Papa.Unsafe.Numeric: ceiling :: (RealFrac a, Integral b) => a -> b
+ Papa.Unsafe.Numeric: data () => Natural
+ Papa.Unsafe.Numeric: data () => Ratio a
+ Papa.Unsafe.Numeric: div :: Integral a => a -> a -> a
+ Papa.Unsafe.Numeric: divMod :: Integral a => a -> a -> (a, a)
+ Papa.Unsafe.Numeric: floor :: (RealFrac a, Integral b) => a -> b
+ Papa.Unsafe.Numeric: fromInteger :: Num a => Integer -> a
+ Papa.Unsafe.Numeric: fromIntegral :: (Integral a, Num b) => a -> b
+ Papa.Unsafe.Numeric: infixl 7 %
+ Papa.Unsafe.Numeric: infixr 8 ^^
+ Papa.Unsafe.Numeric: minusNaturalMaybe :: Natural -> Natural -> Maybe Natural
+ Papa.Unsafe.Numeric: mod :: Integral a => a -> a -> a
+ Papa.Unsafe.Numeric: properFraction :: (RealFrac a, Integral b) => a -> (b, a)
+ Papa.Unsafe.Numeric: quot :: Integral a => a -> a -> a
+ Papa.Unsafe.Numeric: quotRem :: Integral a => a -> a -> (a, a)
+ Papa.Unsafe.Numeric: realToFrac :: (Real a, Fractional b) => a -> b
+ Papa.Unsafe.Numeric: recip :: Fractional a => a -> a
+ Papa.Unsafe.Numeric: rem :: Integral a => a -> a -> a
+ Papa.Unsafe.Numeric: round :: (RealFrac a, Integral b) => a -> b
+ Papa.Unsafe.Numeric: toRational :: Real a => a -> Rational
+ Papa.Unsafe.Numeric: truncate :: (RealFrac a, Integral b) => a -> b
+ Papa.Vector.Data.Vector: (!?) :: Vector a -> Int -> Maybe a
+ Papa.Vector.Data.Vector: (++) :: Vector a -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: (//) :: Vector a -> [(Int, a)] -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: accum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: accumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: all :: (a -> Bool) -> Vector a -> Bool
+ Papa.Vector.Data.Vector: and :: Vector Bool -> Bool
+ Papa.Vector.Data.Vector: any :: (a -> Bool) -> Vector a -> Bool
+ Papa.Vector.Data.Vector: backpermute :: Vector a -> Vector Int -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: break :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: breakR :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: catMaybes :: Vector (Maybe a) -> Vector a
+ Papa.Vector.Data.Vector: cmpBy :: (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering
+ Papa.Vector.Data.Vector: concat :: [Vector a] -> Vector a
+ Papa.Vector.Data.Vector: concatMap :: (a -> Vector b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: cons :: a -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: constructN :: Int -> (Vector a -> a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: constructrN :: Int -> (Vector a -> a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: convert :: (Vector v a, Vector w a) => v a -> w a
+ Papa.Vector.Data.Vector: copy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector: create :: (forall s. () => ST s (MVector s a)) -> Vector a
+ Papa.Vector.Data.Vector: createT :: Traversable f => (forall s. () => ST s (f (MVector s a))) -> f (Vector a)
+ Papa.Vector.Data.Vector: data () => MVector s a
+ Papa.Vector.Data.Vector: data () => Vector a
+ Papa.Vector.Data.Vector: drop :: Int -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: dropWhile :: (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: elem :: Eq a => a -> Vector a -> Bool
+ Papa.Vector.Data.Vector: elemIndex :: Eq a => a -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: elemIndices :: Eq a => a -> Vector a -> Vector Int
+ Papa.Vector.Data.Vector: empty :: Vector a
+ Papa.Vector.Data.Vector: enumFromN :: Num a => a -> Int -> Vector a
+ Papa.Vector.Data.Vector: enumFromStepN :: Num a => a -> a -> Int -> Vector a
+ Papa.Vector.Data.Vector: enumFromThenTo :: Enum a => a -> a -> a -> Vector a
+ Papa.Vector.Data.Vector: enumFromTo :: Enum a => a -> a -> Vector a
+ Papa.Vector.Data.Vector: eqBy :: (a -> b -> Bool) -> Vector a -> Vector b -> Bool
+ Papa.Vector.Data.Vector: filter :: (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: filterM :: Monad m => (a -> m Bool) -> Vector a -> m (Vector a)
+ Papa.Vector.Data.Vector: find :: (a -> Bool) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: findIndex :: (a -> Bool) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: findIndexR :: (a -> Bool) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: findIndices :: (a -> Bool) -> Vector a -> Vector Int
+ Papa.Vector.Data.Vector: fold1M :: Monad m => (a -> a -> m a) -> Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector: fold1M' :: Monad m => (a -> a -> m a) -> Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector: fold1M'_ :: Monad m => (a -> a -> m a) -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector: fold1M_ :: Monad m => (a -> a -> m a) -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector: foldM :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector: foldM' :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector: foldM'_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector: foldM_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector: foldMap :: Monoid m => (a -> m) -> Vector a -> m
+ Papa.Vector.Data.Vector: foldMap' :: Monoid m => (a -> m) -> Vector a -> m
+ Papa.Vector.Data.Vector: foldl :: (a -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector: foldl' :: (a -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector: foldl1 :: (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: foldl1' :: (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: foldr :: (a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector: foldr' :: (a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector: foldr1 :: (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: foldr1' :: (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: forM :: Monad m => Vector a -> (a -> m b) -> m (Vector b)
+ Papa.Vector.Data.Vector: forM_ :: Monad m => Vector a -> (a -> m b) -> m ()
+ Papa.Vector.Data.Vector: force :: Vector a -> Vector a
+ Papa.Vector.Data.Vector: freeze :: PrimMonad m => MVector (PrimState m) a -> m (Vector a)
+ Papa.Vector.Data.Vector: fromArray :: Array a -> Vector a
+ Papa.Vector.Data.Vector: fromList :: [a] -> Vector a
+ Papa.Vector.Data.Vector: fromListN :: Int -> [a] -> Vector a
+ Papa.Vector.Data.Vector: generate :: Int -> (Int -> a) -> Vector a
+ Papa.Vector.Data.Vector: generateM :: Monad m => Int -> (Int -> m a) -> m (Vector a)
+ Papa.Vector.Data.Vector: group :: Eq a => Vector a -> [Vector a]
+ Papa.Vector.Data.Vector: groupBy :: (a -> a -> Bool) -> Vector a -> [Vector a]
+ Papa.Vector.Data.Vector: head :: Vector a -> Maybe a
+ Papa.Vector.Data.Vector: headM :: Monad m => Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector: ifilter :: (Int -> a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: ifoldM :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector: ifoldM' :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector: ifoldM'_ :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector: ifoldM_ :: Monad m => (a -> Int -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector: ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector: ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector: ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector: ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector: iforM :: Monad m => Vector a -> (Int -> a -> m b) -> m (Vector b)
+ Papa.Vector.Data.Vector: iforM_ :: Monad m => Vector a -> (Int -> a -> m b) -> m ()
+ Papa.Vector.Data.Vector: imap :: (Int -> a -> b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: imapM :: Monad m => (Int -> a -> m b) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector: imapM_ :: Monad m => (Int -> a -> m b) -> Vector a -> m ()
+ Papa.Vector.Data.Vector: imapMaybe :: (Int -> a -> Maybe b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: imapMaybeM :: Monad m => (Int -> a -> m (Maybe b)) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector: indexM :: Monad m => Vector a -> Int -> m (Maybe a)
+ Papa.Vector.Data.Vector: indexed :: Vector a -> Vector (Int, a)
+ Papa.Vector.Data.Vector: infix 4 `notElem`
+ Papa.Vector.Data.Vector: infixl 9 //
+ Papa.Vector.Data.Vector: infixr 5 ++
+ Papa.Vector.Data.Vector: init :: Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: iscanl :: (Int -> a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: iscanl' :: (Int -> a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: iscanr :: (Int -> a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: iscanr' :: (Int -> a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: iterateN :: Int -> (a -> a) -> a -> Vector a
+ Papa.Vector.Data.Vector: iterateNM :: Monad m => Int -> (a -> m a) -> a -> m (Vector a)
+ Papa.Vector.Data.Vector: izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c
+ Papa.Vector.Data.Vector: izipWith3 :: (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
+ Papa.Vector.Data.Vector: izipWith4 :: (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
+ Papa.Vector.Data.Vector: izipWith5 :: (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
+ Papa.Vector.Data.Vector: izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
+ Papa.Vector.Data.Vector: izipWithM :: Monad m => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
+ Papa.Vector.Data.Vector: izipWithM_ :: Monad m => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m ()
+ Papa.Vector.Data.Vector: last :: Vector a -> Maybe a
+ Papa.Vector.Data.Vector: lastM :: Monad m => Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector: length :: Vector a -> Int
+ Papa.Vector.Data.Vector: map :: (a -> b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: mapM :: Monad m => (a -> m b) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector: mapM_ :: Monad m => (a -> m b) -> Vector a -> m ()
+ Papa.Vector.Data.Vector: mapMaybe :: (a -> Maybe b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: mapMaybeM :: Monad m => (a -> m (Maybe b)) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector: maxIndex :: Ord a => Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: maximum :: Ord a => Vector a -> Maybe a
+ Papa.Vector.Data.Vector: maximumBy :: (a -> a -> Ordering) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: maximumOn :: Ord b => (a -> b) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: minIndex :: Ord a => Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: minIndexBy :: (a -> a -> Ordering) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector: minimum :: Ord a => Vector a -> Maybe a
+ Papa.Vector.Data.Vector: minimumBy :: (a -> a -> Ordering) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: minimumOn :: Ord b => (a -> b) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector: modify :: (forall s. () => MVector s a -> ST s ()) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: notElem :: Eq a => a -> Vector a -> Bool
+ Papa.Vector.Data.Vector: null :: Vector a -> Bool
+ Papa.Vector.Data.Vector: or :: Vector Bool -> Bool
+ Papa.Vector.Data.Vector: partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: partitionWith :: (a -> Either b c) -> Vector a -> (Vector b, Vector c)
+ Papa.Vector.Data.Vector: postscanl :: (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: postscanr :: (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: postscanr' :: (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: prescanl :: (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: prescanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: prescanr :: (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: prescanr' :: (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: product :: Num a => Vector a -> a
+ Papa.Vector.Data.Vector: replicate :: Int -> a -> Vector a
+ Papa.Vector.Data.Vector: replicateM :: Monad m => Int -> m a -> m (Vector a)
+ Papa.Vector.Data.Vector: reverse :: Vector a -> Vector a
+ Papa.Vector.Data.Vector: scanl :: (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: scanl' :: (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector: scanl1 :: (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: scanl1' :: (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: scanr :: (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: scanr' :: (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector: scanr1 :: (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: scanr1' :: (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: sequence :: Monad m => Vector (m a) -> m (Vector a)
+ Papa.Vector.Data.Vector: sequence_ :: Monad m => Vector (m a) -> m ()
+ Papa.Vector.Data.Vector: singleton :: a -> Vector a
+ Papa.Vector.Data.Vector: slice :: Int -> Int -> Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: snoc :: Vector a -> a -> Vector a
+ Papa.Vector.Data.Vector: span :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: spanR :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: splitAt :: Int -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: sum :: Num a => Vector a -> a
+ Papa.Vector.Data.Vector: tail :: Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: take :: Int -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: takeWhile :: (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector: thaw :: PrimMonad m => Vector a -> m (MVector (PrimState m) a)
+ Papa.Vector.Data.Vector: toArray :: Vector a -> Array a
+ Papa.Vector.Data.Vector: toArraySlice :: Vector a -> (Array a, Int, Int)
+ Papa.Vector.Data.Vector: toList :: Vector a -> [a]
+ Papa.Vector.Data.Vector: uncons :: Vector a -> Maybe (a, Vector a)
+ Papa.Vector.Data.Vector: unfoldr :: (b -> Maybe (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector: unfoldrExactN :: Int -> (b -> (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector: unfoldrExactNM :: Monad m => Int -> (b -> m (a, b)) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector: unfoldrM :: Monad m => (b -> m (Maybe (a, b))) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector: unfoldrN :: Int -> (b -> Maybe (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector: unfoldrNM :: Monad m => Int -> (b -> m (Maybe (a, b))) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector: uniq :: Eq a => Vector a -> Vector a
+ Papa.Vector.Data.Vector: unsnoc :: Vector a -> Maybe (Vector a, a)
+ Papa.Vector.Data.Vector: unstablePartition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector: unzip :: Vector (a, b) -> (Vector a, Vector b)
+ Papa.Vector.Data.Vector: unzip3 :: Vector (a, b, c) -> (Vector a, Vector b, Vector c)
+ Papa.Vector.Data.Vector: unzip4 :: Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)
+ Papa.Vector.Data.Vector: unzip5 :: Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)
+ Papa.Vector.Data.Vector: unzip6 :: Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)
+ Papa.Vector.Data.Vector: update :: Vector a -> Vector (Int, a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: update_ :: Vector a -> Vector Int -> Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector: zip :: Vector a -> Vector b -> Vector (a, b)
+ Papa.Vector.Data.Vector: zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)
+ Papa.Vector.Data.Vector: zip4 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)
+ Papa.Vector.Data.Vector: zip5 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)
+ Papa.Vector.Data.Vector: zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)
+ Papa.Vector.Data.Vector: zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c
+ Papa.Vector.Data.Vector: zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
+ Papa.Vector.Data.Vector: zipWith4 :: (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
+ Papa.Vector.Data.Vector: zipWith5 :: (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
+ Papa.Vector.Data.Vector: zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
+ Papa.Vector.Data.Vector: zipWithM :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
+ Papa.Vector.Data.Vector: zipWithM_ :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Generic: (!?) :: Vector v a => v a -> Int -> Maybe a
+ Papa.Vector.Data.Vector.Generic: (++) :: Vector v a => v a -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: (//) :: Vector v a => v a -> [(Int, a)] -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: accum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: accumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: accumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: all :: Vector v a => (a -> Bool) -> v a -> Bool
+ Papa.Vector.Data.Vector.Generic: and :: Vector v Bool => v Bool -> Bool
+ Papa.Vector.Data.Vector.Generic: any :: Vector v a => (a -> Bool) -> v a -> Bool
+ Papa.Vector.Data.Vector.Generic: backpermute :: (Vector v a, Vector v Int) => v a -> v Int -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: break :: Vector v a => (a -> Bool) -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: breakR :: Vector v a => (a -> Bool) -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: class MVector Mutable v a => Vector (v :: Type -> Type) a
+ Papa.Vector.Data.Vector.Generic: clone :: Vector v a => v a -> New v a
+ Papa.Vector.Data.Vector.Generic: cmp :: (Vector v a, Ord a) => v a -> v a -> Ordering
+ Papa.Vector.Data.Vector.Generic: cmpBy :: (Vector v a, Vector v b) => (a -> b -> Ordering) -> v a -> v b -> Ordering
+ Papa.Vector.Data.Vector.Generic: concat :: Vector v a => [v a] -> v a
+ Papa.Vector.Data.Vector.Generic: concatMap :: (Vector v a, Vector v b) => (a -> v b) -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: concatNE :: Vector v a => NonEmpty (v a) -> v a
+ Papa.Vector.Data.Vector.Generic: cons :: Vector v a => a -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: constructN :: Vector v a => Int -> (v a -> a) -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: constructrN :: Vector v a => Int -> (v a -> a) -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: convert :: (Vector v a, Vector w a) => v a -> w a
+ Papa.Vector.Data.Vector.Generic: copy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Generic: create :: Vector v a => (forall s. () => ST s (Mutable v s a)) -> v a
+ Papa.Vector.Data.Vector.Generic: createT :: (Traversable f, Vector v a) => (forall s. () => ST s (f (Mutable v s a))) -> f (v a)
+ Papa.Vector.Data.Vector.Generic: dataCast :: (Vector v a, Data a, Typeable v, Typeable t) => (forall d. Data d => c (t d)) -> Maybe (c (v a))
+ Papa.Vector.Data.Vector.Generic: drop :: Vector v a => Int -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: dropWhile :: Vector v a => (a -> Bool) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: elem :: (Vector v a, Eq a) => a -> v a -> Bool
+ Papa.Vector.Data.Vector.Generic: elemIndex :: (Vector v a, Eq a) => a -> v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: elemIndices :: (Vector v a, Vector v Int, Eq a) => a -> v a -> v Int
+ Papa.Vector.Data.Vector.Generic: empty :: Vector v a => v a
+ Papa.Vector.Data.Vector.Generic: enumFromN :: (Vector v a, Num a) => a -> Int -> v a
+ Papa.Vector.Data.Vector.Generic: enumFromStepN :: (Vector v a, Num a) => a -> a -> Int -> v a
+ Papa.Vector.Data.Vector.Generic: enumFromThenTo :: (Vector v a, Enum a) => a -> a -> a -> v a
+ Papa.Vector.Data.Vector.Generic: enumFromTo :: (Vector v a, Enum a) => a -> a -> v a
+ Papa.Vector.Data.Vector.Generic: eq :: (Vector v a, Eq a) => v a -> v a -> Bool
+ Papa.Vector.Data.Vector.Generic: eqBy :: (Vector v a, Vector v b) => (a -> b -> Bool) -> v a -> v b -> Bool
+ Papa.Vector.Data.Vector.Generic: filter :: Vector v a => (a -> Bool) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: filterM :: (Monad m, Vector v a) => (a -> m Bool) -> v a -> m (v a)
+ Papa.Vector.Data.Vector.Generic: find :: Vector v a => (a -> Bool) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: findIndex :: Vector v a => (a -> Bool) -> v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: findIndexR :: Vector v a => (a -> Bool) -> v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: findIndices :: (Vector v a, Vector v Int) => (a -> Bool) -> v a -> v Int
+ Papa.Vector.Data.Vector.Generic: fold1M :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Generic: fold1M' :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Generic: fold1M'_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Generic: fold1M_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Generic: foldM :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a
+ Papa.Vector.Data.Vector.Generic: foldM' :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a
+ Papa.Vector.Data.Vector.Generic: foldM'_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()
+ Papa.Vector.Data.Vector.Generic: foldM_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()
+ Papa.Vector.Data.Vector.Generic: foldMap :: (Monoid m, Vector v a) => (a -> m) -> v a -> m
+ Papa.Vector.Data.Vector.Generic: foldMap' :: (Monoid m, Vector v a) => (a -> m) -> v a -> m
+ Papa.Vector.Data.Vector.Generic: foldl :: Vector v b => (a -> b -> a) -> a -> v b -> a
+ Papa.Vector.Data.Vector.Generic: foldl' :: Vector v b => (a -> b -> a) -> a -> v b -> a
+ Papa.Vector.Data.Vector.Generic: foldl1 :: Vector v a => (a -> a -> a) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: foldl1' :: Vector v a => (a -> a -> a) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: foldr :: Vector v a => (a -> b -> b) -> b -> v a -> b
+ Papa.Vector.Data.Vector.Generic: foldr' :: Vector v a => (a -> b -> b) -> b -> v a -> b
+ Papa.Vector.Data.Vector.Generic: foldr1 :: Vector v a => (a -> a -> a) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: foldr1' :: Vector v a => (a -> a -> a) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: forM :: (Monad m, Vector v a, Vector v b) => v a -> (a -> m b) -> m (v b)
+ Papa.Vector.Data.Vector.Generic: forM_ :: (Monad m, Vector v a) => v a -> (a -> m b) -> m ()
+ Papa.Vector.Data.Vector.Generic: force :: Vector v a => v a -> v a
+ Papa.Vector.Data.Vector.Generic: freeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)
+ Papa.Vector.Data.Vector.Generic: fromList :: Vector v a => [a] -> v a
+ Papa.Vector.Data.Vector.Generic: fromListN :: Vector v a => Int -> [a] -> v a
+ Papa.Vector.Data.Vector.Generic: generate :: Vector v a => Int -> (Int -> a) -> v a
+ Papa.Vector.Data.Vector.Generic: generateM :: (Monad m, Vector v a) => Int -> (Int -> m a) -> m (v a)
+ Papa.Vector.Data.Vector.Generic: gfoldl :: (Vector v a, Data a) => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. () => g -> c g) -> v a -> c (v a)
+ Papa.Vector.Data.Vector.Generic: group :: (Vector v a, Eq a) => v a -> [v a]
+ Papa.Vector.Data.Vector.Generic: groupBy :: Vector v a => (a -> a -> Bool) -> v a -> [v a]
+ Papa.Vector.Data.Vector.Generic: head :: Vector v a => v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: headM :: (Vector v a, Monad m) => v a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Generic: ifilter :: Vector v a => (Int -> a -> Bool) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: ifoldM :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m a
+ Papa.Vector.Data.Vector.Generic: ifoldM' :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m a
+ Papa.Vector.Data.Vector.Generic: ifoldM'_ :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m ()
+ Papa.Vector.Data.Vector.Generic: ifoldM_ :: (Monad m, Vector v b) => (a -> Int -> b -> m a) -> a -> v b -> m ()
+ Papa.Vector.Data.Vector.Generic: ifoldl :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a
+ Papa.Vector.Data.Vector.Generic: ifoldl' :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a
+ Papa.Vector.Data.Vector.Generic: ifoldr :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b
+ Papa.Vector.Data.Vector.Generic: ifoldr' :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b
+ Papa.Vector.Data.Vector.Generic: iforM :: (Monad m, Vector v a, Vector v b) => v a -> (Int -> a -> m b) -> m (v b)
+ Papa.Vector.Data.Vector.Generic: iforM_ :: (Monad m, Vector v a) => v a -> (Int -> a -> m b) -> m ()
+ Papa.Vector.Data.Vector.Generic: imap :: (Vector v a, Vector v b) => (Int -> a -> b) -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: imapM :: (Monad m, Vector v a, Vector v b) => (Int -> a -> m b) -> v a -> m (v b)
+ Papa.Vector.Data.Vector.Generic: imapM_ :: (Monad m, Vector v a) => (Int -> a -> m b) -> v a -> m ()
+ Papa.Vector.Data.Vector.Generic: imapMaybe :: (Vector v a, Vector v b) => (Int -> a -> Maybe b) -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: imapMaybeM :: (Monad m, Vector v a, Vector v b) => (Int -> a -> m (Maybe b)) -> v a -> m (v b)
+ Papa.Vector.Data.Vector.Generic: indexM :: (Vector v a, Monad m) => v a -> Int -> m (Maybe a)
+ Papa.Vector.Data.Vector.Generic: indexed :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a)
+ Papa.Vector.Data.Vector.Generic: infix 4 `notElem`
+ Papa.Vector.Data.Vector.Generic: infixl 9 //
+ Papa.Vector.Data.Vector.Generic: infixr 5 ++
+ Papa.Vector.Data.Vector.Generic: init :: Vector v a => v a -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: iscanl :: (Vector v a, Vector v b) => (Int -> a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: iscanl' :: (Vector v a, Vector v b) => (Int -> a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: iscanr :: (Vector v a, Vector v b) => (Int -> a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: iscanr' :: (Vector v a, Vector v b) => (Int -> a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: iterateN :: Vector v a => Int -> (a -> a) -> a -> v a
+ Papa.Vector.Data.Vector.Generic: iterateNM :: (Monad m, Vector v a) => Int -> (a -> m a) -> a -> m (v a)
+ Papa.Vector.Data.Vector.Generic: izipWith :: (Vector v a, Vector v b, Vector v c) => (Int -> a -> b -> c) -> v a -> v b -> v c
+ Papa.Vector.Data.Vector.Generic: izipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (Int -> a -> b -> c -> d) -> v a -> v b -> v c -> v d
+ Papa.Vector.Data.Vector.Generic: izipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (Int -> a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
+ Papa.Vector.Data.Vector.Generic: izipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (Int -> a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f
+ Papa.Vector.Data.Vector.Generic: izipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g
+ Papa.Vector.Data.Vector.Generic: izipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (Int -> a -> b -> m c) -> v a -> v b -> m (v c)
+ Papa.Vector.Data.Vector.Generic: izipWithM_ :: (Monad m, Vector v a, Vector v b) => (Int -> a -> b -> m c) -> v a -> v b -> m ()
+ Papa.Vector.Data.Vector.Generic: last :: Vector v a => v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: lastM :: (Vector v a, Monad m) => v a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Generic: length :: Vector v a => v a -> Int
+ Papa.Vector.Data.Vector.Generic: liftReadsPrec :: Vector v a => (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (v a)
+ Papa.Vector.Data.Vector.Generic: liftShowsPrec :: Vector v a => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> v a -> ShowS
+ Papa.Vector.Data.Vector.Generic: map :: (Vector v a, Vector v b) => (a -> b) -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: mapM :: (Monad m, Vector v a, Vector v b) => (a -> m b) -> v a -> m (v b)
+ Papa.Vector.Data.Vector.Generic: mapM_ :: (Monad m, Vector v a) => (a -> m b) -> v a -> m ()
+ Papa.Vector.Data.Vector.Generic: mapMaybe :: (Vector v a, Vector v b) => (a -> Maybe b) -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: mapMaybeM :: (Monad m, Vector v a, Vector v b) => (a -> m (Maybe b)) -> v a -> m (v b)
+ Papa.Vector.Data.Vector.Generic: maxIndex :: (Vector v a, Ord a) => v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: maxIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: maximum :: (Vector v a, Ord a) => v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: maximumBy :: Vector v a => (a -> a -> Ordering) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: maximumOn :: (Ord b, Vector v a) => (a -> b) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: minIndex :: (Vector v a, Ord a) => v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: minIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Maybe Int
+ Papa.Vector.Data.Vector.Generic: minimum :: (Vector v a, Ord a) => v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: minimumBy :: Vector v a => (a -> a -> Ordering) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: minimumOn :: (Ord b, Vector v a) => (a -> b) -> v a -> Maybe a
+ Papa.Vector.Data.Vector.Generic: mkVecConstr :: String -> Constr
+ Papa.Vector.Data.Vector.Generic: mkVecType :: String -> DataType
+ Papa.Vector.Data.Vector.Generic: modify :: Vector v a => (forall s. () => Mutable v s a -> ST s ()) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: new :: Vector v a => New v a -> v a
+ Papa.Vector.Data.Vector.Generic: notElem :: (Vector v a, Eq a) => a -> v a -> Bool
+ Papa.Vector.Data.Vector.Generic: null :: Vector v a => v a -> Bool
+ Papa.Vector.Data.Vector.Generic: or :: Vector v Bool => v Bool -> Bool
+ Papa.Vector.Data.Vector.Generic: partition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: partitionWith :: (Vector v a, Vector v b, Vector v c) => (a -> Either b c) -> v a -> (v b, v c)
+ Papa.Vector.Data.Vector.Generic: postscanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: postscanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: postscanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: postscanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: prescanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: prescanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: prescanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: prescanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: product :: (Vector v a, Num a) => v a -> a
+ Papa.Vector.Data.Vector.Generic: readPrec :: (Vector v a, Read a) => ReadPrec (v a)
+ Papa.Vector.Data.Vector.Generic: replicate :: Vector v a => Int -> a -> v a
+ Papa.Vector.Data.Vector.Generic: replicateM :: (Monad m, Vector v a) => Int -> m a -> m (v a)
+ Papa.Vector.Data.Vector.Generic: reverse :: Vector v a => v a -> v a
+ Papa.Vector.Data.Vector.Generic: scanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: scanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a
+ Papa.Vector.Data.Vector.Generic: scanl1 :: Vector v a => (a -> a -> a) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: scanl1' :: Vector v a => (a -> a -> a) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: scanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: scanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b
+ Papa.Vector.Data.Vector.Generic: scanr1 :: Vector v a => (a -> a -> a) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: scanr1' :: Vector v a => (a -> a -> a) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: sequence :: (Monad m, Vector v a, Vector v (m a)) => v (m a) -> m (v a)
+ Papa.Vector.Data.Vector.Generic: sequence_ :: (Monad m, Vector v (m a)) => v (m a) -> m ()
+ Papa.Vector.Data.Vector.Generic: showsPrec :: (Vector v a, Show a) => Int -> v a -> ShowS
+ Papa.Vector.Data.Vector.Generic: singleton :: Vector v a => a -> v a
+ Papa.Vector.Data.Vector.Generic: slice :: Vector v a => Int -> Int -> v a -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: snoc :: Vector v a => v a -> a -> v a
+ Papa.Vector.Data.Vector.Generic: span :: Vector v a => (a -> Bool) -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: spanR :: Vector v a => (a -> Bool) -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: splitAt :: Vector v a => Int -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: stream :: Vector v a => v a -> Bundle v a
+ Papa.Vector.Data.Vector.Generic: streamR :: forall v a (u :: Type -> Type). Vector v a => v a -> Bundle u a
+ Papa.Vector.Data.Vector.Generic: sum :: (Vector v a, Num a) => v a -> a
+ Papa.Vector.Data.Vector.Generic: tail :: Vector v a => v a -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: take :: Vector v a => Int -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: takeWhile :: Vector v a => (a -> Bool) -> v a -> v a
+ Papa.Vector.Data.Vector.Generic: thaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)
+ Papa.Vector.Data.Vector.Generic: toList :: Vector v a => v a -> [a]
+ Papa.Vector.Data.Vector.Generic: type family Mutable (v :: Type -> Type) = (mv :: Type -> Type -> Type) | mv -> v
+ Papa.Vector.Data.Vector.Generic: uncons :: Vector v a => v a -> Maybe (a, v a)
+ Papa.Vector.Data.Vector.Generic: unfoldr :: Vector v a => (b -> Maybe (a, b)) -> b -> v a
+ Papa.Vector.Data.Vector.Generic: unfoldrExactN :: Vector v a => Int -> (b -> (a, b)) -> b -> v a
+ Papa.Vector.Data.Vector.Generic: unfoldrExactNM :: (Monad m, Vector v a) => Int -> (b -> m (a, b)) -> b -> m (v a)
+ Papa.Vector.Data.Vector.Generic: unfoldrM :: (Monad m, Vector v a) => (b -> m (Maybe (a, b))) -> b -> m (v a)
+ Papa.Vector.Data.Vector.Generic: unfoldrN :: Vector v a => Int -> (b -> Maybe (a, b)) -> b -> v a
+ Papa.Vector.Data.Vector.Generic: unfoldrNM :: (Monad m, Vector v a) => Int -> (b -> m (Maybe (a, b))) -> b -> m (v a)
+ Papa.Vector.Data.Vector.Generic: uniq :: (Vector v a, Eq a) => v a -> v a
+ Papa.Vector.Data.Vector.Generic: unsnoc :: Vector v a => v a -> Maybe (v a, a)
+ Papa.Vector.Data.Vector.Generic: unstablePartition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)
+ Papa.Vector.Data.Vector.Generic: unstream :: Vector v a => Bundle v a -> v a
+ Papa.Vector.Data.Vector.Generic: unstreamM :: forall m v a (u :: Type -> Type). (Monad m, Vector v a) => MBundle m u a -> m (v a)
+ Papa.Vector.Data.Vector.Generic: unstreamR :: Vector v a => Bundle v a -> v a
+ Papa.Vector.Data.Vector.Generic: unzip :: (Vector v a, Vector v b, Vector v (a, b)) => v (a, b) -> (v a, v b)
+ Papa.Vector.Data.Vector.Generic: unzip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v (a, b, c) -> (v a, v b, v c)
+ Papa.Vector.Data.Vector.Generic: unzip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v (a, b, c, d) -> (v a, v b, v c, v d)
+ Papa.Vector.Data.Vector.Generic: unzip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v (a, b, c, d, e) -> (v a, v b, v c, v d, v e)
+ Papa.Vector.Data.Vector.Generic: unzip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v (a, b, c, d, e, f) -> (v a, v b, v c, v d, v e, v f)
+ Papa.Vector.Data.Vector.Generic: update :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: update_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> Maybe (v a)
+ Papa.Vector.Data.Vector.Generic: zip :: (Vector v a, Vector v b, Vector v (a, b)) => v a -> v b -> v (a, b)
+ Papa.Vector.Data.Vector.Generic: zip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v a -> v b -> v c -> v (a, b, c)
+ Papa.Vector.Data.Vector.Generic: zip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v a -> v b -> v c -> v d -> v (a, b, c, d)
+ Papa.Vector.Data.Vector.Generic: zip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v a -> v b -> v c -> v d -> v e -> v (a, b, c, d, e)
+ Papa.Vector.Data.Vector.Generic: zip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v a -> v b -> v c -> v d -> v e -> v f -> v (a, b, c, d, e, f)
+ Papa.Vector.Data.Vector.Generic: zipWith :: (Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> v a -> v b -> v c
+ Papa.Vector.Data.Vector.Generic: zipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (a -> b -> c -> d) -> v a -> v b -> v c -> v d
+ Papa.Vector.Data.Vector.Generic: zipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e
+ Papa.Vector.Data.Vector.Generic: zipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f
+ Papa.Vector.Data.Vector.Generic: zipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g
+ Papa.Vector.Data.Vector.Generic: zipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (a -> b -> m c) -> v a -> v b -> m (v c)
+ Papa.Vector.Data.Vector.Generic: zipWithM_ :: (Monad m, Vector v a, Vector v b) => (a -> b -> m c) -> v a -> v b -> m ()
+ Papa.Vector.Data.Vector.Storable: (!?) :: Storable a => Vector a -> Int -> Maybe a
+ Papa.Vector.Data.Vector.Storable: (++) :: Storable a => Vector a -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: (//) :: Storable a => Vector a -> [(Int, a)] -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !ForeignPtr a -> MVector s a
+ Papa.Vector.Data.Vector.Storable: accum :: Storable a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: accumulate_ :: (Storable a, Storable b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: all :: Storable a => (a -> Bool) -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Storable: and :: Vector Bool -> Bool
+ Papa.Vector.Data.Vector.Storable: any :: Storable a => (a -> Bool) -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Storable: backpermute :: Storable a => Vector a -> Vector Int -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: break :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: breakR :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: class () => Storable a
+ Papa.Vector.Data.Vector.Storable: cmpBy :: (Storable a, Storable b) => (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering
+ Papa.Vector.Data.Vector.Storable: concat :: Storable a => [Vector a] -> Vector a
+ Papa.Vector.Data.Vector.Storable: concatMap :: (Storable a, Storable b) => (a -> Vector b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: cons :: Storable a => a -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: constructN :: Storable a => Int -> (Vector a -> a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: constructrN :: Storable a => Int -> (Vector a -> a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: convert :: (Vector v a, Vector w a) => v a -> w a
+ Papa.Vector.Data.Vector.Storable: copy :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Storable: create :: Storable a => (forall s. () => ST s (MVector s a)) -> Vector a
+ Papa.Vector.Data.Vector.Storable: createT :: (Traversable f, Storable a) => (forall s. () => ST s (f (MVector s a))) -> f (Vector a)
+ Papa.Vector.Data.Vector.Storable: data () => MVector s a
+ Papa.Vector.Data.Vector.Storable: data () => Vector a
+ Papa.Vector.Data.Vector.Storable: drop :: Storable a => Int -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: dropWhile :: Storable a => (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: elem :: (Storable a, Eq a) => a -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Storable: elemIndex :: (Storable a, Eq a) => a -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: elemIndices :: (Storable a, Eq a) => a -> Vector a -> Vector Int
+ Papa.Vector.Data.Vector.Storable: empty :: Storable a => Vector a
+ Papa.Vector.Data.Vector.Storable: enumFromN :: (Storable a, Num a) => a -> Int -> Vector a
+ Papa.Vector.Data.Vector.Storable: enumFromStepN :: (Storable a, Num a) => a -> a -> Int -> Vector a
+ Papa.Vector.Data.Vector.Storable: enumFromThenTo :: (Storable a, Enum a) => a -> a -> a -> Vector a
+ Papa.Vector.Data.Vector.Storable: enumFromTo :: (Storable a, Enum a) => a -> a -> Vector a
+ Papa.Vector.Data.Vector.Storable: eqBy :: (Storable a, Storable b) => (a -> b -> Bool) -> Vector a -> Vector b -> Bool
+ Papa.Vector.Data.Vector.Storable: filter :: Storable a => (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: filterM :: (Monad m, Storable a) => (a -> m Bool) -> Vector a -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: find :: Storable a => (a -> Bool) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: findIndex :: Storable a => (a -> Bool) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: findIndexR :: Storable a => (a -> Bool) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: findIndices :: Storable a => (a -> Bool) -> Vector a -> Vector Int
+ Papa.Vector.Data.Vector.Storable: fold1M :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Storable: fold1M' :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Storable: fold1M'_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Storable: fold1M_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Storable: foldM :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Storable: foldM' :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Storable: foldM'_ :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Storable: foldM_ :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Storable: foldMap :: (Monoid m, Storable a) => (a -> m) -> Vector a -> m
+ Papa.Vector.Data.Vector.Storable: foldMap' :: (Monoid m, Storable a) => (a -> m) -> Vector a -> m
+ Papa.Vector.Data.Vector.Storable: foldl :: Storable b => (a -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Storable: foldl' :: Storable b => (a -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Storable: foldl1 :: Storable a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: foldl1' :: Storable a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: foldr :: Storable a => (a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Storable: foldr' :: Storable a => (a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Storable: foldr1 :: Storable a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: foldr1' :: Storable a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: forM :: (Monad m, Storable a, Storable b) => Vector a -> (a -> m b) -> m (Vector b)
+ Papa.Vector.Data.Vector.Storable: forM_ :: (Monad m, Storable a) => Vector a -> (a -> m b) -> m ()
+ Papa.Vector.Data.Vector.Storable: force :: Storable a => Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: freeze :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: fromList :: Storable a => [a] -> Vector a
+ Papa.Vector.Data.Vector.Storable: fromListN :: Storable a => Int -> [a] -> Vector a
+ Papa.Vector.Data.Vector.Storable: generate :: Storable a => Int -> (Int -> a) -> Vector a
+ Papa.Vector.Data.Vector.Storable: generateM :: (Monad m, Storable a) => Int -> (Int -> m a) -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: group :: (Storable a, Eq a) => Vector a -> [Vector a]
+ Papa.Vector.Data.Vector.Storable: groupBy :: Storable a => (a -> a -> Bool) -> Vector a -> [Vector a]
+ Papa.Vector.Data.Vector.Storable: head :: Storable a => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: headM :: (Storable a, Monad m) => Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Storable: ifilter :: Storable a => (Int -> a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: ifoldM :: (Monad m, Storable b) => (a -> Int -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Storable: ifoldM' :: (Monad m, Storable b) => (a -> Int -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Storable: ifoldM'_ :: (Monad m, Storable b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Storable: ifoldM_ :: (Monad m, Storable b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Storable: ifoldl :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Storable: ifoldl' :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Storable: ifoldr :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Storable: ifoldr' :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Storable: iforM :: (Monad m, Storable a, Storable b) => Vector a -> (Int -> a -> m b) -> m (Vector b)
+ Papa.Vector.Data.Vector.Storable: iforM_ :: (Monad m, Storable a) => Vector a -> (Int -> a -> m b) -> m ()
+ Papa.Vector.Data.Vector.Storable: imap :: (Storable a, Storable b) => (Int -> a -> b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: imapM :: (Monad m, Storable a, Storable b) => (Int -> a -> m b) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Storable: imapM_ :: (Monad m, Storable a) => (Int -> a -> m b) -> Vector a -> m ()
+ Papa.Vector.Data.Vector.Storable: imapMaybe :: (Storable a, Storable b) => (Int -> a -> Maybe b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: imapMaybeM :: (Monad m, Storable a, Storable b) => (Int -> a -> m (Maybe b)) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Storable: indexM :: (Storable a, Monad m) => Vector a -> Int -> m (Maybe a)
+ Papa.Vector.Data.Vector.Storable: infix 4 `notElem`
+ Papa.Vector.Data.Vector.Storable: infixl 9 //
+ Papa.Vector.Data.Vector.Storable: infixr 5 ++
+ Papa.Vector.Data.Vector.Storable: init :: Storable a => Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: isSameVector :: Storable a => Vector a -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Storable: iscanl :: (Storable a, Storable b) => (Int -> a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: iscanl' :: (Storable a, Storable b) => (Int -> a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: iscanr :: (Storable a, Storable b) => (Int -> a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: iscanr' :: (Storable a, Storable b) => (Int -> a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: iterateN :: Storable a => Int -> (a -> a) -> a -> Vector a
+ Papa.Vector.Data.Vector.Storable: iterateNM :: (Monad m, Storable a) => Int -> (a -> m a) -> a -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: izipWith :: (Storable a, Storable b, Storable c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c
+ Papa.Vector.Data.Vector.Storable: izipWith3 :: (Storable a, Storable b, Storable c, Storable d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
+ Papa.Vector.Data.Vector.Storable: izipWith4 :: (Storable a, Storable b, Storable c, Storable d, Storable e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
+ Papa.Vector.Data.Vector.Storable: izipWith5 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
+ Papa.Vector.Data.Vector.Storable: izipWith6 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
+ Papa.Vector.Data.Vector.Storable: izipWithM :: (Monad m, Storable a, Storable b, Storable c) => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
+ Papa.Vector.Data.Vector.Storable: izipWithM_ :: (Monad m, Storable a, Storable b) => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Storable: last :: Storable a => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: lastM :: (Storable a, Monad m) => Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Storable: length :: Storable a => Vector a -> Int
+ Papa.Vector.Data.Vector.Storable: map :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: mapM :: (Monad m, Storable a, Storable b) => (a -> m b) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Storable: mapM_ :: (Monad m, Storable a) => (a -> m b) -> Vector a -> m ()
+ Papa.Vector.Data.Vector.Storable: mapMaybe :: (Storable a, Storable b) => (a -> Maybe b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: mapMaybeM :: (Monad m, Storable a, Storable b) => (a -> m (Maybe b)) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Storable: maxIndex :: (Storable a, Ord a) => Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: maxIndexBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: maximum :: (Storable a, Ord a) => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: maximumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: maximumOn :: (Ord b, Storable a) => (a -> b) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: minIndex :: (Storable a, Ord a) => Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: minIndexBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Storable: minimum :: (Storable a, Ord a) => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: minimumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: minimumOn :: (Ord b, Storable a) => (a -> b) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Storable: modify :: Storable a => (forall s. () => MVector s a -> ST s ()) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: notElem :: (Storable a, Eq a) => a -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Storable: null :: Storable a => Vector a -> Bool
+ Papa.Vector.Data.Vector.Storable: or :: Vector Bool -> Bool
+ Papa.Vector.Data.Vector.Storable: partition :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: partitionWith :: (Storable a, Storable b, Storable c) => (a -> Either b c) -> Vector a -> (Vector b, Vector c)
+ Papa.Vector.Data.Vector.Storable: postscanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: postscanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: postscanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: postscanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: prescanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: prescanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: prescanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: prescanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: product :: (Storable a, Num a) => Vector a -> a
+ Papa.Vector.Data.Vector.Storable: replicate :: Storable a => Int -> a -> Vector a
+ Papa.Vector.Data.Vector.Storable: replicateM :: (Monad m, Storable a) => Int -> m a -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: reverse :: Storable a => Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: scanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: scanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Storable: scanl1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: scanl1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: scanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: scanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Storable: scanr1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: scanr1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: singleton :: Storable a => a -> Vector a
+ Papa.Vector.Data.Vector.Storable: slice :: Storable a => Int -> Int -> Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: snoc :: Storable a => Vector a -> a -> Vector a
+ Papa.Vector.Data.Vector.Storable: span :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: spanR :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: splitAt :: Storable a => Int -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: sum :: (Storable a, Num a) => Vector a -> a
+ Papa.Vector.Data.Vector.Storable: tail :: Storable a => Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: take :: Storable a => Int -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: takeWhile :: Storable a => (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: thaw :: (Storable a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)
+ Papa.Vector.Data.Vector.Storable: toList :: Storable a => Vector a -> [a]
+ Papa.Vector.Data.Vector.Storable: uncons :: Storable a => Vector a -> Maybe (a, Vector a)
+ Papa.Vector.Data.Vector.Storable: unfoldr :: Storable a => (b -> Maybe (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector.Storable: unfoldrExactN :: Storable a => Int -> (b -> (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector.Storable: unfoldrExactNM :: (Monad m, Storable a) => Int -> (b -> m (a, b)) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: unfoldrM :: (Monad m, Storable a) => (b -> m (Maybe (a, b))) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: unfoldrN :: Storable a => Int -> (b -> Maybe (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector.Storable: unfoldrNM :: (Monad m, Storable a) => Int -> (b -> m (Maybe (a, b))) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector.Storable: uniq :: (Storable a, Eq a) => Vector a -> Vector a
+ Papa.Vector.Data.Vector.Storable: unsnoc :: Storable a => Vector a -> Maybe (Vector a, a)
+ Papa.Vector.Data.Vector.Storable: unstablePartition :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Storable: update_ :: Storable a => Vector a -> Vector Int -> Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Storable: zipWith :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c
+ Papa.Vector.Data.Vector.Storable: zipWith3 :: (Storable a, Storable b, Storable c, Storable d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
+ Papa.Vector.Data.Vector.Storable: zipWith4 :: (Storable a, Storable b, Storable c, Storable d, Storable e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
+ Papa.Vector.Data.Vector.Storable: zipWith5 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
+ Papa.Vector.Data.Vector.Storable: zipWith6 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
+ Papa.Vector.Data.Vector.Storable: zipWithM :: (Monad m, Storable a, Storable b, Storable c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
+ Papa.Vector.Data.Vector.Storable: zipWithM_ :: (Monad m, Storable a, Storable b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Unboxed: (!?) :: Unbox a => Vector a -> Int -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: (++) :: Unbox a => Vector a -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: (//) :: Unbox a => Vector a -> [(Int, a)] -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: As :: a -> As a b
+ Papa.Vector.Data.Vector.Unboxed: DoNotUnboxLazy :: a -> DoNotUnboxLazy a
+ Papa.Vector.Data.Vector.Unboxed: DoNotUnboxNormalForm :: a -> DoNotUnboxNormalForm a
+ Papa.Vector.Data.Vector.Unboxed: DoNotUnboxStrict :: a -> DoNotUnboxStrict a
+ Papa.Vector.Data.Vector.Unboxed: UnboxViaPrim :: a -> UnboxViaPrim a
+ Papa.Vector.Data.Vector.Unboxed: accum :: Unbox a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: accumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: accumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: all :: Unbox a => (a -> Bool) -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Unboxed: and :: Vector Bool -> Bool
+ Papa.Vector.Data.Vector.Unboxed: any :: Unbox a => (a -> Bool) -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Unboxed: backpermute :: Unbox a => Vector a -> Vector Int -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: break :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: breakR :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: class () => IsoUnbox a b
+ Papa.Vector.Data.Vector.Unboxed: class (Vector Vector a, MVector MVector a) => Unbox a
+ Papa.Vector.Data.Vector.Unboxed: cmpBy :: (Unbox a, Unbox b) => (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering
+ Papa.Vector.Data.Vector.Unboxed: concat :: Unbox a => [Vector a] -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: concatMap :: (Unbox a, Unbox b) => (a -> Vector b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: cons :: Unbox a => a -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: constructN :: Unbox a => Int -> (Vector a -> a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: constructrN :: Unbox a => Int -> (Vector a -> a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: convert :: (Vector v a, Vector w a) => v a -> w a
+ Papa.Vector.Data.Vector.Unboxed: copy :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Unboxed: create :: Unbox a => (forall s. () => ST s (MVector s a)) -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: createT :: (Traversable f, Unbox a) => (forall s. () => ST s (f (MVector s a))) -> f (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: data family MVector s a
+ Papa.Vector.Data.Vector.Unboxed: drop :: Unbox a => Int -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: dropWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: elem :: (Unbox a, Eq a) => a -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Unboxed: elemIndex :: (Unbox a, Eq a) => a -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: elemIndices :: (Unbox a, Eq a) => a -> Vector a -> Vector Int
+ Papa.Vector.Data.Vector.Unboxed: empty :: Unbox a => Vector a
+ Papa.Vector.Data.Vector.Unboxed: enumFromN :: (Unbox a, Num a) => a -> Int -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: enumFromStepN :: (Unbox a, Num a) => a -> a -> Int -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: enumFromThenTo :: (Unbox a, Enum a) => a -> a -> a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: enumFromTo :: (Unbox a, Enum a) => a -> a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: eqBy :: (Unbox a, Unbox b) => (a -> b -> Bool) -> Vector a -> Vector b -> Bool
+ Papa.Vector.Data.Vector.Unboxed: filter :: Unbox a => (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: filterM :: (Monad m, Unbox a) => (a -> m Bool) -> Vector a -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: find :: Unbox a => (a -> Bool) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: findIndex :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: findIndexR :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: findIndices :: Unbox a => (a -> Bool) -> Vector a -> Vector Int
+ Papa.Vector.Data.Vector.Unboxed: fold1M :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Unboxed: fold1M' :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Unboxed: fold1M'_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Unboxed: fold1M_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe ())
+ Papa.Vector.Data.Vector.Unboxed: foldM :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Unboxed: foldM' :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Unboxed: foldM'_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Unboxed: foldM_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Unboxed: foldMap :: (Monoid m, Unbox a) => (a -> m) -> Vector a -> m
+ Papa.Vector.Data.Vector.Unboxed: foldMap' :: (Monoid m, Unbox a) => (a -> m) -> Vector a -> m
+ Papa.Vector.Data.Vector.Unboxed: foldl :: Unbox b => (a -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Unboxed: foldl' :: Unbox b => (a -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Unboxed: foldl1 :: Unbox a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: foldl1' :: Unbox a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: foldr :: Unbox a => (a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Unboxed: foldr' :: Unbox a => (a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Unboxed: foldr1 :: Unbox a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: foldr1' :: Unbox a => (a -> a -> a) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: forM :: (Monad m, Unbox a, Unbox b) => Vector a -> (a -> m b) -> m (Vector b)
+ Papa.Vector.Data.Vector.Unboxed: forM_ :: (Monad m, Unbox a) => Vector a -> (a -> m b) -> m ()
+ Papa.Vector.Data.Vector.Unboxed: force :: Unbox a => Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: freeze :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: fromList :: Unbox a => [a] -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: fromListN :: Unbox a => Int -> [a] -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: fromURepr :: IsoUnbox a b => b -> a
+ Papa.Vector.Data.Vector.Unboxed: generate :: Unbox a => Int -> (Int -> a) -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: generateM :: (Monad m, Unbox a) => Int -> (Int -> m a) -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: group :: (Unbox a, Eq a) => Vector a -> [Vector a]
+ Papa.Vector.Data.Vector.Unboxed: groupBy :: Unbox a => (a -> a -> Bool) -> Vector a -> [Vector a]
+ Papa.Vector.Data.Vector.Unboxed: head :: Unbox a => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: headM :: (Unbox a, Monad m) => Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Unboxed: ifilter :: Unbox a => (Int -> a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: ifoldM :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Unboxed: ifoldM' :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m a
+ Papa.Vector.Data.Vector.Unboxed: ifoldM'_ :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Unboxed: ifoldM_ :: (Monad m, Unbox b) => (a -> Int -> b -> m a) -> a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Unboxed: ifoldl :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Unboxed: ifoldl' :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a
+ Papa.Vector.Data.Vector.Unboxed: ifoldr :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Unboxed: ifoldr' :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b
+ Papa.Vector.Data.Vector.Unboxed: iforM :: (Monad m, Unbox a, Unbox b) => Vector a -> (Int -> a -> m b) -> m (Vector b)
+ Papa.Vector.Data.Vector.Unboxed: iforM_ :: (Monad m, Unbox a) => Vector a -> (Int -> a -> m b) -> m ()
+ Papa.Vector.Data.Vector.Unboxed: imap :: (Unbox a, Unbox b) => (Int -> a -> b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: imapM :: (Monad m, Unbox a, Unbox b) => (Int -> a -> m b) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Unboxed: imapM_ :: (Monad m, Unbox a) => (Int -> a -> m b) -> Vector a -> m ()
+ Papa.Vector.Data.Vector.Unboxed: imapMaybe :: (Unbox a, Unbox b) => (Int -> a -> Maybe b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: imapMaybeM :: (Monad m, Unbox a, Unbox b) => (Int -> a -> m (Maybe b)) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Unboxed: indexM :: (Unbox a, Monad m) => Vector a -> Int -> m (Maybe a)
+ Papa.Vector.Data.Vector.Unboxed: indexed :: Unbox a => Vector a -> Vector (Int, a)
+ Papa.Vector.Data.Vector.Unboxed: infix 4 `notElem`
+ Papa.Vector.Data.Vector.Unboxed: infixl 9 //
+ Papa.Vector.Data.Vector.Unboxed: infixr 5 ++
+ Papa.Vector.Data.Vector.Unboxed: init :: Unbox a => Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: iscanl :: (Unbox a, Unbox b) => (Int -> a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: iscanl' :: (Unbox a, Unbox b) => (Int -> a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: iscanr :: (Unbox a, Unbox b) => (Int -> a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: iscanr' :: (Unbox a, Unbox b) => (Int -> a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: iterateN :: Unbox a => Int -> (a -> a) -> a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: iterateNM :: (Monad m, Unbox a) => Int -> (a -> m a) -> a -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: izipWith :: (Unbox a, Unbox b, Unbox c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c
+ Papa.Vector.Data.Vector.Unboxed: izipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
+ Papa.Vector.Data.Vector.Unboxed: izipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
+ Papa.Vector.Data.Vector.Unboxed: izipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
+ Papa.Vector.Data.Vector.Unboxed: izipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
+ Papa.Vector.Data.Vector.Unboxed: izipWithM :: (Monad m, Unbox a, Unbox b, Unbox c) => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
+ Papa.Vector.Data.Vector.Unboxed: izipWithM_ :: (Monad m, Unbox a, Unbox b) => (Int -> a -> b -> m c) -> Vector a -> Vector b -> m ()
+ Papa.Vector.Data.Vector.Unboxed: last :: Unbox a => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: lastM :: (Unbox a, Monad m) => Vector a -> m (Maybe a)
+ Papa.Vector.Data.Vector.Unboxed: length :: Unbox a => Vector a -> Int
+ Papa.Vector.Data.Vector.Unboxed: map :: (Unbox a, Unbox b) => (a -> b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: mapM :: (Monad m, Unbox a, Unbox b) => (a -> m b) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Unboxed: mapM_ :: (Monad m, Unbox a) => (a -> m b) -> Vector a -> m ()
+ Papa.Vector.Data.Vector.Unboxed: mapMaybe :: (Unbox a, Unbox b) => (a -> Maybe b) -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: mapMaybeM :: (Monad m, Unbox a, Unbox b) => (a -> m (Maybe b)) -> Vector a -> m (Vector b)
+ Papa.Vector.Data.Vector.Unboxed: maxIndex :: (Unbox a, Ord a) => Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: maxIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: maximum :: (Unbox a, Ord a) => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: maximumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: maximumOn :: (Ord b, Unbox a) => (a -> b) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: minIndex :: (Unbox a, Ord a) => Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: minIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Maybe Int
+ Papa.Vector.Data.Vector.Unboxed: minimum :: (Unbox a, Ord a) => Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: minimumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: minimumOn :: (Ord b, Unbox a) => (a -> b) -> Vector a -> Maybe a
+ Papa.Vector.Data.Vector.Unboxed: modify :: Unbox a => (forall s. () => MVector s a -> ST s ()) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: newtype () => As a b
+ Papa.Vector.Data.Vector.Unboxed: newtype () => DoNotUnboxLazy a
+ Papa.Vector.Data.Vector.Unboxed: newtype () => DoNotUnboxNormalForm a
+ Papa.Vector.Data.Vector.Unboxed: newtype () => DoNotUnboxStrict a
+ Papa.Vector.Data.Vector.Unboxed: newtype () => UnboxViaPrim a
+ Papa.Vector.Data.Vector.Unboxed: notElem :: (Unbox a, Eq a) => a -> Vector a -> Bool
+ Papa.Vector.Data.Vector.Unboxed: null :: Unbox a => Vector a -> Bool
+ Papa.Vector.Data.Vector.Unboxed: or :: Vector Bool -> Bool
+ Papa.Vector.Data.Vector.Unboxed: partition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: partitionWith :: (Unbox a, Unbox b, Unbox c) => (a -> Either b c) -> Vector a -> (Vector b, Vector c)
+ Papa.Vector.Data.Vector.Unboxed: postscanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: postscanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: postscanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: postscanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: prescanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: prescanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: prescanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: prescanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: product :: (Unbox a, Num a) => Vector a -> a
+ Papa.Vector.Data.Vector.Unboxed: replicate :: Unbox a => Int -> a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: replicateM :: (Monad m, Unbox a) => Int -> m a -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: reverse :: Unbox a => Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: scanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: scanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: scanl1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: scanl1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: scanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: scanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b
+ Papa.Vector.Data.Vector.Unboxed: scanr1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: scanr1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: singleton :: Unbox a => a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: slice :: Unbox a => Int -> Int -> Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: snoc :: Unbox a => Vector a -> a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: span :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: spanR :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: splitAt :: Unbox a => Int -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: sum :: (Unbox a, Num a) => Vector a -> a
+ Papa.Vector.Data.Vector.Unboxed: tail :: Unbox a => Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: take :: Unbox a => Int -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: takeWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: thaw :: (Unbox a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)
+ Papa.Vector.Data.Vector.Unboxed: toList :: Unbox a => Vector a -> [a]
+ Papa.Vector.Data.Vector.Unboxed: toURepr :: IsoUnbox a b => a -> b
+ Papa.Vector.Data.Vector.Unboxed: uncons :: Unbox a => Vector a -> Maybe (a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: unfoldr :: Unbox a => (b -> Maybe (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: unfoldrExactN :: Unbox a => Int -> (b -> (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: unfoldrExactNM :: (Monad m, Unbox a) => Int -> (b -> m (a, b)) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: unfoldrM :: (Monad m, Unbox a) => (b -> m (Maybe (a, b))) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: unfoldrN :: Unbox a => Int -> (b -> Maybe (a, b)) -> b -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: unfoldrNM :: (Monad m, Unbox a) => Int -> (b -> m (Maybe (a, b))) -> b -> m (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: uniq :: (Unbox a, Eq a) => Vector a -> Vector a
+ Papa.Vector.Data.Vector.Unboxed: unsnoc :: Unbox a => Vector a -> Maybe (Vector a, a)
+ Papa.Vector.Data.Vector.Unboxed: unstablePartition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)
+ Papa.Vector.Data.Vector.Unboxed: unzip :: (Unbox a, Unbox b) => Vector (a, b) -> (Vector a, Vector b)
+ Papa.Vector.Data.Vector.Unboxed: unzip3 :: (Unbox a, Unbox b, Unbox c) => Vector (a, b, c) -> (Vector a, Vector b, Vector c)
+ Papa.Vector.Data.Vector.Unboxed: unzip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)
+ Papa.Vector.Data.Vector.Unboxed: unzip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)
+ Papa.Vector.Data.Vector.Unboxed: unzip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)
+ Papa.Vector.Data.Vector.Unboxed: update :: Unbox a => Vector a -> Vector (Int, a) -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: update_ :: Unbox a => Vector a -> Vector Int -> Vector a -> Maybe (Vector a)
+ Papa.Vector.Data.Vector.Unboxed: zip :: (Unbox a, Unbox b) => Vector a -> Vector b -> Vector (a, b)
+ Papa.Vector.Data.Vector.Unboxed: zip3 :: (Unbox a, Unbox b, Unbox c) => Vector a -> Vector b -> Vector c -> Vector (a, b, c)
+ Papa.Vector.Data.Vector.Unboxed: zip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)
+ Papa.Vector.Data.Vector.Unboxed: zip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)
+ Papa.Vector.Data.Vector.Unboxed: zip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)
+ Papa.Vector.Data.Vector.Unboxed: zipWith :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c
+ Papa.Vector.Data.Vector.Unboxed: zipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d
+ Papa.Vector.Data.Vector.Unboxed: zipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e
+ Papa.Vector.Data.Vector.Unboxed: zipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f
+ Papa.Vector.Data.Vector.Unboxed: zipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g
+ Papa.Vector.Data.Vector.Unboxed: zipWithM :: (Monad m, Unbox a, Unbox b, Unbox c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)
+ Papa.Vector.Data.Vector.Unboxed: zipWithM_ :: (Monad m, Unbox a, Unbox b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()
- Papa.Associative.Renamed: class AsMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
+ Papa.Associative.Renamed: class () => AsMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
- Papa.Associative.Renamed: class AsPartialMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
+ Papa.Associative.Renamed: class () => AsPartialMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
- Papa.Associative.Renamed: class AsPartialSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
+ Papa.Associative.Renamed: class () => AsPartialSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
- Papa.Associative.Renamed: class AsSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
+ Papa.Associative.Renamed: class () => AsSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
- Papa.Associative.Renamed: class HasMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
+ Papa.Associative.Renamed: class () => HasMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
- Papa.Associative.Renamed: class HasPartialMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
+ Papa.Associative.Renamed: class () => HasPartialMonoidOpT c (f :: Type -> Type) a b i | c -> f a b i
- Papa.Associative.Renamed: class HasPartialSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
+ Papa.Associative.Renamed: class () => HasPartialSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
- Papa.Associative.Renamed: class HasSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
+ Papa.Associative.Renamed: class () => HasSemigroupOpT c (f :: Type -> Type) a b | c -> f a b
- Papa.Associative.Renamed: data MonoidOpT (f :: Type -> Type) a b i
+ Papa.Associative.Renamed: data () => MonoidOpT (f :: Type -> Type) a b i
- Papa.Associative.Renamed: data PartialMonoidOpT (f :: Type -> Type) a b i
+ Papa.Associative.Renamed: data () => PartialMonoidOpT (f :: Type -> Type) a b i
- Papa.Associative.Renamed: newtype PartialSemigroupOpT (f :: Type -> Type) a b
+ Papa.Associative.Renamed: newtype () => PartialSemigroupOpT (f :: Type -> Type) a b
- Papa.Associative.Renamed: newtype SemigroupOpT (f :: Type -> Type) a b
+ Papa.Associative.Renamed: newtype () => SemigroupOpT (f :: Type -> Type) a b
- Papa.Base: cycle :: HasCallStack => [a] -> [a]
+ Papa.Base: cycle :: [a] -> Maybe [a]
- Papa.Base.Control.Applicative: newtype Const a (b :: k)
+ Papa.Base.Control.Applicative: newtype () => Const a (b :: k)
- Papa.Base.Control.Category: class Category (cat :: k -> k -> Type)
+ Papa.Base.Control.Category: class () => Category (cat :: k -> k -> Type)
- Papa.Base.Control.DeepSeq: class NFData a
+ Papa.Base.Control.DeepSeq: class () => NFData a
- Papa.Base.Control.Monad: class Functor (f :: Type -> Type)
+ Papa.Base.Control.Monad: class () => Functor (f :: Type -> Type)
- Papa.Base.Data.Char: chr :: Int -> Char
+ Papa.Base.Data.Char: chr :: Int -> Maybe Char
- Papa.Base.Data.Char: data Char
+ Papa.Base.Data.Char: data () => Char
- Papa.Base.Data.Char: data GeneralCategory
+ Papa.Base.Data.Char: data () => GeneralCategory
- Papa.Base.Data.Data: class Typeable (a :: k)
+ Papa.Base.Data.Data: class () => Typeable (a :: k)
- Papa.Base.Data.Either: data Either a b
+ Papa.Base.Data.Either: data () => Either a b
- Papa.Base.Data.Either: fromLeft :: a -> Either a b -> a
+ Papa.Base.Data.Either: fromLeft :: LeftLike (->) (Const (First a)) s s a a => a -> s -> a
- Papa.Base.Data.Either: fromRight :: b -> Either a b -> b
+ Papa.Base.Data.Either: fromRight :: RightLike (->) (Const (First b)) s s b b => b -> s -> b
- Papa.Base.Data.Either: lefts :: forall (f :: Type -> Type) a b a'. Traversable f => Traversal (f (Either a b)) (f (Either a' b)) a a'
+ Papa.Base.Data.Either: lefts :: Traversable f => Traversal (f (Either a b)) (f (Either a' b)) a a'
- Papa.Base.Data.Either: partitionEithers :: [Either a b] -> ([a], [b])
+ Papa.Base.Data.Either: partitionEithers :: Foldable f => f (Either a b) -> ([a], [b])
- Papa.Base.Data.Either: rights :: forall (f :: Type -> Type) a b b'. Traversable f => Traversal (f (Either a b)) (f (Either a b')) b b'
+ Papa.Base.Data.Either: rights :: Traversable f => Traversal (f (Either a b)) (f (Either a b')) b b'
- Papa.Base.Data.Foldable: class Foldable (t :: Type -> Type)
+ Papa.Base.Data.Foldable: class () => Foldable (t :: Type -> Type)
- Papa.Base.Data.Foldable: forM_ :: (Foldable t, Applicative m) => t a -> (a -> m b) -> m ()
+ Papa.Base.Data.Foldable: forM_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
- Papa.Base.Data.Function: ($) :: (a -> b) -> a -> b
+ Papa.Base.Data.Function: ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- Papa.Base.Data.Functor: class Functor (f :: Type -> Type)
+ Papa.Base.Data.Functor: class () => Functor (f :: Type -> Type)
- Papa.Base.Data.List: cycle :: HasCallStack => [a] -> [a]
+ Papa.Base.Data.List: cycle :: [a] -> Maybe [a]
- Papa.Base.Data.List.NonEmpty: data NonEmpty a
+ Papa.Base.Data.List.NonEmpty: data () => NonEmpty a
- Papa.Base.Data.List.NonEmpty: head :: forall a f. Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a)
+ Papa.Base.Data.List.NonEmpty: head :: Lens' (NonEmpty a) a
- Papa.Base.Data.List.NonEmpty: init :: forall a f. Functor f => ([a] -> f [a]) -> NonEmpty a -> f (NonEmpty a)
+ Papa.Base.Data.List.NonEmpty: init :: Lens' (NonEmpty a) [a]
- Papa.Base.Data.List.NonEmpty: last :: forall a f. Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a)
+ Papa.Base.Data.List.NonEmpty: last :: Lens' (NonEmpty a) a
- Papa.Base.Data.List.NonEmpty: tail :: forall a f. Functor f => ([a] -> f [a]) -> NonEmpty a -> f (NonEmpty a)
+ Papa.Base.Data.List.NonEmpty: tail :: Lens' (NonEmpty a) [a]
- Papa.Base.Data.Maybe: data Maybe a
+ Papa.Base.Data.Maybe: data () => Maybe a
- Papa.Base.Data.Monoid: mconcat :: (Monoid a, Foldable f) => f a -> a
+ Papa.Base.Data.Monoid: mconcat :: (Foldable f, Monoid a) => f a -> a
- Papa.Base.Data.Ord: newtype Down a
+ Papa.Base.Data.Ord: newtype () => Down a
- Papa.Base.Data.Semigroup: class Semigroup a
+ Papa.Base.Data.Semigroup: class () => Semigroup a
- Papa.Base.Data.Semigroup: data Arg a b
+ Papa.Base.Data.Semigroup: data () => Arg a b
- Papa.Base.Data.Semigroup: mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
+ Papa.Base.Data.Semigroup: mtimesDefault :: (Integral b, Monoid a) => b -> a -> Maybe a
- Papa.Base.Data.Semigroup: stimes :: (Semigroup a, Integral b) => b -> a -> a
+ Papa.Base.Data.Semigroup: stimes :: (Integral b, Semigroup a) => b -> a -> Maybe a
- Papa.Base.Data.Semigroup: stimesIdempotent :: Integral b => b -> a -> a
+ Papa.Base.Data.Semigroup: stimesIdempotent :: Integral b => b -> a -> Maybe a
- Papa.Base.Data.Semigroup: stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a
+ Papa.Base.Data.Semigroup: stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> Maybe a
- Papa.Base.Data.Semigroup: stimesMonoid :: (Integral b, Monoid a) => b -> a -> a
+ Papa.Base.Data.Semigroup: stimesMonoid :: (Integral b, Monoid a) => b -> a -> Maybe a
- Papa.Base.Data.Show: class Show a
+ Papa.Base.Data.Show: class () => Show a
- Papa.Base.GHC.Generics: class Generic a
+ Papa.Base.GHC.Generics: class () => Generic a
- Papa.Base.GHC.Generics: class Generic1 (f :: k -> Type)
+ Papa.Base.GHC.Generics: class () => Generic1 (f :: k -> Type)
- Papa.Base.Prelude: ($) :: (a -> b) -> a -> b
+ Papa.Base.Prelude: ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- Papa.Base.Prelude: class Enum a
+ Papa.Base.Prelude: class () => Enum a
- Papa.Base.Prelude: class Eq a
+ Papa.Base.Prelude: class () => Eq a
- Papa.Base.Prelude: class Foldable (t :: Type -> Type)
+ Papa.Base.Prelude: class () => Foldable (t :: Type -> Type)
- Papa.Base.Prelude: class Functor (f :: Type -> Type)
+ Papa.Base.Prelude: class () => Functor (f :: Type -> Type)
- Papa.Base.Prelude: class Num a
+ Papa.Base.Prelude: class () => Num a
- Papa.Base.Prelude: class Show a
+ Papa.Base.Prelude: class () => Show a
- Papa.Base.Prelude: data Bool
+ Papa.Base.Prelude: data () => Bool
- Papa.Base.Prelude: data Char
+ Papa.Base.Prelude: data () => Char
- Papa.Base.Prelude: data Double
+ Papa.Base.Prelude: data () => Double
- Papa.Base.Prelude: data Either a b
+ Papa.Base.Prelude: data () => Either a b
- Papa.Base.Prelude: data Float
+ Papa.Base.Prelude: data () => Float
- Papa.Base.Prelude: data IO a
+ Papa.Base.Prelude: data () => IO a
- Papa.Base.Prelude: data Int
+ Papa.Base.Prelude: data () => Int
- Papa.Base.Prelude: data Integer
+ Papa.Base.Prelude: data () => Integer
- Papa.Base.Prelude: data Maybe a
+ Papa.Base.Prelude: data () => Maybe a
- Papa.Base.Prelude: data Ordering
+ Papa.Base.Prelude: data () => Ordering
- Papa.Base.Prelude: data Word
+ Papa.Base.Prelude: data () => Word
- Papa.Base.Prelude: infix 4 `notElem`
+ Papa.Base.Prelude: infix 4 ~
- Papa.Base.Prelude: infixl 7 /
+ Papa.Base.Prelude: infixl 7 *
- Papa.Base.Prelude: infixr 0 $
+ Papa.Base.Prelude: infixr 0 $!
- Papa.Base.Prelude: infixr 8 ^^
+ Papa.Base.Prelude: infixr 8 **
- Papa.Bifunctors: class Bifoldable (p :: Type -> Type -> Type)
+ Papa.Bifunctors: class () => Bifoldable (p :: Type -> Type -> Type)
- Papa.Bifunctors: class BifunctorFunctor (t :: k -> k1 -> Type -> k2 -> k3 -> Type)
+ Papa.Bifunctors: class () => BifunctorFunctor (t :: k -> k1 -> Type -> k2 -> k3 -> Type)
- Papa.Bifunctors: data Biff (p :: k -> k1 -> Type) (f :: k2 -> k) (g :: k3 -> k1) (a :: k2) (b :: k3)
+ Papa.Bifunctors: data () => Biff (p :: k -> k1 -> Type) (f :: k2 -> k) (g :: k3 -> k1) (a :: k2) (b :: k3)
- Papa.Bifunctors: data Clown (f :: k -> Type) (a :: k) (b :: k1)
+ Papa.Bifunctors: data () => Clown (f :: k -> Type) (a :: k) (b :: k1)
- Papa.Bifunctors: data Fix (p :: Type -> k -> Type) (a :: k)
+ Papa.Bifunctors: data () => Fix (p :: Type -> k -> Type) (a :: k)
- Papa.Bifunctors: data Flip (p :: k -> k1 -> Type) (a :: k1) (b :: k)
+ Papa.Bifunctors: data () => Flip (p :: k -> k1 -> Type) (a :: k1) (b :: k)
- Papa.Contravariant.Data.Functor.Contravariant: class Contravariant (f :: Type -> Type)
+ Papa.Contravariant.Data.Functor.Contravariant: class () => Contravariant (f :: Type -> Type)
- Papa.Lens: class AsEmpty a
+ Papa.Lens: class () => AsEmpty a
- Papa.Lens: class Cons s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Cons s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Contains m
+ Papa.Lens: class () => Contains m
- Papa.Lens: class Contravariant (f :: Type -> Type)
+ Papa.Lens: class () => Contravariant (f :: Type -> Type)
- Papa.Lens: class Each s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Each s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field10 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field10 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field11 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field11 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field12 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field12 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field13 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field13 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field14 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field14 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field15 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field15 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field16 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field16 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field17 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field17 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field18 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field18 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field19 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field19 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class GPlated a (g :: k -> Type)
+ Papa.Lens: class () => GPlated a (g :: k -> Type)
- Papa.Lens: class GPlated1 (f :: k -> Type) (g :: k -> Type)
+ Papa.Lens: class () => GPlated1 (f :: k -> Type) (g :: k -> Type)
- Papa.Lens: class Ixed m
+ Papa.Lens: class () => Ixed m
- Papa.Lens: class Plated a
+ Papa.Lens: class () => Plated a
- Papa.Lens: class Prefixed t
+ Papa.Lens: class () => Prefixed t
- Papa.Lens: class Profunctor (p :: Type -> Type -> Type)
+ Papa.Lens: class () => Profunctor (p :: Type -> Type -> Type)
- Papa.Lens: class Reversing t
+ Papa.Lens: class () => Reversing t
- Papa.Lens: class Snoc s t a b | s -> a, t -> b, s b -> t, t a -> s
+ Papa.Lens: class () => Snoc s t a b | s -> a, t -> b, s b -> t, t a -> s
- Papa.Lens: class Suffixed t
+ Papa.Lens: class () => Suffixed t
- Papa.Lens: class Wrapped s where {
+ Papa.Lens: class () => Wrapped s where {
- Papa.Lens: data (a :: k) :~: (b :: k)
+ Papa.Lens: data () => (a :: k) :~: (b :: k)
- Papa.Lens: data Context a b t
+ Papa.Lens: data () => Context a b t
- Papa.Lens: data DefName
+ Papa.Lens: data () => DefName
- Papa.Lens: data Identical (a :: k) (b :: k1) (s :: k) (t :: k1)
+ Papa.Lens: data () => Identical (a :: k) (b :: k1) (s :: k) (t :: k1)
- Papa.Lens: data Leftmost a
+ Papa.Lens: data () => Leftmost a
- Papa.Lens: data LensRules
+ Papa.Lens: data () => LensRules
- Papa.Lens: data Level i a
+ Papa.Lens: data () => Level i a
- Papa.Lens: data Magma i t b a
+ Papa.Lens: data () => Magma i t b a
- Papa.Lens: data Rightmost a
+ Papa.Lens: data () => Rightmost a
- Papa.Lens: data Sequenced a (m :: Type -> Type)
+ Papa.Lens: data () => Sequenced a (m :: Type -> Type)
- Papa.Lens: data Traversed a (f :: Type -> Type)
+ Papa.Lens: data () => Traversed a (f :: Type -> Type)
- Papa.Lens: infixl 8 ^@?!
+ Papa.Lens: infixl 8 ^@?
- Papa.Lens: infixr 5 :<
+ Papa.Lens: infixr 5 `cons`
- Papa.Lens: newtype Bazaar (p :: Type -> Type -> Type) a b t
+ Papa.Lens: newtype () => Bazaar (p :: Type -> Type -> Type) a b t
- Papa.Lens: newtype Bazaar1 (p :: Type -> Type -> Type) a b t
+ Papa.Lens: newtype () => Bazaar1 (p :: Type -> Type -> Type) a b t
- Papa.Lens: newtype Const a (b :: k)
+ Papa.Lens: newtype () => Const a (b :: k)
- Papa.Lens: newtype Identity a
+ Papa.Lens: newtype () => Identity a
- Papa.Lens: newtype Indexed i a b
+ Papa.Lens: newtype () => Indexed i a b
- Papa.Lens: newtype ReifiedFold s a
+ Papa.Lens: newtype () => ReifiedFold s a
- Papa.Lens: newtype ReifiedGetter s a
+ Papa.Lens: newtype () => ReifiedGetter s a
- Papa.Lens: newtype ReifiedIndexedFold i s a
+ Papa.Lens: newtype () => ReifiedIndexedFold i s a
- Papa.Lens: newtype ReifiedIndexedGetter i s a
+ Papa.Lens: newtype () => ReifiedIndexedGetter i s a
- Papa.Lens: newtype ReifiedIndexedLens i s t a b
+ Papa.Lens: newtype () => ReifiedIndexedLens i s t a b
- Papa.Lens: newtype ReifiedIndexedSetter i s t a b
+ Papa.Lens: newtype () => ReifiedIndexedSetter i s t a b
- Papa.Lens: newtype ReifiedIndexedTraversal i s t a b
+ Papa.Lens: newtype () => ReifiedIndexedTraversal i s t a b
- Papa.Lens: newtype ReifiedIso s t a b
+ Papa.Lens: newtype () => ReifiedIso s t a b
- Papa.Lens: newtype ReifiedLens s t a b
+ Papa.Lens: newtype () => ReifiedLens s t a b
- Papa.Lens: newtype ReifiedPrism s t a b
+ Papa.Lens: newtype () => ReifiedPrism s t a b
- Papa.Lens: newtype ReifiedSetter s t a b
+ Papa.Lens: newtype () => ReifiedSetter s t a b
- Papa.Lens: newtype ReifiedTraversal s t a b
+ Papa.Lens: newtype () => ReifiedTraversal s t a b
- Papa.Lens: simply :: forall {k} {k1} p (f :: k -> k1) (s :: k) (a :: k) r. (Optic' p f s a -> r) -> Optic' p f s a -> r
+ Papa.Lens: simply :: forall {k} {k1} p (f :: k -> k1) (s :: k) (a :: k) (rep :: RuntimeRep) (r :: TYPE rep). (Optic' p f s a -> r) -> Optic' p f s a -> r
- Papa.Lens: substEq :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) r. AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r
+ Papa.Lens: substEq :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) (rep :: RuntimeRep) (r :: TYPE rep). AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r
- Papa.Lens: withEquality :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) r. AnEquality s t a b -> ((s :~: a) -> (b :~: t) -> r) -> r
+ Papa.Lens: withEquality :: forall {k1} {k2} (s :: k1) (t :: k2) (a :: k1) (b :: k2) (rep :: RuntimeRep) (r :: TYPE rep). AnEquality s t a b -> ((s :~: a) -> (b :~: t) -> r) -> r
- Papa.Lens: withIso :: AnIso s t a b -> ((s -> a) -> (b -> t) -> r) -> r
+ Papa.Lens: withIso :: forall s t a b (rep :: RuntimeRep) (r :: TYPE rep). AnIso s t a b -> ((s -> a) -> (b -> t) -> r) -> r
- Papa.Lens: withLens :: ALens s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r
+ Papa.Lens: withLens :: forall s t a b (rep :: RuntimeRep) (r :: TYPE rep). ALens s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r
- Papa.One.Renamed: class GetterOne x (f :: Type -> Type) a t | x -> f a t
+ Papa.One.Renamed: class () => GetterOne x (f :: Type -> Type) a t | x -> f a t
- Papa.One.Renamed: class GetterOneItem x where {
+ Papa.One.Renamed: class () => GetterOneItem x where {
- Papa.One.Renamed: class ReviewOne x (f :: Type -> Type) a t | x -> f a t
+ Papa.One.Renamed: class () => ReviewOne x (f :: Type -> Type) a t | x -> f a t
- Papa.One.Renamed: class ReviewOneItem x where {
+ Papa.One.Renamed: class () => ReviewOneItem x where {
- Papa.One.Renamed: data One (f :: Type -> Type) a t
+ Papa.One.Renamed: data () => One (f :: Type -> Type) a t
- Papa.Profunctors.Renamed: class Profunctor (p :: Type -> Type -> Type)
+ Papa.Profunctors.Renamed: class () => Profunctor (p :: Type -> Type -> Type)
- Papa.Profunctors.Renamed: newtype Costar (f :: k -> Type) (d :: k) c
+ Papa.Profunctors.Renamed: newtype () => Costar (f :: k -> Type) (d :: k) c
- Papa.Profunctors.Renamed: newtype Forget r a (b :: k)
+ Papa.Profunctors.Renamed: newtype () => Forget r a (b :: k)
- Papa.Profunctors.Renamed: newtype Star (f :: k -> Type) d (c :: k)
+ Papa.Profunctors.Renamed: newtype () => Star (f :: k -> Type) d (c :: k)
- Papa.Semigroupoids: class Semigroupoid (c :: k -> k -> Type)
+ Papa.Semigroupoids: class () => Semigroupoid (c :: k -> k -> Type)
- Papa.Semigroupoids: data MaybeApply (f :: Type -> Type) a
+ Papa.Semigroupoids: data () => MaybeApply (f :: Type -> Type) a
- Papa.Semigroupoids: data Semi m (a :: k) (b :: k1)
+ Papa.Semigroupoids: data () => Semi m (a :: k) (b :: k1)
- Papa.Semigroupoids: data Static (f :: Type -> Type) a b
+ Papa.Semigroupoids: data () => Static (f :: Type -> Type) a b
- Papa.Semigroupoids: data WrappedApplicative (f :: Type -> Type) a
+ Papa.Semigroupoids: data () => WrappedApplicative (f :: Type -> Type) a
- Papa.Semigroupoids: data WrappedCategory (k2 :: k -> k1 -> Type) (a :: k) (b :: k1)
+ Papa.Semigroupoids: data () => WrappedCategory (k2 :: k -> k1 -> Type) (a :: k) (b :: k1)
- Papa.Semigroupoids: infixl 4 <..>
+ Papa.Semigroupoids: infixl 4 <<..>>
- Papa.Witherable.Renamed: newtype WrappedFoldable (f :: Type -> Type) a
+ Papa.Witherable.Renamed: newtype () => WrappedFoldable (f :: Type -> Type) a

Files

+ bench/BenchVector.hs view
@@ -0,0 +1,95 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these benchmark Papa's total head and maximum of vectors against+-- vector's partial ones, whose names HLint restricts whatever module they+-- come from.++-- | Benchmarks of the total vector and hash map functions against the+-- partial ones of vector and unordered-containers, and of lens's 'ix' and+-- 'at' against indexing.+module BenchVector (+  benchmarks,+) where++import Criterion.Main (Benchmark, bench, bgroup, nf, whnf)+import qualified Data.HashMap.Strict as OHM+import qualified Data.Vector as OV+import qualified Data.Vector.Unboxed as OU+import Papa+import qualified Papa.UnorderedContainers.Data.HashMap as HashMap+import qualified Papa.Vector.Data.Vector as PV+import qualified Papa.Vector.Data.Vector.Unboxed as PU++size :: Int+size =+  100000++boxed :: PV.Vector Int+boxed =+  PV.enumFromN 0 size++unboxed :: PU.Vector Int+unboxed =+  PU.enumFromN 0 size++someIndices :: [Int]+someIndices =+  PV.toList (PV.enumFromStepN 0 7 1000)++updates :: [(Int, Int)]+updates =+  fmap (\i -> (i, i)) someIndices++hashMap :: HashMap Int Int+hashMap =+  HashMap.fromList (fmap (\i -> (i, i)) (PV.toList boxed))++-- | The benchmarks of the vector and hash map modules.+--+-- A total maximum that returns its 'Maybe' to the benchmark, unconsumed,+-- runs some 20% (boxed) to 45% (unboxed) slower than vector's: GHC allocates+-- the 'Just' and the boxed element in the loop's exit, and so checks the heap+-- on every iteration of the loop (as for @Just $! Data.Vector.maximum v@,+-- written by hand). A use that consumes the 'Maybe' in place+-- (@fromMaybe 0 . maximum@) runs at vector's speed.+benchmarks :: [Benchmark]+benchmarks =+  [ bgroup+      "vector"+      [ bench "Papa V.maximum (100000)" (nf PV.maximum boxed)+      , bench "Data.Vector maximum (100000)" (nf OV.maximum boxed)+      , bench "Papa U.maximum (100000, unboxed)" (nf PU.maximum unboxed)+      , bench "Data.Vector.Unboxed maximum (100000)" (nf OU.maximum unboxed)+      , bench "Papa V.maximum, consumed (100000)" (nf (fromMaybe 0 . PV.maximum) boxed)+      , bench "Papa U.maximum, consumed (100000, unboxed)" (nf (fromMaybe 0 . PU.maximum) unboxed)+      , bench "Papa V.maximumBy compare (100000)" (nf (PV.maximumBy compare) boxed)+      , bench "Data.Vector maximumBy compare (100000)" (nf (OV.maximumBy compare) boxed)+      , bench "Papa V.foldl1' (100000)" (nf (PV.foldl1' (+)) boxed)+      , bench "Data.Vector foldl1' (100000)" (nf (OV.foldl1' (+)) boxed)+      , bench "Papa V.// (1000 updates)" (nf (PV.// updates) boxed)+      , bench "Data.Vector // (1000 updates)" (nf (OV.// updates) boxed)+      , bench "Papa V.backpermute (1000)" (nf (PV.backpermute boxed) (PV.fromList someIndices))+      , bench "Data.Vector backpermute (1000)" (nf (OV.backpermute boxed) (OV.fromList someIndices))+      , bench "Papa V.slice (1000 slices)" (whnf (foldl' (\acc i -> acc + maybe 0 PV.length (PV.slice i 10 boxed)) 0) someIndices)+      , bench "Data.Vector slice (1000 slices)" (whnf (foldl' (\acc i -> acc + OV.length (OV.slice i 10 boxed)) 0) someIndices)+      , bench "Papa V.head (1000 tails)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (PV.head (PV.drop i boxed))) 0) someIndices)+      , bench "Data.Vector head (1000 tails)" (whnf (foldl' (\acc i -> acc + OV.head (OV.drop i boxed)) 0) someIndices)+      , bench "lens ^? ix (sum over 1000)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (boxed ^? ix i)) 0) someIndices)+      , bench "Data.Vector !? (sum over 1000)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (boxed OV.!? i)) 0) someIndices)+      , bench "Data.Vector ! (sum over 1000)" (whnf (foldl' (\acc i -> acc + (boxed OV.! i)) 0) someIndices)+      , bench "lens ^? ix (unboxed, sum over 1000)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (unboxed ^? ix i)) 0) someIndices)+      , bench "Data.Vector.Unboxed ! (sum over 1000)" (whnf (foldl' (\acc i -> acc + (unboxed OU.! i)) 0) someIndices)+      , bench "lens ix .~ (1 element)" (nf (\v -> v & ix 500 .~ 0) boxed)+      , bench "Papa V.// (1 element)" (nf (PV.// [(500, 0)]) boxed)+      ]+  , bgroup+      "unordered-containers"+      [ bench "lens the at (sum over 1000)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (the (at i) hashMap)) 0) someIndices)+      , bench "lens ^? ix (sum over 1000)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (hashMap ^? ix i)) 0) someIndices)+      , bench "Data.HashMap.Strict ! (sum over 1000)" (whnf (foldl' (\acc i -> acc + (hashMap OHM.! i)) 0) someIndices)+      , bench "lens at ?~ (insert)" (whnf (\m -> HashMap.size (m & at size ?~ 0)) hashMap)+      , bench "Data.HashMap.Strict insert" (whnf (HashMap.size . HashMap.insert size 0) hashMap)+      ]+  ]
+ bench/Main.hs view
@@ -0,0 +1,92 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these benchmark Papa's total maximum and div, whose names HLint+-- restricts whatever module they come from.++-- | Benchmarks of the functions that Papa defines, against the base+-- functions they replace where there is one.+module Main (+  main,+) where++import qualified BenchVector+import Criterion.Main (bench, bgroup, defaultMain, nf, whnf)+import qualified Data.Either as E+import qualified Data.Map.Strict as M+import Nub (nubBenchmarks)+import Papa+import qualified Papa.Containers.Data.Map as Map+import Text (textBenchmarks)+import Totality (totality)+import qualified Prelude as P++ints :: [Int]+ints =+  [1 .. 100000]++pairs :: [(Int, Int)]+pairs =+  fmap (\n -> (n, n)) ints++bigMap :: Map.Map Int Int+bigMap =+  Map.fromList pairs++eithers :: [Either Int Int]+eithers =+  fmap (\n -> bool (Left n) (Right n) (even n)) ints++main :: IO ()+main =+  defaultMain+    ( [ bgroup+          "list"+          [ bench "maximumOf folded (list)" (whnf (maximumOf folded) ints)+          , bench "maximum (Foldable1, NonEmpty)" (whnf maximum (0 :| ints))+          , bench "Papa.lookup (last key)" (whnf (lookup 100000) pairs)+          , bench "(++) right-nested (10 x 10000)" (nf (\xs -> xs ++ xs ++ xs ++ xs ++ xs ++ xs ++ xs ++ xs ++ xs ++ xs) (take 10000 ints))+          , bench "(!?) last index" (whnf (ints !?) 99999)+          , bench "Papa.partitionEithers" (nf partitionEithers eithers)+          , bench "Data.Either.partitionEithers" (nf E.partitionEithers eithers)+          ]+      , bgroup+          "maybe"+          [ bench "whenJust (sum over 100000)" (whnf (foldl' (\acc n -> acc + whenJust (\x -> bool Nothing (Just x) (even x)) (* 2) n) 0) ints)+          , bench "maybe (sum over 100000)" (whnf (foldl' (\acc n -> acc + maybe n (* 2) (bool Nothing (Just n) (even n))) 0) ints)+          , bench "whenJustM Maybe (sum over 100000)" (whnf (foldl' (\acc n -> acc + fromMaybe 0 (whenJustM (\x -> Just (bool Nothing (Just x) (even x))) (Just . (* 2)) n)) 0) ints)+          ]+      , bgroup+          "containers"+          [ bench "Papa Map.elemAt (sum over 1000)" (whnf (foldl' (\acc i -> acc + maybe 0 snd (Map.elemAt i bigMap)) 0) (take 1000 ints))+          , bench "Data.Map elemAt (sum over 1000)" (whnf (foldl' (\acc i -> acc + snd (M.elemAt i bigMap)) 0) (take 1000 ints))+          , bench "Papa Map.fromDistinctAscList (100000)" (whnf (maybe 0 Map.size . Map.fromDistinctAscList) pairs)+          , bench "Data.Map fromDistinctAscList (100000)" (whnf (M.size . M.fromDistinctAscList) pairs)+          , bench "Data.Map fromList (100000, sorted)" (whnf (M.size . M.fromList) pairs)+          , bench "Papa Map.! (sum over 1000)" (whnf (foldl' (\acc i -> acc + fromMaybe 0 (bigMap Map.! i)) 0) (take 1000 ints))+          , bench "Data.Map ! (sum over 1000)" (whnf (foldl' (\acc i -> acc + (bigMap M.! i)) 0) (take 1000 ints))+          ]+      , bgroup+          "fractional"+          [ bench "divideNonZero checking each divisor (sum over 100000)" (whnf (foldl' (\acc n -> acc + maybe 0 (divideNonZero 1) (preview nonZero (P.fromIntegral n :: Double))) 0) ints)+          , bench "Prelude./ (sum over 100000)" (whnf (foldl' (\acc n -> acc + (P./) 1 (P.fromIntegral n)) (0 :: Double)) ints)+          ]+      , bgroup+          "integral"+          [ bench "divModNonZero by one NonZero (sum over 100000)" (whnf (\xs -> maybe 0 (\d -> foldl' (\acc n -> acc + fst (divModNonZero n d)) 0 xs) (preview nonZero (7 :: Int))) ints)+          , bench "Prelude.divMod (sum over 100000)" (whnf (foldl' (\acc n -> acc + fst (P.divMod n 7)) 0) ints)+          ]+      , totality+      , bgroup+          "nonEmpty"+          [ bench "the head" (whnf (the head) (0 :| ints))+          , bench "the last" (whnf (the last) (0 :| ints))+          , bench "set last" (nf (set last 1) (0 :| ints))+          , bench "the init" (nf (the init) (0 :| ints))+          ]+      , bgroup "text and bytestring" textBenchmarks+      ]+        <> nubBenchmarks+        <> BenchVector.benchmarks+    )
+ bench/Nub.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Use nubOrd" -}+-- Reason: this benchmarks nub against nubOrd, which the hint would replace+-- it with.++-- | Benchmarks of Papa's duplicate removal, against "Data.List"'s @nub@.+module Nub (+  nubBenchmarks,+) where++import Criterion.Main (Benchmark, bench, bgroup, nf)+import qualified Data.List as L+import Papa++-- | 2000 elements, 1000 of them distinct.+duplicates :: [Int]+duplicates =+  maybe [] (\d -> fmap (`modNonZero` d) [1 .. 2000]) (preview nonZero (1000 :: Int))++-- | Papa's duplicate removal, against "Data.List"'s @nub@.+nubBenchmarks :: [Benchmark]+nubBenchmarks =+  [ bgroup+      "nub"+      [ bench "Data.List nub" (nf L.nub duplicates)+      , bench "nubOrd" (nf nubOrd duplicates)+      , bench "nubInt" (nf nubInt duplicates)+      ]+  ]
+ bench/Text.hs view
@@ -0,0 +1,152 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these benchmark the total head, maximum and index of the Text and+-- ByteString modules against the partial ones of text and bytestring, whose+-- names HLint restricts whatever module they come from.++-- | Benchmarks of the Text and ByteString modules against the functions of+-- text and bytestring that they replace.+module Text (+  textBenchmarks,+) where++import Criterion.Main (Benchmark, bench, bgroup, env, nf, nfIO, whnf)+import qualified Data.ByteString as SB+import qualified Data.ByteString.Char8 as SC+import qualified Data.Text as ST+import qualified Data.Text.Encoding as STE+import qualified Data.Text.IO as STIO+import qualified Data.Text.Read as STR+import Papa+import qualified Papa.Bytestring.Data.ByteString as B+import qualified Papa.Bytestring.Data.ByteString.Char8 as BC+import qualified Papa.Text.Data.Text as T+import qualified Papa.Text.Data.Text.Encoding as TE+import qualified Papa.Text.Data.Text.IO as TIO+import qualified Papa.Text.Data.Text.Read as TR+import qualified System.Directory as D+import qualified System.IO as IO++-- | 100000 characters, some of them not ASCII.+bigText :: Text+bigText =+  ST.replicate 20000 "ab\233\955c"++-- | 100000 bytes.+bigBytes :: ByteString+bigBytes =+  SB.take 100000 (SB.concat (replicate 400 (SB.pack [0 .. 255])))++-- | 100000 ASCII characters, which "Data.Text.IO" writes in any locale.+asciiText :: Text+asciiText =+  ST.replicate 20000 "abcde"++-- | 10000 short lines, some of their characters not ASCII.+shortLines :: [Text]+shortLines =+  replicate 10000 "hello, w\246rld \955"++-- | 100 lines of 10000 characters, some of them not ASCII.+longLines :: [Text]+longLines =+  replicate 100 (ST.replicate 2000 "ab\233\955c")++-- | A handle opened for writing UTF-8, block-buffered, as "Data.Text.IO"+-- needs to write any character; and the same for reading.+withUtf8 :: FilePath -> IO.IOMode -> (IO.Handle -> IO a) -> IO a+withUtf8 file mode k =+  IO.withFile file mode (\h -> IO.hSetEncoding h IO.utf8 >> IO.hSetBuffering h (IO.BlockBuffering Nothing) >> k h)++-- | Write lines with Papa's hPutStrLn.+papaPutLines :: FilePath -> [Text] -> IO ()+papaPutLines file ls =+  withUtf8 file IO.WriteMode (\h -> traverse_ (runExceptT . TIO.hPutStrLn h) ls)++-- | Write lines with "Data.Text.IO"'s hPutStrLn.+textPutLines :: FilePath -> [Text] -> IO ()+textPutLines file ls =+  withUtf8 file IO.WriteMode (\h -> traverse_ (STIO.hPutStrLn h) ls)++-- | Read every line with Papa's hGetLine.+papaGetLines :: FilePath -> IO Int+papaGetLines file =+  withUtf8 file IO.ReadMode (\h -> let go n = runExceptT (TIO.hGetLine h) >>= either (\_ -> pure n) (\t -> go $! n + ST.length t) in go 0)++-- | Read every line with "Data.Text.IO"'s hGetLine.+textGetLines :: FilePath -> IO Int+textGetLines file =+  withUtf8 file IO.ReadMode (\h -> let go n = IO.hIsEOF h >>= bool (STIO.hGetLine h >>= \t -> go $! n + ST.length t) (pure n) in go 0)++-- | A file in the temporary directory, of lines.+tempFile :: FilePath -> [Text] -> IO FilePath+tempFile name ls = do+  file <- fmap (<> name) D.getTemporaryDirectory+  file <$ textPutLines file ls++-- | The benchmarks of the Text and ByteString modules.+textBenchmarks :: [Benchmark]+textBenchmarks =+  [ bgroup+      "text"+      [ bench "Papa Text.head" (nf T.head bigText)+      , bench "Data.Text head" (nf ST.head bigText)+      , bench "Papa Text.maximum" (nf T.maximum bigText)+      , bench "Data.Text maximum" (nf ST.maximum bigText)+      , bench "Papa Text.index (last)" (nf (T.index bigText) 99999)+      , bench "Data.Text index (last)" (nf (ST.index bigText) 99999)+      , bench "Papa Text.splitOn" (nf (T.splitOn "\955") bigText)+      , bench "Data.Text splitOn" (nf (ST.splitOn "\955") bigText)+      , bench "Papa Text.replace" (nf (T.replace "\955" "x") bigText)+      , bench "Data.Text replace" (nf (ST.replace "\955" "x") bigText)+      , bench "Papa Encoding.decodeUtf16LE" (nf TE.decodeUtf16LE (STE.encodeUtf16LE bigText))+      , bench "Data.Text.Encoding decodeUtf16LE" (nf STE.decodeUtf16LE (STE.encodeUtf16LE bigText))+      , bench "Papa Read.decimal (Int)" (nf (\t -> TR.decimal t :: Either [Char] (Int, Text)) "1234567890123")+      , bench "Data.Text.Read decimal (Int)" (nf (\t -> STR.decimal t :: Either [Char] (Int, Text)) "1234567890123")+      ]+  , bgroup+      "bytestring"+      [ bench "Papa ByteString.maximum" (nf B.maximum bigBytes)+      , bench "Data.ByteString maximum" (whnf SB.maximum bigBytes)+      , bench "Papa ByteString.foldl1'" (nf (B.foldl1' max) bigBytes)+      , bench "Data.ByteString foldl1'" (whnf (SB.foldl1' max) bigBytes)+      , bench "Papa Char8.pack (100000)" (nf BC.pack (SC.unpack bigBytes))+      , bench "Data.ByteString.Char8 pack (100000)" (nf SC.pack (SC.unpack bigBytes))+      , bench "Papa Char8.elem (absent)" (nf (BC.elem '\0') (SB.filter (/= 0) bigBytes))+      , bench "Data.ByteString.Char8 elem (absent)" (nf (SC.elem '\0') (SB.filter (/= 0) bigBytes))+      ]+  , env+      (fmap (<> "/papa-bench-text.txt") D.getTemporaryDirectory)+      ( \file ->+          bgroup+            "text io"+            [ bench "Papa TextIO.writeFile and readFile (100000 characters)" (nfIO (fmap (preview _Right) (runExceptT (TIO.writeFile file asciiText >> TIO.readFile file))))+            , bench "Data.Text.IO writeFile and readFile (100000 characters)" (nfIO (STIO.writeFile file asciiText >> STIO.readFile file))+            , bench "Papa TextIO.hPutStrLn (10000 short lines)" (nfIO (papaPutLines file shortLines))+            , bench "Data.Text.IO hPutStrLn (10000 short lines)" (nfIO (textPutLines file shortLines))+            , bench "Papa TextIO.hPutStrLn (100 lines of 10000)" (nfIO (papaPutLines file longLines))+            , bench "Data.Text.IO hPutStrLn (100 lines of 10000)" (nfIO (textPutLines file longLines))+            ]+      )+  , env+      (tempFile "/papa-bench-lines.txt" shortLines)+      ( \file ->+          bgroup+            "text io read"+            [ bench "Papa TextIO.hGetLine (10000 short lines)" (nfIO (papaGetLines file))+            , bench "Data.Text.IO hGetLine (10000 short lines)" (nfIO (textGetLines file))+            ]+      )+  , env+      (tempFile "/papa-bench-big.txt" (concat (replicate 10 longLines)))+      ( \file ->+          bgroup+            "text io readFile"+            [ bench "Papa TextIO.readFile (10 MB)" (nfIO (fmap (preview _Right) (runExceptT (TIO.readFile file))))+            , bench "Data.Text.IO readFile (10 MB)" (nfIO (withUtf8 file IO.ReadMode STIO.hGetContents))+            ]+      )+  ]
+ bench/Totality.hs view
@@ -0,0 +1,190 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these benchmark Papa's total functions against the partial ones+-- of Papa.Unsafe.Numeric, Prelude and containers, whose names HLint+-- restricts.++-- | The cost of totality: each total function of Papa against the partial+-- function it replaces, at the same inputs. Each group has two benchmarks,+-- @papa@ and @partial@.+--+-- The inputs are built in 'env', at run time, so that GHC cannot fold a+-- divisor or a length into the code.+module Totality (+  totality,+) where++import Criterion.Main (Benchmark, bench, bgroup, env, nf, whnf)+import qualified Data.IntMap.Strict as IM+import qualified Data.IntSet as IS+import qualified Data.Map.Strict as M+import qualified Data.Sequence as Sq+import qualified Data.Set as St+import Papa+import qualified Papa.Containers.Data.IntMap as IntMap+import qualified Papa.Containers.Data.IntSet as IntSet+import qualified Papa.Containers.Data.Map as Map+import qualified Papa.Containers.Data.Seq as Seq+import qualified Papa.Containers.Data.Set as Set+import qualified Papa.Unsafe.Numeric as U+import qualified Prelude as P++-- | A total function against a partial one.+pair :: String -> Benchmark -> Benchmark -> Benchmark+pair name total partial =+  bgroup name [total, partial]++-- | The inputs, built at run time.+data Inputs+  = Inputs+      [Int]+      Int+      (NonZero Int)+      [Double]+      Double+      (NonZero Double)+      [Int32]+      (Map Int Int)+      (Set Int)+      (IntMap Int)+      IntSet+      (Seq Int)+      [(Int, Int)]+      [Int]++instance NFData Inputs where+  rnf (Inputs a b c d e f g h i j k l m n) =+    rnf (a, b, c, d, e, f, g) `seq` rnf (h, i, j, k, l, m, n)++-- | The inputs: 10000 values, a divisor of 7 (and the same in 'NonZero'),+-- and containers of 10000 elements.+inputs :: IO Inputs+inputs = do+  nz <- maybe (die (pack "the divisor is zero")) pure (preview nonZero seven)+  nzd <- maybe (die (pack "the divisor is zero")) pure (preview nonZero (integralToFloating seven :: Double))+  evaluate+    ( force+        ( Inputs+            ints+            seven+            nz+            doubles+            (integralToFloating seven)+            nzd+            (mapMaybe toIntegralSized ints)+            (M.fromList kvs)+            (St.fromList ints)+            (IM.fromList kvs)+            (IS.fromList ints)+            (Sq.fromList ints)+            kvs+            ints+        )+    )+ where+  ints = [1 .. 10000]+  seven = length (take 7 ints)+  doubles = fmap (\n -> integralToFloating n P.* 1.37) ints+  kvs = fmap (\n -> (n, n)) ints++-- | Every pair.+totality :: Benchmark+totality =+  env inputs (\ ~(Inputs xs d nz ys dd nzd i32s m s im is sq kvs ks) -> bgroup "totality" (integral xs d nz i32s <> fractional ys dd nzd <> conversion ys xs <> containers xs m s im is sq <> builders kvs ks m s im is))++-- | Sum of a function over a list.+sumOver :: (Num b) => (a -> b) -> [a] -> b+sumOver f =+  foldl' (\acc x -> acc + f x) 0+{-# INLINE sumOver #-}++integral :: [Int] -> Int -> NonZero Int -> [Int32] -> [Benchmark]+integral xs d nz i32s =+  [ pair "divNonZero vs div" (bench "papa" (whnf (sumOver (`divNonZero` nz)) xs)) (bench "partial" (whnf (sumOver (`U.div` d)) xs))+  , pair "modNonZero vs mod" (bench "papa" (whnf (sumOver (`modNonZero` nz)) xs)) (bench "partial" (whnf (sumOver (`U.mod` d)) xs))+  , pair "divModNonZero vs divMod" (bench "papa" (whnf (sumOver (uncurry (+) . (`divModNonZero` nz))) xs)) (bench "partial" (whnf (sumOver (uncurry (+) . (`U.divMod` d))) xs))+  , pair "quotNonZero vs quot" (bench "papa" (whnf (sumOver (`quotNonZero` nz)) xs)) (bench "partial" (whnf (sumOver (`U.quot` d)) xs))+  , pair "remNonZero vs rem" (bench "papa" (whnf (sumOver (`remNonZero` nz)) xs)) (bench "partial" (whnf (sumOver (`U.rem` d)) xs))+  , pair "quotRemNonZero vs quotRem" (bench "papa" (whnf (sumOver (uncurry (+) . (`quotRemNonZero` nz))) xs)) (bench "partial" (whnf (sumOver (uncurry (+) . (`U.quotRem` d))) xs))+  ]+    <> foldMap (\nzi -> [pair "ratioNonZero vs (%)" (bench "papa" (nf (fmap (\x -> ratioNonZero (toInteger x) nzi)) xs)) (bench "partial" (nf (fmap (\x -> toInteger x U.% toInteger d)) xs))]) (preview nonZero (toInteger d))+    <> [ pair "pow vs (^)" (bench "papa" (whnf (sumOver (`pow` 3)) xs)) (bench "partial" (whnf (sumOver (\x -> x U.^ (3 :: Word))) xs))+       , pair "intCast vs fromIntegral (Int32 -> Int64)" (bench "papa" (whnf (sumOver (intCast :: Int32 -> Int64)) i32s)) (bench "partial" (whnf (sumOver (U.fromIntegral :: Int32 -> Int64)) i32s))+       , pair "succ vs succ" (bench "papa" (whnf (sumOver (fromMaybe 0 . succ)) xs)) (bench "partial" (whnf (sumOver P.succ) xs))+       , pair "pred vs pred" (bench "papa" (whnf (sumOver (fromMaybe 0 . pred)) xs)) (bench "partial" (whnf (sumOver P.pred) xs))+       ]++fractional :: [Double] -> Double -> NonZero Double -> [Benchmark]+fractional ys d nz =+  [ pair "divideNonZero vs (/)" (bench "papa" (whnf (sumOver (`divideNonZero` nz)) ys)) (bench "partial" (whnf (sumOver (U./ d)) ys))+  , pair "recipNonZero vs recip" (bench "papa" (whnf (sumOver (\y -> y * recipNonZero nz)) ys)) (bench "partial" (whnf (sumOver (\y -> y * U.recip d)) ys))+  , pair "powNonZero vs (^^)" (bench "papa" (whnf (sumOver (\y -> y * powNonZero nz (-3 :: Int))) ys)) (bench "partial" (whnf (sumOver (\y -> y * (d U.^^ (-3 :: Int)))) ys))+  ]++conversion :: [Double] -> [Int] -> [Benchmark]+conversion ys xs =+  [ pair "truncateMaybe vs truncate (Double -> Int)" (bench "papa" (whnf (sumOver (fromMaybe 0 . (truncateMaybe :: Double -> Maybe Int))) ys)) (bench "partial" (whnf (sumOver (U.truncate :: Double -> Int)) ys))+  , pair "roundMaybe vs round (Double -> Int)" (bench "papa" (whnf (sumOver (fromMaybe 0 . (roundMaybe :: Double -> Maybe Int))) ys)) (bench "partial" (whnf (sumOver (U.round :: Double -> Int)) ys))+  , pair "ceilingMaybe vs ceiling (Double -> Int)" (bench "papa" (whnf (sumOver (fromMaybe 0 . (ceilingMaybe :: Double -> Maybe Int))) ys)) (bench "partial" (whnf (sumOver (U.ceiling :: Double -> Int)) ys))+  , pair "floorMaybe vs floor (Double -> Int)" (bench "papa" (whnf (sumOver (fromMaybe 0 . (floorMaybe :: Double -> Maybe Int))) ys)) (bench "partial" (whnf (sumOver (U.floor :: Double -> Int)) ys))+  , pair "truncateMaybe vs truncate (Double -> Integer)" (bench "papa" (whnf (sumOver (fromMaybe 0 . (truncateMaybe :: Double -> Maybe Integer))) ys)) (bench "partial" (whnf (sumOver (U.truncate :: Double -> Integer)) ys))+  , pair "properFractionMaybe vs properFraction (Double -> Int)" (bench "papa" (whnf (sumOver (maybe 0 fst . (properFractionMaybe :: Double -> Maybe (Int, Double)))) ys)) (bench "partial" (whnf (sumOver (fst . (U.properFraction :: Double -> (Int, Double)))) ys))+  , pair "toRationalMaybe vs toRational" (bench "papa" (nf (fmap toRationalMaybe) ys)) (bench "partial" (nf (fmap U.toRational) ys))+  , pair "doubleToFloat vs realToFrac" (bench "papa" (whnf (sumOver doubleToFloat) ys)) (bench "partial" (whnf (sumOver (U.realToFrac :: Double -> Float)) ys))+  , pair "floatToDouble vs realToFrac" (bench "papa" (whnf (sumOver (floatToDouble . doubleToFloat)) ys)) (bench "partial" (whnf (sumOver ((U.realToFrac :: Float -> Double) . doubleToFloat)) ys))+  , pair "integralToFloating vs fromIntegral (Int -> Double)" (bench "papa" (whnf (sumOver (integralToFloating :: Int -> Double)) xs)) (bench "partial" (whnf (sumOver (U.fromIntegral :: Int -> Double)) xs))+  ]++containers :: [Int] -> Map Int Int -> Set Int -> IntMap Int -> IntSet -> Seq Int -> [Benchmark]+containers xs m s im is sq =+  [ pair "Map.! vs Data.Map.!" (bench "papa" (whnf (sumOver (fromMaybe 0 . (m Map.!))) xs)) (bench "partial" (whnf (sumOver (m M.!)) xs))+  , pair "Map.findMin vs Data.Map.findMin" (bench "papa" (whnf Map.findMin m)) (bench "partial" (whnf M.findMin m))+  , pair "Map.findMax vs Data.Map.findMax" (bench "papa" (whnf Map.findMax m)) (bench "partial" (whnf M.findMax m))+  , pair "Map.deleteFindMin vs Data.Map.deleteFindMin" (bench "papa" (nf Map.deleteFindMin m)) (bench "partial" (nf M.deleteFindMin m))+  , pair "Map.deleteFindMax vs Data.Map.deleteFindMax" (bench "papa" (nf Map.deleteFindMax m)) (bench "partial" (nf M.deleteFindMax m))+  , pair "Map.elemAt vs Data.Map.elemAt" (bench "papa" (whnf (sumOver (\i -> maybe 0 snd (Map.elemAt (i - 1) m))) xs)) (bench "partial" (whnf (sumOver (\i -> snd (M.elemAt (i - 1) m))) xs))+  , pair "Map.findIndex vs Data.Map.findIndex" (bench "papa" (whnf (sumOver (\k -> fromMaybe 0 (Map.findIndex k m))) xs)) (bench "partial" (whnf (sumOver (`M.findIndex` m)) xs))+  , pair "Map.deleteAt vs Data.Map.deleteAt" (bench "papa" (nf (Map.deleteAt 5000) m)) (bench "partial" (nf (M.deleteAt 5000) m))+  , pair "Map.updateAt vs Data.Map.updateAt" (bench "papa" (nf (Map.updateAt (\_ v -> Just (v + 1)) 5000) m)) (bench "partial" (nf (M.updateAt (\_ v -> Just (v + 1)) 5000) m))+  , pair "Set.findMin vs Data.Set.findMin" (bench "papa" (whnf Set.findMin s)) (bench "partial" (whnf St.findMin s))+  , pair "Set.findMax vs Data.Set.findMax" (bench "papa" (whnf Set.findMax s)) (bench "partial" (whnf St.findMax s))+  , pair "Set.deleteFindMin vs Data.Set.deleteFindMin" (bench "papa" (nf Set.deleteFindMin s)) (bench "partial" (nf St.deleteFindMin s))+  , pair "Set.elemAt vs Data.Set.elemAt" (bench "papa" (whnf (sumOver (\i -> fromMaybe 0 (Set.elemAt (i - 1) s))) xs)) (bench "partial" (whnf (sumOver (\i -> St.elemAt (i - 1) s)) xs))+  , pair "Set.findIndex vs Data.Set.findIndex" (bench "papa" (whnf (sumOver (\a -> fromMaybe 0 (Set.findIndex a s))) xs)) (bench "partial" (whnf (sumOver (`St.findIndex` s)) xs))+  , pair "Set.deleteAt vs Data.Set.deleteAt" (bench "papa" (nf (Set.deleteAt 5000) s)) (bench "partial" (nf (St.deleteAt 5000) s))+  , pair "IntMap.! vs Data.IntMap.!" (bench "papa" (whnf (sumOver (fromMaybe 0 . (im IntMap.!))) xs)) (bench "partial" (whnf (sumOver (im IM.!)) xs))+  , pair "IntMap.findMin vs Data.IntMap.findMin" (bench "papa" (whnf IntMap.findMin im)) (bench "partial" (whnf IM.findMin im))+  , pair "IntMap.deleteFindMin vs Data.IntMap.deleteFindMin" (bench "papa" (nf IntMap.deleteFindMin im)) (bench "partial" (nf IM.deleteFindMin im))+  , pair "IntSet.findMin vs Data.IntSet.findMin" (bench "papa" (whnf IntSet.findMin is)) (bench "partial" (whnf IS.findMin is))+  , pair "IntSet.deleteFindMin vs Data.IntSet.deleteFindMin" (bench "papa" (nf IntSet.deleteFindMin is)) (bench "partial" (nf IS.deleteFindMin is))+  , pair "Seq.index vs Data.Sequence.index" (bench "papa" (whnf (sumOver (\i -> fromMaybe 0 (Seq.index sq (i - 1)))) xs)) (bench "partial" (whnf (sumOver (\i -> Sq.index sq (i - 1))) xs))+  , pair "Seq.replicate vs Data.Sequence.replicate" (bench "papa" (nf (`Seq.replicate` 'x') (length xs))) (bench "partial" (nf (`Sq.replicate` 'x') (length xs)))+  , pair "Seq.iterateN vs Data.Sequence.iterateN" (bench "papa" (nf (\n -> Seq.iterateN n (+ 1) (0 :: Int)) (length xs))) (bench "partial" (nf (\n -> Sq.iterateN n (+ 1) (0 :: Int)) (length xs)))+  , pair "Seq.fromFunction vs Data.Sequence.fromFunction" (bench "papa" (nf (`Seq.fromFunction` (+ 1)) (length xs))) (bench "partial" (nf (`Sq.fromFunction` (+ 1)) (length xs)))+  , pair "Seq.chunksOf vs Data.Sequence.chunksOf" (bench "papa" (nf (Seq.chunksOf 7) sq)) (bench "partial" (nf (Sq.chunksOf 7) sq))+  , pair "Seq.cycleTaking vs Data.Sequence.cycleTaking" (bench "papa" (nf (Seq.cycleTaking 30000) sq)) (bench "partial" (nf (Sq.cycleTaking 30000) sq))+  , pair "Seq.scanl1 vs Data.Sequence.scanl1" (bench "papa" (nf (Seq.scanl1 (+)) sq)) (bench "partial" (nf (Sq.scanl1 (+)) sq))+  , pair "Seq.scanr1 vs Data.Sequence.scanr1" (bench "papa" (nf (Seq.scanr1 (+)) sq)) (bench "partial" (nf (Sq.scanr1 (+)) sq))+  ]++builders :: [(Int, Int)] -> [Int] -> Map Int Int -> Set Int -> IntMap Int -> IntSet -> [Benchmark]+builders kvs ks m s im is =+  [ pair "Map.fromAscList vs Data.Map.fromAscList" (bench "papa" (nf Map.fromAscList kvs)) (bench "partial" (nf M.fromAscList kvs))+  , pair "Map.fromAscListWith vs Data.Map.fromAscListWith" (bench "papa" (nf (Map.fromAscListWith (+)) kvs)) (bench "partial" (nf (M.fromAscListWith (+)) kvs))+  , pair "Map.fromDistinctAscList vs Data.Map.fromDistinctAscList" (bench "papa" (nf Map.fromDistinctAscList kvs)) (bench "partial" (nf M.fromDistinctAscList kvs))+  , pair "Map.fromDescList vs Data.Map.fromDescList" (bench "papa" (nf Map.fromDescList (reverse kvs))) (bench "partial" (nf M.fromDescList (reverse kvs)))+  , pair "Map.fromDistinctDescList vs Data.Map.fromDistinctDescList" (bench "papa" (nf Map.fromDistinctDescList (reverse kvs))) (bench "partial" (nf M.fromDistinctDescList (reverse kvs)))+  , pair "Map.mapKeysMonotonic vs Data.Map.mapKeysMonotonic" (bench "papa" (nf (Map.mapKeysMonotonic (* 2)) m)) (bench "partial" (nf (M.mapKeysMonotonic (* 2)) m))+  , pair "Set.fromAscList vs Data.Set.fromAscList" (bench "papa" (nf Set.fromAscList ks)) (bench "partial" (nf St.fromAscList ks))+  , pair "Set.fromDistinctAscList vs Data.Set.fromDistinctAscList" (bench "papa" (nf Set.fromDistinctAscList ks)) (bench "partial" (nf St.fromDistinctAscList ks))+  , pair "Set.fromDescList vs Data.Set.fromDescList" (bench "papa" (nf Set.fromDescList (reverse ks))) (bench "partial" (nf St.fromDescList (reverse ks)))+  , pair "Set.mapMonotonic vs Data.Set.mapMonotonic" (bench "papa" (nf (Set.mapMonotonic (* 2)) s)) (bench "partial" (nf (St.mapMonotonic (* 2)) s))+  , pair "IntMap.fromAscList vs Data.IntMap.fromAscList" (bench "papa" (nf IntMap.fromAscList kvs)) (bench "partial" (nf IM.fromAscList kvs))+  , pair "IntMap.fromDistinctAscList vs Data.IntMap.fromDistinctAscList" (bench "papa" (nf IntMap.fromDistinctAscList kvs)) (bench "partial" (nf IM.fromDistinctAscList kvs))+  , pair "IntMap.mapKeysMonotonic vs Data.IntMap.mapKeysMonotonic" (bench "papa" (nf (IntMap.mapKeysMonotonic (* 2)) im)) (bench "partial" (nf (IM.mapKeysMonotonic (* 2)) im))+  , pair "IntSet.fromAscList vs Data.IntSet.fromAscList" (bench "papa" (nf IntSet.fromAscList ks)) (bench "partial" (nf IS.fromAscList ks))+  , pair "IntSet.fromDistinctAscList vs Data.IntSet.fromDistinctAscList" (bench "papa" (nf IntSet.fromDistinctAscList ks)) (bench "partial" (nf IS.fromDistinctAscList ks))+  , pair "IntSet.mapMonotonic vs Data.IntSet.mapMonotonic" (bench "papa" (nf (IntSet.mapMonotonic (* 2)) is)) (bench "partial" (nf (IS.mapMonotonic (* 2)) is))+  ]
changelog.md view
@@ -1,3 +1,271 @@+0.7.0++Breaking changes:++* `Papa` no longer exports `div`, `mod`, `divMod`, `quot`, `rem`, `quotRem`,+  `(^)`, `(/)`, `recip`, `(^^)` or `(%)`. `Prelude`'s, which throw, are in+  the new `Papa.Unsafe`, which `Papa` does not import, with `printf` and+  `hPrintf`. The total versions in `Papa` have names of their own and take a+  `NonZero` divisor: `divNonZero`, `modNonZero`, `divModNonZero`,+  `quotNonZero`, `remNonZero`, `quotRemNonZero`, `ratioNonZero`,+  `divideNonZero`, `recipNonZero`, `powNonZero`; and `pow` takes a `Word`+  exponent. `ratioNonZero` is `Integer -> NonZero Integer -> Rational`. Build a divisor once with `preview nonZero`, read it back with+  `the divisor`+* `maximum`, `minimum`, `maximumBy`, `minimumBy` are `Data.Foldable1`'s (any+  `Foldable1`, total, no `Maybe`); remove `maximum1`, `minimum1` and+  `Papa.Semigroupoids.Data.Semigroup.Foldable`+* `fromIntegral` is no longer exported by `Papa`: it is in+  `Papa.Unsafe.Numeric`. Use `intCast` (new; lossless conversions checked by+  the type checker) or `toIntegralSized`+* `Papa.Unsafe` is all of `Papa` with every partial function; the partial+  functions are also in `Papa.Unsafe.Numeric` and `Papa.Unsafe.Format`, which+  export only them+* `succ` needs only `Enum` (it works at `Integer`, `Natural`, `Double`)+* `fromLeft`, `fromRight` are generalised to the new names `left` and+  `right` (`LeftLike`, `RightLike`); `Papa.Base.Control.Arrow` exports+  `ArrowChoice`'s `left`, `right` as `leftA`, `rightA`+* `Papa.Base.Control.Monad.State`, `.Reader` and `.Error` are re-exported by+  `Papa`+* `Papa` exports the core of lens (`Papa.Lens.Core`) instead of all of+  `Control.Lens`; all of it, less its partial combinators, is in `Papa.Lens`+* Remove `Papa.Adjunctions.Renamed`, `Papa.Polytree.Renamed` and+  `Papa.Selective.Renamed`: `Papa.Adjunctions`, `Papa.Polytree` and+  `Papa.Selective` now import alongside `Papa`; `Papa.Associative.Renamed`+  hides only `null`+* `zero` (`Plus`) and `mfix` (`MonadFix`) are no longer exported: they throw+  at some instances; their classes still are+* Text first, and I/O errors are values: `putStr`, `putStrLn`, `print`,+  `getLine`, `getContents`, `readFile`, `writeFile`, `appendFile`,+  `interact`, `hPutStr`, `hPutStrLn`, `hGetLine`, `hGetContents` and `hPrint`+  are `Papa.Text.Data.Text.IO`'s: they read and write `Text` as UTF-8 whatever+  the locale, read strictly, and return `IOExcept` (`ExceptT IOFailure IO`)+  instead of throwing; invalid UTF-8 is a `DecodeFailed`. `lines`,+  `words`, `unlines` and `unwords` are `Text`'s (the `String` ones are in+  `Papa.Base.Data.List`)+* `openFile`, `withFile`, `hClose`, `hFlush`, `hIsEOF` and `hSetBuffering`+  return `IOExcept`. `hGetContents'`, `hGetChar`, `putChar` and `readLn` are+  no longer exported. Base's `System.IO`, String, lazy and throwing, is+  `Papa.Unsafe.IO`, imported qualified: `Papa.Unsafe` does not re-export it,+  since its names are `Papa`'s+* `catch`, `handle` and `try` never catch an asynchronous exception, even at+  `SomeException`; `bracket`, `bracket_`, `bracketOnError`, `finally` and+  `onException` release under `uninterruptibleMask_` (the semantics of+  safe-exceptions, implemented in `Papa.Base.Control.Exception`)+* `truncate`, `round`, `ceiling`, `floor`, `properFraction`, `toRational`+  and `realToFrac` are in `Papa.Unsafe.Numeric`: at `Double` and `Float` they+  return an arbitrary number for NaN and the infinities, and the rounding+  functions wrap where the result does not fit. `Papa` exports `RealFrac` and+  `Real` without these methods+* `modifyIORef` is not exported: use `modifyIORef'`+* `fromInteger` is not exported (numeric literals still work); the types+  `Natural` and `Ratio`, `minusNaturalMaybe` and `approxRational` are not+  exported either, and `Papa.Base.Numeric.Natural` is removed. All are in+  `Papa.Unsafe.Numeric`. `Papa` keeps `Rational`, `numerator` and+  `denominator`+* Pure `throw`, `error`, `errorWithoutStackTrace`, `undefined`, and lens's+  `throwing` and `throwing_`, are in the new `Papa.Unsafe.Exception`+* The `NonZero` division functions, the conversions and the order checks are+  rewritten for speed: they allocate no `Integer`, `pow` takes a `Word` path,+  `succ` allocates no list+* The vector, `Text` and `Char8` wrappers inline when partially applied+  (`foldl1' (+)`, `maximumBy compare`, `splitOn p`, `map f`): `foldl1' (+)`+  on a boxed vector goes from 242 µs to 98 µs, level with vector+* `Text` I/O's `hPutStr` and `hPutStrLn` write UTF-8 straight into the+  handle's buffer; both are 2–5 times as fast as `Data.Text.IO`+* `readMaybe`, `readEither` and `readIO` take `Text`, and `readEither`'s+  error is `Text`; `die` takes `Text` and writes it to `stderr` as UTF-8,+  exiting whether or not it could be written. Base's `String` versions are+  still in `Papa.Base`. `getArgs`, `getProgName` and `lookupEnv` still return+  `String`: an argument or a variable need not be UTF-8, and a file name+  must keep its bytes+* `Text` I/O's `hGetLine` finds the line in the handle's byte buffer and+  copies it straight into the text once it is checked as UTF-8, with no+  intermediate `ByteString`: 1.25–1.6 times as fast as before++Additions:++* `IOExcept` (`ExceptT IOFailure IO`), `exceptIO`, and `IOFailure`+  (`Papa.Base.System.IO.Except`): an `IOException` (`IOFailed`) or bytes that+  are not UTF-8 from a handle or file (`DecodeFailed`), with the prisms+  `_IOFailed`, `_DecodeFailed`, an `AsIOException` instance, and the classy+  `GetIOFailure`, `HasIOFailure`, `ReviewIOFailure`, `AsIOFailure`+* `except`, `liftEither`, `withExcept`, `mapExceptT`+* `approxRationalMaybe`+* The `Enum` documentation explains range syntax at `Float` and `Double`+* `MIGRATION.md`: a guide from `Prelude` to Papa+* `Papa.Directory.System.Directory`, re-exported by `Papa`: every action of+  `directory`, returning `IOExcept`. `withCurrentDirectory` takes an+  `IOExcept` action and restores the directory whether or not it fails. Not+  exported: `getDirectoryContents`, `isSymbolicLink`, `findFileWith`,+  `findFilesWith`+* `Papa.Filepath.System.FilePath`, re-exported by `Papa`: all of `filepath`,+  which is total; `(<.>)` is hidden, since it clashes with lens's (use+  `addExtension` or `-<.>`); `getSearchPath` returns `IOExcept`+* `Papa.Async.Control.Concurrent.Async`, re-exported by `Papa`: structured+  concurrency whose results are values (`waitCatch`, `waitExcept`, `poll`,+  the `…Catch` functions); `waitAnyCatch`, `waitAnyCatchSTM` and+  `waitAnyCatchCancel` take a `NonEmpty`; `concurrentlyExcept`, `raceExcept`+  for `ExceptT e IO`+* `Papa.Unsafe.Async`, re-exported by `Papa.Unsafe`: the `wait` functions,+  which rethrow, and `link`, `link2`, `linkOnly`, `link2Only`+* Depend on async (>= 2.2.5), directory and filepath+* `display :: Show a => a -> Text`+* `displayFixed`, `displayExponent :: RealFloat a => Word -> a -> Text`:+  a floating-point number with a number of decimal places (`showFFloat`,+  `showEFloat`, as `printf "%.2f"` shows it)+* `Papa.Base.Data.RealFloat`, re-exported by `Papa`: total floating-point+  division and rounding, whose results are floating-point numbers.+  `divideFloating` and `recipFloating` are `(/)` and `recip` at `RealFloat`+  only, where division by zero is an infinity or NaN; `floorFloating`,+  `ceilingFloating`, `truncateFloating` and `roundFloating` round to a whole+  number of the same type, as C's `floor` and the like do (NaN, the+  infinities and the sign of zero kept); `modFloating` is `Data.Fixed`'s+  `mod'`, NaN for a divisor of zero, where `mod'` throws+* `previewNonZero :: (Eq a, Num a) => a -> Maybe (NonZero a)`: `preview+  nonZero` whose type comes from where it is used, so a literal needs no+  annotation (`quotNonZero n <$> previewNonZero 100`), at any `Num`+* `truncateMaybe`, `roundMaybe`, `ceilingMaybe`, `floorMaybe`,+  `properFractionMaybe`, `toRationalMaybe`: `Nothing` for NaN, the+  infinities, and a result that does not fit; `floatToDouble`,+  `doubleToFloat` (NaN and the infinities kept, no `Rational`);+  `integralToFloating` (`Papa.Base.Data.RealFrac`)+* Exceptions: `mask`, `mask_`, `uninterruptibleMask`,+  `uninterruptibleMask_`, `getMaskingState`, `MaskingState`, `throwTo`,+  `SomeAsyncException`, `AsyncException`, `ArithException`, `ArrayException`,+  `ErrorCall`, `forkFinally`; `MonadThrow`, `MonadCatch`, `MonadMask` (the+  classes); lens's exception optics (`Papa.Lens.Control.Exception`:+  `catching`, `handling`, `trying`, `throwingM`, `_IOException`, ...) and+  `IOException` optics (`Papa.Lens.System.IO.Error`: `errorType`,+  `fileName`, `_NoSuchThing`, `_PermissionDenied`, ...; lens's `handle` is+  `errorHandle`)+* `nubOrd`, `nubOrdOn`, `nubInt`, `nubIntOn`+* text and bytestring, imported qualified, with total same-named+  replacements returning `Maybe` or `Either` for each function that throws:+  `Papa.Text.Data.Text`, `.Lazy`, `.Encoding`, `.Lazy.Encoding`, `.Read`,+  `.Lazy.Read` (range-checked: text's read `"300"` as `44` at `Word8`),+  `.Lazy.Builder`, `.Lazy.Builder.Int`, `.IO`; `Papa.Bytestring.Data.ByteString`,+  `.Lazy`, `.Char8`, `.Lazy.Char8`, `.Builder`, whose I/O returns `IOExcept`,+  whose `Char8` and `Builder` functions return `Nothing` rather than truncate+  a character, and which export no lazy I/O+* vector and unordered-containers, imported qualified:+  `Papa.Vector.Data.Vector`, `.Unboxed`, `.Storable`, `.Generic`, whose+  functions that throw for an index out of range, an empty vector, a+  negative length or mismatched lengths return `Maybe` under the same names+  in the same time; `(!)` and the `unsafe*` functions are not exported (use+  `ix`); `Papa.UnorderedContainers.Data.HashMap` (strict, without `(!)`),+  `.HashSet`, `Papa.Hashable.Data.Hashable`. `Papa` exports `Vector`,+  `HashMap`, `HashSet` and `Hashable`+* Depend on exceptions, hashable, primitive, unordered-containers and+  vector; `containers >= 0.6.0.1`, `text >= 2.0.2`++* `NonZero`, `nonZero` (the smart constructor, a prism at each numeric type+  of base), `divisor`, `validNonZero`, `lawNamesNonZero`, `InheritNonZero`,+  `inheritNonZero`, following the classy optics recipe+* `userError`, `Identity`, the equality constraint `~`, `showList`,+  `toNonEmpty`+* `the` (`Papa.Lens.Optic`), the classy optics reader+* `intCast`, `IntCast`, `IsIntSubType` (`Papa.Base.Data.IntCast`): integral+  conversions that cannot lose information, checked by the type checker,+  after the `int-cast` package+* `NonZero` instances `Eq1`, `Ord1`, `Show1`, `Foldable`, `Foldable1`+* `Text`, `pack`, `unpack`, `encodeUtf8`, `decodeUtf8'`; `ByteString`; the+  types `Map`, `Set`, `IntMap`, `IntSet`, `Seq`+* mtl: `StateT`, `State`, `ReaderT`, `Reader`, `ExceptT`, `Except`, their+  runners, `modify`, `modify'`, `gets`, `asks`, `withExceptT`+* Handles: `IOMode`, `BufferMode`, and (in `IOExcept`, above) `openFile`,+  `withFile`, `hClose`, `hIsEOF`, `hSetBuffering`+* Concurrency: `forkIO`, `ThreadId`, `myThreadId`, `killThread`,+  `threadDelay`, `MVar` and its functions; STM: `STM`, `TVar`, `atomically`,+  `newTVar`, `newTVarIO`, `readTVar`, `readTVarIO`, `writeTVar`,+  `modifyTVar'`, `retry`, `orElse`+* `time`: `UTCTime`, `NominalDiffTime`, `Day`, `getCurrentTime`,+  `diffUTCTime`, `addUTCTime`+* `die`, `coerce`, `Coercible`, `HasCallStack`, `swap`, `IsString`,+  `fromString`++Tests and tooling:++* The classy optics laws of `NonZero` (the prism laws at all 15 numeric+  types), and the laws of its new instances; the prism laws of `left` and+  `right`+* Fix: the `NonZero` division functions threw at `Natural` and divided wrongly+  by `maxBound` at the unsigned types (the `-1` check used `negate 1`)+* Fix: the lazy UTF-16 and UTF-32 decoders terminate (text's `...With`+  versions loop on input that ends partway through a code unit, and are not+  exported); the lazy `decimal` and `hexadecimal` reject input with no digit+* Every total function agrees with the partial one it replaces (`Nothing`+  exactly where it throws): the numeric functions at every numeric type of+  base, and the replacements of containers, text, bytestring and vector+* `test/Deny.hs`: the test suite does not compile if `Papa` exports any of+  73 partial, lossy or throwing names, or the types `Natural` and `Ratio`;+  `test/Totals.hs` pins the total type of+  each name `Papa` reuses+* `papa/exports`: the exports of every public module, checked in CI by+  `bin/exports.sh --check`+* The `inspection` test suite: the `NonZero` functions and conversions+  compile, at `Int`, `Word` and `Double`, to code with no class dictionary+  and no `Integer`+* `bench/Totality.hs`: each total function against the partial one it+  replaces+* `hGetLine` agrees with `Data.ByteString.Char8`'s `hGetLine` then+  `decodeUtf8'` on bytes that are not UTF-8 (overlong forms, surrogates,+  truncated sequences), at buffer sizes from 1 byte, and at any encoding+* `floorFloating`, `ceilingFloating`, `truncateFloating` and `roundFloating`+  agree with C's `floor`, `ceil`, `trunc` and `rint` at `Double` and+  `Float`, including at NaN, the infinities and `-0`; `modFloating` agrees+  with `Data.Fixed`'s `mod'` at `Rational`, rounded+* `examples/`: programs written for `Prelude` (`wind-correction`,+  `addgitignore`), ported to Papa; CI builds them with each change+* Properties of the files, directories and paths (agreement with+  `System.Directory`, and filepath's totality at every string) and of async+* Benchmarks of `Text` I/O against `Data.Text.IO`, and of the vector+  wrappers, partially applied and with their `Maybe` consumed+* GitLab CI runs every test suite, doctests included, on every GHC version++0.6.0++Breaking changes:++* Total replacements return `Maybe`: `(/)`, `recip`, `(^^)`, `exitWith`, `div` (new), `mod`, `divMod`, `quot`, `rem`, `quotRem`, `(^)`, `(%)`, `cycle`, `chr`, `succ` (new), `pred` (new), `stimes`, `stimesMonoid`, `stimesIdempotent`, `stimesIdempotentMonoid`, `mtimesDefault`, `readIO`+* `maximum`, `minimum` take a list and return a `Maybe`; `maximum1`, `minimum1` take a `NonEmpty`+* `concat`, `concatMap` are `Data.Foldable`'s again, not `Bind`'s; remove `Papa.Semigroupoids.Data.Functor.Bind`+* `partitionEithers` is generalised to any `Foldable`+* `Papa` no longer re-exports `Control.Comonad.Env` (its `ask`, `asks`, `local` clashed with `MonadReader`); import `Papa.Comonad.Control.Comonad.Env` qualified+* `Papa.Base.Control.Arrow` exports `Arrow`'s `first`, `second` as `firstA`, `secondA`, so that it imports alongside `Papa`+* The containers modules check the order of the input of `fromAscList`, `fromDescList`, `fromDistinctAscList`, `fromDistinctDescList`, their `With`/`WithKey` variants, `mapKeysMonotonic` and `mapMonotonic`, and return `Maybe` (containers' build a structure that breaks its invariant)+* `toEnum`, `fromEnum` are not exported (they throw outside the range of `Int`); `Enum` is exported for its constraint+* lens's partial combinators are no longer exported: `(^?!)`, `(^@?!)`, `foldr1Of`, `foldl1Of`, `foldr1Of'`, `foldl1Of'`, `singular`, `unsafeSingular`, `unsafePartsOf`, `unsafePartsOf'`, `iunsafePartsOf`, `iunsafePartsOf'`+* `fail` is no longer exported (it throws in `IO`); `MonadFail` still is+* The containers modules replace their partial functions with total ones of the same names: `Map`'s `(!)`, `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`, `elemAt`, `findIndex`, `deleteAt`, `updateAt`; `Set`'s `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`, `elemAt`, `findIndex`, `deleteAt`; `IntMap`'s `(!)`, `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`; `IntSet`'s `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`; `Seq`'s `index`, `replicate`, `replicateA`, `replicateM`, `iterateN`, `fromFunction`, `chunksOf`, `cycleTaking`, `scanl1`, `scanr1`+* `fromLeft`, `fromRight` are those of the relude replacements (same behaviour)+* Require GHC 9.6 or later (`base >= 4.18`); remove all CPP++Fixes:++* `(++)` is `infixr 5`, as in Prelude (it was `infixl 9`)+* `biconcat`, `biconcatMap` are defined once (importing `Papa` with `Papa.Bifunctors.Data.Bifoldable` was ambiguous)+* Export the constructors of `Sum`, `Product`, `Min`, `Max`, `First`, `Last`, `Dual`, `Endo`, `All`, `Any`, `WrappedMonoid`, `ZipList`, `WrappedMonad`, `WrappedArrow`+* `singleton`, `(!?)` are exported on every supported GHC, not only base 4.19 and later++Additions to `Papa`:++* `whenJust`, `whenJustM`+* `Handle`, `stdin`, `stdout`, `stderr`, `hPutStr`, `hPutStrLn`, `hFlush`; `Proxy`; `Compose`; `reads`; `MonadTrans`, `lift`; `(&&&)`+* `toIntegralSized` and `Bits` (the total `fromIntegral`)+* `seq`, `($!)`, `print`, `Bounded`, `Enum` (the class), `RealFrac`, `Word8`–`Word64`, `Natural`, `minusNaturalMaybe`, `unzip`, `singleton`, `(!?)`+* `catMaybes`, `mapMaybe`, `isJust`, `isNothing`, `listToMaybe`, `maybeToList`, `isLeft`, `isRight`+* `(>=>)`, `(<=<)`, `ap`, `liftM`, `liftM2`, `zipWithM`, `zipWithM_`, `MonadIO`, `liftIO`+* `Read` (the class), `readMaybe`, `readEither`+* `Exception`, `SomeException`, `IOException`, `throwIO`, `catch`, `handle`, `try`, `bracket`, `bracket_`, `finally`, `onException`, `evaluate`+* `IORef` and its functions; `getArgs`, `getProgName`, `getEnvironment`, `lookupEnv`; `ExitCode`, `exitWith`, `exitSuccess`, `exitFailure`++Tests and tooling:++* Hedgehog property suite for every function papa defines, with hedgehog-fn, lens laws for the `NonEmpty` lenses, and a check that every documented module imports alongside `Papa`+* Doctests, each with a Hedgehog property, for every function+* Criterion benchmarks+* GHC 9.6.7, 9.8.4, 9.10.3, 9.12.4, 9.14.1+ 0.5.0  * Remove `lens-indexed-plated` dependency to resolve GHC 9.12+ compatibility
papa.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               papa-version:            0.5.0+version:            0.7.0 license:            BSD-3-Clause license-file:       LICENCE author:             Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> <dibblego>@@ -12,98 +12,64 @@ description:   <<https://logo.systemf.com.au/systemf-450x450.png>>   .-  Papa is a curated Haskell prelude that re-exports only total, safe functions and integrates-  seamlessly with the modern Haskell ecosystem. It eliminates partial functions while providing-  comprehensive type class coverage across base, lens, bifunctors, semigroupoids, comonads,-  profunctors, and more.-  .-  = Core Design Principles+  Papa is a Haskell prelude that replaces the partial functions of Prelude+  with total ones, generalises the familiar names to type classes, and+  brings in lens, semigroupoids, bifunctors and comonad.   .-  * __No Partial Functions__ — All re-exported functions are total and safe-  * __Type Class-Driven__ — Maximizes use of standard type classes for polymorphic code-  * __Optics Integration__ — Full lens support with indexed operations and plated recursion-  * __Modern Ecosystem__ — Integrates adjunctions, comonads, profunctors, selective functors, and more+  = Total replacements   .-  = What's Included+  Total division takes a @NonZero@ divisor, checked once by+  @preview nonZero@ (@divNonZero@, @divideNonZero@, @ratioNonZero@, ...), and+  @pow@ a @Natural@ exponent, and @intCast@ converts between integral types+  only where no value can be lost; Prelude's partial versions, with+  @fromIntegral@, are in the separate module @Papa.Unsafe.Numeric@. Elsewhere, where Prelude throws, Papa returns a+  @Maybe@: @cycle@ (empty list), @(!!)@, @(!?)@ (index out of range), @chr@,+  @succ@, @pred@ (out of range), @stimes@ (count out of range) and @readIO@+  (no parse). On any @Foldable1@, @maximum@, @minimum@, @maximumBy@ and+  @minimumBy@ need no @Maybe@, and @head@, @tail@, @last@ and @init@ are+  lenses into a @NonEmpty@.   .-  Papa provides a comprehensive set of type classes and operations:+  @fromJust@, @read@, @error@, @undefined@, @throw@, @foldl1@, @foldr1@,+  @truncate@, @round@, @realToFrac@ and every @unsafe*@ function are not+  exported (@truncateMaybe@, @roundMaybe@, @floatToDouble@, ... instead); a+  test fails to compile if they are.   .-  * __Base functionality__ — Safe alternatives to Prelude with Eq1/Eq2, Ord1/Ord2, Show1/Show2-  * __Functor hierarchy__ — Functor, Applicative, Monad, Alternative, MonadPlus, with Apply/Bind-  * __Foldable/Traversable__ — Including Foldable1/Traversable1 for non-empty structures-  * __Lens integration__ — Full optics support with At, Ixed, Plated, IndexedPlated, Field1-9-  * __Bifunctors__ — Bifunctor, Bifoldable, Bitraversable with indexed variants-  * __Comonads__ — Comonad, ComonadApply, Env, Store, Traced comonads-  * __Profunctors__ — Strong, Choice, Closed profunctors (import qualified)-  * __Containers__ — Map, Set, IntMap, IntSet, Seq, Tree (import qualified)-  * __Free structures__ — Free monads and Cofree comonads-  * __Transformers__ — MonadTrans, MonadIO, mtl classes (MonadReader, State, Writer, etc.)-  * __Specialized functors__ — Contravariant, Distributive, Selective, Witherable-  * __Generic programming__ — Generic, Generic1, Data, Typeable-  * __Performance__ — NFData for strict evaluation, all utility functions marked INLINE+  = Text first, and I/O errors as values   .-  = Forbidden Functions+  @putStrLn@, @readFile@, @print@, @lines@, @words@ and the rest are+  @Text@'s, read and write UTF-8 whatever the locale, read strictly, and+  return their @IOException@ in @IOExcept@ (@ExceptT IOException IO@) rather+  than throw it. @catch@, @try@ and @bracket@ never catch an asynchronous+  exception. The functions of text, bytestring, containers, vector and+  unordered-containers are wrapped, imported qualified, with a total+  function of the same name for each one that throws.   .-  Papa explicitly does NOT export these partial functions:+  = Generalised names   .-  * @head@, @tail@, @init@, @last@ — Use optics or pattern matching-  * @(!!)@ — Use safe @(^? ix n)@ from lens (Papa provides a safe version)-  * @maximum@, @minimum@ — Use @maximum1@/@minimum1@ for non-empty structures-  * @foldl1@, @foldr1@ — Use Foldable1 versions-  * @fromJust@ — Use @fromMaybe@ or pattern matching-  * @read@ — Use @readMaybe@ or parser libraries-  * @error@, @undefined@ — Use typed errors with Either-  * All @unsafe*@ functions+  @map@ is @fmap@, @(++)@ is @(<>)@, @const@ is @pure@, @mapM@ is+  @traverse@, @fst@ and @snd@ work on any tuple, @lookup@ and+  @partitionEithers@ work on any @Foldable@, and @lefts@ and @rights@ are+  traversals.   .   = Usage   .   > {-# LANGUAGE NoImplicitPrelude #-}   > import Papa   >-  > -- Use safe, total functions-  > safeHead :: [a] -> Maybe a-  > safeHead = (^? ix 0)-  >-  > -- Leverage type classes-  > genericLength :: (Foldable f, Num n) => f a -> n-  > genericLength = foldl' (\n _ -> n + 1) 0-  >-  > -- Work with lenses-  > data Person = Person { _name :: String, _age :: Int }-  > name :: Lens' Person String-  .-  Some modules require qualified import to avoid name conflicts:-  .-  > import qualified Papa.Containers.Data.Map as Map-  > import qualified Papa.Profunctors.Data.Profunctor as Profunctor-  .-  = Future Plans-  .-  __Note:__ Future versions may split this package into separate dependencies to reduce-  compilation times and allow finer-grained control over transitive dependencies. The-  current monolithic structure prioritizes ease of use and comprehensive type class-  coverage, but may be reorganized as:-  .-  * @papa-base@ — Core prelude with base, bifunctors, semigroupoids-  * @papa-lens@ — Lens integration and optics-  * @papa-comonad@ — Comonad hierarchy-  * @papa-transformers@ — MTL and transformer classes-  * @papa-ecosystem@ — Profunctors, selective, witherable, etc.+  > average :: [Int] -> Maybe Int+  > average xs = fmap (divNonZero (sum xs)) (preview nonZero (length xs))   .-  This reorganization would allow users to depend only on the pieces they need while-  maintaining API compatibility through the top-level @papa@ package as a convenience-  re-export.+  See "Papa" for the modules that import alongside it, and those to import+  qualified. homepage:           https://gitlab.com/system-f/code/papa bug-reports:        https://gitlab.com/system-f/code/papa/issues build-type:         Simple extra-doc-files:    changelog.md tested-with:        GHC == 9.6.7                   , GHC == 9.8.4-                  , GHC == 9.10.1+                  , GHC == 9.10.3                   , GHC == 9.12.4-                  -- GHC 9.0-9.4 require older versions of dependencies:-                  -- one < 0.0.4, associative < 0.0.4, id < 0.0.3-                  -- (liftA2 and MkSolo compatibility issues)+                  , GHC == 9.14.1  flag dev   description:      Enable development warnings (-Werror)@@ -114,38 +80,53 @@   type:             git   location:         git@gitlab.com:system-f/code/papa.git +common warnings+  ghc-options:+                    -Wall -Wcompat -Wincomplete-uni-patterns -Werror=incomplete-patterns++  if flag(dev)+    ghc-options:    -Werror+ library+  import:           warnings+   default-language:                     Haskell2010    build-depends:-                    base >= 4.11 && < 6+                    base >= 4.18 && < 5                     , adjunctions >= 4 && < 5+                    , async >= 2.2.5 && < 2.3+                    , bytestring >= 0.11.2 && < 0.13                     , associative >= 0 && < 1                     , bifunctors >= 5 && < 7                     , comonad >= 5 && < 6-                    , containers >= 0.5 && < 1+                    , containers >= 0.6.0.1 && < 1                     , contravariant >= 1 && < 2                     , deepseq >= 1.4 && < 2+                    , directory >= 1.3.8 && < 1.4                     , distributive >= 0 && < 1+                    , exceptions >= 0.10 && < 0.11+                    , filepath >= 1.4.100 && < 1.6                     , free >= 5 && < 6                     , id >= 0 && < 1-                    , lens >= 4 && < 6+                    , lens >= 5.2 && < 6                     , mtl >= 2 && < 3                     , one >= 0.0.4 && < 1                     , polytree >= 0 && < 1                     , profunctors >= 5 && < 6                     , selective >= 0 && < 1                     , semigroupoids >= 5 && < 7+                    , stm >= 2.5 && < 2.6+                    , text >= 2.0.2 && < 2.2+                    , time >= 1.12 && < 1.16                     , transformers >= 0.5 && < 1+                    , hashable >= 1.4 && < 1.6+                    , primitive >= 0.7 && < 0.10+                    , unordered-containers >= 0.2.19 && < 0.3+                    , vector >= 0.13.2 && < 0.14                     , witherable >= 0 && < 1 -  ghc-options:-                    -Wall--  if flag(dev)-    ghc-options:    -Werror-   default-extensions:                     NoImplicitPrelude @@ -155,9 +136,9 @@   exposed-modules:                     Papa                     Papa.Adjunctions+                    Papa.Async.Control.Concurrent.Async                     Papa.Adjunctions.Data.Functor.Adjunction                     Papa.Adjunctions.Data.Functor.Rep-                    Papa.Adjunctions.Renamed                     Papa.Associative                     Papa.Associative.Data.Associative                     Papa.Associative.Renamed@@ -165,39 +146,70 @@                     Papa.Base.Control.Applicative                     Papa.Base.Control.Arrow                     Papa.Base.Control.Category+                    Papa.Base.Control.Concurrent                     Papa.Base.Control.DeepSeq+                    Papa.Base.Control.Exception                     Papa.Base.Control.Monad                     Papa.Base.Control.Monad.Cont                     Papa.Base.Control.Monad.Error-                    Papa.Base.Control.Monad.Reader                     Papa.Base.Control.Monad.RWS+                    Papa.Base.Control.Monad.Reader                     Papa.Base.Control.Monad.State                     Papa.Base.Control.Monad.Trans                     Papa.Base.Control.Monad.Writer                     Papa.Base.Data.Bool                     Papa.Base.Data.Char+                    Papa.Base.Data.Coerce                     Papa.Base.Data.Data+                    Papa.Base.Data.Divisor                     Papa.Base.Data.Either+                    Papa.Base.Data.Enum                     Papa.Base.Data.Eq                     Papa.Base.Data.Foldable+                    Papa.Base.Data.Foldable1+                    Papa.Base.Data.Fractional                     Papa.Base.Data.Function                     Papa.Base.Data.Functor+                    Papa.Base.Data.Functor.Compose+                    Papa.Base.Data.Functor.Identity+                    Papa.Base.Data.IORef                     Papa.Base.Data.Int+                    Papa.Base.Data.IntCast+                    Papa.Base.Data.Integral+                    Papa.Base.Data.Left                     Papa.Base.Data.List                     Papa.Base.Data.List.NonEmpty                     Papa.Base.Data.Maybe                     Papa.Base.Data.Monoid+                    Papa.Base.Data.NonZero                     Papa.Base.Data.Ord+                    Papa.Base.Data.Proxy                     Papa.Base.Data.Ratio+                    Papa.Base.Data.RealFloat+                    Papa.Base.Data.RealFrac+                    Papa.Base.Data.Right                     Papa.Base.Data.Semigroup                     Papa.Base.Data.Show                     Papa.Base.Data.String                     Papa.Base.Data.Traversable+                    Papa.Base.Data.Tuple                     Papa.Base.Data.Void+                    Papa.Base.Data.Word                     Papa.Base.GHC.Generics+                    Papa.Base.GHC.Stack                     Papa.Base.Prelude+                    Papa.Base.System.Environment+                    Papa.Base.System.Exit+                    Papa.Base.System.IO+                    Papa.Base.System.IO.Except+                    Papa.Base.Text.Read                     Papa.Bifunctors                     Papa.Bifunctors.Data.Bifoldable+                    Papa.Bytestring.Data.ByteString+                    Papa.Bytestring.Data.ByteString.Builder+                    Papa.Bytestring.Data.ByteString.Char8+                    Papa.Bytestring.Data.ByteString.Lazy+                    Papa.Bytestring.Data.ByteString.Lazy.Char8                     Papa.Comonad                     Papa.Comonad.Control.Comonad                     Papa.Comonad.Control.Comonad.Env@@ -205,16 +217,19 @@                     Papa.Comonad.Control.Comonad.Traced                     Papa.Comonad.Renamed                     Papa.Containers-                    Papa.Contravariant-                    Papa.Contravariant.Data.Functor.Contravariant+                    Papa.Containers.Data.Containers.ListUtils                     Papa.Containers.Data.IntMap                     Papa.Containers.Data.IntSet                     Papa.Containers.Data.Map                     Papa.Containers.Data.Seq                     Papa.Containers.Data.Set                     Papa.Containers.Data.Tree+                    Papa.Contravariant+                    Papa.Contravariant.Data.Functor.Contravariant+                    Papa.Directory.System.Directory                     Papa.Distributive                     Papa.Distributive.Data.Distributive+                    Papa.Filepath.System.FilePath                     Papa.Free                     Papa.Free.Control.Applicative.Free                     Papa.Free.Control.Comonad.Cofree@@ -223,14 +238,17 @@                     Papa.Id.Data.BiId                     Papa.Id.Data.Id                     Papa.Lens+                    Papa.Lens.Control.Exception+                    Papa.Lens.Core                     Papa.Lens.Data.List                     Papa.Lens.Data.Tuple+                    Papa.Lens.Optic+                    Papa.Lens.System.IO.Error                     Papa.One                     Papa.One.Control.One                     Papa.One.Renamed                     Papa.Polytree                     Papa.Polytree.Data.Polytree-                    Papa.Polytree.Renamed                     Papa.Profunctors                     Papa.Profunctors.Data.Profunctor                     Papa.Profunctors.Data.Profunctor.Choice@@ -238,15 +256,43 @@                     Papa.Profunctors.Renamed                     Papa.Selective                     Papa.Selective.Control.Selective-                    Papa.Selective.Renamed                     Papa.Semigroupoids-                    Papa.Semigroupoids.Data.Functor.Bind-                    Papa.Semigroupoids.Data.Semigroup.Foldable+                    Papa.Stm.Control.Concurrent.STM+                    Papa.Text.Data.Text+                    Papa.Text.Data.Text.Encoding+                    Papa.Text.Data.Text.IO+                    Papa.Text.Data.Text.Lazy+                    Papa.Text.Data.Text.Lazy.Builder+                    Papa.Text.Data.Text.Lazy.Builder.Int+                    Papa.Text.Data.Text.Lazy.Encoding+                    Papa.Text.Data.Text.Lazy.Read+                    Papa.Text.Data.Text.Read+                    Papa.Time.Data.Time+                    Papa.Unsafe+                    Papa.Unsafe.Async+                    Papa.Unsafe.Exception+                    Papa.Hashable.Data.Hashable+                    Papa.UnorderedContainers.Data.HashMap+                    Papa.UnorderedContainers.Data.HashSet+                    Papa.Vector.Data.Vector+                    Papa.Vector.Data.Vector.Generic+                    Papa.Vector.Data.Vector.Storable+                    Papa.Vector.Data.Vector.Unboxed+                    Papa.Unsafe.Format+                    Papa.Unsafe.IO+                    Papa.Unsafe.Numeric                     Papa.Witherable                     Papa.Witherable.Renamed                     Papa.Witherable.Witherable -test-suite papa-test+  other-modules:+                    Papa.Internal.Char8+                    Papa.Internal.Order+                    Papa.Internal.Read++test-suite hedgehog+  import:           warnings+   type:                     exitcode-stdio-1.0 @@ -259,20 +305,71 @@   main-is:                     Main.hs +  other-modules:+                    Agree+                    Composes+                    ComposesUnsafe+                    Deny+                    Properties+                    PropertiesIO+                    PropertiesVector+                    PropertiesAsync+                    PropertiesContainers+                    PropertiesFS+                    PropertiesNumeric+                    PropertiesText+                    Totals+   build-depends:-                    base >= 4.11 && < 6+                    base >= 4.18 && < 5+                    , async+                    , bytestring+                    , containers+                    , deepseq+                    , directory+                    , filepath+                    , hedgehog >= 1.2 && < 2+                    , hedgehog-fn >= 1.0 && < 2                     , papa+                    , tagged+                    , text+                    , time+                    , transformers+                    , unordered-containers+                    , vector    ghc-options:-                    -Wall+                    -threaded -  if flag(dev)-    ghc-options:    -Werror+  default-extensions:+                    NoImplicitPrelude +test-suite inspection+  import:           warnings++  type:+                    exitcode-stdio-1.0++  default-language:+                    Haskell2010++  hs-source-dirs:+                    test++  main-is:+                    Inspection.hs++  build-depends:+                    base >= 4.18 && < 5+                    , inspection-testing >= 0.5 && < 0.7+                    , papa+   default-extensions:                     NoImplicitPrelude  test-suite doctest+  import:           warnings+   type:                     exitcode-stdio-1.0 @@ -283,7 +380,7 @@                     Doctest.hs    build-depends:-                    base >= 4.11 && < 6+                    base >= 4.18 && < 5                     , process >= 1 && < 2    build-tool-depends:@@ -292,8 +389,40 @@   default-language:                     Haskell2010 +benchmark papa-bench+  import:           warnings++  type:+                    exitcode-stdio-1.0++  default-language:+                    Haskell2010++  hs-source-dirs:+                    bench++  main-is:+                    Main.hs++  other-modules:+                    Nub+                    BenchVector+                    Totality+                    Text++  build-depends:+                    base >= 4.18 && < 5+                    , bytestring+                    , containers+                    , criterion >= 1.6 && < 1.7+                    , directory+                    , papa+                    , unordered-containers+                    , vector+                    , text+   ghc-options:-                    -Wall+                    -O2 -  if flag(dev)-    ghc-options:    -Werror+  default-extensions:+                    NoImplicitPrelude
src/Papa.hs view
@@ -1,95 +1,217 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} --- | Papa prelude - a curated Haskell prelude+-- | Papa: a total, lens-based, type class-driven prelude. ----- This module re-exports the core prelude functionality. Many ecosystem packages--- are not re-exported from this module to avoid name conflicts. Users should import--- them qualified or directly as needed:+-- > {-# LANGUAGE NoImplicitPrelude #-}+-- > import Papa ----- Containers:--- > import qualified Papa.Containers.Data.Map as Map--- > import qualified Papa.Containers.Data.Set as Set+-- == Principles ----- Free structures:--- > import qualified Papa.Free.Control.Monad.Free as Free--- > import qualified Papa.Free.Control.Comonad.Cofree as Cofree+-- * __No partial functions.__ Nothing that @import Papa@ brings into scope+--   throws, loops on finite input, or returns @undefined@: no @head@ of a+--   list, @fromJust@, @read@, @error@, @div@ by zero, lazy I/O or+--   @fromIntegral@ that wraps. The test suite checks this: it does not+--   compile if "Papa" exports one of the denied names, or a reused name at+--   its partial type. ----- Other ecosystem packages (import qualified to avoid conflicts):--- > import qualified Papa.Profunctors.Data.Profunctor as Profunctor--- > import qualified Papa.Selective.Control.Selective as Selective--- > import qualified Papa.Witherable.Witherable as Witherable--- > import qualified Papa.Associative.Data.Associative as Associative--- > import qualified Papa.One.Control.One as One--- > import qualified Papa.Adjunctions.Data.Functor.Rep as Rep--- > import qualified Papa.Comonad.Control.Comonad.Traced as Traced--- > import qualified Papa.Id.Data.Id as Id--- > import qualified Papa.Id.Data.BiId as BiId--- > import qualified Papa.Polytree.Data.Polytree as Polytree+-- * __Names that should never have been partial are reused for total+--   functions.__ 'head', 'last', 'maximum' take a+--   'Data.List.NonEmpty.NonEmpty' (any 'Data.Semigroup.Foldable.Foldable1');+--   ('!!'), 'succ', 'pred', 'chr', 'cycle' return a 'Data.Maybe.Maybe'. ----- | Papa prelude — a comprehensive, type class-driven Haskell prelude+-- * __Partial functions that ought to exist are in "Papa.Unsafe", under+--   their own names.__ @div@, @(/)@, @truncate@, @printf@, @error@, … are in+--   "Papa.Unsafe" (which is "Papa" and all of them), or one area at a time+--   in "Papa.Unsafe.Numeric", "Papa.Unsafe.Format", "Papa.Unsafe.Exception"+--   and "Papa.Unsafe.IO". "Papa" has total versions under other names:+--   'divNonZero' takes a 'NonZero' divisor; 'roundMaybe' returns 'Nothing'+--   for NaN, infinities and values out of range; 'intCast' compiles only+--   where it is lossless. ----- This module re-exports the core functionality. For additional modules,--- import them directly:+-- * __I\/O errors are values.__ An I\/O action that can fail has type+--   @'IOExcept' a@, which is @'ExceptT' 'IOFailure' 'IO' a@: its failure is+--   the 'Data.Either.Left' of 'runExceptT', not an exception. An+--   'IOFailure' is the operating system's 'IOException' ('_IOFailed'; take+--   it apart with 'errorType', '_NoSuchThing', …) or bytes that are not+--   UTF-8 ('_DecodeFailed'). 'exceptIO' brings any other library's I\/O+--   into 'IOExcept'. Asynchronous exceptions are never caught; 'catch',+--   'try', 'handle' and 'bracket' are safe with them. ----- == Aggregator Modules (import individually)+-- * __Text first.__ Strings are 'Text'; 'putStrLn', 'readFile', 'lines',+--   'words' are the 'Text' ones. Text I\/O is strict and UTF-8 whatever the+--   locale. ----- These modules aggregate related functionality and can be imported separately:+-- * __Optics first.__ Papa exports the core of lens ("Papa.Lens.Core";+--   "Papa.Lens" is all of lens less its partial combinators), and its own+--   functions are optics or classy optics where it can. ----- > import Papa.Comonad           -- All comonad functionality--- > import Papa.Contravariant      -- Contravariant functors--- > import Papa.Distributive       -- Distributive functors--- > import Papa.Adjunctions        -- Adjunctions and representable functors--- > import Papa.Associative        -- Associative operations--- > import Papa.One                -- One type class--- > import Papa.Polytree           -- Polytree data structure--- > import Papa.Profunctors        -- Profunctor hierarchy--- > import Papa.Selective          -- Selective functors--- > import Papa.Witherable         -- Witherable and Filterable+-- == Example ----- == Renamed Modules (conflicts hidden)+-- > {-# LANGUAGE NoImplicitPrelude #-}+-- > {-# LANGUAGE OverloadedStrings #-}+-- > import Papa+-- >+-- > -- | The number of lines of a file, or why not.+-- > countLines :: FilePath -> IOExcept Int+-- > countLines p =+-- >   length . lines <$> readFile p+-- >+-- > main :: IO ()+-- > main = do+-- >   r <- runExceptT (countLines "/etc/hosts" >>= print)+-- >   either (die . pack . displayException) pure r ----- For modules with naming conflicts, use the .Renamed versions:+-- == What it re-exports ----- > import Papa.Comonad.Renamed       -- Hides First/Last/Alt/mconcat conflicts--- > import Papa.Adjunctions.Renamed   -- Hides 'index' conflict--- > import Papa.Associative.Renamed   -- Hides 'null'/'op' conflicts--- > import Papa.One.Renamed           -- Hides 'nonEmpty' conflict--- > import Papa.Polytree.Renamed      -- Hides 'levels' conflict--- > import Papa.Profunctors.Renamed   -- Hides 'WrappedArrow' conflict--- > import Papa.Selective.Renamed     -- Hides 'Over' conflict--- > import Papa.Witherable.Renamed    -- Hides 'filter' conflict+-- The total part of base ("Papa.Base"), the core of lens, bifunctors+-- ("Papa.Bifunctors"), semigroupoids ("Papa.Semigroupoids"), the+-- 'Control.Comonad.Comonad' and 'Control.Comonad.Store.ComonadStore'+-- comonads, mtl's 'StateT', 'ReaderT' and 'ExceptT', STM, time, and the+-- types (only) of text, bytestring, containers, vector and+-- unordered-containers, whose functions are imported qualified. ----- == Qualified Imports (internal conflicts)+-- == Modules that import unqualified alongside "Papa" ----- Some modules have internal conflicts and must be imported qualified:+-- > import Papa.Base.Control.Arrow        -- Arrow (first/second as firstA/secondA)+-- > import Papa.Base.Control.Monad.Reader -- MonadReader+-- > import Papa.Base.Control.Monad.State  -- MonadState+-- > import Papa.Base.Control.Monad.Writer -- MonadWriter+-- > import Papa.Base.Control.Monad.Error  -- MonadError+-- > import Papa.Base.Control.Monad.Cont   -- MonadCont+-- > import Papa.Base.Control.Monad.Trans  -- MonadTrans+-- > import Papa.Contravariant             -- Contravariant, Divisible, Decidable+-- > import Papa.Distributive              -- Distributive+-- > import Papa.Adjunctions               -- Adjunction, Representable+-- > import Papa.Polytree                  -- Polytree+-- > import Papa.Selective                 -- Selective+-- > import Papa.Associative.Renamed       -- hides null+-- > import Papa.One.Renamed               -- hides nonEmpty+-- > import Papa.Profunctors.Renamed       -- hides WrappedArrow+-- > import Papa.Witherable.Renamed        -- hides filter, mapMaybe, catMaybes --+-- "Papa.Lens" (all of lens, less its partial combinators) imports alongside+-- "Papa", but its names clash with "Papa.Adjunctions" (@index@),+-- "Papa.Polytree" (@levels@) and "Papa.Selective" (@Over@).+--+-- == Modules to import qualified+--+-- Their names clash with each other or with "Papa". Each replaces the+-- partial functions of its library module (@Map.!@, @Set.findMin@,+-- @Vector.head@, @Text.head@, …) with total ones of the same names, which+-- return 'Data.Maybe.Maybe', or hides them where a total one already exists+-- (@ix@, 'Control.Lens.At').+--+-- > import qualified Papa.Text.Data.Text as Text+-- > import qualified Papa.Text.Data.Text.Lazy as LazyText+-- > import qualified Papa.Text.Data.Text.IO as TextIO+-- > import qualified Papa.Text.Data.Text.Read as TextRead+-- > import qualified Papa.Bytestring.Data.ByteString as ByteString+-- > import qualified Papa.Bytestring.Data.ByteString.Char8 as Char8+-- > import qualified Papa.Bytestring.Data.ByteString.Lazy as LazyByteString+-- > import qualified Papa.Bytestring.Data.ByteString.Builder as Builder+-- > import qualified Papa.Vector.Data.Vector as Vector+-- > import qualified Papa.Vector.Data.Vector.Unboxed as Unboxed+-- > import qualified Papa.UnorderedContainers.Data.HashMap as HashMap+-- > import qualified Papa.UnorderedContainers.Data.HashSet as HashSet -- > import qualified Papa.Containers.Data.Map as Map -- > import qualified Papa.Containers.Data.Set as Set -- > import qualified Papa.Containers.Data.IntMap as IntMap -- > import qualified Papa.Containers.Data.IntSet as IntSet -- > import qualified Papa.Containers.Data.Seq as Seq -- > import qualified Papa.Containers.Data.Tree as Tree+-- > import qualified Papa.Comonad.Control.Comonad.Env as Env       -- ask, asks, local clash with MonadReader+-- > import qualified Papa.Comonad.Control.Comonad.Traced as Traced -- > import qualified Papa.Free.Control.Monad.Free as Free -- > import qualified Papa.Free.Control.Applicative.Free as FreeAp -- > import qualified Papa.Free.Control.Comonad.Cofree as Cofree -- > import qualified Papa.Id.Data.Id as Id -- > import qualified Papa.Id.Data.BiId as BiId+--+-- == Partial functions+--+-- > import Papa.Unsafe                                 -- Papa, and every partial function+-- > import Papa.Unsafe.Numeric                         -- div, (/), truncate, fromIntegral, …+-- > import Papa.Unsafe.Format                          -- printf+-- > import Papa.Unsafe.Exception                       -- throw, error, undefined+-- > import qualified Papa.Unsafe.IO as UnsafeIO        -- System.IO, lazy and throwing+--+-- == Known remaining partiality+--+-- Class methods that Papa exports with their class, and syntax that GHC+-- desugars whatever is in scope, are partial at some types: @(-)@ and+-- @negate@ at @Natural@ throw (Papa exports neither the type nor+-- @fromInteger@), fixed-size arithmetic wraps, and a numeric literal that+-- does not fit its type wraps (@-Woverflowed-literals@ warns). Range syntax+-- (@[a, b .. c]@) uses the methods of 'Enum', which Papa does not export, and is+-- surprising at 'Double'. module Papa (-  -- * Core Modules   module Papa.Base,+  module Papa.Async.Control.Concurrent.Async,+  module Papa.Directory.System.Directory,+  module Papa.Filepath.System.FilePath,   module Papa.Bifunctors,   module Papa.Comonad.Control.Comonad,-  module Papa.Comonad.Control.Comonad.Env,   module Papa.Comonad.Control.Comonad.Store,-  module Papa.Lens,+  module Papa.Lens.Core,+  module Papa.Lens.Control.Exception,+  module Papa.Lens.System.IO.Error,+  module Papa.Lens.Data.List,+  module Papa.Lens.Data.Tuple,+  module Papa.Containers,+  module Papa.Lens.Optic,+  module Papa.Text.Data.Text,+  module Papa.Text.Data.Text.IO,+  module Papa.Text.Data.Text.Encoding,+  module Papa.Bytestring.Data.ByteString,+  module Papa.Stm.Control.Concurrent.STM,+  module Papa.Time.Data.Time,   module Papa.Semigroupoids,+  module Papa.Hashable.Data.Hashable,+  module Papa.UnorderedContainers.Data.HashMap,+  module Papa.UnorderedContainers.Data.HashSet,+  module Papa.Vector.Data.Vector, ) where -import Papa.Base+import Papa.Async.Control.Concurrent.Async+import Papa.Base hiding (die, readEither, readIO, readMaybe) import Papa.Bifunctors+import Papa.Bytestring.Data.ByteString (ByteString) import Papa.Comonad.Control.Comonad-import Papa.Comonad.Control.Comonad.Env import Papa.Comonad.Control.Comonad.Store-import Papa.Lens+import Papa.Containers+import Papa.Directory.System.Directory+import Papa.Filepath.System.FilePath+import Papa.Hashable.Data.Hashable (Hashable)+import Papa.Lens.Control.Exception+import Papa.Lens.Core+import Papa.Lens.Data.List+import Papa.Lens.Data.Tuple+import Papa.Lens.Optic+import Papa.Lens.System.IO.Error import Papa.Semigroupoids+import Papa.Stm.Control.Concurrent.STM+import Papa.Text.Data.Text (Text, display, displayExponent, displayFixed, lines, pack, readEither, readMaybe, unlines, unpack, unwords, words)+import Papa.Text.Data.Text.Encoding (decodeUtf8', encodeUtf8)+import Papa.Text.Data.Text.IO (+  appendFile,+  die,+  getContents,+  getLine,+  hGetContents,+  hGetLine,+  hPrint,+  hPutStr,+  hPutStrLn,+  interact,+  print,+  putStr,+  putStrLn,+  readFile,+  readIO,+  writeFile,+ )+import Papa.Time.Data.Time+import Papa.UnorderedContainers.Data.HashMap (HashMap)+import Papa.UnorderedContainers.Data.HashSet (HashSet)+import Papa.Vector.Data.Vector (Vector)
− src/Papa/Adjunctions/Renamed.hs
@@ -1,16 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# OPTIONS_GHC -Wall #-}---- | Re-exports from Papa.Adjunctions with conflicting identifiers hidden.------ The 'index' function from Data.Functor.Rep conflicts with Control.Lens.index.--- It is hidden from this module. Use 'Data.Functor.Rep.index' directly when needed,--- or import qualified:--- > import qualified Data.Functor.Rep as Rep-module Papa.Adjunctions.Renamed (-  module Papa.Adjunctions.Data.Functor.Adjunction,-  module Papa.Adjunctions.Data.Functor.Rep,-) where--import Papa.Adjunctions.Data.Functor.Adjunction-import Papa.Adjunctions.Data.Functor.Rep hiding (index)
src/Papa/Associative/Renamed.hs view
@@ -4,8 +4,7 @@ -- | Re-exports from Papa.Associative with conflicting identifiers hidden. -- -- Conflicts hidden:--- - 'null' (conflicts with Data.Foldable.null)--- - 'op' (conflicts with Control.Lens.Wrapped.op)+-- - @null@ (conflicts with Data.Foldable.null) -- -- Use qualified imports when needed: -- > import qualified Data.Associative.PartialSemigroupOp as PSO@@ -14,4 +13,4 @@   module Papa.Associative.Data.Associative, ) where -import Papa.Associative.Data.Associative hiding (null, op)+import Papa.Associative.Data.Associative hiding (null)
+ src/Papa/Async/Control/Concurrent/Async.hs view
@@ -0,0 +1,288 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Structured concurrency ("Control.Concurrent.Async"): threads whose+-- lifetime is bounded by a scope, and whose results, or failures, are values.+--+-- == Which functions rethrow+--+-- An 'Async' is a thread that ends with a result or an exception. This module+-- returns that exception as a value ('waitCatch', 'waitExcept', 'poll', the+-- @…Catch@ functions), never rethrowing it into the waiting thread.+--+-- The combinators of a scope ('withAsync', 'concurrently', 'race',+-- 'mapConcurrently', …) run their actions in threads, and when an action+-- throws, cancel the other threads and throw its exception in the caller,+-- just as the action itself would have, had it run in the caller. They add no+-- failure: an action that does not throw, such as one of 'Papa.Base.System.IO.Except.IOExcept', which+-- returns its failure, does not make them throw. 'concurrentlyExcept' and+-- 'raceExcept' run actions of @'ExceptT' e 'IO'@, and the first failure+-- cancels the others.+--+-- The functions that rethrow a thread's exception in another thread are in+-- "Papa.Unsafe.Async": @wait@, @waitAny@, @waitEither@, @waitBoth@ (and their+-- @…STM@ and @…Cancel@ forms), which rethrow it in the waiting thread, and+-- @link@, @link2@, which throw it asynchronously into the linked thread.+--+-- 'waitAnyCatch', 'waitAnyCatchSTM' and 'waitAnyCatchCancel' take a+-- 'NonEmpty' list: at an empty list, "Control.Concurrent.Async"'s wait forever.+--+-- ==== __Examples__+--+-- >>> concurrently (pure 1) (pure 'a')+-- (1,'a')+--+-- >>> race (C.threadDelay 10000000) (pure 'a')+-- Right 'a'+--+-- >>> mapConcurrently (\x -> pure (x * 2)) [1, 2, 3]+-- [2,4,6]+--+-- >>> forConcurrently (Just 3) pure+-- Just 3+--+-- >>> replicateConcurrently 3 (pure 'x')+-- "xxx"+--+-- >>> runConcurrently ((,) <$> Concurrently (pure 1) <*> Concurrently (pure 2))+-- (1,2)+--+-- >>> concurrentlyE (pure (Right 1)) (pure (Left "b")) :: IO (Either String (Int, Int))+-- Left "b"+--+-- An action that throws, throws in the caller:+--+-- >>> E.try (concurrently (E.throwIO (userError "x")) (C.threadDelay 10000000)) :: IO (Either IOException ((), ()))+-- Left user error (x)+--+-- A thread that is cancelled ends with 'AsyncCancelled':+--+-- >>> do { a <- async (C.threadDelay 10000000); cancel a; r <- waitCatch a; pure (either (\e -> E.fromException e == Just AsyncCancelled) (const False) r) }+-- True+--+-- >>> withAsync (pure 'x') (\a -> waitCatch a *> poll a) >>= traverse (pure . preview _Right)+-- Just (Just 'x')+--+-- @since 0.7.0+module Papa.Async.Control.Concurrent.Async (+  -- * Asynchronous actions+  Async,+  AsyncCancelled (AsyncCancelled),+  asyncThreadId,+  compareAsyncs,++  -- * Scoped+  withAsync,+  withAsyncBound,+  withAsyncOn,+  withAsyncWithUnmask,+  withAsyncOnWithUnmask,++  -- * Unscoped+  async,+  asyncBound,+  asyncOn,+  asyncWithUnmask,+  asyncOnWithUnmask,++  -- * Results as values+  waitCatch,+  waitCatchSTM,+  waitExcept,+  poll,+  pollSTM,+  waitAnyCatch,+  waitAnyCatchSTM,+  waitAnyCatchCancel,+  waitEitherCatch,+  waitEitherCatchSTM,+  waitEitherCatchCancel,++  -- * Cancelling+  cancel,+  cancelWith,+  uninterruptibleCancel,++  -- * Combinators+  concurrently,+  concurrently_,+  race,+  race_,+  mapConcurrently,+  mapConcurrently_,+  forConcurrently,+  forConcurrently_,+  replicateConcurrently,+  replicateConcurrently_,+  Concurrently (Concurrently, runConcurrently),++  -- * Combinators of failures as values+  concurrentlyE,+  ConcurrentlyE (ConcurrentlyE, runConcurrentlyE),+  concurrentlyExcept,+  raceExcept,+) where++import Control.Category ((.))+import Control.Concurrent.Async (+  Async,+  AsyncCancelled (AsyncCancelled),+  Concurrently (Concurrently, runConcurrently),+  ConcurrentlyE (ConcurrentlyE, runConcurrentlyE),+  async,+  asyncBound,+  asyncOn,+  asyncOnWithUnmask,+  asyncThreadId,+  asyncWithUnmask,+  cancel,+  cancelWith,+  compareAsyncs,+  concurrently,+  concurrentlyE,+  concurrently_,+  forConcurrently,+  forConcurrently_,+  mapConcurrently,+  mapConcurrently_,+  poll,+  pollSTM,+  race,+  race_,+  replicateConcurrently,+  replicateConcurrently_,+  uninterruptibleCancel,+  waitCatch,+  waitCatchSTM,+  waitEitherCatch,+  waitEitherCatchCancel,+  waitEitherCatchSTM,+  withAsync,+  withAsyncBound,+  withAsyncOn,+  withAsyncOnWithUnmask,+  withAsyncWithUnmask,+ )+import qualified Control.Concurrent.Async as A+import Control.Concurrent.STM (STM)+import Control.Exception (SomeException)+import Control.Monad.Trans.Except (ExceptT (ExceptT), runExceptT)+import Data.Either (Either (Left, Right), either)+import Data.Foldable (toList)+import Data.Functor (fmap, (<$>))+import Data.List.NonEmpty (NonEmpty)+import System.IO (IO)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Control.Concurrent as C+-- >>> import qualified Control.Exception as E+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Wait for a thread, returning its exception, if it threw one, as a+-- 'Left'.+--+-- ==== __Examples__+--+-- >>> withAsync (pure 3) (runExceptT . waitExcept)+-- Right 3+--+-- >>> withAsync (E.throwIO (userError "x") :: IO ()) (fmap (either (const "threw") (const "returned")) . runExceptT . waitExcept)+-- "threw"+--+-- >>> check $ property $ do { n <- forAll (Gen.int (Range.linear 0 100)); r <- evalIO (withAsync (pure n) (runExceptT . waitExcept)); preview _Right r === Just n }+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+waitExcept :: Async a -> ExceptT SomeException IO a+waitExcept =+  ExceptT . waitCatch+{-# INLINE waitExcept #-}++-- | Wait for the first of some threads to end, returning it and its result+-- or exception.+--+-- ==== __Examples__+--+-- >>> withAsync (C.threadDelay 1000000 *> pure 1) (\a -> withAsync (pure 2) (\b -> fmap (preview _Right . snd) (waitAnyCatch (a :| [b]))))+-- Just 2+--+-- @since 0.7.0+waitAnyCatch :: NonEmpty (Async a) -> IO (Async a, Either SomeException a)+waitAnyCatch =+  A.waitAnyCatch . toList+{-# INLINE waitAnyCatch #-}++-- | 'waitAnyCatch' in 'STM'.+--+-- ==== __Examples__+--+-- >>> withAsync (pure 'x') (\a -> fmap (preview _Right . snd) (atomically (waitAnyCatchSTM (a :| []))))+-- Just 'x'+--+-- @since 0.7.0+waitAnyCatchSTM :: NonEmpty (Async a) -> STM (Async a, Either SomeException a)+waitAnyCatchSTM =+  A.waitAnyCatchSTM . toList+{-# INLINE waitAnyCatchSTM #-}++-- | 'waitAnyCatch', and then cancel all of the threads.+--+-- ==== __Examples__+--+-- >>> do { a <- async (C.threadDelay 10000000); b <- async (pure ()); _ <- waitAnyCatchCancel (a :| [b]); fmap (fmap (either (const "cancelled") (const "ended"))) (poll a) }+-- Just "cancelled"+--+-- @since 0.7.0+waitAnyCatchCancel :: NonEmpty (Async a) -> IO (Async a, Either SomeException a)+waitAnyCatchCancel =+  A.waitAnyCatchCancel . toList+{-# INLINE waitAnyCatchCancel #-}++-- | Run two actions of @'ExceptT' e 'IO'@ at once, and return both results.+-- The first failure cancels the other action, and is returned: when both+-- fail, it is the failure of whichever fails first.+--+-- An exception that an action throws is thrown in the caller, as in+-- 'concurrently'.+--+-- ==== __Examples__+--+-- >>> runExceptT (concurrentlyExcept (pure 1) (pure 'a') :: ExceptT () IO (Int, Char))+-- Right (1,'a')+--+-- >>> runExceptT (concurrentlyExcept (throwError "a") (ExceptT (C.threadDelay 10000000 *> pure (Right ()))) :: ExceptT String IO ((), ()))+-- Left "a"+--+-- >>> check $ property $ do { a <- forAll (Gen.either (Gen.int (Range.linear 0 9)) Gen.alpha); b <- forAll (Gen.either (Gen.int (Range.linear 0 9)) Gen.alpha); r <- evalIO (runExceptT (concurrentlyExcept (ExceptT (pure a)) (ExceptT (pure b)))); r === ((,) <$> a <*> b) }+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+concurrentlyExcept :: ExceptT e IO a -> ExceptT e IO b -> ExceptT e IO (a, b)+concurrentlyExcept a b =+  ExceptT (concurrentlyE (runExceptT a) (runExceptT b))+{-# INLINE concurrentlyExcept #-}++-- | Run two actions of @'ExceptT' e 'IO'@ at once, and return the result or+-- failure of the first to end. It cancels the other.+--+-- An exception that an action throws is thrown in the caller, as in 'race'.+--+-- ==== __Examples__+--+-- >>> runExceptT (raceExcept (pure 1) (ExceptT (C.threadDelay 10000000 *> pure (Right 'a'))) :: ExceptT () IO (Either Int Char))+-- Right (Left 1)+--+-- >>> runExceptT (raceExcept (ExceptT (C.threadDelay 10000000 *> pure (Right ()))) (throwError "b") :: ExceptT String IO (Either () ()))+-- Left "b"+--+-- @since 0.7.0+raceExcept :: ExceptT e IO a -> ExceptT e IO b -> ExceptT e IO (Either a b)+raceExcept a b =+  ExceptT (either (fmap Left) (fmap Right) <$> race (runExceptT a) (runExceptT b))+{-# INLINE raceExcept #-}
src/Papa/Base.hs view
@@ -1,74 +1,113 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} --- | Papa.Base re-exports core base functionality------ Note: The following modules are available but not re-exported to avoid conflicts:--- - Papa.Base.Control.Arrow (conflicts with bifunctor first/second)--- - Papa.Base.Control.Monad.* (mtl classes conflict with comonad equivalents)------ Import them directly if needed:--- > import Papa.Base.Control.Arrow--- > import Papa.Base.Control.Monad.Reader+-- | The total part of base, and the mtl classes and transformers. module Papa.Base (   module Papa.Base.Control.Applicative,   module Papa.Base.Control.Category,   module Papa.Base.Control.DeepSeq,+  module Papa.Base.Control.Exception,   module Papa.Base.Control.Monad,   module Papa.Base.Data.Bool,   module Papa.Base.Data.Char,   module Papa.Base.Data.Data,   module Papa.Base.Data.Either,+  module Papa.Base.Data.Enum,   module Papa.Base.Data.Eq,   module Papa.Base.Data.Foldable,+  module Papa.Base.Data.Foldable1,+  module Papa.Base.Data.Fractional,   module Papa.Base.Data.Function,   module Papa.Base.Data.Functor,   module Papa.Base.Data.Int,+  module Papa.Base.Data.IntCast,+  module Papa.Base.Data.Integral,+  module Papa.Base.Data.IORef,   module Papa.Base.Data.List,   module Papa.Base.Data.List.NonEmpty,   module Papa.Base.Data.Maybe,   module Papa.Base.Data.Monoid,   module Papa.Base.Data.Ord,   module Papa.Base.Data.Ratio,+  module Papa.Base.Data.RealFloat,+  module Papa.Base.Data.RealFrac,   module Papa.Base.Data.Semigroup,   module Papa.Base.Data.Show,   module Papa.Base.Data.String,   module Papa.Base.Data.Traversable,   module Papa.Base.Data.Void,+  module Papa.Base.Data.Word,   module Papa.Base.GHC.Generics,+  module Papa.Base.Data.Functor.Compose,+  module Papa.Base.Data.Proxy,+  module Papa.Base.System.IO,+  module Papa.Base.System.IO.Except,+  module Papa.Base.Data.Divisor,+  module Papa.Base.Data.NonZero,+  module Papa.Base.Data.Functor.Identity,+  module Papa.Base.Control.Concurrent,+  module Papa.Base.Control.Monad.Error,+  module Papa.Base.Control.Monad.Reader,+  module Papa.Base.Control.Monad.State,+  module Papa.Base.Data.Coerce,+  module Papa.Base.Data.Tuple,+  module Papa.Base.GHC.Stack,   module Papa.Base.Prelude,+  module Papa.Base.System.Environment,+  module Papa.Base.System.Exit,+  module Papa.Base.Text.Read, ) where  import Papa.Base.Control.Applicative import Papa.Base.Control.Category+import Papa.Base.Control.Concurrent import Papa.Base.Control.DeepSeq+import Papa.Base.Control.Exception import Papa.Base.Control.Monad+import Papa.Base.Control.Monad.Error+import Papa.Base.Control.Monad.Reader+import Papa.Base.Control.Monad.State import Papa.Base.Data.Bool import Papa.Base.Data.Char+import Papa.Base.Data.Coerce import Papa.Base.Data.Data+import Papa.Base.Data.Divisor import Papa.Base.Data.Either+import Papa.Base.Data.Enum import Papa.Base.Data.Eq import Papa.Base.Data.Foldable+import Papa.Base.Data.Foldable1+import Papa.Base.Data.Fractional import Papa.Base.Data.Function import Papa.Base.Data.Functor+import Papa.Base.Data.Functor.Compose+import Papa.Base.Data.Functor.Identity+import Papa.Base.Data.IORef import Papa.Base.Data.Int---- Hide uncons/unsnoc on GHC 9.8+ to avoid conflicts with Control.Lens.Cons-#if MIN_VERSION_base(4,19,0)-import Papa.Base.Data.List hiding (uncons, unsnoc)-#else-import Papa.Base.Data.List-#endif+import Papa.Base.Data.IntCast+import Papa.Base.Data.Integral+import Papa.Base.Data.List hiding (lines, unlines, unwords, words) import Papa.Base.Data.List.NonEmpty import Papa.Base.Data.Maybe import Papa.Base.Data.Monoid+import Papa.Base.Data.NonZero import Papa.Base.Data.Ord+import Papa.Base.Data.Proxy import Papa.Base.Data.Ratio+import Papa.Base.Data.RealFloat+import Papa.Base.Data.RealFrac import Papa.Base.Data.Semigroup import Papa.Base.Data.Show-import Papa.Base.Data.String+import Papa.Base.Data.String hiding (lines, unlines, unwords, words) import Papa.Base.Data.Traversable+import Papa.Base.Data.Tuple import Papa.Base.Data.Void+import Papa.Base.Data.Word import Papa.Base.GHC.Generics-import Papa.Base.Prelude+import Papa.Base.GHC.Stack+import Papa.Base.Prelude hiding (lines, unlines, unwords, words)+import Papa.Base.System.Environment+import Papa.Base.System.Exit+import Papa.Base.System.IO+import Papa.Base.System.IO.Except+import Papa.Base.Text.Read
src/Papa/Base/Control/Applicative.hs view
@@ -1,13 +1,14 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Applicative functors, with 'const' generalised to any 'Applicative'. module Papa.Base.Control.Applicative (   Applicative (pure, (<*>), (*>), (<*)),   Alternative (empty, (<|>), some, many),   Const (Const, getConst),-  WrappedMonad (unwrapMonad),-  WrappedArrow (unwrapArrow),-  ZipList (getZipList),+  WrappedMonad (WrapMonad, unwrapMonad),+  WrappedArrow (WrapArrow, unwrapArrow),+  ZipList (ZipList, getZipList),   (<$>),   (<$),   (<**>),@@ -24,9 +25,9 @@   Alternative (empty, many, some, (<|>)),   Applicative (pure, (*>), (<*), (<*>)),   Const (Const, getConst),-  WrappedArrow (unwrapArrow),-  WrappedMonad (unwrapMonad),-  ZipList (getZipList),+  WrappedArrow (WrapArrow, unwrapArrow),+  WrappedMonad (WrapMonad, unwrapMonad),+  ZipList (ZipList, getZipList),   liftA,   liftA2,   liftA3,@@ -35,50 +36,79 @@   (<$>),   (<**>),  )-import Papa.Base.Prelude (IO, Int, Maybe, otherwise, (-), (<=))+import Control.Monad (replicateM, replicateM_)+import Data.Int (Int) -{-# INLINE const #-}-const ::-  (Applicative f) =>-  a ->-  f a+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)++-- | 'pure', under the name of "Prelude"'s @const@. At the function+-- 'Applicative' (@f = (->) b@) it is "Prelude"'s @const@.+--+-- ==== __Examples__+--+-- >>> const 'a' (1 :: Int)+-- 'a'+--+-- >>> const 'a' :: Maybe Char+-- Just 'a'+--+-- >>> check $ withTests 100 $ property $ do a <- forAll genInt; b <- forAll genInt; const a b === a+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+const :: (Applicative f) => a -> f a const =   pure+{-# INLINE const #-} -{-# INLINEABLE replicateA #-}-{-# SPECIALIZE replicateA ::-  Int ->-  IO a ->-  IO [a]-  #-}-{-# SPECIALIZE replicateA ::-  Int ->-  Maybe a ->-  Maybe [a]-  #-}+-- | Perform an action @n@ times, collecting the results. No times for+-- @n <= 0@. This is 'replicateM', which needs only 'Applicative'.+--+-- ==== __Examples__+--+-- >>> replicateA 3 (Just 'x')+-- Just "xxx"+--+-- >>> replicateA 0 (Nothing :: Maybe Char)+-- Just ""+--+-- >>> replicateA 2 "ab"+-- ["aa","ab","ba","bb"]+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-5) 10)); a <- forAll genInt; replicateA n (Just a) === Just (replicate n a)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0 replicateA :: (Applicative f) => Int -> f a -> f [a]-replicateA cnt0 f =-  loop cnt0- where-  loop cnt-    | cnt <= 0 = pure []-    | otherwise = liftA2 (:) f (loop (cnt - 1))+replicateA =+  replicateM+{-# INLINE replicateA #-} -{-# INLINEABLE replicateA_ #-}-{-# SPECIALIZE replicateA_ ::-  Int ->-  IO a ->-  IO ()-  #-}-{-# SPECIALIZE replicateA_ ::-  Int ->-  Maybe a ->-  Maybe ()-  #-}+-- | Perform an action @n@ times, discarding the results. No times for+-- @n <= 0@. This is 'replicateM_', which needs only 'Applicative'.+--+-- ==== __Examples__+--+-- >>> replicateA_ 3 (Just 'x')+-- Just ()+--+-- >>> replicateA_ 2 "ab"+-- [(),(),(),()]+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-5) 6)); replicateA_ n "ab" === void (replicateA n "ab")+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0 replicateA_ :: (Applicative f) => Int -> f a -> f ()-replicateA_ cnt0 f =-  loop cnt0- where-  loop cnt-    | cnt <= 0 = pure ()-    | otherwise = f *> loop (cnt - 1)+replicateA_ =+  replicateM_+{-# INLINE replicateA_ #-}
src/Papa/Base/Control/Arrow.hs view
@@ -1,15 +1,111 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Arrows.+--+-- The 'Arrow' methods @first@ and @second@ are exported as 'firstA' and+-- 'secondA', and the 'ArrowChoice' methods @left@ and @right@ as 'leftA' and+-- 'rightA', so that this module can be imported with "Papa", whose @first@+-- and @second@ are those of 'Data.Bifunctor.Bifunctor', and whose @left@+-- and @right@ are the names of the sides of a sum. module Papa.Base.Control.Arrow (   module P,+  firstA,+  secondA,+  leftA,+  rightA, ) where  import Control.Arrow as P (-  Arrow (arr, first, second, (&&&), (***)),+  Arrow (arr, (&&&), (***)),   ArrowApply (app),-  ArrowChoice (left, right, (+++), (|||)),+  ArrowChoice ((+++), (|||)),   ArrowLoop (loop),   ArrowPlus ((<+>)),   ArrowZero (zeroArrow),+  Kleisli (Kleisli, runKleisli),  )+import qualified Control.Arrow as A+import Data.Either (Either)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Papa.Base.Control.Arrow+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)++-- | Send the first component of the input through the arrow, and the+-- second through unchanged. @Arrow@'s @first@.+--+-- ==== __Examples__+--+-- >>> firstA (+ 1) (1 :: Int, 'x')+-- (2,'x')+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genInt); a <- forAll genInt; c <- forAll Gen.alpha; firstA (apply f) (a, c) === first (apply f) (a, c)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+firstA :: (Arrow a) => a b c -> a (b, d) (c, d)+firstA =+  A.first+{-# INLINE firstA #-}++-- | Send the second component of the input through the arrow, and the+-- first through unchanged. @Arrow@'s @second@.+--+-- ==== __Examples__+--+-- >>> secondA (+ 1) ('x', 1 :: Int)+-- ('x',2)+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genInt); a <- forAll genInt; c <- forAll Gen.alpha; secondA (apply f) (c, a) === second (apply f) (c, a)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+secondA :: (Arrow a) => a b c -> a (d, b) (d, c)+secondA =+  A.second+{-# INLINE secondA #-}++-- | Send a 'Data.Either.Left' input through the arrow, and a 'Data.Either.Right' input through+-- unchanged. @ArrowChoice@'s @left@.+--+-- ==== __Examples__+--+-- >>> leftA (+ 1) (Left 1 :: Either Int Char)+-- Left 2+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genInt); e <- forAll (Gen.either genInt Gen.alpha); leftA (apply f) e === first (apply f) e+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+leftA :: (ArrowChoice a) => a b c -> a (Either b d) (Either c d)+leftA =+  A.left+{-# INLINE leftA #-}++-- | Send a 'Data.Either.Right' input through the arrow, and a 'Data.Either.Left' input through+-- unchanged. @ArrowChoice@'s @right@.+--+-- ==== __Examples__+--+-- >>> rightA (+ 1) (Right 1 :: Either Char Int)+-- Right 2+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genInt); e <- forAll (Gen.either Gen.alpha genInt); rightA (apply f) e === second (apply f) e+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+rightA :: (ArrowChoice a) => a b c -> a (Either d b) (Either d c)+rightA =+  A.right+{-# INLINE rightA #-}
+ src/Papa/Base/Control/Concurrent.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Threads and mutable variables shared between them.+--+-- 'forkFinally' runs an action when the thread ends, with how it ended: the+-- way to fork a thread whose failure must be seen.+--+-- @since 0.7.0+module Papa.Base.Control.Concurrent (+  module P,+) where++import Control.Concurrent as P (+  MVar,+  ThreadId,+  forkFinally,+  forkIO,+  killThread,+  modifyMVar,+  modifyMVar_,+  myThreadId,+  newEmptyMVar,+  newMVar,+  putMVar,+  readMVar,+  takeMVar,+  threadDelay,+  tryReadMVar,+  tryTakeMVar,+ )
+ src/Papa/Base/Control/Exception.hs view
@@ -0,0 +1,266 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Exceptions in 'Prelude.IO', caught without catching asynchronous+-- exceptions, and released without being interrupted.+--+-- 'catch', 'handle' and 'try' differ from "Control.Exception"'s: they never+-- catch an asynchronous exception (one thrown to the thread by+-- 'Control.Concurrent.killThread', 'Control.Concurrent.throwTo' or+-- 'System.Timeout.timeout'), even at 'SomeException'. They rethrow it, so+-- that a thread told to stop, stops.+--+-- 'bracket', 'bracket_', 'bracketOnError', 'finally' and 'onException' differ+-- too: they run the release action under 'uninterruptibleMask_', so that a+-- second asynchronous exception cannot interrupt a release that blocks (an+-- 'Control.Concurrent.MVar', closing a socket) and leak the resource. The+-- cost: a release action that blocks forever cannot be interrupted, so it+-- hangs the thread. When the body throws, an exception thrown by the release+-- action is discarded and the body's is rethrown. These are the semantics of+-- the @safe-exceptions@ package, which Papa does not depend on.+--+-- @throw@, which throws from pure code, is not exported: like @error@, it+-- makes a function partial. It is in "Papa.Unsafe.Exception".+module Papa.Base.Control.Exception (+  module P,+  catch,+  handle,+  try,+  bracket,+  bracket_,+  bracketOnError,+  finally,+  onException,+) where++import Control.Applicative (pure, (<$>))+import Control.Category ((.))+import Control.Exception as P (+  ArithException (..),+  ArrayException (..),+  AsyncException (HeapOverflow, StackOverflow, ThreadKilled, UserInterrupt),+  ErrorCall,+  Exception (displayException, fromException, toException),+  IOException,+  MaskingState (MaskedInterruptible, MaskedUninterruptible, Unmasked),+  SomeAsyncException (SomeAsyncException),+  SomeException,+  asyncExceptionFromException,+  asyncExceptionToException,+  evaluate,+  getMaskingState,+  mask,+  mask_,+  throwIO,+  throwTo,+  uninterruptibleMask,+  uninterruptibleMask_,+ )+import qualified Control.Exception as E+import Control.Monad ((>>=))+import Data.Bool (Bool, bool)+import Data.Either (Either (Left, Right), either)+import Data.Function (const, flip)+import Data.Maybe (Maybe, isJust)+import Prelude (IO)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XScopedTypeVariables+-- >>> :set -XTypeApplications+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Whether an exception was thrown asynchronously.+isAsync :: SomeException -> Bool+isAsync e =+  isJust (fromException e :: Maybe SomeAsyncException)+{-# INLINE isAsync #-}++-- | Run the action; if it throws a synchronous exception of type @e@, run the+-- handler on it. An asynchronous exception is rethrown, even where @e@ is+-- 'SomeException'.+--+-- ==== __Examples__+--+-- >>> catch (throwIO (userError "u")) (\(e :: IOException) -> pure (displayException e))+-- "user error (u)"+--+-- >>> catch (throwIO DivideByZero) (\(_ :: SomeException) -> pure "caught")+-- "caught"+--+-- An asynchronous exception is not caught, even at 'SomeException':+--+-- >>> do { s <- newEmptyMVar; v <- newEmptyMVar; t <- forkFinally (catch (putMVar s () *> threadDelay 10000000 *> pure "finished") (\(_ :: SomeException) -> pure "caught")) (putMVar v . either show id); takeMVar s; killThread t; takeMVar v }+-- "thread killed"+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (catch (throwIO (userError (show n))) (\(e :: IOException) -> pure (displayException e))); r === "user error (" <> show n <> ")"+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+catch :: (Exception e) => IO a -> (e -> IO a) -> IO a+catch a h =+  E.catch a (\e -> bool (h e) (E.throwIO e) (isAsync (toException e)))+{-# INLINE catch #-}++-- | 'catch' with its arguments flipped.+--+-- ==== __Examples__+--+-- >>> handle (\(e :: ArithException) -> pure (show e)) (throwIO Overflow)+-- "arithmetic overflow"+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (handle (\(_ :: SomeException) -> pure 0) (pure n)); r === n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+handle :: (Exception e) => (e -> IO a) -> IO a -> IO a+handle =+  flip catch+{-# INLINE handle #-}++-- | Run the action, returning a synchronous exception of type @e@ as a+-- 'Left'. An asynchronous exception is rethrown, even where @e@ is+-- 'SomeException'.+--+-- ==== __Examples__+--+-- >>> try @ArithException (throwIO DivideByZero)+-- Left divide by zero+--+-- >>> try @ArithException (pure 'a')+-- Right 'a'+--+-- An asynchronous exception is not caught, even at 'SomeException':+--+-- >>> do { s <- newEmptyMVar; v <- newEmptyMVar; t <- forkFinally (try @SomeException (putMVar s () *> threadDelay 10000000)) (putMVar v . either show (either (\(_ :: SomeException) -> "caught") (\() -> "finished"))); takeMVar s; killThread t; takeMVar v }+-- "thread killed"+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (try @SomeException (pure n)); either (\(_ :: SomeException) -> Nothing) Just r === Just n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+try :: (Exception e) => IO a -> IO (Either e a)+try a =+  catch (Right <$> a) (pure . Left)+{-# INLINE try #-}++-- | Acquire a resource, use it, and release it, whether or not the use+-- throws. The release runs under 'uninterruptibleMask_'; if the use throws,+-- the release's own exception is discarded and the use's rethrown.+--+-- ==== __Examples__+--+-- >>> do { r <- newIORef []; _ <- try @ArithException (bracket (modifyIORef' r ("acquire" :)) (\_ -> modifyIORef' r ("release" :)) (\_ -> throwIO Overflow)); readIORef r }+-- ["release","acquire"]+--+-- >>> bracket (pure 1) (\_ -> pure ()) (\n -> pure (n + 1))+-- 2+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear 0 100)); r <- evalIO (do v <- newIORef 0; _ <- bracket (pure n) (writeIORef v) pure; readIORef v); r === n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c+bracket acquire release use =+  mask+    ( \restore ->+        acquire+          >>= \a ->+            E.try (restore (use a))+              >>= either+                (\(e :: SomeException) -> E.try (uninterruptibleMask_ (release a)) >>= \(_ :: Either SomeException b) -> E.throwIO e)+                (\c -> uninterruptibleMask_ (release a) >>= const (pure c))+    )+{-# INLINEABLE bracket #-}++-- | 'bracket' whose release and use do not take the resource.+--+-- ==== __Examples__+--+-- >>> do { r <- newIORef []; bracket_ (modifyIORef' r ("acquire" :)) (modifyIORef' r ("release" :)) (modifyIORef' r ("use" :)); readIORef r }+-- ["release","use","acquire"]+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear 0 100)); r <- evalIO (bracket_ (pure ()) (pure ()) (pure n)); r === n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+bracket_ :: IO a -> IO b -> IO c -> IO c+bracket_ acquire release use =+  bracket acquire (const release) (const use)+{-# INLINE bracket_ #-}++-- | 'bracket' that releases the resource only if the use throws.+--+-- ==== __Examples__+--+-- >>> do { r <- newIORef []; _ <- bracketOnError (pure ()) (\_ -> modifyIORef' r ("release" :)) (\_ -> pure ()); readIORef r }+-- []+--+-- >>> do { r <- newIORef []; _ <- try @ArithException (bracketOnError (pure ()) (\_ -> modifyIORef' r ("release" :)) (\_ -> throwIO Overflow)); readIORef r }+-- ["release"]+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear 0 100)); r <- evalIO (bracketOnError (pure n) (\_ -> pure ()) pure); r === n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+bracketOnError :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c+bracketOnError acquire release use =+  mask+    ( \restore ->+        acquire+          >>= \a ->+            E.try (restore (use a))+              >>= either+                (\(e :: SomeException) -> E.try (uninterruptibleMask_ (release a)) >>= \(_ :: Either SomeException b) -> E.throwIO e)+                pure+    )+{-# INLINEABLE bracketOnError #-}++-- | Run the first action, then the second, whether or not the first throws.+-- The second runs under 'uninterruptibleMask_'.+--+-- ==== __Examples__+--+-- >>> do { r <- newIORef []; _ <- try @ArithException (throwIO Overflow `finally` modifyIORef' r ("finally" :)); readIORef r }+-- ["finally"]+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear 0 100)); r <- evalIO (pure n `finally` pure ()); r === n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+finally :: IO a -> IO b -> IO a+finally use release =+  bracket_ (pure ()) release use+{-# INLINE finally #-}++-- | Run the first action, then, only if it throws, the second, and rethrow.+-- The second runs under 'uninterruptibleMask_'.+--+-- ==== __Examples__+--+-- >>> do { r <- newIORef []; _ <- try @ArithException (throwIO Overflow `onException` modifyIORef' r ("onException" :)); readIORef r }+-- ["onException"]+--+-- >>> do { r <- newIORef []; _ <- pure () `onException` modifyIORef' r ("onException" :); readIORef r }+-- []+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear 0 100)); r <- evalIO (pure n `onException` pure ()); r === n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+onException :: IO a -> IO b -> IO a+onException use release =+  bracketOnError (pure ()) (const release) (const use)+{-# INLINE onException #-}
src/Papa/Base/Control/Monad.hs view
@@ -1,15 +1,28 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Monads.+--+-- 'MonadFail' is exported without its method @fail@, which throws in+-- 'Prelude.IO'. A failing pattern in @do@ notation still uses it.+--+-- 'MonadFix' is exported without its method @mfix@, which throws for+-- base's 'Maybe', list and 'Data.Either.Either' instances, and for free's,+-- where the function forces its own result. @mdo@ and @rec@ notation+-- (@RecursiveDo@) still use it. module Papa.Base.Control.Monad (   Functor (fmap),   Monad ((>>=), return, (>>)),-  MonadFail (fail),-  MonadFix (mfix),+  MonadFail,+  MonadFix,+  MonadIO (liftIO),   MonadPlus (mzero, mplus),+  MonadTrans (lift),   MonadZip (mzip, mzipWith, munzip),+  ap,   forever,+  liftM,+  liftM2,   msum,   mfilter,   filterM,@@ -20,7 +33,11 @@   guard,   when,   unless,+  zipWithM,+  zipWithM_,   (<$!>),+  (>=>),+  (<=<),   anyM,   allM,   findM,@@ -29,76 +46,120 @@ import Control.Monad (   Functor (fmap),   Monad (return, (>>), (>>=)),-  MonadFail (fail),+  MonadFail,   MonadPlus (mplus, mzero),+  ap,   filterM,   foldM,   foldM_,   forever,   guard,+  liftM,+  liftM2,   mfilter,   msum,   replicateM,   replicateM_,   unless,   when,+  zipWithM,+  zipWithM_,   (<$!>),+  (<=<),+  (>=>),  )-import Control.Monad.Fix as P (-  MonadFix (mfix),+import Control.Monad.Fix (+  MonadFix,  )-import Control.Monad.Zip as P (+import Control.Monad.IO.Class (+  MonadIO (liftIO),+ )+import Control.Monad.Trans.Class (+  MonadTrans (lift),+ )+import Control.Monad.Zip (   MonadZip (munzip, mzip, mzipWith),  )--import Data.Bool (Bool (False, True))+import Data.Bool (Bool (False, True), bool) import Data.Maybe (Maybe (Just, Nothing)) -{-# INLINE anyM #-}-anyM ::-  (Monad m) =>-  (a -> m Bool) ->-  [a] ->-  m Bool+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (Fn, fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInts = Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-100) 100))+-- >>> let genP = fn Gen.bool :: Gen (Fn Int Bool)++-- | Whether any element satisfies a monadic predicate. Stops at the first+-- element that does.+--+-- ==== __Examples__+--+-- >>> anyM (\x -> Just (x > 2)) [1, 2, 3 :: Int]+-- Just True+--+-- >>> anyM (\x -> if x > 2 then Nothing else Just False) [1, 2 :: Int]+-- Just False+--+-- >>> anyM (\_ -> Nothing) ([] :: [Int])+-- Just False+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; p <- forAll genP; anyM (Just . apply p) xs === Just (any (apply p) xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+anyM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool anyM _ [] =   return False anyM f (a : as) =-  do-    z <- f a-    if z-      then return True-      else anyM f as+  f a >>= bool (anyM f as) (return True)+{-# INLINEABLE anyM #-} -{-# INLINE allM #-}-allM ::-  (Monad m) =>-  (a -> m Bool) ->-  [a] ->-  m Bool+-- | Whether every element satisfies a monadic predicate. Stops at the first+-- element that does not.+--+-- ==== __Examples__+--+-- >>> allM (\x -> Just (x > 0)) [1, 2, 3 :: Int]+-- Just True+--+-- >>> allM (\_ -> Nothing) ([] :: [Int])+-- Just True+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; p <- forAll genP; allM (Just . apply p) xs === Just (all (apply p) xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+allM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool allM _ [] =   return True allM f (a : as) =-  do-    z <- f a-    if z-      then allM f as-      else return False--{-# INLINE findM #-}+  f a >>= bool (return False) (allM f as)+{-# INLINEABLE allM #-} --- | Find an element satisfying a predicate-findM ::-  (Monad m) =>-  (a -> m Bool) ->-  [a] ->-  m (Maybe a)+-- | The first element that satisfies a monadic predicate. Stops there.+--+-- ==== __Examples__+--+-- >>> findM (\x -> Just (x > 1)) [1, 2, 3 :: Int]+-- Just (Just 2)+--+-- >>> findM (\_ -> Just False) [1, 2, 3 :: Int]+-- Just Nothing+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; p <- forAll genP; findM (Just . apply p) xs === Just (find (apply p) xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+findM :: (Monad m) => (a -> m Bool) -> [a] -> m (Maybe a) findM _ [] =   return Nothing findM f (x : xs) =-  do-    b <- f x-    if b-      then-        return (Just x)-      else-        findM f xs+  f x >>= bool (findM f xs) (return (Just x))+{-# INLINEABLE findM #-}
src/Papa/Base/Control/Monad/Error.hs view
@@ -1,10 +1,20 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Errors: the class, and the exception monad transformer. module Papa.Base.Control.Monad.Error (   module P, ) where  import Control.Monad.Except as P (+  Except,+  ExceptT (ExceptT),   MonadError (catchError, throwError),+  liftEither,+  mapExceptT,+  runExcept,+  runExceptT,+  withExcept,+  withExceptT,  )+import Control.Monad.Trans.Except as P (except)
src/Papa/Base/Control/Monad/Reader.hs view
@@ -1,10 +1,15 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Reader: the class, and the reader monad transformer. module Papa.Base.Control.Monad.Reader (   module P, ) where -import Control.Monad.Reader.Class as P (+import Control.Monad.Reader as P (   MonadReader (ask, local, reader),+  Reader,+  ReaderT (ReaderT, runReaderT),+  asks,+  runReader,  )
src/Papa/Base/Control/Monad/State.hs view
@@ -1,10 +1,24 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | State: the class, and the strict state monad transformer.+--+-- The transformer is "Control.Monad.State.Strict"'s, whose bind does not+-- build a chain of thunks. module Papa.Base.Control.Monad.State (   module P, ) where -import Control.Monad.State.Class as P (+import Control.Monad.State.Strict as P (   MonadState (get, put, state),+  State,+  StateT (StateT, runStateT),+  evalState,+  evalStateT,+  execState,+  execStateT,+  gets,+  modify,+  modify',+  runState,  )
src/Papa/Base/Data/Char.hs view
@@ -1,14 +1,16 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Characters, with a total 'chr'. module Papa.Base.Data.Char (   module P,+  chr, ) where +import Data.Bool (bool, (&&)) import Data.Char as P (   Char,   GeneralCategory (ClosePunctuation, ConnectorPunctuation, Control, CurrencySymbol, DashPunctuation, DecimalNumber, EnclosingMark, FinalQuote, Format, InitialQuote, LetterNumber, LineSeparator, LowercaseLetter, MathSymbol, ModifierLetter, ModifierSymbol, NonSpacingMark, NotAssigned, OpenPunctuation, OtherLetter, OtherNumber, OtherPunctuation, OtherSymbol, ParagraphSeparator, PrivateUse, Space, SpacingCombiningMark, Surrogate, TitlecaseLetter, UppercaseLetter),-  chr,   isAlpha,   isAlphaNum,   isAscii,@@ -34,3 +36,37 @@   toTitle,   toUpper,  )+import qualified Data.Char as C+import Data.Int (Int)+import Data.Maybe (Maybe (Just, Nothing))+import Data.Ord (Ord ((<=)))++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen++-- | Total 'Data.Char.chr': 'Data.Maybe.Nothing' outside the range of 'Char'+-- (@0@ to @0x10FFFF@), where "Data.Char"'s @chr@ throws.+--+-- ==== __Examples__+--+-- >>> chr 65+-- Just 'A'+--+-- >>> chr (-1)+-- Nothing+--+-- >>> chr 0x110000+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll Gen.unicodeAll; chr (ord c) === Just c+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+chr :: Int -> Maybe Char+chr n =+  bool Nothing (Just (C.chr n)) (0 <= n && n <= 0x10FFFF)+{-# INLINE chr #-}
+ src/Papa/Base/Data/Coerce.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Safe coercion between types with the same representation.+--+-- @since 0.7.0+module Papa.Base.Data.Coerce (+  module P,+) where++import Data.Coerce as P (+  Coercible,+  coerce,+ )
+ src/Papa/Base/Data/Divisor.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The name @divisor@ (classy optics, rule 4): the value that a+-- 'Papa.Base.Data.NonZero.NonZero' holds.+--+-- Its target is a type variable, so the name has no identity instance+-- (rule 4).+--+-- @since 0.7.0+module Papa.Base.Data.Divisor (+  DivisorLike (..),+) where++import Control.Lens (Optic)++-- | A field or a constructor named @divisor@.+--+-- @since 0.7.0+class DivisorLike p f x x' a a' | x -> a where+  divisor ::+    Optic p f x x' a a'
src/Papa/Base/Data/Either.hs view
@@ -1,37 +1,143 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Sums, with optics for the two sides: the names 'left' and 'right'+-- ("Papa.Base.Data.Left", "Papa.Base.Data.Right"), and functions over+-- them. module Papa.Base.Data.Either (   module P,+  LeftLike (left),+  RightLike (right),   lefts,   rights,   fromLeft,   fromRight,+  partitionEithers, ) where -import Control.Applicative (Applicative (pure))-import Control.Category (Category (id, (.)))-import Control.Lens (Traversal, _Left, _Right)+import Control.Category ((.))+import Control.Lens (Traversal, preview) import Data.Either as P (   Either (Left, Right),   either,-  partitionEithers,+  isLeft,+  isRight,  )+import Data.Foldable (Foldable (foldr))+import Data.Functor.Const (Const)+import Data.Maybe (fromMaybe)+import Data.Monoid (First) import Data.Traversable (Traversable (traverse))+import Papa.Base.Data.Left (LeftLike (left))+import Papa.Base.Data.Right (RightLike (right)) -{-# INLINE lefts #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genEither = Gen.either (Gen.int (Range.linear 0 9)) Gen.alpha+-- >>> let genEithers = Gen.list (Range.linear 0 20) genEither++-- | The 'Left' values of a 'Traversable' of 'Either's.+--+-- ==== __Examples__+--+-- >>> toListOf lefts [Left 1, Right 'x', Left (2 :: Int)]+-- [1,2]+--+-- >>> over lefts (+ 1) [Left 1, Right 'x', Left (2 :: Int)]+-- [Left 2,Right 'x',Left 3]+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genEithers; toListOf lefts xs === [a | Left a <- xs]+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0 lefts :: (Traversable f) => Traversal (f (Either a b)) (f (Either a' b)) a a'-lefts = traverse . _Left+lefts =+  traverse . left+{-# INLINE lefts #-} -{-# INLINE rights #-}+-- | The 'Right' values of a 'Traversable' of 'Either's.+--+-- ==== __Examples__+--+-- >>> toListOf rights [Left 1, Right 'x', Left (2 :: Int)]+-- "x"+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genEithers; toListOf rights xs === [b | Right b <- xs]+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0 rights :: (Traversable f) => Traversal (f (Either a b)) (f (Either a b')) b b'-rights = traverse . _Right+rights =+  traverse . right+{-# INLINE rights #-} +-- | The value of the name 'left', or the given default, for any data type+-- that has the name.+--+-- ==== __Examples__+--+-- >>> fromLeft 0 (Left 3 :: Either Int Char)+-- 3+--+-- >>> fromLeft 0 (Right 'x' :: Either Int Char)+-- 0+--+-- >>> check $ withTests 100 $ property $ do d <- forAll (Gen.int (Range.linear 0 9)); e <- forAll genEither; fromLeft d e === either id (\_ -> d) e+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fromLeft :: (LeftLike (->) (Const (First a)) s s a a) => a -> s -> a+fromLeft a =+  fromMaybe a . preview left {-# INLINE fromLeft #-}-fromLeft :: a -> Either a b -> a-fromLeft x = either id (pure x) +-- | The value of the name 'right', or the given default, for any data type+-- that has the name.+--+-- ==== __Examples__+--+-- >>> fromRight 'z' (Right 'x' :: Either Int Char)+-- 'x'+--+-- >>> fromRight 'z' (Left 3 :: Either Int Char)+-- 'z'+--+-- >>> check $ withTests 100 $ property $ do d <- forAll Gen.alpha; e <- forAll genEither; fromRight d e === either (\_ -> d) id e+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fromRight :: (RightLike (->) (Const (First b)) s s b b) => b -> s -> b+fromRight b =+  fromMaybe b . preview right {-# INLINE fromRight #-}-fromRight :: b -> Either a b -> b-fromRight x = either (pure x) id++-- | Partition the 'Either's of any 'Foldable' into the 'Left' values and+-- the 'Right' values, in order, in one lazy pass (as "Data.Either"'s+-- @partitionEithers@ does for a list).+--+-- ==== __Examples__+--+-- >>> partitionEithers [Left 1, Right 'x', Left (2 :: Int)]+-- ([1,2],"x")+--+-- >>> partitionEithers (Just (Right 'x' :: Either Int Char))+-- ([],"x")+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genEithers; partitionEithers xs === (toListOf lefts xs, toListOf rights xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+partitionEithers :: (Foldable f) => f (Either a b) -> ([a], [b])+partitionEithers =+  foldr (\e ~(ls, rs) -> either (\a -> (a : ls, rs)) (\b -> (ls, b : rs)) e) ([], [])+{-# INLINE partitionEithers #-}
+ src/Papa/Base/Data/Enum.hs view
@@ -0,0 +1,133 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Total enumeration.+--+-- The 'Enum' methods @succ@ and @pred@ of "Prelude" throw at the ends of the+-- range of a type. These return 'Data.Maybe.Nothing' there instead.+--+-- * 'succ' is the second element of @enumFrom@, which stops at the last value+--   of a bounded type and does not stop for an unbounded one, so it needs only+--   'Enum', and works at 'Prelude.Integer', 'Numeric.Natural.Natural' and+--   'Prelude.Double'.+-- * 'pred' needs the lower end of the range, so it is defined for types that+--   are 'Bounded' as well as 'Enum'. @enumFrom@ has no counterpart that goes+--   down without already knowing the predecessor.+--+-- 'Enum' is exported without its methods, for its constraint. @toEnum@ and+-- @fromEnum@ are not exported: base's instances throw for a value that does+-- not fit in an 'Data.Int.Int' (a @Word@ or @Word64@ above+-- @'maxBound' :: Int@), and a total version cannot be written for every+-- 'Enum' type. Use 'Papa.Base.Data.Integral.toIntegralSized' between integral+-- types, and 'Data.Char.ord' and 'Papa.Base.Data.Char.chr' for 'Data.Char.Char'.+--+-- == Range syntax+--+-- @[a ..]@, @[a, b ..]@, @[a .. c]@ and @[a, b .. c]@ are syntax for+-- The methods of 'Enum' (@enumFrom@, …), which GHC calls whether or not they are+-- in scope, so not exporting them does not take the syntax away. It is total+-- at every type of base, but at 'Prelude.Float' and 'Prelude.Double' it is+-- not what it looks like: a range goes on to half a step past its end, and+-- its elements are sums of the step, with their rounding errors.+--+-- >>> [1.0 .. 2.5 :: Double]+-- [1.0,2.0,3.0]+--+-- >>> [0, 0.1 .. 0.3 :: Double]+-- [0.0,0.1,0.2,0.30000000000000004]+--+-- A step of zero repeats the first element without end:+--+-- >>> take 3 [1, 1 .. 5 :: Int]+-- [1,1,1]+--+-- For fractional values, build the range over an integral type, and divide:+--+-- >>> (\d -> fmap (\n -> divideNonZero (integralToFloating n) d) [0 .. 3 :: Int]) <$> preview nonZero (10 :: Double)+-- Just [0.0,0.1,0.2,0.3]+--+-- @since 0.6.0+module Papa.Base.Data.Enum (+  Bounded (minBound, maxBound),+  Enum,+  succ,+  pred,+) where++import Control.Category ((.))+import Data.Bool (bool)+import Data.Eq (Eq ((==)))+import Data.Maybe (Maybe (Just, Nothing))+import Prelude (Bounded (maxBound, minBound), Enum)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> import qualified Prelude as P++-- | Total 'P.succ': 'Nothing' at the last value of a bounded type.+--+-- ==== __Examples__+--+-- >>> succ False+-- Just True+--+-- >>> succ True+-- Nothing+--+-- >>> succ (maxBound :: Int)+-- Nothing+--+-- >>> succ (3 :: Integer)+-- Just 4+--+-- >>> succ (1.5 :: Double)+-- Just 2.5+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int Range.linearBounded); succ n === bool (Just (P.succ n)) Nothing (n == maxBound)+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.integral (Range.linearFrom 0 (-1000) 1000) :: Gen Integer); succ n === Just (n + 1)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+succ :: (Enum a) => a -> Maybe a+succ =+  second . P.enumFrom+{-# INLINE succ #-}++-- | The second element of a list. A right fold, so that it fuses with+-- @enumFrom@ and allocates no list.+second :: [a] -> Maybe a+second xs =+  P.foldr (\x k i -> bool (k (1 :: P.Int)) (Just x) (i == 1)) (P.const Nothing) xs 0+{-# INLINE second #-}++-- | Total 'P.pred': 'Nothing' at 'minBound'.+--+-- ==== __Examples__+--+-- >>> pred True+-- Just False+--+-- >>> pred False+-- Nothing+--+-- >>> pred (minBound :: Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int Range.linearBounded); (pred n >>= succ) === if n == minBound then Nothing else Just n+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+pred :: (Bounded a, Enum a, Eq a) => a -> Maybe a+pred a =+  bool (Just (P.pred a)) Nothing (a == minBound)+{-# INLINEABLE pred #-}
src/Papa/Base/Data/Foldable.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Folds, with the monadic folds of "Prelude" generalised to 'Applicative'. module Papa.Base.Data.Foldable (   module P,   mapM_,@@ -9,12 +9,15 @@   sequence_, ) where +import Control.Applicative (Applicative) import Data.Foldable as P (-  Foldable (elem, fold, foldMap, foldl, foldl', foldr, foldr', null, product, sum, toList),+  Foldable (elem, fold, foldMap, foldMap', foldl, foldl', foldr, foldr', length, null, product, sum, toList),   all,   and,   any,   asum,+  concat,+  concatMap,   find,   foldlM,   foldrM,@@ -25,53 +28,72 @@   traverse_,  ) -import Control.Applicative (Applicative)-import Data.Foldable ()--{-# INLINE mapM_ #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> import Control.Monad.Trans.Writer.CPS (runWriter, tell)+-- >>> let genInts = Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-100) 100)) --- | Map each element to an action, evaluate these actions left to right, and ignore the results.+-- | 'traverse_', under the name of "Prelude"'s @mapM_@, which needs only+-- 'Applicative'. ----- >>> import Data.Maybe (Maybe(..))--- >>> mapM_ (\x -> Just x) [1,2,3]+-- ==== __Examples__+--+-- >>> mapM_ (\x -> Just x) [1, 2, 3 :: Int] -- Just ()--- >>> mapM_ (\_ -> Nothing) [1,2,3]+--+-- >>> mapM_ (\x -> if x > 2 then Nothing else Just x) [1, 2, 3 :: Int] -- Nothing-mapM_ ::-  (Foldable t, Applicative f) =>-  (a -> f b) ->-  t a ->-  f ()+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; f <- forAll (fn (Gen.list (Range.linear 0 3) (Gen.int (Range.linear 0 9)))); runWriter (mapM_ (tell . apply f) xs) === runWriter (traverse_ (tell . apply f) xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+mapM_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () mapM_ =   traverse_--{-# INLINE forM_ #-}+{-# INLINE mapM_ #-} --- | 'forM_' is 'mapM_' with its arguments flipped.+-- | 'for_', under the name of "Prelude"'s @forM_@, which needs only+-- 'Applicative'. ----- >>> import Data.Maybe (Maybe(..))--- >>> forM_ [1,2,3] (\x -> Just x)+-- ==== __Examples__+--+-- >>> forM_ [1, 2, 3 :: Int] (\x -> Just x) -- Just ()-forM_ ::-  (Foldable t, Applicative m) =>-  t a ->-  (a -> m b) ->-  m ()-forM_ a f =-  mapM_ f a--{-# INLINE sequence_ #-}+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; f <- forAll (fn (Gen.list (Range.linear 0 3) (Gen.int (Range.linear 0 9)))); runWriter (forM_ xs (tell . apply f)) === runWriter (traverse_ (tell . apply f) xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+forM_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()+forM_ =+  for_+{-# INLINE forM_ #-} --- | Evaluate each action in the structure left to right, and ignore the results.+-- | 'sequenceA_', under the name of "Prelude"'s @sequence_@, which needs+-- only 'Applicative'. ----- >>> import Data.Maybe (Maybe(..))--- >>> sequence_ [Just 1, Just 2, Just 3]+-- ==== __Examples__+--+-- >>> sequence_ [Just 1, Just (2 :: Int)] -- Just ()--- >>> sequence_ [Just 1, Nothing, Just 3]+--+-- >>> sequence_ [Just 1, Nothing :: Maybe Int] -- Nothing-sequence_ ::-  (Foldable t, Applicative f) =>-  t (f a) ->-  f ()+--+-- >>> check $ withTests 100 $ property $ do xss <- forAll (Gen.list (Range.linear 0 5) genInts); runWriter (sequence_ (fmap tell xss)) === runWriter (sequenceA_ (fmap tell xss))+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+sequence_ :: (Foldable t, Applicative f) => t (f a) -> f () sequence_ =   sequenceA_+{-# INLINE sequence_ #-}
+ src/Papa/Base/Data/Foldable1.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The largest and smallest elements of a non-empty structure.+--+-- These are "Data.Foldable1"'s: total, because a 'Data.Foldable1.Foldable1'+-- is never empty, so they need no 'Data.Maybe.Maybe'. "Data.Foldable"'s+-- @maximum@, @minimum@, @maximumBy@ and @minimumBy@, which throw for an empty+-- structure, are not exported. For a structure that may be empty (a list),+-- use 'Control.Lens.maximumOf' 'Control.Lens.folded', or make it a+-- 'Data.List.NonEmpty.NonEmpty' first with 'Data.List.NonEmpty.nonEmpty'.+--+-- @since 0.7.0+module Papa.Base.Data.Foldable1 (+  module P,+) where++import Data.Foldable1 as P (+  Foldable1 (toNonEmpty),+  maximum,+  maximumBy,+  minimum,+  minimumBy,+ )
+ src/Papa/Base/Data/Fractional.hs view
@@ -0,0 +1,92 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Total division.+--+-- "Prelude"'s @(/)@, @recip@ and @(^^)@ throw @Ratio has zero denominator@ at+-- 'Data.Ratio.Rational' (and any 'Data.Ratio.Ratio') when they divide by+-- zero. They are in "Papa.Unsafe.Numeric". The functions here take a 'NonZero'+-- divisor, so they cannot, and return the result itself; build the divisor+-- once with @preview nonZero@.+--+-- @since 0.6.0+module Papa.Base.Data.Fractional (+  divideNonZero,+  recipNonZero,+  powNonZero,+) where++import Papa.Base.Data.Divisor (DivisorLike (divisor))+import Papa.Base.Data.NonZero (NonZero)+import Papa.Lens.Optic (the)+import Prelude (Fractional, Integral)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genRational = Gen.realFrac_ (Range.linearFracFrom 0 (-100) 100) :: Gen Rational+-- >>> let genNonZero = Gen.just (preview nonZero <$> genRational)++-- | Division by a 'NonZero'. "Prelude"'s @(/)@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (divideNonZero 1) (preview nonZero (4 :: Rational))+-- Just (1 % 4)+--+-- >>> fmap (divideNonZero 1) (preview nonZero (0 :: Double))+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genRational; y <- forAll genNonZero; divideNonZero x y * the divisor y === x+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+divideNonZero :: (Fractional a) => a -> NonZero a -> a+divideNonZero x y =+  x P./ the divisor y+{-# INLINE divideNonZero #-}++-- | The reciprocal of a 'NonZero'. "Prelude"'s @recip@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap recipNonZero (preview nonZero (4 :: Rational))+-- Just (1 % 4)+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genNonZero; recipNonZero x === divideNonZero 1 x+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+recipNonZero :: (Fractional a) => NonZero a -> a+recipNonZero x =+  P.recip (the divisor x)+{-# INLINE recipNonZero #-}++-- | Exponentiation of a 'NonZero' by an integral power, which may be+-- negative. For a base that may be zero, use 'Papa.Base.Data.Integral.pow',+-- whose power is a 'Data.Word.Word'. "Prelude"'s @(^^)@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (`powNonZero` (-2 :: Int)) (preview nonZero (2 :: Rational))+-- Just (1 % 4)+--+-- >>> fmap (`powNonZero` (0 :: Int)) (preview nonZero (2 :: Rational))+-- Just (1 % 1)+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genNonZero; e <- forAll (Gen.int (Range.linear 0 5)); powNonZero x (negate e) * powNonZero x e === 1+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+powNonZero :: (Fractional a, Integral b) => NonZero a -> b -> a+powNonZero x n =+  the divisor x P.^^ n+{-# INLINE powNonZero #-}
src/Papa/Base/Data/Function.hs view
@@ -1,33 +1,49 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Functions, with 'flip' generalised to any 'Functor', and '(&&&)' of+-- "Control.Arrow" (both functions applied to the same argument). module Papa.Base.Data.Function (   module P,+  (&&&),   flip, ) where +import Control.Arrow ((&&&)) import Data.Function as P (   fix,   on,   ($),   (&),  )--import Data.Functor (Functor (fmap))+import Data.Functor (Functor, (<&>)) -{-# INLINE flip #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100) --- | Apply a functorial function to a value.+-- | Apply every function in a 'Functor' to the same argument. At the+-- function 'Functor' (@f = (->) c@) this is "Prelude"'s @flip@. ----- >>> import Data.Maybe (Maybe(..))--- >>> flip (Just (\x -> x)) 5--- Just 5--- >>> flip [(\x -> x), (\x -> x)] 3--- [3,3]-flip ::-  (Functor f) =>-  f (a -> b) ->-  a ->-  f b+-- ==== __Examples__+--+-- >>> flip (-) 1 (10 :: Int)+-- 9+--+-- >>> flip [(+ 1), (* 2)] (10 :: Int)+-- [11,20]+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn (fn genInt)); a <- forAll genInt; b <- forAll genInt; flip (\x y -> apply (apply f x) y) a b === apply (apply f b) a+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+flip :: (Functor f) => f (a -> b) -> a -> f b flip f a =-  fmap (\k -> k a) f+  f <&> (\k -> k a)+{-# INLINE flip #-}
src/Papa/Base/Data/Functor.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wall #-} +-- | Functors, with 'map' generalised to any 'Functor'. module Papa.Base.Data.Functor (   module P,   map,@@ -12,26 +12,39 @@   void,   ($>),   (<$>),-#if MIN_VERSION_base(4,11,0)   (<&>),-#endif  ) -{-# INLINE map #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInts = Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-100) 100))+-- >>> let genF = fn (Gen.int (Range.linear (-100) 100)) --- | Map a function over a functor.+-- | 'fmap', under the name of "Prelude"'s @map@. ----- >>> map (\x -> x) [1,2,3]--- [1,2,3]--- >>> import Data.Maybe (Maybe(..))--- >>> map (\x -> x) (Just 5)--- Just 5--- >>> map (\x -> x) Nothing--- Nothing-map ::-  (Functor f) =>-  (a -> b) ->-  f a ->-  f b+-- ==== __Examples__+--+-- >>> map (+ 1) [1, 2, 3 :: Int]+-- [2,3,4]+--+-- >>> map (+ 1) (Just (1 :: Int))+-- Just 2+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; map id xs === xs+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; f <- forAll genF; g <- forAll genF; map (apply f . apply g) xs === map (apply f) (map (apply g) xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+map :: (Functor f) => (a -> b) -> f a -> f b map =   fmap+{-# INLINE map #-}
+ src/Papa/Base/Data/Functor/Compose.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The composition of two functors.+module Papa.Base.Data.Functor.Compose (+  module P,+) where++import Data.Functor.Compose as P (+  Compose (Compose, getCompose),+ )
+ src/Papa/Base/Data/Functor/Identity.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The identity functor.+module Papa.Base.Data.Functor.Identity (+  module P,+) where++import Data.Functor.Identity as P (+  Identity (Identity, runIdentity),+ )
+ src/Papa/Base/Data/IORef.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Mutable references in 'Prelude.IO'.+--+-- Only the strict modifiers are exported: "Data.IORef"'s @modifyIORef@ and+-- @atomicModifyIORef@ store the unevaluated result, and a reference modified+-- many times without being read holds a chain of thunks (a space leak).+-- 'modifyIORef'' and 'atomicModifyIORef'' evaluate it.+module Papa.Base.Data.IORef (+  module P,+) where++import Data.IORef as P (+  IORef,+  atomicModifyIORef',+  atomicWriteIORef,+  modifyIORef',+  newIORef,+  readIORef,+  writeIORef,+ )
+ src/Papa/Base/Data/IntCast.hs view
@@ -0,0 +1,157 @@+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Conversions between integral types that cannot lose information,+-- checked by the type checker.+--+-- 'intCast' converts only where every value of the source type is a value of+-- the target type; any other conversion is a compile error that names both+-- types. For a conversion that may not fit, use+-- 'Papa.Base.Data.Integral.toIntegralSized', which checks the value and+-- returns a 'Data.Maybe.Maybe'. "Prelude"'s @fromIntegral@, which wraps around+-- (@fromIntegral (300 :: Int) :: Word8@ is @44@) or throws (to 'Natural' from a+-- negative number), is in "Papa.Unsafe.Numeric".+--+-- The relation holds on every platform that GHC supports: 'Int' and 'Word'+-- are at least 32 and at most 64 bits wide, so @'Int32' → 'Int' → 'Int64'@+-- and @'Word32' → 'Word' → 'Word64'@ are lossless, but @'Int64' → 'Int'@ (lossless+-- only where 'Int' has 64 bits) is not, and goes through+-- 'Papa.Base.Data.Integral.toIntegralSized'.+--+-- After the @int-cast@ package (Herbert Valerio Riedel, BSD-3-Clause), whose+-- relation is computed per platform with CPP.+--+-- @since 0.7.0+module Papa.Base.Data.IntCast (+  intCast,+  IntCast,+  IsIntSubType,+) where++import Data.Bool (Bool (False, True))+import Data.Int (Int, Int16, Int32, Int64, Int8)+import Data.Kind (Constraint)+import Data.Word (Word, Word16, Word32, Word64, Word8)+import GHC.TypeLits (ErrorMessage (ShowType, Text, (:$$:), (:<>:)), TypeError)+import Numeric.Natural (Natural)+import Prelude (Integer, Integral, Num)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Unsafe.Numeric as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Whether every value of the integral type @a@ is a value of the integral+-- type @b@, on every platform: 'True' for the pairs below, and for any type+-- to itself; 'False' for every other pair.+--+-- @since 0.7.0+type family IsIntSubType a b :: Bool where+  IsIntSubType a a = 'True+  -- Signed: Int8 < Int16 < Int32 < Int < Int64 < Integer+  IsIntSubType Int8 Int16 = 'True+  IsIntSubType Int8 Int32 = 'True+  IsIntSubType Int8 Int = 'True+  IsIntSubType Int8 Int64 = 'True+  IsIntSubType Int8 Integer = 'True+  IsIntSubType Int16 Int32 = 'True+  IsIntSubType Int16 Int = 'True+  IsIntSubType Int16 Int64 = 'True+  IsIntSubType Int16 Integer = 'True+  IsIntSubType Int32 Int = 'True+  IsIntSubType Int32 Int64 = 'True+  IsIntSubType Int32 Integer = 'True+  IsIntSubType Int Int64 = 'True+  IsIntSubType Int Integer = 'True+  IsIntSubType Int64 Integer = 'True+  -- Unsigned: Word8 < Word16 < Word32 < Word < Word64 < Natural < Integer+  IsIntSubType Word8 Word16 = 'True+  IsIntSubType Word8 Word32 = 'True+  IsIntSubType Word8 Word = 'True+  IsIntSubType Word8 Word64 = 'True+  IsIntSubType Word8 Natural = 'True+  IsIntSubType Word8 Integer = 'True+  IsIntSubType Word16 Word32 = 'True+  IsIntSubType Word16 Word = 'True+  IsIntSubType Word16 Word64 = 'True+  IsIntSubType Word16 Natural = 'True+  IsIntSubType Word16 Integer = 'True+  IsIntSubType Word32 Word = 'True+  IsIntSubType Word32 Word64 = 'True+  IsIntSubType Word32 Natural = 'True+  IsIntSubType Word32 Integer = 'True+  IsIntSubType Word Word64 = 'True+  IsIntSubType Word Natural = 'True+  IsIntSubType Word Integer = 'True+  IsIntSubType Word64 Natural = 'True+  IsIntSubType Word64 Integer = 'True+  IsIntSubType Natural Integer = 'True+  -- Unsigned into a wider signed type+  IsIntSubType Word8 Int16 = 'True+  IsIntSubType Word8 Int32 = 'True+  IsIntSubType Word8 Int = 'True+  IsIntSubType Word8 Int64 = 'True+  IsIntSubType Word16 Int32 = 'True+  IsIntSubType Word16 Int = 'True+  IsIntSubType Word16 Int64 = 'True+  IsIntSubType Word32 Int64 = 'True+  IsIntSubType a b = 'False++-- | The constraint of 'intCast': satisfied where 'IsIntSubType' is 'True, and+-- a compile error naming both types where it is 'False.+type family IntCastCheck a b (ok :: Bool) :: Constraint where+  IntCastCheck a b 'True = ()+  IntCastCheck a b 'False =+    TypeError+      ( 'Text "intCast: not every value of type "+          ':<>: 'ShowType a+          ':<>: 'Text " fits in type "+          ':<>: 'ShowType b+          ':$$: 'Text "Use toIntegralSized, which checks the value and returns a Maybe."+      )++-- | Every value of @a@ is a value of @b@.+--+-- @since 0.7.0+type IntCast a b = IntCastCheck a b (IsIntSubType a b)++-- | Convert an integral value to a type that holds every value of its type.+-- The value is unchanged: @'P.toInteger' . 'intCast' == 'P.toInteger'@.+--+-- ==== __Examples__+--+-- >>> intCast (200 :: Word8) :: Int+-- 200+--+-- >>> intCast (-5 :: Int32) :: Integer+-- -5+--+-- A conversion that may lose information does not compile:+--+-- >>> intCast (300 :: Int) :: Word8+-- ...+-- ...not every value of type Int fits in type Word8...+-- ...+--+-- >>> intCast (-1 :: Int) :: Natural+-- ...+-- ...not every value of type Int fits in type Natural...+-- ...+--+-- >>> check $ withTests 200 $ property $ do x <- forAll (Gen.int32 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+intCast :: (Integral a, Num b, IntCast a b) => a -> b+intCast =+  P.fromIntegral+{-# INLINE intCast #-}
+ src/Papa/Base/Data/Integral.hs view
@@ -0,0 +1,251 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Total integral division and exponentiation.+--+-- "Prelude"'s @div@, @mod@, @divMod@, @quot@, @rem@ and @quotRem@ throw for a+-- divisor of zero, and for @'Prelude.minBound' \`div\` (-1)@ on a bounded+-- type; @(^)@ throws for a negative exponent. They are in "Papa.Unsafe.Numeric".+-- The functions here are total, under names of their own:+--+-- * the division functions take a 'NonZero' divisor, so they cannot divide by+--   zero, and return the result itself; build the divisor once with+--   @preview nonZero@;+-- * 'pow' takes a 'Word' exponent, so it cannot be negative.+--+-- A divisor of @-1@ is handled without dividing: the quotient is+-- @'Prelude.negate' n@ and the remainder is @0@. On a signed bounded type,+-- @'Prelude.negate' 'Prelude.minBound'@ is 'Prelude.minBound' (two's+-- complement wrap-around), which is what every other arithmetic operation of+-- that type does on overflow. The divisor is @-1@ when it is negative and one+-- more than it is zero, which is never true at an unsigned type (whose+-- @'Prelude.negate' 1@ is 'Prelude.maxBound') or at 'Numeric.Natural.Natural' (whose+-- @'Prelude.negate' 1@ throws), so these are divided as "Prelude" divides+-- them. The test needs no 'Prelude.Integer', so at 'Data.Int.Int' and+-- 'Data.Word.Word' each function is "Prelude"'s plus two comparisons.+--+-- 'toIntegralSized' (of "Data.Bits") is the total @fromIntegral@ between+-- integral types: 'Data.Maybe.Nothing' where the value does not fit in the target type,+-- where 'Prelude.fromIntegral' wraps around (@'Prelude.fromIntegral' (256 ::+-- Int) :: Word8@ is @0@) or throws (to @Natural@ from a negative number).+--+-- @since 0.6.0+module Papa.Base.Data.Integral (+  divNonZero,+  modNonZero,+  divModNonZero,+  quotNonZero,+  remNonZero,+  quotRemNonZero,+  pow,+  Bits,+  toIntegralSized,+) where++import Data.Bits (Bits, toIntegralSized)+import Data.Bool (bool, (&&))+import Data.Eq (Eq ((==)))+import Data.Int (Int)+import Data.Word (Word)+import Papa.Base.Data.Divisor (DivisorLike (divisor))+import Papa.Base.Data.NonZero (NonZero)+import Papa.Lens.Optic (the)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Unsafe.Numeric as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linearFrom 0 (-1000) 1000)+-- >>> let genNonZero = Gen.just (preview nonZero <$> Gen.int (Range.linearFrom 0 (-1000) 1000))+-- >>> let genWord8 = Gen.word8 Range.linearBounded+-- >>> let genNonZeroWord8 = Gen.just (preview nonZero <$> Gen.word8 Range.linearBounded)+-- >>> let genNatural = Gen.integral (Range.linear 0 1000) :: Gen U.Natural+-- >>> let genNonZeroNatural = Gen.just (preview nonZero <$> (Gen.integral (Range.linear 0 1000) :: Gen U.Natural))++-- | Whether a divisor is @-1@: negative, and one more than it is zero. It is+-- never @-1@ at an unsigned type or at 'Numeric.Natural.Natural', where nothing is negative,+-- and @d + 1@ is not computed there.+minusOne :: (P.Integral a) => a -> P.Bool+minusOne d =+  d P.< 0 && d P.+ 1 == 0+{-# INLINE minusOne #-}++-- | Integer division by a 'NonZero', truncated toward negative infinity.+-- "Prelude"'s @div@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (divNonZero 7) (preview nonZero (2 :: Int))+-- Just 3+--+-- >>> fmap (divNonZero (-7)) (preview nonZero (2 :: Int))+-- Just (-4)+--+-- >>> fmap (divNonZero minBound) (preview nonZero (-1 :: Int)) == Just minBound+-- True+--+-- >>> fmap (divNonZero 7) (preview nonZero (2 :: U.Natural))+-- Just 3+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInt; d <- forAll genNonZero; divNonZero n d * the divisor d + modNonZero n d === n+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+divNonZero :: (P.Integral a) => a -> NonZero a -> a+divNonZero n nz =+  let d = the divisor nz+   in bool (P.div n d) (P.negate n) (minusOne d)+{-# INLINE divNonZero #-}++-- | Integer modulus by a 'NonZero', with the sign of the divisor.+-- "Prelude"'s @mod@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (modNonZero 7) (preview nonZero (2 :: Int))+-- Just 1+--+-- >>> fmap (modNonZero (-7)) (preview nonZero (2 :: Int))+-- Just 1+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInt; d <- forAll genNonZero; modNonZero n d === P.snd (divModNonZero n d)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+modNonZero :: (P.Integral a) => a -> NonZero a -> a+modNonZero n nz =+  let d = the divisor nz+   in bool (P.mod n d) 0 (minusOne d)+{-# INLINE modNonZero #-}++-- | Simultaneous 'divNonZero' and 'modNonZero'. "Prelude"'s @divMod@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (divModNonZero 7) (preview nonZero (2 :: Int))+-- Just (3,1)+--+-- >>> fmap (divModNonZero 7) (preview nonZero (255 :: Word8))+-- Just (0,7)+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInt; d <- forAll genNonZero; (\(q, m) -> q * the divisor d + m) (divModNonZero n d) === n+-- ...passed 200 tests.+-- True+--+-- At an unsigned type and at 'Numeric.Natural.Natural', it is "Prelude"'s:+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genWord8; d <- forAll genNonZeroWord8; divModNonZero n d === U.divMod n (the divisor d)+-- ...passed 200 tests.+-- True+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genNatural; d <- forAll genNonZeroNatural; divModNonZero n d === U.divMod n (the divisor d)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+divModNonZero :: (P.Integral a) => a -> NonZero a -> (a, a)+divModNonZero n nz =+  let d = the divisor nz+   in bool (P.divMod n d) (P.negate n, 0) (minusOne d)+{-# INLINE divModNonZero #-}++-- | Integer division by a 'NonZero', truncated toward zero. "Prelude"'s+-- @quot@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (quotNonZero (-7)) (preview nonZero (2 :: Int))+-- Just (-3)+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInt; d <- forAll genNonZero; quotNonZero n d === P.fst (quotRemNonZero n d)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+quotNonZero :: (P.Integral a) => a -> NonZero a -> a+quotNonZero n nz =+  let d = the divisor nz+   in bool (P.quot n d) (P.negate n) (minusOne d)+{-# INLINE quotNonZero #-}++-- | Integer remainder by a 'NonZero', with the sign of the dividend.+-- "Prelude"'s @rem@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (remNonZero (-7)) (preview nonZero (2 :: Int))+-- Just (-1)+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInt; d <- forAll genNonZero; remNonZero n d === P.snd (quotRemNonZero n d)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+remNonZero :: (P.Integral a) => a -> NonZero a -> a+remNonZero n nz =+  let d = the divisor nz+   in bool (P.rem n d) 0 (minusOne d)+{-# INLINE remNonZero #-}++-- | Simultaneous 'quotNonZero' and 'remNonZero'. "Prelude"'s @quotRem@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> fmap (quotRemNonZero (-7)) (preview nonZero (2 :: Int))+-- Just (-3,-1)+--+-- >>> fmap (quotRemNonZero minBound) (preview nonZero (-1 :: Int)) == Just (minBound, 0)+-- True+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInt; d <- forAll genNonZero; (\(q, r) -> q * the divisor d + r) (quotRemNonZero n d) === n+-- ...passed 200 tests.+-- True+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genWord8; d <- forAll genNonZeroWord8; quotRemNonZero n d === U.quotRem n (the divisor d)+-- ...passed 200 tests.+-- True+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genNatural; d <- forAll genNonZeroNatural; quotRemNonZero n d === U.quotRem n (the divisor d)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+quotRemNonZero :: (P.Integral a) => a -> NonZero a -> (a, a)+quotRemNonZero n nz =+  let d = the divisor nz+   in bool (P.quotRem n d) (P.negate n, 0) (minusOne d)+{-# INLINE quotRemNonZero #-}++-- | Exponentiation by a 'Word' power, which cannot be negative.+-- "Prelude"'s @(^)@, which throws for a negative exponent, is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> pow (2 :: Int) 10+-- 1024+--+-- >>> pow (2 :: Double) 0+-- 1.0+--+-- >>> check $ withTests 100 $ property $ do x <- forAll genInt; e <- forAll (Gen.integral (Range.linear 0 6)); pow x (e + 1) === pow x e * x+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+pow :: (P.Num a) => a -> Word -> a+pow =+  (P.^)+{-# INLINEABLE pow #-}+{-# SPECIALIZE pow :: Int -> Word -> Int #-}+{-# SPECIALIZE pow :: Word -> Word -> Word #-}+{-# SPECIALIZE pow :: P.Integer -> Word -> P.Integer #-}+{-# SPECIALIZE pow :: P.Double -> Word -> P.Double #-}
+ src/Papa/Base/Data/Left.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The name @left@ (classy optics, rule 4): the value of the @Left@ side of a+-- sum.+--+-- Its target is a type variable, so the name has no identity instance+-- (rule 4). Its instance for 'Either', a library type, is in this module+-- (rule 15).+--+-- @since 0.7.0+module Papa.Base.Data.Left (+  LeftLike (..),+) where++import Control.Lens (Choice, Optic, _Left)+import Data.Either (Either)+import Data.Type.Equality (type (~))+import Prelude (Applicative)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genEither = Gen.either (Gen.int (Range.linear 0 9)) Gen.alpha++-- | A field or a constructor named @left@.+--+-- ==== __Examples__+--+-- >>> preview left (Left 'x' :: Either Char Int)+-- Just 'x'+--+-- >>> preview left (Right 1 :: Either Char Int)+-- Nothing+--+-- >>> review left 'x' :: Either Char Int+-- Left 'x'+--+-- Prism laws:+--+-- >>> check $ withTests 100 $ property $ do x <- forAll (Gen.int (Range.linear 0 9)); preview left (review left x :: Either Int Char) === Just x+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do e <- forAll genEither; for_ (preview left e) (\x -> review left x === e)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+class LeftLike p f x x' a a' | x -> a where+  left ::+    Optic p f x x' a a'++-- Prism+instance (Choice p, Applicative f, x' ~ Either a' b) => LeftLike p f (Either a b) x' a a' where+  left =+    _Left+  {-# INLINE left #-}
src/Papa/Base/Data/List.hs view
@@ -1,19 +1,35 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wall #-} +-- | Lists, with total versions of the partial functions of "Data.List".+--+-- @uncons@ and @unsnoc@ are not re-exported from "Data.List": the+-- generalised ones of "Control.Lens" are exported by "Papa". module Papa.Base.Data.List (   module P,++  -- * Removing duplicates+  -- $nub+  nub,+  nubBy,+  cycle,   lookup,+  (!?),   (++), ) where +import Control.Category ((.))+import Control.Lens (Ixed (ix), filtered, folded, has, only, preview, _1, _2)+import Data.Eq (Eq)+import Data.Foldable (Foldable)+import Data.Functor (fmap)+import Data.Int (Int)+import Data.List (nub, nubBy) import Data.List as P (   all,   and,   any,   break,-  cycle,   delete,   deleteBy,   deleteFirstsBy,@@ -44,8 +60,6 @@   mapAccumL,   mapAccumR,   notElem,-  nub,-  nubBy,   null,   or,   partition,@@ -53,6 +67,7 @@   product,   replicate,   reverse,+  singleton,   sort,   sortBy,   sortOn,@@ -68,55 +83,123 @@   unionBy,   unlines,   unwords,+  unzip,   words,   (\\),-#if MIN_VERSION_base(4,19,0)-  -- Added in base 4.19 (GHC 9.8)-  singleton,-  uncons,-  unsnoc,-  (!?),-#endif  )--import Data.Eq (Eq ((==)))-import Data.Foldable (Foldable)-import Data.Maybe (Maybe (Just, Nothing))+import qualified Data.List.NonEmpty as NE+import Data.Maybe (Maybe) import Data.Semigroup (Semigroup ((<>))) -{-# INLINE lookup #-}+-- $nub+-- 'nub' and 'nubBy' take /O(n²)/ time: each element is compared with every+-- element kept before it. Where the elements are 'Data.Ord.Ord',+-- 'Papa.Containers.Data.Containers.ListUtils.nubOrd' and+-- 'Papa.Containers.Data.Containers.ListUtils.nubOrdOn' do the same in+-- /O(n log n)/, and at 'Int', 'Papa.Containers.Data.Containers.ListUtils.nubInt'+-- and 'Papa.Containers.Data.Containers.ListUtils.nubIntOn' faster still. --- | Look up a key in an association list.+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInts = Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-100) 100))++-- | Total @cycle@: the infinite repetition of a list. 'Data.Maybe.Nothing' for the+-- empty list, where "Data.List"'s @cycle@ throws. ----- >>> import Data.Maybe (Maybe(..))--- >>> lookup 2 [(1,'a'), (2,'b'), (3,'c')]--- Just 'b'--- >>> lookup 4 [(1,'a'), (2,'b'), (3,'c')]+-- ==== __Examples__+--+-- >>> fmap (take 7) (cycle [1, 2, 3 :: Int])+-- Just [1,2,3,1,2,3,1]+--+-- >>> cycle ([] :: [Int]) -- Nothing-lookup ::-  (Eq a, Foldable f) =>-  a ->-  f (a, b) ->-  Maybe b+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; fmap (take (length xs)) (cycle xs) === (xs <$ preview _head xs)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+cycle :: [a] -> Maybe [a]+cycle =+  fmap (NE.toList . NE.cycle) . NE.nonEmpty+{-# INLINE cycle #-}++-- | The value of the first pair whose key is equal to the given key, in any+-- 'Foldable' of pairs.+--+-- ==== __Examples__+--+-- >>> lookup 'b' [('a', 1), ('b', 2 :: Int)]+-- Just 2+--+-- >>> lookup 'z' [('a', 1 :: Int)]+-- Nothing+--+-- >>> lookup 'a' (Just ('a', "x"))+-- Just "x"+--+-- >>> check $ withTests 100 $ property $ do k <- forAll (Gen.int (Range.linear 0 5)); kvs <- forAll (Gen.list (Range.linear 0 10) ((,) <$> Gen.int (Range.linear 0 5) <*> Gen.alpha)); lookup k kvs === fmap snd (find ((== k) . fst) kvs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+lookup :: (Eq a, Foldable f) => a -> f (a, b) -> Maybe b lookup a =-  foldr (\(x, y) b -> if x == a then Just y else b) Nothing+  preview (folded . filtered (has (_1 . only a)) . _2)+{-# INLINE lookup #-} -{-# SPECIALIZE (++) ::-  [a] ->-  [a] ->-  [a]-  #-}+-- | Total list indexing. 'Data.Maybe.Nothing' for an index out of range.+--+-- ==== __Examples__+--+-- >>> [10, 20, 30 :: Int] !? 1+-- Just 20+--+-- >>> [10, 20, 30 :: Int] !? 3+-- Nothing+--+-- >>> [10, 20, 30 :: Int] !? (-1)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; i <- forAll (Gen.int (Range.linear (-5) 25)); (xs !? i) === preview (ix i) xs+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+(!?) :: [a] -> Int -> Maybe a+xs !? n =+  preview (ix n) xs+{-# INLINE (!?) #-} --- | Append two semigroups.+infixl 9 !?++-- | Append, generalised from lists to any 'Semigroup'. ----- >>> [1,2] ++ [3,4]--- [1,2,3,4]--- >>> "hello" ++ " world"--- "hello world"-(++) ::-  (Semigroup a) =>-  a ->-  a ->-  a+-- ==== __Examples__+--+-- >>> "abc" ++ "def"+-- "abcdef"+--+-- >>> Just [1 :: Int] ++ Nothing ++ Just [2]+-- Just [1,2]+--+-- Right-associative at precedence 5, as in "Prelude":+--+-- >>> 1 `elem` [2] ++ [1 :: Int]+-- True+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; ys <- forAll genInts; zs <- forAll genInts; (xs ++ ys) ++ zs === xs ++ (ys ++ zs)+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+(++) :: (Semigroup a) => a -> a -> a (++) =   (<>)+{-# INLINE (++) #-}++infixr 5 ++
src/Papa/Base/Data/List/NonEmpty.hs view
@@ -2,7 +2,18 @@ {-# OPTIONS_GHC -Wall #-}  {- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines Papa's total head, tail, last and init (lenses+-- into a NonEmpty), whose names HLint restricts whatever module they come+-- from. +-- | Non-empty lists, with lenses for the parts that "Data.List" can only+-- give partially.+--+-- 'head', 'tail', 'last' and 'init' are lenses, not functions: read them with+-- 'Papa.Lens.Optic.the', and write them with 'Control.Lens.set' and+-- 'Control.Lens.over'. On a list, use 'Control.Lens._head',+-- 'Control.Lens._tail', 'Control.Lens._last' and 'Control.Lens._init',+-- which are traversals of at most one target. module Papa.Base.Data.List.NonEmpty (   module P,   head,@@ -12,7 +23,7 @@ ) where  import Control.Lens (Lens')-import Data.Functor (Functor (fmap))+import Data.Functor (fmap) import Data.List.NonEmpty as P (   NonEmpty ((:|)),   group,@@ -38,70 +49,155 @@   xor,  ) import qualified Data.List.NonEmpty as NE-import Data.Semigroup ((<>))+import Papa.Lens.Optic (the) --- | Lens to the head (first element) of a 'NonEmpty' list.+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)+-- >>> let genInts = Gen.list (Range.linear 0 10) genInt+-- >>> let genNonEmpty = Gen.nonEmpty (Range.linear 1 10) genInt++-- | The first element of a 'NonEmpty'. ----- >>> import Control.Lens--- >>> let ne = 1 :| [2,3,4]--- >>> ne ^. head+-- ==== __Examples__+--+-- >>> the head (1 :| [2, 3 :: Int]) -- 1--- >>> ne & head .~ 99--- 99 :| [2,3,4]--- >>> ne & head %~ (\x -> x)--- 1 :| [2,3,4]-{-# INLINE head #-}+--+-- >>> set head 9 (1 :| [2, 3 :: Int])+-- 9 :| [2,3]+--+-- Lens laws:+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; set head (the head s) s === s+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInt; the head (set head a s) === a+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInt; b <- forAll genInt; set head b (set head a s) === set head b s+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0 head :: Lens' (NonEmpty a) a-head f (h :| t) = fmap (:| t) (f h)+head f (h :| t) =+  fmap (:| t) (f h)+{-# INLINE head #-} --- | Lens to the tail (all elements except the first) of a 'NonEmpty' list.+-- | Every element of a 'NonEmpty' after the first. ----- >>> import Control.Lens--- >>> let ne = 1 :| [2,3,4]--- >>> ne ^. tail--- [2,3,4]--- >>> ne & tail .~ [99]--- 1 :| [99]--- >>> ne & tail .~ []+-- ==== __Examples__+--+-- >>> the tail (1 :| [2, 3 :: Int])+-- [2,3]+--+-- >>> set tail [] (1 :| [2, 3 :: Int]) -- 1 :| []-{-# INLINE tail #-}+--+-- Lens laws:+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; set tail (the tail s) s === s+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInts; the tail (set tail a s) === a+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInts; b <- forAll genInts; set tail b (set tail a s) === set tail b s+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0 tail :: Lens' (NonEmpty a) [a]-tail f (h :| t) = fmap (h :|) (f t)+tail f (h :| t) =+  fmap (h :|) (f t)+{-# INLINE tail #-} --- | Lens to the last element of a 'NonEmpty' list.+-- | The last element of a 'NonEmpty'. ----- >>> import Control.Lens--- >>> let ne = 1 :| [2,3,4]--- >>> ne ^. last--- 4--- >>> ne & last .~ 99--- 1 :| [2,3,99]--- >>> (1 :| []) ^. last--- 1--- >>> (1 :| []) & last .~ 99--- 99 :| []-{-# INLINE last #-}+-- ==== __Examples__+--+-- >>> the last (1 :| [2, 3 :: Int])+-- 3+--+-- >>> set last 9 (1 :| [2, 3 :: Int])+-- 1 :| [2,9]+--+-- Lens laws:+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; set last (the last s) s === s+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInt; the last (set last a s) === a+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInt; b <- forAll genInt; set last b (set last a s) === set last b s+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0 last :: Lens' (NonEmpty a) a-last f (h :| []) = fmap (:| []) (f h)-last f (h :| (x : xs)) = fmap (\(y :| ys) -> h :| (y : ys)) (last f (x :| xs))+last f (h :| t) =+  case t of+    [] -> fmap (:| []) (f h)+    x : xs -> fmap (h NE.<|) (last f (x :| xs))+{-# INLINEABLE last #-} --- | Lens to the init (all elements except the last) of a 'NonEmpty' list.+-- | Every element of a 'NonEmpty' before the last. ----- >>> import Control.Lens--- >>> let ne = 1 :| [2,3,4]--- >>> ne ^. init--- [1,2,3]--- >>> ne & init .~ [99]--- 99 :| [4]--- >>> ne & init .~ []--- 4 :| []--- >>> (1 :| []) ^. init--- []--- >>> (1 :| []) & init .~ [10,20]--- 10 :| [20,1]-{-# INLINE init #-}+-- ==== __Examples__+--+-- >>> the init (1 :| [2, 3 :: Int])+-- [1,2]+--+-- >>> set init [] (1 :| [2, 3 :: Int])+-- 3 :| []+--+-- >>> set init [7, 8, 9] (1 :| [2, 3 :: Int])+-- 7 :| [8,9,3]+--+-- Lens laws:+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; set init (the init s) s === s+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInts; the init (set init a s) === a+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; a <- forAll genInts; b <- forAll genInts; set init b (set init a s) === set init b s+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0 init :: Lens' (NonEmpty a) [a]-init f ne = fmap rebuild (f (NE.init ne))+init f ne =+  fmap (\i -> NE.prependList i (the last ne :| [])) (f (initList ne))+{-# INLINE init #-}++-- | Every element of a 'NonEmpty' before the last, as a list.+--+-- >>> initList (1 :| [2, 3 :: Int])+-- [1,2]+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genNonEmpty; initList s === the init s+-- ...passed 100 tests.+-- True+initList :: NonEmpty a -> [a]+initList (h :| t) =+  go h t  where-  rebuild [] = NE.last ne :| []-  rebuild (x : xs) = x :| (xs <> [NE.last ne])+  go _ [] = []+  go x (y : ys) = x : go y ys+{-# INLINEABLE initList #-}
src/Papa/Base/Data/Maybe.hs view
@@ -1,13 +1,104 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Optional values. @fromJust@ is not exported: it is partial. module Papa.Base.Data.Maybe (   module P,+  whenJust,+  whenJustM, ) where +import Control.Monad (Monad (return, (>>=))) import Data.Maybe as P (   Maybe (Just, Nothing),+  catMaybes,   fromMaybe,+  isJust,+  isNothing,+  listToMaybe,+  mapMaybe,   maybe,+  maybeToList,  )++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (Fn, fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)++-- | Apply a step to a value where it applies, and keep the value where it+-- does not: @p a@ is 'Just' a result, which @f@ turns back into a value, or+-- 'Nothing', which keeps @a@.+--+-- ==== __Examples__+--+-- >>> whenJust (\n -> if even n then Just (show n) else Nothing) length (10 :: Int)+-- 2+--+-- >>> whenJust (\n -> if even n then Just (show n) else Nothing) length (7 :: Int)+-- 7+--+-- >>> whenJust (preview _Left) (Right . length) (Left "abc" :: Either String Int)+-- Right 3+--+-- With 'Control.Category.id', a rewrite step that keeps the value where it does not apply:+--+-- >>> whenJust (\s -> stripPrefix "un" s) id "undo"+-- "do"+--+-- Where the step never applies, 'whenJust' is the identity:+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genInt :: Gen (Fn Int Int)); a <- forAll genInt; whenJust (const Nothing) (apply f) a === a+-- ...passed 100 tests.+-- True+--+-- Where the step always applies, it is the composition:+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genInt); g <- forAll (fn genInt); a <- forAll genInt; whenJust (Just . apply g) (apply f) a === apply f (apply g a)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+whenJust :: (a -> Maybe b) -> (b -> a) -> a -> a+whenJust p f a =+  maybe a f (p a)+{-# INLINE whenJust #-}++-- | 'whenJust' in a 'Monad': run the step on a value, and where its result+-- is 'Just', run @f@ on it; where it is 'Nothing', return the value.+--+-- ==== __Examples__+--+-- >>> whenJustM (\n -> [Just n, Nothing]) (\n -> [n + 1, n + 2]) (10 :: Int)+-- [11,12,10]+--+-- >>> whenJustM (\_ -> Just Nothing) (\_ -> Nothing) 'a'+-- Just 'a'+--+-- At 'Data.Functor.Identity.Identity', 'whenJustM' is 'whenJust':+--+-- >>> check $ withTests 100 $ property $ do p <- forAll (fn (Gen.maybe genInt)); f <- forAll (fn genInt); a <- forAll genInt; runIdentity (whenJustM (Identity . apply p) (Identity . apply f) a) === whenJust (apply p) (apply f) a+-- ...passed 100 tests.+-- True+--+-- Where the step never applies, it returns the value:+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn (Gen.maybe genInt) :: Gen (Fn Int (Maybe Int))); a <- forAll genInt; whenJustM (\_ -> Just Nothing) (apply f) a === Just a+-- ...passed 100 tests.+-- True+--+-- Where the step always applies, it is Kleisli composition:+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn (Gen.maybe genInt)); g <- forAll (fn (Gen.maybe genInt)); a <- forAll genInt; whenJustM (fmap Just . apply g) (apply f) a === (apply g >=> apply f) a+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+whenJustM :: (Monad f) => (a -> f (Maybe b)) -> (b -> f a) -> a -> f a+whenJustM p f a =+  p a >>= maybe (return a) f+{-# INLINE whenJustM #-}
src/Papa/Base/Data/Monoid.hs view
@@ -1,28 +1,41 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Monoids, with 'mconcat' generalised to any 'Foldable'. module Papa.Base.Data.Monoid (   module P,   mconcat, ) where +import Data.Foldable (Foldable, fold) import Data.Monoid as P (   Monoid (mappend, mempty),  ) -import Data.Foldable (Foldable, fold)--{-# INLINE mconcat #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genStrings = Gen.list (Range.linear 0 10) (Gen.string (Range.linear 0 5) Gen.alpha) --- | Fold a list using the monoid.+-- | 'fold', under the name of "Data.Monoid"'s @mconcat@. ----- >>> mconcat [[1,2], [3,4], [5,6]]--- [1,2,3,4,5,6]--- >>> mconcat ["hello", " ", "world"]--- "hello world"-mconcat ::-  (Monoid a, Foldable f) =>-  f a ->-  a+-- ==== __Examples__+--+-- >>> mconcat ["a", "b", "c"]+-- "abc"+--+-- >>> mconcat (Just "a")+-- "a"+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genStrings; mconcat xs === foldr (<>) mempty xs+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+mconcat :: (Foldable f, Monoid a) => f a -> a mconcat =   fold+{-# INLINE mconcat #-}
+ src/Papa/Base/Data/NonZero.hs view
@@ -0,0 +1,360 @@+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | A number that is not zero: a divisor (classy optics, rule 14, a data+-- type with an invariant).+--+-- Division by a 'NonZero' needs no 'Data.Maybe.Maybe': the divisor is+-- checked once, where it is built, and then divides any number of times+-- ('Papa.Base.Data.Integral.div', 'Papa.Base.Data.Fractional./',+-- 'Papa.Base.Data.Ratio.%', ...).+--+-- * The constructor is not exported.+-- * Its own name, 'nonZero', is also its smart constructor: a prism from the+--   number, whose 'Control.Lens.preview' checks that it is not zero and+--   whose 'Control.Lens.review' gives the number back. The prism laws hold,+--   because the check never changes the number.+-- * The smart constructor has an instance for each numeric type of base+--   ('Int', 'Int8' .. 'Int64', 'Integer', 'Word', 'Word8' .. 'Word64',+--   'Natural', 'Float', 'Double', 'Ratio'), not one for every type: an+--   instance for a type variable would overlap the identity instance.+-- * Its field, 'divisor', is a getter, so no optic can make it zero.+-- * No instance that could build a zero is written: not 'Prelude.Num'+--   (@fromInteger 0@, @-@), 'Data.Semigroup.Semigroup' (a product of+--   fixed-width integers can overflow to 0), 'GHC.Generics.Generic' or+--   'Data.Data.Data'.+--+-- @since 0.7.0+module Papa.Base.Data.NonZero (+  -- * Type+  NonZero,+  validNonZero,+  previewNonZero,++  -- * Optics+  NonZeroLike (..),+  lawNamesNonZero,+  InheritNonZero,+  inheritNonZero,+) where++import Control.Category (id)+import Control.DeepSeq (NFData)+import Control.Lens (Choice, Optic, preview, prism')+import Data.Bool (Bool (False), bool)+import Data.Eq (Eq ((/=)))+import Data.Foldable (Foldable (foldMap, foldr, length, null))+import Data.Foldable1 (Foldable1 (foldMap1, toNonEmpty))+import Data.Functor (Functor)+import Data.Functor.Classes (Eq1 (liftEq), Ord1 (liftCompare), Show1 (liftShowsPrec), showsUnaryWith)+import Data.Functor.Const (Const)+import Data.Functor.Contravariant (Contravariant, phantom)+import Data.Int (Int, Int16, Int32, Int64, Int8)+import Data.List.NonEmpty (NonEmpty ((:|)))+import Data.Maybe (Maybe (Just, Nothing))+import Data.Monoid (First)+import Data.Ord (Ord)+import Data.Ratio (Ratio)+import Data.Type.Equality (type (~))+import Data.Word (Word, Word16, Word32, Word64, Word8)+import Numeric.Natural (Natural)+import Papa.Base.Data.Divisor (DivisorLike (divisor))+import Papa.Lens.Optic (the)+import Prelude (Applicative, Double, Float, Integer, Integral, Num, Show)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linearFrom 0 (-100) 100)+-- >>> let genNonZero = Gen.just (preview nonZero <$> genInt)++-- | A number that is not zero. Build one with @preview nonZero@.+--+-- ==== __Examples__+--+-- >>> preview nonZero (3 :: Int)+-- Just (NonZero 3)+--+-- >>> preview nonZero (0 :: Int)+-- Nothing+--+-- >>> preview nonZero (0.5 :: Double)+-- Just (NonZero 0.5)+--+-- @since 0.7.0+newtype NonZero a = NonZero a+  deriving stock (Eq, Ord, Show)+  deriving newtype (NFData)++-- | The two values are compared with the given equality.+--+-- >>> liftEq (==) <$> preview nonZero (1 :: Int) <*> preview nonZero (1 :: Int)+-- Just True+--+-- >>> check $ withTests 100 $ property $ do x <- forAll genNonZero; y <- forAll genNonZero; liftEq (==) x y === (x == y)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+instance Eq1 NonZero where+  liftEq f (NonZero a) (NonZero b) =+    f a b+  {-# INLINE liftEq #-}++-- | The two values are compared with the given comparison.+--+-- >>> check $ withTests 100 $ property $ do x <- forAll genNonZero; y <- forAll genNonZero; liftCompare compare x y === compare x y+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+instance Ord1 NonZero where+  liftCompare f (NonZero a) (NonZero b) =+    f a b+  {-# INLINE liftCompare #-}++-- | Shown as the derived 'Show' shows it.+--+-- >>> check $ withTests 100 $ property $ do x <- forAll genNonZero; d <- forAll (Gen.int (Range.linear 0 11)); liftShowsPrec showsPrec showList d x "" === showsPrec d x ""+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+instance Show1 NonZero where+  liftShowsPrec sp _ d (NonZero a) =+    showsUnaryWith sp "NonZero" d a+  {-# INLINE liftShowsPrec #-}++-- | Right fold of a 'NonZero': the worker of 'foldr' (fusion-rules+-- pattern).+--+-- A 'NonZero' holds exactly one value and has no 'Functor' (rule 14: @fmap@+-- could make it zero), and no @build@, so none of the fusion rules of the+-- fusion-rules skill (map/fold, map/map, build/fold) has a left-hand side+-- here; the workers are not recursive, so they are @INLINE@.+foldrNonZero :: (a -> b -> b) -> b -> NonZero a -> b+foldrNonZero k z (NonZero a) =+  k a z+{-# INLINE foldrNonZero #-}++-- | The worker of 'foldMap' and 'foldMap1'.+foldMapNonZero :: (a -> m) -> NonZero a -> m+foldMapNonZero f (NonZero a) =+  f a+{-# INLINE foldMapNonZero #-}++-- | The one value.+--+-- >>> fmap toList (preview nonZero (3 :: Int))+-- Just [3]+--+-- >>> check $ withTests 100 $ property $ do x <- forAll genNonZero; (toList x, length x, null x, sum x) === ([the divisor x], 1, False, the divisor x)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+instance Foldable NonZero where+  foldr =+    foldrNonZero+  {-# INLINE foldr #-}+  foldMap =+    foldMapNonZero+  {-# INLINE foldMap #-}+  length _ =+    1+  {-# INLINE length #-}+  null _ =+    False+  {-# INLINE null #-}++-- | Exactly one value, so a 'NonZero' is never empty.+--+-- >>> check $ withTests 100 $ property $ do x <- forAll genNonZero; (toNonEmpty x, foldMap1 (: []) x) === (the divisor x :| [], [the divisor x])+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+instance Foldable1 NonZero where+  foldMap1 =+    foldMapNonZero+  {-# INLINE foldMap1 #-}+  toNonEmpty (NonZero a) =+    a :| []+  {-# INLINE toNonEmpty #-}++-- | The invariant: the number is not zero.+--+-- >>> validNonZero (0 :: Int)+-- False+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genInt; validNonZero n === (n /= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+validNonZero :: (Eq a, Num a) => a -> Bool+validNonZero n =+  n /= 0+{-# INLINE validNonZero #-}++-- | The 'preview' of the smart constructor: 'Just' a 'NonZero' where the+-- invariant holds. Each instance of 'nonZero' for a number is the prism+-- whose 'preview' this is.+--+-- Unlike @preview nonZero@, it takes the type of the 'NonZero' from where it+-- is used, so a literal needs no annotation: in @quotNonZero n \<$\>+-- previewNonZero 100@, @100@ has the type of @n@. ('nonZero''s class goes+-- from the number's type to the 'NonZero''s, so @preview nonZero 100@ needs+-- @(100 :: Int)@.) It works at any 'Num' with 'Eq', such as "Data.Fixed".+--+-- >>> previewNonZero (0 :: Int)+-- Nothing+--+-- >>> (\n -> quotNonZero n <$> previewNonZero 100) (1234 :: Integer)+-- Just 12+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genInt; previewNonZero n === preview nonZero n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+previewNonZero :: (Eq a, Num a) => a -> Maybe (NonZero a)+previewNonZero n =+  bool Nothing (Just (NonZero n)) (validNonZero n)+{-# INLINE previewNonZero #-}++-- | The class of 'NonZero' (rule 3).+--+-- @since 0.7.0+class NonZeroLike p f x x' a a' | x -> a where+  nonZero ::+    Optic p f x x' (NonZero a) (NonZero a')++-- Identity+instance (x' ~ NonZero a') => NonZeroLike p f (NonZero a) x' a a' where+  nonZero = id+  {-# INLINE nonZero #-}++-- Prism: the smart constructor, for each numeric type of base. preview+-- checks the invariant, and review gives back the number.+instance (Choice p, Applicative f, x' ~ Int, a' ~ Int) => NonZeroLike p f Int x' Int a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Int8, a' ~ Int8) => NonZeroLike p f Int8 x' Int8 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Int16, a' ~ Int16) => NonZeroLike p f Int16 x' Int16 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Int32, a' ~ Int32) => NonZeroLike p f Int32 x' Int32 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Int64, a' ~ Int64) => NonZeroLike p f Int64 x' Int64 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Integer, a' ~ Integer) => NonZeroLike p f Integer x' Integer a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Word, a' ~ Word) => NonZeroLike p f Word x' Word a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Word8, a' ~ Word8) => NonZeroLike p f Word8 x' Word8 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Word16, a' ~ Word16) => NonZeroLike p f Word16 x' Word16 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Word32, a' ~ Word32) => NonZeroLike p f Word32 x' Word32 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Word64, a' ~ Word64) => NonZeroLike p f Word64 x' Word64 a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Natural, a' ~ Natural) => NonZeroLike p f Natural x' Natural a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Float, a' ~ Float) => NonZeroLike p f Float x' Float a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, x' ~ Double, a' ~ Double) => NonZeroLike p f Double x' Double a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Prism+instance (Choice p, Applicative f, Integral b, x' ~ Ratio b, a' ~ Ratio b) => NonZeroLike p f (Ratio b) x' (Ratio b) a' where+  nonZero = prism' (the divisor) previewNonZero+  {-# INLINE nonZero #-}++-- Getter+instance (p ~ (->), Contravariant f, Functor f, x' ~ NonZero a, a' ~ a) => DivisorLike p f (NonZero a) x' a a' where+  divisor f (NonZero n) = phantom (f n)+  {-# INLINE divisor #-}++-- | Rebuild a value through the smart constructor (rule 7), so it can fail.+-- It holds at each numeric type that has a smart constructor.+--+-- Laws:+--+-- > lawNamesNonZero == Just+--+-- >>> check $ withTests 100 $ property $ do s <- forAll (Gen.just (preview nonZero <$> genInt)); lawNamesNonZero s === Just s+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+lawNamesNonZero :: (NonZeroLike (->) (Const (First (NonZero a))) a a a a) => NonZero a -> Maybe (NonZero a)+lawNamesNonZero s =+  preview nonZero (the divisor s)+{-# INLINE lawNamesNonZero #-}++-- | The classes that a data type holding 'NonZero' inherits (rule 6).+--+-- @since 0.7.0+type InheritNonZero s a =+  ( NonZeroLike (->) (Const ()) s s a a+  , DivisorLike (->) (Const ()) s s a a+  )++-- | Check, where it is applied, that @s@ inherits every name of 'NonZero'.+--+-- @since 0.7.0+inheritNonZero :: (InheritNonZero s a) => proxy s -> ()+inheritNonZero _ =+  ()+{-# INLINE inheritNonZero #-}
+ src/Papa/Base/Data/Proxy.hs view
@@ -0,0 +1,11 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Proxies for types.+module Papa.Base.Data.Proxy (+  module P,+) where++import Data.Proxy as P (+  Proxy (Proxy),+ )
src/Papa/Base/Data/Ratio.hs view
@@ -1,15 +1,54 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Rational numbers, with 'ratioNonZero', whose denominator is 'NonZero'.+--+-- Only 'Rational', a ratio of 'Prelude.Integer's, is exported: a ratio of a+-- bounded type such as 'Data.Int.Int' wraps around on overflow and so returns+-- wrong numbers. "Data.Ratio"'s @Ratio@, and its @approxRational@ (an+-- arbitrary number for @NaN@ and the infinities; total:+-- 'Papa.Base.Data.RealFrac.approxRationalMaybe'), are in+-- "Papa.Unsafe.Numeric". module Papa.Base.Data.Ratio (   module P,+  ratioNonZero, ) where  import Data.Ratio as P (-  Ratio,   Rational,-  approxRational,   denominator,   numerator,-  (%),  )+import qualified Data.Ratio as R+import Papa.Base.Data.Divisor (DivisorLike (divisor))+import Papa.Base.Data.NonZero (NonZero)+import Papa.Lens.Optic (the)+import Prelude (Integer)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInteger = Gen.integral (Range.linearFrom 0 (-1000) 1000) :: Gen Integer+-- >>> let genNonZero = Gen.just (preview nonZero <$> genInteger)++-- | A ratio of an 'Integer' and a 'NonZero' denominator, reduced to lowest+-- terms. "Data.Ratio"'s @%@, which throws for a zero denominator, is in+-- "Papa.Unsafe.Numeric"; this one cannot be given one.+--+-- ==== __Examples__+--+-- >>> fmap (ratioNonZero 6) (preview nonZero 4)+-- Just (3 % 2)+--+-- >>> check $ withTests 200 $ property $ do n <- forAll genInteger; d <- forAll genNonZero; numerator (ratioNonZero n d) * the divisor d === denominator (ratioNonZero n d) * n+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+ratioNonZero :: Integer -> NonZero Integer -> Rational+ratioNonZero n d =+  n R.% the divisor d+{-# INLINE ratioNonZero #-}
+ src/Papa/Base/Data/RealFloat.hs view
@@ -0,0 +1,273 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Total floating-point division and rounding, whose results are+-- floating-point numbers.+--+-- At a floating-point type ('Prelude.Double', 'Prelude.Float'), division by+-- zero does not throw: IEEE 754 defines it as an infinity, or @NaN@ for+-- @0 / 0@. "Prelude"'s @(/)@ is in "Papa.Unsafe.Numeric" because it throws+-- at 'Prelude.Rational'. 'divideFloating' and 'recipFloating' are @(/)@ and+-- @recip@ at 'RealFloat' only, so they need no+-- 'Papa.Base.Data.NonZero.NonZero' divisor, and do not compile at+-- 'Prelude.Rational'.+--+-- 'floorFloating', 'ceilingFloating', 'truncateFloating' and 'roundFloating'+-- round to a whole number of the same type, as C's @floor@ and the like do.+-- They are total: @NaN@ and the infinities are their own results, and so is+-- every number too large to have a fractional part. Where the result is+-- zero, its sign is that of the argument (@ceilingFloating (-0.5)@ is+-- @-0.0@). "Papa.Base.Data.RealFrac"'s 'Papa.Base.Data.RealFrac.floorMaybe'+-- and the like convert to an integral type instead.+--+-- 'modFloating' is "Data.Fixed"'s @mod'@, which throws for a divisor of+-- zero, made total.+--+-- These functions assume that the 'RealFloat' instance is IEEE 754+-- arithmetic, as those of base are.+--+-- @since 0.7.0+module Papa.Base.Data.RealFloat (+  divideFloating,+  recipFloating,+  floorFloating,+  ceilingFloating,+  truncateFloating,+  roundFloating,+  modFloating,+) where++import Data.Bool (bool, not, (&&), (||))+import Data.Eq (Eq ((==)))+import Data.Ord (Ord ((<), (>), (>=)))+import Prelude (Integer, Num (abs, negate, (*), (-)), RealFloat (encodeFloat, floatDigits, isInfinite, isNaN, isNegativeZero), RealFrac, toRational)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Data.Fixed as Fixed+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genDouble = Gen.double (Range.exponentialFloatFrom 0 (-1e30) 1e30)+-- >>> let genSmall = Gen.double (Range.linearFracFrom 0 (-1000) 1000)++-- | Division at a floating-point type. Division by zero is an infinity, or+-- @NaN@ for @0 / 0@, as IEEE 754 defines it. "Prelude"'s @(/)@, which throws+-- at 'Prelude.Rational', is in "Papa.Unsafe.Numeric"; for a 'Prelude.Rational'+-- use 'Papa.Base.Data.Fractional.divideNonZero'.+--+-- ==== __Examples__+--+-- >>> divideFloating 1 4 :: Double+-- 0.25+--+-- >>> divideFloating 1 0 :: Double+-- Infinity+--+-- >>> isNaN (divideFloating 0 0 :: Double)+-- True+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; y <- forAll (Gen.filter (/= 0) genDouble); Just (divideFloating x y) === fmap (divideNonZero x) (preview nonZero y)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+divideFloating :: (RealFloat a) => a -> a -> a+divideFloating =+  (P./)+{-# INLINE divideFloating #-}++-- | The reciprocal at a floating-point type: an infinity for zero.+--+-- ==== __Examples__+--+-- >>> recipFloating 4 :: Double+-- 0.25+--+-- >>> recipFloating (-0) :: Double+-- -Infinity+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; recipFloating x === divideFloating 1 x+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+recipFloating :: (RealFloat a) => a -> a+recipFloating =+  P.recip+{-# INLINE recipFloating #-}++-- | Round with the given function to an 'Integer', where the value has a+-- fractional part. A value whose magnitude is at least+-- @'floatRadix' ^ ('floatDigits' - 1)@ (2^52 at 'Prelude.Double') has+-- none, and nor have @NaN@ and the infinities: each is its own result. Below+-- that, the rounded 'Integer' converts back exactly. A zero result takes the+-- sign of the argument.+wholeWith :: (RealFloat a) => (a -> Integer) -> a -> a+wholeWith f x =+  let r = P.fromInteger (f x)+   in bool+        (bool r (negate 0) (r == 0 && (x < 0 || isNegativeZero x)))+        x+        (isNaN x || isInfinite x || abs x >= encodeFloat 1 (floatDigits x P.- 1))+{-# INLINE wholeWith #-}++-- | The greatest whole number not greater than the argument, at the+-- argument's type. @NaN@ and the infinities are their own results.+--+-- ==== __Examples__+--+-- >>> floorFloating 2.5 :: Double+-- 2.0+--+-- >>> floorFloating (-2.5) :: Double+-- -3.0+--+-- >>> floorFloating (-0.0) :: Double+-- -0.0+--+-- >>> floorFloating 1e300 :: Double+-- 1.0e300+--+-- >>> check $ withTests 500 $ property $ do x <- forAll genDouble; Just (floorFloating x) === fmap integralToFloating (floorMaybe x :: Maybe Integer)+-- ...passed 500 tests.+-- True+--+-- @since 0.7.0+floorFloating :: (RealFloat a) => a -> a+floorFloating =+  wholeWith P.floor+{-# INLINE floorFloating #-}++-- | The least whole number not less than the argument, at the argument's+-- type. @NaN@ and the infinities are their own results.+--+-- ==== __Examples__+--+-- >>> ceilingFloating 2.5 :: Double+-- 3.0+--+-- >>> ceilingFloating (-0.5) :: Double+-- -0.0+--+-- >>> check $ withTests 500 $ property $ do x <- forAll genDouble; Just (ceilingFloating x) === fmap integralToFloating (ceilingMaybe x :: Maybe Integer)+-- ...passed 500 tests.+-- True+--+-- @since 0.7.0+ceilingFloating :: (RealFloat a) => a -> a+ceilingFloating =+  wholeWith P.ceiling+{-# INLINE ceilingFloating #-}++-- | The argument without its fractional part (rounded towards zero), at the+-- argument's type. @NaN@ and the infinities are their own results.+--+-- ==== __Examples__+--+-- >>> truncateFloating 2.7 :: Double+-- 2.0+--+-- >>> truncateFloating (-2.7) :: Double+-- -2.0+--+-- >>> check $ withTests 500 $ property $ do x <- forAll genDouble; Just (truncateFloating x) === fmap integralToFloating (truncateMaybe x :: Maybe Integer)+-- ...passed 500 tests.+-- True+--+-- @since 0.7.0+truncateFloating :: (RealFloat a) => a -> a+truncateFloating =+  wholeWith P.truncate+{-# INLINE truncateFloating #-}++-- | The nearest whole number, at the argument's type; a half rounds to the+-- even number, as "Prelude"'s @round@ does. @NaN@ and the infinities are+-- their own results.+--+-- ==== __Examples__+--+-- >>> roundFloating 2.5 :: Double+-- 2.0+--+-- >>> roundFloating 3.5 :: Double+-- 4.0+--+-- >>> divideFloating (roundFloating (2.345 * 100)) 100 :: Double+-- 2.35+--+-- >>> check $ withTests 500 $ property $ do x <- forAll genDouble; Just (roundFloating x) === fmap integralToFloating (roundMaybe x :: Maybe Integer)+-- ...passed 500 tests.+-- True+--+-- @since 0.7.0+roundFloating :: (RealFloat a) => a -> a+roundFloating =+  wholeWith P.round+{-# INLINE roundFloating #-}++-- | The remainder of floored division, at a floating-point type: the+-- remainder has the sign of the divisor, as 'Papa.Base.Data.Integral.modNonZero'+-- does, so that @modFloating a 360@ is an angle from 0 to 360.+--+-- The remainder is computed exactly and then rounded, so it is the+-- floating-point number nearest to the true remainder. That number can be+-- the divisor itself, where the true remainder is less than the divisor by+-- less than its precision: @modFloating (-1e-20) 360@ is @360.0@.+--+-- 'Data.Fixed.mod'' throws for a divisor of zero. Here:+--+-- * a divisor of zero or @NaN@, or a dividend of @NaN@ or an infinity, gives+--   @NaN@, as C's @fmod@ does;+-- * an infinite divisor gives the dividend where the two have the same sign+--   (or the dividend is zero), and the divisor where they do not, which are+--   the limits of the remainder.+--+-- ==== __Examples__+--+-- >>> modFloating 370 360 :: Double+-- 10.0+--+-- >>> modFloating (-90) 360 :: Double+-- 270.0+--+-- >>> modFloating 7.5 (-2) :: Double+-- -0.5+--+-- >>> isNaN (modFloating 1 0 :: Double)+-- True+--+-- >>> check $ withTests 500 $ property $ do x <- forAll genSmall; y <- forAll (Gen.filter (/= 0) genSmall); modFloating x y === P.fromRational (Fixed.mod' (P.toRational x) (P.toRational y))+-- ...passed 500 tests.+-- True+--+-- >>> check $ withTests 500 $ property $ do a <- forAll (Gen.integral (Range.linear (-1000) 1000)); b <- forAll (Gen.filter (/= 0) (Gen.integral (Range.linear (-1000) 1000))); modFloating (integralToFloating a) (integralToFloating b) === (integralToFloating (maybe 0 (modNonZero a) (preview nonZero (b :: Integer))) :: Double)+-- ...passed 500 tests.+-- True+--+-- @since 0.7.0+modFloating :: (RealFloat a) => a -> a -> a+modFloating x y+  | isNaN x || isInfinite x || isNaN y || y == 0 =+      0 P./ 0+  | isInfinite y =+      bool y x (x == 0 || (x > 0) == (y > 0))+  | P.otherwise =+      let r = P.fromRational (exactMod x y)+       in bool r (negate 0) (r == 0 && y < 0)+{-# INLINEABLE modFloating #-}++-- | The remainder of floored division, as a 'Prelude.Rational', exactly.+-- The divisor is finite and not zero.+exactMod :: (RealFrac a) => a -> a -> P.Rational+exactMod x y =+  let rx = toRational x+      ry = toRational y+   in rx - ry * P.fromInteger (P.floor (rx P./ ry))+{-# INLINE exactMod #-}++-- Bring 'not' into use for HLint-free guards elsewhere.+_unused :: P.Bool -> P.Bool+_unused = not
+ src/Papa/Base/Data/RealFrac.hs view
@@ -0,0 +1,404 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Total conversions from fractional types, and between floating types.+--+-- The 'RealFrac' methods of "Prelude" (@truncate@, @round@, @ceiling@,+-- @floor@, @properFraction@), its 'Real' method @toRational@, and+-- @realToFrac@, and "Data.Ratio"'s @approxRational@, are in+-- "Papa.Unsafe.Numeric": at 'Double' and 'Float' they+-- return an arbitrary number for @NaN@ and the infinities+-- (@truncate nan :: Integer@ has 309 digits), and the+-- 'RealFrac' methods wrap around where the result does not fit in the target+-- type (@truncate (300.5 :: Double) :: Word8@ is @44@). @realToFrac@ goes+-- through 'Rational', which has no @NaN@ or infinity, so at+-- @Double -> Double@ it turns @NaN@ into a number, depending on optimisation.+--+-- The functions here are total:+--+-- * 'truncateMaybe', 'roundMaybe', 'ceilingMaybe', 'floorMaybe',+--   'properFractionMaybe', 'toRationalMaybe' and 'approxRationalMaybe' are 'Data.Maybe.Nothing' for @NaN@, the+--   infinities, and (except 'toRationalMaybe') a result that does not fit in+--   the target type;+-- * 'floatToDouble' (exact) and 'doubleToFloat' (rounding) convert between+--   'Float' and 'Double' directly, so that @NaN@, the infinities and @-0@ are+--   kept;+-- * 'integralToFloating' converts an integral value to a floating type,+--   rounding where it has more digits than the floating type holds; it does not+--   wrap or throw (a value beyond the range of the floating type is an+--   infinity).+--+-- A value is finite when it equals itself (@NaN@ does not) and is zero or+-- differs from its double (an infinity is its own double). This needs no+-- 'RealFloat', so the functions work at 'Rational' and "Data.Fixed" as well.+-- At a 'Data.Ratio.Ratio' of a bounded type, whose arithmetic wraps around,+-- the results are those of its arithmetic.+--+-- @since 0.7.0+module Papa.Base.Data.RealFrac (+  truncateMaybe,+  roundMaybe,+  ceilingMaybe,+  floorMaybe,+  properFractionMaybe,+  toRationalMaybe,+  approxRationalMaybe,+  floatToDouble,+  doubleToFloat,+  integralToFloating,+) where++import Control.Monad (guard)+import Data.Bits (Bits (bitSizeMaybe, isSigned, shiftL), toIntegralSized)+import Data.Bool (Bool, bool, (&&), (||))+import Data.Eq (Eq ((/=), (==)))+import Data.Functor (fmap, ($>))+import Data.Maybe (Maybe (Just), maybe)+import Data.Ord (Ord ((<), (<=)))+import Data.Ratio (approxRational)+import GHC.Float (double2Float, float2Double)+import Prelude (Double, Float, Integer, Integral, Num ((*)), Rational, Real, RealFloat, RealFrac)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Unsafe.Numeric as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let nan = 0 U./ 0 :: Double+-- >>> let inf = 1 U./ 0 :: Double+-- >>> let genDouble = Gen.double (Range.exponentialFloatFrom 0 (-1e30) 1e30)++-- | Whether a value is finite: not @NaN@ (which differs from itself), and+-- zero or different from its double (an infinity is its own double).+-- Doubling is exact, or overflows to an infinity, at every finite+-- floating-point value, subnormals included; it is exact at 'Rational' and+-- "Data.Fixed".+finite :: (Real a) => a -> Bool+finite x =+  x == x && (x == 0 || x * 2 /= x)+{-# INLINE finite #-}++-- | The integral part of a value by a rounding function of "Prelude",+-- given at 'Integer' and at the target type: 'Data.Maybe.Nothing' for a value that is+-- not finite or whose integral part does not fit in the target type.+--+-- A value well inside the range of a bounded target type (less than a+-- quarter of it from zero, for a signed type; less than half of its maximum,+-- for an unsigned one) is converted directly, which at 'Double' and 'Float' to+-- 'Data.Int.Int' and the other machine types is one machine instruction; its integral+-- part fits, whichever way it rounds. Every other value goes through+-- 'Integer' and 'toIntegralSized', which is exact. @NaN@ is never well inside+-- a range, so the fast path needs no test for it.+integralPart :: forall a b. (RealFrac a, Integral b, Bits b) => (a -> Integer) -> (a -> b) -> a -> Maybe b+integralPart toInteger toTarget x =+  maybe exact fast (bitSizeMaybe (0 :: b))+ where+  exact =+    guard (finite x) P.*> toIntegralSized (toInteger x)+  fast n =+    bool exact (Just (toTarget x)) (bool (0 <= x && x < power (n P.- 1)) (P.abs x < power (n P.- 2)) (isSigned (0 :: b)))+  power k =+    P.fromInteger (shiftL 1 k)+{-# INLINE integralPart #-}++-- | Total @truncate@: the integral part, rounded toward zero; 'Data.Maybe.Nothing' for @NaN@, the infinities, and a result+-- that does not fit in the target type. "Prelude"'s @truncate@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> truncateMaybe (-2.5 :: Double) :: Maybe Int+-- Just (-2)+--+-- >>> truncateMaybe (2.5 :: Double) :: Maybe Int+-- Just 2+--+-- >>> truncateMaybe nan :: Maybe Integer+-- Nothing+--+-- >>> truncateMaybe (negate inf) :: Maybe Integer+-- Nothing+--+-- >>> truncateMaybe (300.5 :: Double) :: Maybe Word8+-- Nothing+--+-- >>> truncateMaybe (3.5 :: Rational) :: Maybe U.Natural+-- Just 3+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; truncateMaybe x === (toIntegralSized (U.truncate x :: Integer) :: Maybe Int)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+truncateMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b+truncateMaybe =+  integralPart P.truncate P.truncate+{-# INLINE truncateMaybe #-}++-- | Total @round@: the nearest integer, and the even one of two equally near; 'Data.Maybe.Nothing' for @NaN@, the infinities, and a result+-- that does not fit in the target type. "Prelude"'s @round@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> roundMaybe (-2.5 :: Double) :: Maybe Int+-- Just (-2)+--+-- >>> roundMaybe (2.5 :: Double) :: Maybe Int+-- Just 2+--+-- >>> roundMaybe nan :: Maybe Integer+-- Nothing+--+-- >>> roundMaybe (negate inf) :: Maybe Integer+-- Nothing+--+-- >>> roundMaybe (300.5 :: Double) :: Maybe Word8+-- Nothing+--+-- >>> roundMaybe (3.5 :: Rational) :: Maybe U.Natural+-- Just 4+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; roundMaybe x === (toIntegralSized (U.round x :: Integer) :: Maybe Int)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+roundMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b+roundMaybe =+  integralPart P.round P.round+{-# INLINE roundMaybe #-}++-- | Total @ceiling@: the least integer not less than the value; 'Data.Maybe.Nothing' for @NaN@, the infinities, and a result+-- that does not fit in the target type. "Prelude"'s @ceiling@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> ceilingMaybe (-2.5 :: Double) :: Maybe Int+-- Just (-2)+--+-- >>> ceilingMaybe (2.5 :: Double) :: Maybe Int+-- Just 3+--+-- >>> ceilingMaybe nan :: Maybe Integer+-- Nothing+--+-- >>> ceilingMaybe (negate inf) :: Maybe Integer+-- Nothing+--+-- >>> ceilingMaybe (300.5 :: Double) :: Maybe Word8+-- Nothing+--+-- >>> ceilingMaybe (3.5 :: Rational) :: Maybe U.Natural+-- Just 4+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; ceilingMaybe x === (toIntegralSized (U.ceiling x :: Integer) :: Maybe Int)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+ceilingMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b+ceilingMaybe =+  integralPart P.ceiling P.ceiling+{-# INLINE ceilingMaybe #-}++-- | Total @floor@: the greatest integer not greater than the value; 'Data.Maybe.Nothing' for @NaN@, the infinities, and a result+-- that does not fit in the target type. "Prelude"'s @floor@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> floorMaybe (-2.5 :: Double) :: Maybe Int+-- Just (-3)+--+-- >>> floorMaybe (2.5 :: Double) :: Maybe Int+-- Just 2+--+-- >>> floorMaybe nan :: Maybe Integer+-- Nothing+--+-- >>> floorMaybe (negate inf) :: Maybe Integer+-- Nothing+--+-- >>> floorMaybe (300.5 :: Double) :: Maybe Word8+-- Nothing+--+-- >>> floorMaybe (3.5 :: Rational) :: Maybe U.Natural+-- Just 3+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; floorMaybe x === (toIntegralSized (U.floor x :: Integer) :: Maybe Int)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+floorMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe b+floorMaybe =+  integralPart P.floor P.floor+{-# INLINE floorMaybe #-}++-- | Total @properFraction@: the integral part (rounded toward zero) and the+-- fractional part, with the sign of the value; 'Data.Maybe.Nothing' for @NaN@, the+-- infinities, and an integral part that does not fit in the target type.+-- "Prelude"'s @properFraction@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> properFractionMaybe (-3.75 :: Double) :: Maybe (Int, Double)+-- Just (-3,-0.75)+--+-- >>> properFractionMaybe nan :: Maybe (Integer, Double)+-- Nothing+--+-- >>> properFractionMaybe (300.5 :: Double) :: Maybe (Word8, Double)+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; fmap (toInteger . fst) (properFractionMaybe x :: Maybe (Int, Double)) === fmap toInteger (truncateMaybe x :: Maybe Int)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+properFractionMaybe :: (RealFrac a, Integral b, Bits b) => a -> Maybe (b, a)+properFractionMaybe x =+  fmap (\n -> (n, x P.- P.fromIntegral n)) (truncateMaybe x)+{-# INLINE properFractionMaybe #-}++-- | Total @toRational@: the exact value of a finite number; 'Data.Maybe.Nothing' for+-- @NaN@ and the infinities. "Prelude"'s @toRational@ is in+-- "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> toRationalMaybe (0.75 :: Double)+-- Just (3 % 4)+--+-- >>> toRationalMaybe nan+-- Nothing+--+-- >>> toRationalMaybe (doubleToFloat inf)+-- Nothing+--+-- >>> toRationalMaybe (7 :: Int)+-- Just (7 % 1)+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; toRationalMaybe x === Just (U.toRational x)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+toRationalMaybe :: (Real a) => a -> Maybe Rational+toRationalMaybe x =+  guard (finite x) $> P.toRational x+{-# INLINE toRationalMaybe #-}++-- | Total @approxRational@: the simplest 'Rational' within the given distance+-- of a finite number; 'Data.Maybe.Nothing' where the number or the distance+-- is @NaN@ or an infinity, for which "Data.Ratio"'s @approxRational@, in+-- "Papa.Unsafe.Numeric", returns an arbitrary number.+--+-- ==== __Examples__+--+-- >>> approxRationalMaybe (3.14159 :: Double) 0.001+-- Just (201 % 64)+--+-- >>> approxRationalMaybe nan 0.1+-- Nothing+--+-- >>> approxRationalMaybe 0.5 inf+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; e <- forAll genDouble; approxRationalMaybe x e === Just (U.approxRational x e)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+approxRationalMaybe :: (RealFrac a) => a -> a -> Maybe Rational+approxRationalMaybe x e =+  guard (finite x && finite e) $> approxRational x e+{-# INLINE approxRationalMaybe #-}++-- | A 'Float' as a 'Double', exactly: every 'Float' is a 'Double', @NaN@,+-- the infinities and @-0@ included. Use it where "Prelude" has+-- @realToFrac@, which is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> floatToDouble 0.5+-- 0.5+--+-- >>> isNaN (floatToDouble (doubleToFloat nan))+-- True+--+-- >>> floatToDouble (doubleToFloat (negate inf))+-- -Infinity+--+-- >>> isNegativeZero (floatToDouble (-0))+-- True+--+-- >>> check $ withTests 200 $ property $ do x <- forAll (Gen.float (Range.exponentialFloatFrom 0 (-1e30) 1e30)); doubleToFloat (floatToDouble x) === x+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+floatToDouble :: Float -> Double+floatToDouble =+  float2Double+{-# INLINE floatToDouble #-}++-- | A 'Double' as a 'Float', rounded to the nearest 'Float' (an infinity+-- beyond the range of 'Float'); @NaN@, the infinities and @-0@ are kept.+-- Use it where "Prelude" has @realToFrac@, which is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> doubleToFloat 0.1+-- 0.1+--+-- >>> doubleToFloat 1e300+-- Infinity+--+-- >>> isNaN (doubleToFloat nan)+-- True+--+-- >>> isNegativeZero (doubleToFloat (-0))+-- True+--+-- >>> check $ withTests 200 $ property $ do x <- forAll genDouble; doubleToFloat x === U.realToFrac x+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+doubleToFloat :: Double -> Float+doubleToFloat =+  double2Float+{-# INLINE doubleToFloat #-}++-- | An integral value in a floating type, rounded where it has more digits+-- than the floating type holds; a value beyond the range of the floating type+-- is an infinity. It does not wrap around or throw. "Prelude"'s+-- @fromIntegral@ is in "Papa.Unsafe.Numeric".+--+-- ==== __Examples__+--+-- >>> integralToFloating (3 :: Int) :: Double+-- 3.0+--+-- >>> integralToFloating (pow 2 53 + 1 :: Integer) :: Double+-- 9.007199254740992e15+--+-- >>> integralToFloating (pow 10 400 :: Integer) :: Double+-- Infinity+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.int (Range.linearFrom 0 (negate (pow 2 53)) (pow 2 53))); U.truncate (integralToFloating n :: Double) === n+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+integralToFloating :: (Integral a, RealFloat b) => a -> b+integralToFloating =+  P.fromIntegral+{-# INLINE integralToFloating #-}
+ src/Papa/Base/Data/Right.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The name @right@ (classy optics, rule 4): the value of the @Right@ side of a+-- sum.+--+-- Its target is a type variable, so the name has no identity instance+-- (rule 4). Its instance for 'Either', a library type, is in this module+-- (rule 15).+--+-- @since 0.7.0+module Papa.Base.Data.Right (+  RightLike (..),+) where++import Control.Lens (Choice, Optic, _Right)+import Data.Either (Either)+import Data.Type.Equality (type (~))+import Prelude (Applicative)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genEither = Gen.either (Gen.int (Range.linear 0 9)) Gen.alpha++-- | A field or a constructor named @right@.+--+-- ==== __Examples__+--+-- >>> preview right (Right 'x' :: Either Int Char)+-- Just 'x'+--+-- >>> preview right (Left 1 :: Either Int Char)+-- Nothing+--+-- >>> review right 'x' :: Either Int Char+-- Right 'x'+--+-- Prism laws:+--+-- >>> check $ withTests 100 $ property $ do x <- forAll (Gen.alpha); preview right (review right x :: Either Int Char) === Just x+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do e <- forAll genEither; for_ (preview right e) (\x -> review right x === e)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+class RightLike p f x x' a a' | x -> a where+  right ::+    Optic p f x x' a a'++-- Prism+instance (Choice p, Applicative f, x' ~ Either a b') => RightLike p f (Either a b) x' b b' where+  right =+    _Right+  {-# INLINE right #-}
src/Papa/Base/Data/Semigroup.hs view
@@ -1,30 +1,158 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Semigroups, with total repetition.+--+-- The repetition functions of "Data.Semigroup" ('Data.Semigroup.stimes'+-- and the functions for defining it) throw for a count that is out of+-- range. These return 'Nothing' there instead. To define the 'stimes'+-- method of an instance, import "Data.Semigroup". module Papa.Base.Data.Semigroup (   module P,+  stimes,+  stimesMonoid,+  stimesIdempotent,+  stimesIdempotentMonoid,+  mtimesDefault, ) where +import Data.Bool (bool)+import Data.Maybe (Maybe (Just, Nothing))+import Data.Monoid (Monoid)+import Data.Ord (Ord ((<), (<=))) import Data.Semigroup as P (-  All (getAll),-  Any (getAny),+  All (All, getAll),+  Any (Any, getAny),   Arg (Arg),   ArgMax,   ArgMin,-  Dual (getDual),-  Endo (appEndo),-  First (getFirst),-  Last (getLast),-  Max (getMax),-  Min (getMin),-  Product (getProduct),-  Semigroup (sconcat, stimes, (<>)),-  Sum (getSum),-  WrappedMonoid (unwrapMonoid),+  Dual (Dual, getDual),+  Endo (Endo, appEndo),+  First (First, getFirst),+  Last (Last, getLast),+  Max (Max, getMax),+  Min (Min, getMin),+  Product (Product, getProduct),+  Semigroup (sconcat, (<>)),+  Sum (Sum, getSum),+  WrappedMonoid (WrapMonoid, unwrapMonoid),   cycle1,   diff,-  mtimesDefault,-  stimesIdempotent,-  stimesIdempotentMonoid,-  stimesMonoid,  )+import qualified Data.Semigroup as S+import Prelude (Integral)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genString = Gen.string (Range.linear 0 10) Gen.alpha++-- | Total 'S.stimes': repeat a value a positive number of times. 'Nothing'+-- for a count that is not positive.+--+-- ==== __Examples__+--+-- >>> stimes (3 :: Int) "ab"+-- Just "ababab"+--+-- >>> stimes (0 :: Int) "ab"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; n <- forAll (Gen.int (Range.linear 1 10)); stimes (n + 1) s === fmap (s <>) (stimes n s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+stimes :: (Integral b, Semigroup a) => b -> a -> Maybe a+stimes n a =+  bool (Just (S.stimes n a)) Nothing (n <= 0)+{-# INLINE stimes #-}++-- | Total 'S.stimesMonoid': repeat a value a non-negative number of times.+-- 'Nothing' for a negative count.+--+-- ==== __Examples__+--+-- >>> stimesMonoid (0 :: Int) "ab"+-- Just ""+--+-- >>> stimesMonoid (-1 :: Int) "ab"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; n <- forAll (Gen.int (Range.linear (-10) 10)); stimesMonoid n s === if n < 0 then Nothing else Just (concat (replicate n s))+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+stimesMonoid :: (Integral b, Monoid a) => b -> a -> Maybe a+stimesMonoid n a =+  bool (Just (S.stimesMonoid n a)) Nothing (n < 0)+{-# INLINE stimesMonoid #-}++-- | Total 'S.stimesIdempotent': repetition of an idempotent value+-- (@a '<>' a = a@), which is the value itself. 'Nothing' for a count that is+-- not positive.+--+-- ==== __Examples__+--+-- >>> stimesIdempotent (5 :: Int) (Max 'x')+-- Just (Max {getMax = 'x'})+--+-- >>> stimesIdempotent (0 :: Int) (Max 'x')+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll Gen.alpha; n <- forAll (Gen.int (Range.linear (-10) 10)); stimesIdempotent n (Max c) === if n <= 0 then Nothing else Just (Max c)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+stimesIdempotent :: (Integral b) => b -> a -> Maybe a+stimesIdempotent n a =+  bool (Just a) Nothing (n <= 0)+{-# INLINE stimesIdempotent #-}++-- | Total 'S.stimesIdempotentMonoid': repetition of an idempotent value in a+-- monoid, which is 'Data.Monoid.mempty' for a count of zero. 'Nothing' for a+-- negative count.+--+-- ==== __Examples__+--+-- >>> stimesIdempotentMonoid (0 :: Int) (Any True)+-- Just (Any {getAny = False})+--+-- >>> stimesIdempotentMonoid (-1 :: Int) (Any True)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll Gen.bool; n <- forAll (Gen.int (Range.linear (-10) 10)); stimesIdempotentMonoid n (Any b) === if n < 0 then Nothing else Just (Any (b && n > 0))+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> Maybe a+stimesIdempotentMonoid n a =+  bool (Just (S.stimesIdempotentMonoid n a)) Nothing (n < 0)+{-# INLINE stimesIdempotentMonoid #-}++-- | Total 'S.mtimesDefault': repeat a value in a monoid a non-negative number+-- of times. 'Nothing' for a negative count.+--+-- ==== __Examples__+--+-- >>> mtimesDefault (2 :: Int) [1, 2 :: Int]+-- Just [1,2,1,2]+--+-- >>> mtimesDefault (-2 :: Int) [1, 2 :: Int]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; n <- forAll (Gen.int (Range.linear 0 10)); mtimesDefault n s === stimesMonoid n s+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+mtimesDefault :: (Integral b, Monoid a) => b -> a -> Maybe a+mtimesDefault n a =+  bool (Just (S.mtimesDefault n a)) Nothing (n < 0)+{-# INLINE mtimesDefault #-}
src/Papa/Base/Data/Show.hs view
@@ -11,7 +11,7 @@   Show2 (liftShowsPrec2),  ) import Prelude as P (-  Show (show, showsPrec),+  Show (show, showList, showsPrec),   ShowS,   showString,   shows,
src/Papa/Base/Data/String.hs view
@@ -6,6 +6,7 @@ ) where  import Data.String as P (+  IsString (fromString),   String,   lines,   unlines,
src/Papa/Base/Data/Traversable.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Traversals, with the monadic traversals of "Prelude" generalised to+-- 'Applicative'. module Papa.Base.Data.Traversable (   module P,   mapM,@@ -8,6 +10,7 @@   sequence, ) where +import Control.Applicative (Applicative) import Data.Traversable as P (   Traversable (sequenceA, traverse),   fmapDefault,@@ -16,52 +19,69 @@   mapAccumL,  ) -import Control.Applicative (Applicative)--{-# INLINE mapM #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInts = Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-100) 100))+-- >>> let genF = fn (Gen.maybe (Gen.int (Range.linear 0 9))) --- | Map each element to an action, evaluate these actions left to right, and collect the results.+-- | 'traverse', under the name of "Prelude"'s @mapM@, which needs only+-- 'Applicative'. ----- >>> import Data.Maybe (Maybe(..))--- >>> mapM (\x -> Just x) [1,2,3]--- Just [1,2,3]--- >>> mapM (\_ -> Nothing) [1,2,3]--- Nothing-mapM ::-  (Traversable t, Applicative f) =>-  (a -> f b) ->-  t a ->-  f (t b)+-- ==== __Examples__+--+-- >>> mapM (\x -> Just (x + 1)) [1, 2, 3 :: Int]+-- Just [2,3,4]+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; f <- forAll genF; mapM (apply f) xs === traverse (apply f) xs+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+mapM :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) mapM =   traverse+{-# INLINE mapM #-} +-- | 'for', under the name of "Prelude"'s @forM@, which needs only+-- 'Applicative'.+--+-- ==== __Examples__+--+-- >>> forM [1, 2, 3 :: Int] (\x -> Just (x + 1))+-- Just [2,3,4]+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; f <- forAll genF; forM xs (apply f) === traverse (apply f) xs+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+forM :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)+forM =+  for {-# INLINE forM #-} --- | 'forM' is 'mapM' with its arguments flipped.+-- | 'sequenceA', under the name of "Prelude"'s @sequence@, which needs only+-- 'Applicative'. ----- >>> import Data.Maybe (Maybe(..))--- >>> forM [1,2,3] (\x -> Just x)--- Just [1,2,3]-forM ::-  (Traversable t, Applicative f) =>-  t a ->-  (a -> f b) ->-  f (t b)-forM a f =-  traverse f a--{-# INLINE sequence #-}---- | Evaluate each action in the structure left to right, and collect the results.+-- ==== __Examples__ ----- >>> import Data.Maybe (Maybe(..))--- >>> sequence [Just 1, Just 2, Just 3]--- Just [1,2,3]--- >>> sequence [Just 1, Nothing, Just 3]+-- >>> sequence [Just 1, Just (2 :: Int)]+-- Just [1,2]+--+-- >>> sequence [Just 1, Nothing :: Maybe Int] -- Nothing-sequence ::-  (Traversable t, Applicative f) =>-  t (f a) ->-  f (t a)+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll (Gen.list (Range.linear 0 10) (Gen.maybe (Gen.int (Range.linear 0 9)))); sequence xs === sequenceA xs+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+sequence :: (Traversable t, Applicative f) => t (f a) -> f (t a) sequence =   sequenceA+{-# INLINE sequence #-}
+ src/Papa/Base/Data/Tuple.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Pairs. @fst@ and @snd@ are "Papa.Lens.Data.Tuple"'s, for any tuple.+--+-- @since 0.7.0+module Papa.Base.Data.Tuple (+  module P,+) where++import Data.Tuple as P (+  swap,+ )
+ src/Papa/Base/Data/Word.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Unsigned integral types.+module Papa.Base.Data.Word (+  module P,+) where++import Data.Word as P (+  Word,+  Word16,+  Word32,+  Word64,+  Word8,+ )
+ src/Papa/Base/GHC/Stack.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Call stacks, for the constraint 'HasCallStack'.+--+-- @since 0.7.0+module Papa.Base.GHC.Stack (+  module P,+) where++import GHC.Stack as P (+  HasCallStack,+ )
src/Papa/Base/Prelude.hs view
@@ -1,16 +1,36 @@+{-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | The total part of "Prelude".+--+-- The partial functions of "Prelude" are not re-exported. Their total+-- replacements are in "Papa.Base.Data.Integral" (@div@, @mod@, @divMod@,+-- @quot@, @rem@, @quotRem@, @(^)@), "Papa.Base.Data.Fractional" (@(/)@,+-- @recip@, @(^^)@), "Papa.Base.Data.List" (@cycle@),+-- "Papa.Base.Data.IntCast" (@intCast@, for @fromIntegral@),+-- "Papa.Base.Data.RealFrac" (@truncate@, @round@, @ceiling@, @floor@,+-- @properFraction@, @toRational@, @realToFrac@),+-- "Papa.Base.Data.Enum" (@succ@, @pred@) and+-- "Papa.Base.Text.Read" (@readIO@).+--+-- The I/O functions of "Prelude" (@putStr@, @putStrLn@, @print@, @getLine@,+-- @getContents@, @readFile@, @writeFile@, @appendFile@, @interact@, @readLn@,+-- @readIO@) throw their 'IOError's, and some read lazily; they are in+-- "Papa.Unsafe.IO". module Papa.Base.Prelude (   module P,+  type (~), ) where +import Data.Type.Equality (type (~)) import Prelude as P (   Applicative,   Bool (     False,     True   ),+  Bounded (maxBound, minBound),   Char,   Double,   Either (@@ -46,6 +66,7 @@   Rational,   Real,   RealFloat,+  RealFrac,   Show,   ShowS,   Traversable,@@ -56,21 +77,17 @@   all,   and,   any,-  appendFile,   asin,   asinh,   atan,   atan2,   atanh,   break,-  ceiling,   compare,   cos,   cosh,   curry,-  cycle,   decodeFloat,-  divMod,   drop,   dropWhile,   either,@@ -83,19 +100,13 @@   floatDigits,   floatRadix,   floatRange,-  floor,   fmap,   foldMap,   foldl,   foldr,-  fromInteger,-  fromIntegral,   fromRational,   gcd,   getChar,-  getContents,-  getLine,-  interact,   ioError,   isDenormalized,   isIEEE,@@ -110,7 +121,6 @@   maybe,   mempty,   min,-  mod,   negate,   not,   notElem,@@ -119,21 +129,10 @@   otherwise,   pi,   product,-  properFraction,   pure,-  putChar,-  putStr,-  putStrLn,-  quot,-  quotRem,-  readFile,-  readIO,-  realToFrac,-  recip,-  rem,   replicate,-  round,   scaleFloat,+  seq,   sequenceA,   show,   showParen,@@ -153,27 +152,25 @@   tan,   tanh,   toInteger,-  toRational,   traverse,-  truncate,   uncurry,   unlines,   until,   unwords,   unzip3,+  userError,   words,-  writeFile,   zip,   zip3,   zipWith,   zipWith3,   ($),+  ($!),   (&&),   (*),   (**),   (+),   (-),-  (/),   (/=),   (<),   (<$),@@ -183,7 +180,5 @@   (==),   (>),   (>=),-  (^),-  (^^),   (||),  )
+ src/Papa/Base/System/Environment.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The program's arguments and environment.+module Papa.Base.System.Environment (+  module P,+) where++import System.Environment as P (+  getArgs,+  getEnvironment,+  getProgName,+  lookupEnv,+ )
+ src/Papa/Base/System/Exit.hs view
@@ -0,0 +1,53 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Exiting the program, with a total 'exitWith'.+module Papa.Base.System.Exit (+  module P,+  exitWith,+) where++import Data.Maybe (Maybe (Just, Nothing))+import System.Exit as P (+  ExitCode (ExitFailure, ExitSuccess),+  die,+  exitFailure,+  exitSuccess,+ )+import qualified System.Exit as E+import Prelude (IO)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Total 'E.exitWith': the action that exits with the given code.+-- 'Nothing' for @'ExitFailure' 0@, which is not a failure code, and for+-- which "System.Exit"'s @exitWith@ throws an 'Prelude.IOError' instead of+-- exiting.+--+-- ==== __Examples__+--+-- >>> (() <$ exitWith (ExitFailure 1))+-- Just ()+--+-- >>> (() <$ exitWith ExitSuccess)+-- Just ()+--+-- >>> (() <$ exitWith (ExitFailure 0))+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linearFrom 0 (-255) 255)); has _Just (exitWith (ExitFailure n) :: Maybe (IO ())) === (n /= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+exitWith :: ExitCode -> Maybe (IO a)+exitWith c =+  case c of+    ExitFailure 0 -> Nothing+    _ -> Just (E.exitWith c)+{-# INLINE exitWith #-}
+ src/Papa/Base/System/IO.hs view
@@ -0,0 +1,178 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Handles: opening, closing, flushing and buffering, returning their+-- 'Control.Exception.IOException' in 'IOExcept' instead of throwing it.+--+-- "System.IO"'s versions, which throw, are in "Papa.Unsafe.IO", with the+-- functions that read and write 'Data.String.String's in the locale's encoding.+module Papa.Base.System.IO (+  module P,+  openFile,+  withFile,+  hClose,+  hFlush,+  hIsEOF,+  hSetBuffering,+) where++import Control.Category ((.))+import Control.Monad ((>>=))+import Control.Monad.Except (liftEither, runExceptT)+import Data.Bool (Bool)+import Papa.Base.Control.Exception (bracket)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import System.IO as P (+  BufferMode (BlockBuffering, LineBuffering, NoBuffering),+  FilePath,+  Handle,+  IOMode (AppendMode, ReadMode, ReadWriteMode, WriteMode),+  stderr,+  stdin,+  stdout,+ )+import qualified System.IO as IO++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Unsafe.IO as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Open a file, returning the 'Control.Exception.IOException' if it cannot+-- be opened.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (openFile "/nonexistent/papa" ReadMode)+-- True+--+-- >>> runExceptT (openFile "/dev/null" ReadMode >>= \h -> hIsEOF h <* hClose h)+-- Right True+--+-- @since 0.7.0+openFile :: FilePath -> IOMode -> IOExcept Handle+openFile p m =+  exceptIO (IO.openFile p m)+{-# INLINE openFile #-}++-- | Open a file, use its handle, and close it, whether or not the use+-- fails. The 'Control.Exception.IOException' of the open, the use or the+-- close is returned.+--+-- The handle is closed by 'bracket' over 'IO.openFile' and 'IO.hClose', not+-- by "System.IO"'s @withFile@, which rewrites the exceptions thrown by the+-- use to name the file.+--+-- ==== __Examples__+--+-- >>> runExceptT (withFile "/dev/null" ReadMode hIsEOF)+-- Right True+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (withFile "/nonexistent/papa" ReadMode hIsEOF)+-- True+--+-- The handle is closed when the use fails:+--+-- >>> do { h <- newIORef Nothing; _ <- runExceptT (withFile "/dev/null" ReadMode (\x -> exceptIO (writeIORef h (Just x)) *> openFile "/nonexistent/papa" ReadMode)); readIORef h >>= traverse U.hIsClosed }+-- Just True+--+-- >>> check $ withTests 20 $ property $ do m <- forAll (Gen.element [ReadMode, WriteMode, AppendMode, ReadWriteMode]); r <- evalIO (runExceptT (withFile "/dev/null" m (const (pure ())))); r === Right ()+-- ...passed 20 tests.+-- True+--+-- @since 0.7.0+withFile :: FilePath -> IOMode -> (Handle -> IOExcept a) -> IOExcept a+withFile p m use =+  exceptIO (bracket (IO.openFile p m) IO.hClose (runExceptT . use)) >>= liftEither+{-# INLINE withFile #-}++-- | Close a handle, returning the 'Control.Exception.IOException' of the+-- flush of its buffer.+--+-- ==== __Examples__+--+-- >>> runExceptT (openFile "/dev/null" ReadMode >>= hClose)+-- Right ()+--+-- Closing a closed handle is not a failure:+--+-- >>> runExceptT (openFile "/dev/null" ReadMode >>= \h -> hClose h *> hClose h)+-- Right ()+--+-- >>> check $ withTests 20 $ property $ do m <- forAll (Gen.element [ReadMode, WriteMode]); r <- evalIO (runExceptT (openFile "/dev/null" m >>= hClose)); r === Right ()+-- ...passed 20 tests.+-- True+--+-- @since 0.7.0+hClose :: Handle -> IOExcept ()+hClose =+  exceptIO . IO.hClose+{-# INLINE hClose #-}++-- | Write a handle's buffer, returning the 'Control.Exception.IOException'+-- if it cannot be written.+--+-- ==== __Examples__+--+-- >>> runExceptT (withFile "/dev/null" WriteMode hFlush)+-- Right ()+--+-- A closed handle cannot be flushed:+--+-- >>> either (has (_IOException . errorType . _IllegalOperation)) (const False) <$> runExceptT (openFile "/dev/null" WriteMode >>= \h -> hClose h *> hFlush h)+-- True+--+-- >>> check $ withTests 20 $ property $ do b <- forAll Gen.bool; r <- evalIO (runExceptT (withFile "/dev/null" WriteMode (\h -> bool (pure ()) (hClose h) b *> hFlush h))); isRight r === not b+-- ...passed 20 tests.+-- True+--+-- @since 0.7.0+hFlush :: Handle -> IOExcept ()+hFlush =+  exceptIO . IO.hFlush+{-# INLINE hFlush #-}++-- | Whether a handle is at the end of its input, returning the+-- 'Control.Exception.IOException' if the handle cannot be read.+--+-- ==== __Examples__+--+-- >>> runExceptT (withFile "/dev/null" ReadMode hIsEOF)+-- Right True+--+-- >>> either (has (_IOException . errorType . _IllegalOperation)) (const False) <$> runExceptT (withFile "/dev/null" WriteMode hIsEOF)+-- True+--+-- >>> check $ withTests 20 $ property $ do m <- forAll (Gen.element [ReadMode, WriteMode]); r <- evalIO (runExceptT (withFile "/dev/null" m hIsEOF)); isRight r === (m == ReadMode)+-- ...passed 20 tests.+-- True+--+-- @since 0.7.0+hIsEOF :: Handle -> IOExcept Bool+hIsEOF =+  exceptIO . IO.hIsEOF+{-# INLINE hIsEOF #-}++-- | Set a handle's buffering, returning the 'Control.Exception.IOException'+-- if it cannot be set.+--+-- ==== __Examples__+--+-- >>> runExceptT (withFile "/dev/null" WriteMode (\h -> hSetBuffering h NoBuffering))+-- Right ()+--+-- >>> either (has (_IOException . errorType . _IllegalOperation)) (const False) <$> runExceptT (openFile "/dev/null" WriteMode >>= \h -> hClose h *> hSetBuffering h LineBuffering)+-- True+--+-- >>> check $ withTests 20 $ property $ do b <- forAll (Gen.element [NoBuffering, LineBuffering, BlockBuffering Nothing]); r <- evalIO (runExceptT (withFile "/dev/null" WriteMode (\h -> hSetBuffering h b *> exceptIO (U.hGetBuffering h)))); r === Right b+-- ...passed 20 tests.+-- True+--+-- @since 0.7.0+hSetBuffering :: Handle -> BufferMode -> IOExcept ()+hSetBuffering h =+  exceptIO . IO.hSetBuffering h+{-# INLINE hSetBuffering #-}
+ src/Papa/Base/System/IO/Except.hs view
@@ -0,0 +1,251 @@+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | I/O actions whose expected failures are values, not exceptions.+--+-- An action of type @'IOExcept' a@ returns its failure as a+-- 'Data.Either.Left' of 'Control.Monad.Trans.Except.runExceptT': an+-- 'IOFailure', which is either the 'IOException' of the operating system+-- (file not found, permission denied, a closed handle, …) or the+-- 'UnicodeException' of bytes that are not UTF-8.+--+-- The prism '_IOFailed' (or 'Control.Exception.Lens._IOException') and the+-- classy prisms of "System.IO.Error.Lens" ('System.IO.Error.Lens.errorType',+-- 'System.IO.Error.Lens._NoSuchThing', …) take an 'IOException' apart;+-- '_DecodeFailed' a decoding failure.+--+-- It catches only 'IOException', which is synchronous: asynchronous+-- exceptions ('Control.Exception.killThread', 'System.Timeout.timeout') pass+-- through, as they must.+--+-- @since 0.7.0+module Papa.Base.System.IO.Except (+  -- * Failure+  IOFailure (IOFailed, DecodeFailed),+  _IOFailed,+  _DecodeFailed,++  -- * Classy optics+  GetIOFailure (getIOFailure),+  HasIOFailure (setIOFailure, ioFailure),+  ReviewIOFailure (reviewIOFailure),+  AsIOFailure (matchIOFailure, _IOFailure),++  -- * Actions+  IOExcept,+  exceptIO,+) where++import Control.Category (id)+import Control.Exception (Exception (displayException, fromException, toException), IOException, SomeException, try)+import Control.Exception.Lens (AsIOException (_IOException))+import Control.Lens (Getter, Lens', Prism', Review, lens, prism, prism', review, unto, view)+import Control.Monad.Trans.Except (ExceptT (ExceptT))+import Data.Bifunctor (first)+import Data.Either (Either (Left, Right), either)+import Data.Eq (Eq)+import Data.Function (flip, (.))+import Data.Functor (fmap)+import Data.Maybe (Maybe (Just, Nothing))+import Data.Monoid ((<>))+import Data.Text.Encoding.Error (UnicodeException)+import Data.Tuple (uncurry)+import GHC.Generics (Generic)+import System.IO (FilePath, Handle, IO)+import Text.Show (Show (show))++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified System.IO as IO+-- >>> import qualified System.IO.Error as IO+-- >>> import Data.Text.Encoding.Error (UnicodeException (DecodeError))++-- | The failure of an I/O action: an 'IOException' of the operating system,+-- or bytes that are not UTF-8, read from a handle or a file.+--+-- ==== __Examples__+--+-- >>> runExceptT (exceptIO (IO.readFile "/nonexistent/papa"))+-- Left (IOFailed /nonexistent/papa: openFile: does not exist (No such file or directory))+--+-- >>> displayException (DecodeFailed (Right "f.txt") (DecodeError "bad" Nothing))+-- "f.txt: Cannot decode input: bad"+--+-- @since 0.7.0+data IOFailure+  = -- | An 'IOException' of the operating system.+    IOFailed IOException+  | -- | Bytes that are not UTF-8, read from a handle ('Left') or a file+    -- ('Right').+    DecodeFailed (Either Handle FilePath) UnicodeException+  deriving stock (Eq, Show, Generic)++-- | 'displayException' is that of the 'IOException', or the handle or file and the+-- decoding error.+--+-- @since 0.7.0+instance Exception IOFailure where+  displayException (IOFailed e) =+    displayException e+  displayException (DecodeFailed w e) =+    either show id w <> ": " <> displayException e++-- | The 'IOException' of an 'IOFailure'.+--+-- ==== __Examples__+--+-- >>> either (preview _IOFailed) (const Nothing) <$> runExceptT (exceptIO (IO.readFile "/nonexistent/papa"))+-- Just /nonexistent/papa: openFile: does not exist (No such file or directory)+--+-- >>> preview _IOFailed (DecodeFailed (Right "f.txt") (DecodeError "bad" Nothing))+-- Nothing+--+-- @since 0.7.0+_IOFailed :: Prism' IOFailure IOException+_IOFailed =+  prism'+    IOFailed+    ( \case+        IOFailed e -> Just e+        DecodeFailed _ _ -> Nothing+    )+{-# INLINE _IOFailed #-}++-- | The handle or file, and the decoding error, of an 'IOFailure'.+--+-- ==== __Examples__+--+-- >>> preview _DecodeFailed (DecodeFailed (Right "f.txt") (DecodeError "bad" Nothing))+-- Just (Right "f.txt",Cannot decode input: bad)+--+-- @since 0.7.0+_DecodeFailed :: Prism' IOFailure (Either Handle FilePath, UnicodeException)+_DecodeFailed =+  prism+    (uncurry DecodeFailed)+    ( \x -> case x of+        DecodeFailed w e -> Right (w, e)+        IOFailed _ -> Left x+    )+{-# INLINE _DecodeFailed #-}++-- | An 'IOFailure' is an 'IOException' by '_IOFailed', so that the classy+-- prisms of "System.IO.Error.Lens" apply to it.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (exceptIO (IO.readFile "/nonexistent/papa"))+-- True+--+-- @since 0.7.0+instance AsIOException IOFailure where+  _IOException =+    _IOFailed+  {-# INLINE _IOException #-}++-- | Values from which an 'IOFailure' can be viewed.+--+-- @since 0.7.0+class GetIOFailure s where+  getIOFailure :: Getter s IOFailure++-- | @since 0.7.0+instance GetIOFailure IOFailure where+  getIOFailure =+    id+  {-# INLINE getIOFailure #-}++-- | Values with a lens into an 'IOFailure'.+--+-- @since 0.7.0+class (GetIOFailure s) => HasIOFailure s where+  {-# MINIMAL setIOFailure #-}+  setIOFailure :: IOFailure -> s -> s+  ioFailure :: Lens' s IOFailure+  ioFailure =+    lens (view getIOFailure) (flip setIOFailure)+  {-# INLINE ioFailure #-}++-- | @since 0.7.0+instance HasIOFailure IOFailure where+  setIOFailure x _ =+    x+  {-# INLINE setIOFailure #-}++-- | Values that can be built from an 'IOFailure'.+--+-- @since 0.7.0+class ReviewIOFailure t where+  reviewIOFailure :: Review t IOFailure++-- | @since 0.7.0+instance ReviewIOFailure IOFailure where+  reviewIOFailure =+    unto id+  {-# INLINE reviewIOFailure #-}++-- | @since 0.7.0+instance ReviewIOFailure SomeException where+  reviewIOFailure =+    unto toException+  {-# INLINE reviewIOFailure #-}++-- | Values with a prism into an 'IOFailure': an error type of a program's own+-- with an 'IOFailure' among its cases.+--+-- ==== __Examples__+--+-- >>> matchIOFailure (toException (IOFailed (IO.userError "x")))+-- Just (IOFailed user error (x))+--+-- @since 0.7.0+class (ReviewIOFailure t) => AsIOFailure t where+  {-# MINIMAL matchIOFailure #-}+  matchIOFailure :: t -> Maybe IOFailure+  _IOFailure :: Prism' t IOFailure+  _IOFailure =+    prism' (review reviewIOFailure) matchIOFailure+  {-# INLINE _IOFailure #-}++-- | @since 0.7.0+instance AsIOFailure IOFailure where+  matchIOFailure =+    Just+  {-# INLINE matchIOFailure #-}++-- | @since 0.7.0+instance AsIOFailure SomeException where+  matchIOFailure =+    fromException+  {-# INLINE matchIOFailure #-}++-- | An I/O action that returns its 'IOFailure' instead of throwing it.+--+-- @since 0.7.0+type IOExcept =+  ExceptT IOFailure IO++-- | Return the 'IOException' that an I/O action throws as a+-- 'Data.Either.Left', instead of throwing it. Other exceptions are not+-- caught.+--+-- ==== __Examples__+--+-- >>> runExceptT (exceptIO (IO.readFile "/nonexistent/papa"))+-- Left (IOFailed /nonexistent/papa: openFile: does not exist (No such file or directory))+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (exceptIO (IO.readFile "/nonexistent/papa"))+-- True+--+-- >>> runExceptT (exceptIO (pure 3))+-- Right 3+--+-- @since 0.7.0+exceptIO :: IO a -> IOExcept a+exceptIO =+  ExceptT . fmap (first IOFailed) . try+{-# INLINE exceptIO #-}
+ src/Papa/Base/Text/Read.hs view
@@ -0,0 +1,53 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Total parsing of 'Prelude.Show'n values.+--+-- @read@ is not exported: it is partial. The 'Read' class is exported, so+-- that its constraint can be written, but not its methods. Do not write+-- 'Read' instances; use a parser library for anything that is not the+-- output of 'Prelude.show'.+module Papa.Base.Text.Read (+  module P,+  readIO,+) where++import Control.Applicative (pure)+import Control.Category ((.))+import Data.Maybe (Maybe)+import Data.String (String)+import Text.Read as P (+  Read,+  readEither,+  readMaybe,+  reads,+ )+import Prelude (IO)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa hiding (readEither, readIO, readMaybe)+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Total 'Prelude.readIO': 'Data.Maybe.Nothing' for a string that does not parse,+-- where "Prelude"'s @readIO@ throws an 'Prelude.IOError'.+--+-- ==== __Examples__+--+-- >>> readIO "42" :: IO (Maybe Int)+-- Just 42+--+-- >>> readIO "forty-two" :: IO (Maybe Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (readIO (show n)); r === Just n+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+readIO :: (Read a) => String -> IO (Maybe a)+readIO =+  pure . readMaybe+{-# INLINE readIO #-}
src/Papa/Bifunctors.hs view
@@ -19,20 +19,4 @@ import Data.Bifunctor.Tannen as P (Tannen (Tannen, runTannen)) import Data.Bifunctor.Wrapped as P (WrappedBifunctor (WrapBifunctor, unwrapBifunctor)) import Data.Bitraversable as P (Bitraversable (bitraverse), bifoldMapDefault, bifor, biforM, bimapAccumL, bimapAccumR, bimapDefault, bimapM, bisequence, bisequenceA)-import Data.Monoid (Monoid)--biconcat ::-  (Bifoldable p, Monoid m) =>-  p m m ->-  m-biconcat =-  bifold--biconcatMap ::-  (Bifoldable p, Monoid m) =>-  (a -> m) ->-  (b -> m) ->-  p a b ->-  m-biconcatMap =-  bifoldMap+import Papa.Bifunctors.Data.Bifoldable (biconcat, biconcatMap)
src/Papa/Bifunctors/Data/Bifoldable.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Folds of both sides of a 'Bifoldable', under the names of the list+-- functions @concat@ and @concatMap@. module Papa.Bifunctors.Data.Bifoldable (   biconcat,   biconcatMap,@@ -9,32 +11,49 @@ import Data.Bifoldable (Bifoldable (bifold, bifoldMap)) import Data.Monoid (Monoid) -{-# INLINE biconcat #-}+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genString = Gen.string (Range.linear 0 5) Gen.alpha --- | Fold a bifunctor containing monoids.+-- | Combine both sides of a 'Bifoldable' of a 'Monoid'. This is 'bifold'. ----- >>> biconcat ([1,2], [3,4])--- [1,2,3,4]--- >>> biconcat ("hello", " world")--- "hello world"-biconcat ::-  (Bifoldable p, Monoid m) =>-  p m m ->-  m+-- ==== __Examples__+--+-- >>> biconcat ("ab", "cd")+-- "abcd"+--+-- >>> biconcat (Left "ab" :: Either String String)+-- "ab"+--+-- >>> check $ withTests 100 $ property $ do a <- forAll genString; b <- forAll genString; biconcat (a, b) === a <> b+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+biconcat :: (Bifoldable p, Monoid m) => p m m -> m biconcat =   bifold--{-# INLINE biconcatMap #-}+{-# INLINE biconcat #-} --- | Map each side of a bifunctor to a monoid and combine.+-- | Map both sides of a 'Bifoldable' into a 'Monoid', and combine them.+-- This is 'bifoldMap'. ----- >>> biconcatMap (\x -> [x]) (\x -> [x]) (1, 2)--- [1,2]-biconcatMap ::-  (Bifoldable p, Monoid m) =>-  (a -> m) ->-  (b -> m) ->-  p a b ->-  m+-- ==== __Examples__+--+-- >>> biconcatMap show (: []) (1 :: Int, 'x')+-- "1x"+--+-- >>> check $ withTests 100 $ property $ do f <- forAll (fn genString); g <- forAll (fn genString); a <- forAll (Gen.int (Range.linear 0 9)); b <- forAll Gen.bool; biconcatMap (apply f) (apply g) (a, b) === apply f a <> apply g b+-- ...passed 100 tests.+-- True+--+-- @since 0.1.0+biconcatMap :: (Bifoldable p, Monoid m) => (a -> m) -> (b -> m) -> p a b -> m biconcatMap =   bifoldMap+{-# INLINE biconcatMap #-}
+ src/Papa/Bytestring/Data/ByteString.hs view
@@ -0,0 +1,543 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total head, last, tail, init, maximum and+-- minimum, whose names HLint restricts whatever module they come from; and+-- calls "Data.ByteString"'s maximum and minimum only on a byte string that is+-- not empty, for their speed.++-- | Strict byte strings, with total versions of the partial functions of+-- "Data.ByteString", and I/O that returns its errors. Import qualified:+--+-- > import qualified Papa.Bytestring.Data.ByteString as ByteString+--+-- The functions of "Data.ByteString" that throw are replaced by functions of+-- the same names that return 'Data.Maybe.Nothing' there instead:+--+-- * for an empty byte string: 'head', 'last', 'tail', 'init', 'foldl1',+--   'foldl1'', 'foldr1', 'foldr1'', 'maximum', 'minimum';+-- * for an index out of range: 'index' (which is 'X.indexMaybe').+--+-- Its I/O actions are replaced by actions of the same names that return+-- their 'Control.Exception.IOException' ('Papa.Base.System.IO.Except.IOExcept'):+-- 'getLine', 'getContents', 'putStr', 'interact', 'readFile', 'writeFile',+-- 'appendFile', 'hGetLine', 'hGetContents', 'hGet', 'hGetSome',+-- 'hGetNonBlocking', 'hPut', 'hPutNonBlocking', 'hPutStr', 'packCString',+-- 'packCStringLen', 'fromFilePath', 'toFilePath'. All of them read strictly.+--+-- The optics of @lens@ work on 'ByteString' too: @'Control.Lens.preview'+-- 'Control.Lens._head'@ and @'Control.Lens.preview' ('Control.Lens.ix' i)@+-- read a byte, and "Data.ByteString.Lens"'s @packedBytes@ and @bytes@ convert+-- and traverse.+--+-- @since 0.7.0+module Papa.Bytestring.Data.ByteString (+  module X,+  head,+  last,+  tail,+  init,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  minimum,+  index,+  getLine,+  getContents,+  putStr,+  interact,+  readFile,+  writeFile,+  appendFile,+  hGetLine,+  hGetContents,+  hGet,+  hGetSome,+  hGetNonBlocking,+  hPut,+  hPutNonBlocking,+  hPutStr,+  packCString,+  packCStringLen,+  fromFilePath,+  toFilePath,+) where++import Control.Monad (guard)+import Data.Bool (not)+import Data.ByteString as X hiding (+  appendFile,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  fromFilePath,+  getContents,+  getLine,+  hGet,+  hGetContents,+  hGetLine,+  hGetNonBlocking,+  hGetSome,+  hPut,+  hPutNonBlocking,+  hPutStr,+  head,+  index,+  init,+  interact,+  last,+  maximum,+  minimum,+  packCString,+  packCStringLen,+  putStr,+  readFile,+  tail,+  toFilePath,+  writeFile,+ )+import qualified Data.ByteString as B+import qualified Data.ByteString.Char8 as B8+import Data.Function ((.))+import Data.Functor (fmap, (<$))+import Data.Int (Int)+import Data.Maybe (Maybe)+import Data.Tuple (fst, snd, uncurry)+import Data.Word (Word8)+import Foreign.C.String (CString, CStringLen)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import System.IO (FilePath, Handle)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Bytestring.Data.ByteString as ByteString+-- >>> import qualified System.IO.Error as IO+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genBytes = Gen.bytes (Range.linear 0 20)++-- | Total 'B.head': the first byte. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.head "abc"+-- Just 97+--+-- >>> ByteString.head ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.head b === preview _head (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: ByteString -> Maybe Word8+head =+  fmap fst . B.uncons+{-# INLINE head #-}++-- | Total 'B.last': the last byte. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.last "abc"+-- Just 99+--+-- >>> ByteString.last ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.last b === preview _last (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: ByteString -> Maybe Word8+last =+  fmap snd . B.unsnoc+{-# INLINE last #-}++-- | Total 'B.tail': all but the first byte. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> ByteString.tail "abc"+-- Just "bc"+--+-- >>> ByteString.tail ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap ByteString.unpack (ByteString.tail b) === preview _tail (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: ByteString -> Maybe ByteString+tail =+  fmap snd . B.uncons+{-# INLINE tail #-}++-- | Total 'B.init': all but the last byte. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> ByteString.init "abc"+-- Just "ab"+--+-- >>> ByteString.init ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap ByteString.unpack (ByteString.init b) === preview _init (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: ByteString -> Maybe ByteString+init =+  fmap fst . B.unsnoc+{-# INLINE init #-}++-- | Total 'B.foldl1': a left fold seeded with the first byte. 'Data.Maybe.Nothing' for+-- the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.foldl1 (-) "\10\3\2"+-- Just 5+--+-- >>> ByteString.foldl1 (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.foldl1 max b === maximumOf folded (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldl1 f =+  fmap (uncurry (B.foldl f)) . B.uncons+{-# INLINE foldl1 #-}++-- | Total 'B.foldl1'': a strict left fold seeded with the first byte.+-- 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.foldl1' (-) "\10\3\2"+-- Just 5+--+-- >>> ByteString.foldl1' (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.foldl1' (-) b === ByteString.foldl1 (-) b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldl1' f =+  fmap (uncurry (B.foldl' f)) . B.uncons+{-# INLINE foldl1' #-}++-- | Total 'B.foldr1': a right fold seeded with the last byte. 'Data.Maybe.Nothing' for+-- the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.foldr1 (-) "\10\3\2"+-- Just 9+--+-- >>> ByteString.foldr1 (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.foldr1 min b === minimumOf folded (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldr1 f =+  fmap (\(b, w) -> B.foldr f w b) . B.unsnoc+{-# INLINE foldr1 #-}++-- | Total 'B.foldr1'': a strict right fold seeded with the last byte.+-- 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.foldr1' (-) "\10\3\2"+-- Just 9+--+-- >>> ByteString.foldr1' (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.foldr1' (-) b === ByteString.foldr1 (-) b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldr1' f =+  fmap (\(b, w) -> B.foldr' f w b) . B.unsnoc+{-# INLINE foldr1' #-}++-- | Total 'B.maximum': the greatest byte. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> ByteString.maximum "abca"+-- Just 99+--+-- >>> ByteString.maximum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.maximum b === maximumOf folded (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: ByteString -> Maybe Word8+maximum b =+  B.maximum b <$ guard (not (B.null b))+{-# INLINE maximum #-}++-- | Total 'B.minimum': the least byte. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> ByteString.minimum "bcab"+-- Just 97+--+-- >>> ByteString.minimum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; ByteString.minimum b === minimumOf folded (ByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: ByteString -> Maybe Word8+minimum b =+  B.minimum b <$ guard (not (B.null b))+{-# INLINE minimum #-}++-- | Total 'B.index': the byte at a position, counting from 0. 'Data.Maybe.Nothing' for a+-- negative index or one past the end. This is 'X.indexMaybe'.+--+-- ==== __Examples__+--+-- >>> ByteString.index "abc" 1+-- Just 98+--+-- >>> ByteString.index "abc" 3+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; i <- forAll (Gen.int (Range.linear (-3) 25)); ByteString.index b i === (ByteString.unpack b !! i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+index :: ByteString -> Int -> Maybe Word8+index =+  B.indexMaybe+{-# INLINE index #-}++-- | Read a line from 'System.IO.stdin', up to a newline byte, which is+-- removed. See 'hGetLine'.+--+-- @since 0.7.0+getLine :: IOExcept ByteString+getLine =+  exceptIO B8.getLine+{-# INLINE getLine #-}++-- | Read all of 'System.IO.stdin'.+--+-- @since 0.7.0+getContents :: IOExcept ByteString+getContents =+  exceptIO B.getContents+{-# INLINE getContents #-}++-- | Write to 'System.IO.stdout'.+--+-- @since 0.7.0+putStr :: ByteString -> IOExcept ()+putStr =+  exceptIO . B.putStr+{-# INLINE putStr #-}++-- | Read all of 'System.IO.stdin', and write a function of it to+-- 'System.IO.stdout'.+--+-- @since 0.7.0+interact :: (ByteString -> ByteString) -> IOExcept ()+interact =+  exceptIO . B.interact+{-# INLINE interact #-}++-- | Read a file.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (ByteString.readFile "/nonexistent/papa")+-- True+--+-- @since 0.7.0+readFile :: FilePath -> IOExcept ByteString+readFile =+  exceptIO . B.readFile+{-# INLINE readFile #-}++-- | Write a file, replacing it.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (ByteString.writeFile "/nonexistent/papa" "x")+-- True+--+-- @since 0.7.0+writeFile :: FilePath -> ByteString -> IOExcept ()+writeFile p =+  exceptIO . B.writeFile p+{-# INLINE writeFile #-}++-- | Append to a file.+--+-- @since 0.7.0+appendFile :: FilePath -> ByteString -> IOExcept ()+appendFile p =+  exceptIO . B.appendFile p+{-# INLINE appendFile #-}++-- | Read a line from a handle, up to a newline byte (@\\n@), which is+-- removed; a carriage return before it is kept. An end-of-file error at the+-- end of the handle.+--+-- @since 0.7.0+hGetLine :: Handle -> IOExcept ByteString+hGetLine =+  exceptIO . B8.hGetLine+{-# INLINE hGetLine #-}++-- | Read the rest of a handle, and close it.+--+-- @since 0.7.0+hGetContents :: Handle -> IOExcept ByteString+hGetContents =+  exceptIO . B.hGetContents+{-# INLINE hGetContents #-}++-- | Read up to the given number of bytes from a handle, waiting for all of+-- them unless the end is reached. An error for a negative number.+--+-- @since 0.7.0+hGet :: Handle -> Int -> IOExcept ByteString+hGet h =+  exceptIO . B.hGet h+{-# INLINE hGet #-}++-- | Read up to the given number of bytes from a handle, waiting for at least+-- one unless the end is reached. An error for a negative number.+--+-- @since 0.7.0+hGetSome :: Handle -> Int -> IOExcept ByteString+hGetSome h =+  exceptIO . B.hGetSome h+{-# INLINE hGetSome #-}++-- | Read up to the given number of bytes from a handle, without waiting. An+-- error for a negative number.+--+-- @since 0.7.0+hGetNonBlocking :: Handle -> Int -> IOExcept ByteString+hGetNonBlocking h =+  exceptIO . B.hGetNonBlocking h+{-# INLINE hGetNonBlocking #-}++-- | Write to a handle.+--+-- @since 0.7.0+hPut :: Handle -> ByteString -> IOExcept ()+hPut h =+  exceptIO . B.hPut h+{-# INLINE hPut #-}++-- | Write to a handle without waiting, and return what was not written.+--+-- @since 0.7.0+hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString+hPutNonBlocking h =+  exceptIO . B.hPutNonBlocking h+{-# INLINE hPutNonBlocking #-}++-- | Write to a handle. This is 'hPut'.+--+-- @since 0.7.0+hPutStr :: Handle -> ByteString -> IOExcept ()+hPutStr h =+  exceptIO . B.hPutStr h+{-# INLINE hPutStr #-}++-- | Copy a NUL-terminated C string. The pointer must point to one.+--+-- @since 0.7.0+packCString :: CString -> IOExcept ByteString+packCString =+  exceptIO . B.packCString+{-# INLINE packCString #-}++-- | Copy a C string of the given length. An error for a negative length; the+-- pointer must point to that many bytes.+--+-- @since 0.7.0+packCStringLen :: CStringLen -> IOExcept ByteString+packCStringLen =+  exceptIO . B.packCStringLen+{-# INLINE packCStringLen #-}++-- | The bytes of a file path, in the file system's encoding. An error for a+-- path that the encoding cannot represent.+--+-- ==== __Examples__+--+-- >>> runExceptT (ByteString.fromFilePath "a/b")+-- Right "a/b"+--+-- @since 0.7.0+fromFilePath :: FilePath -> IOExcept ByteString+fromFilePath =+  exceptIO . B.fromFilePath+{-# INLINE fromFilePath #-}++-- | The file path of some bytes, in the file system's encoding. An error for+-- bytes that the encoding cannot decode.+--+-- ==== __Examples__+--+-- >>> runExceptT (ByteString.toFilePath "a/b")+-- Right "a/b"+--+-- >>> check $ withTests 100 $ property $ do p <- forAll (Gen.string (Range.linear 0 10) Gen.alphaNum); r <- evalIO (runExceptT (ByteString.fromFilePath p >>= ByteString.toFilePath)); r === Right p+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+toFilePath :: ByteString -> IOExcept FilePath+toFilePath =+  exceptIO . B.toFilePath+{-# INLINE toFilePath #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Bytestring/Data/ByteString/Builder.hs view
@@ -0,0 +1,171 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Building byte strings, with no silent truncation, and I/O that returns+-- its errors. Import qualified:+--+-- > import qualified Papa.Bytestring.Data.ByteString.Builder as Builder+--+-- "Data.ByteString.Builder"'s @char7@ and @string7@ store a character's code+-- point modulo 128, and @char8@ and @string8@ modulo 256. They are replaced by+-- functions of the same names that return 'Data.Maybe.Nothing' for a character that+-- does not fit. 'X.charUtf8' and 'X.stringUtf8' encode every character.+--+-- 'hPutBuilder' and 'writeFile' return their+-- 'Control.Exception.IOException' ('Papa.Base.System.IO.Except.IOExcept').+--+-- @since 0.7.0+module Papa.Bytestring.Data.ByteString.Builder (+  module X,+  char7,+  string7,+  char8,+  string8,+  hPutBuilder,+  writeFile,+) where++import Control.Monad (guard)+import Data.Bool (Bool)+import Data.ByteString.Builder as X hiding (+  char7,+  char8,+  hPutBuilder,+  string7,+  string8,+  writeFile,+ )+import qualified Data.ByteString.Builder as B+import Data.Char (Char)+import Data.Foldable (all)+import Data.Function ((.))+import Data.Functor ((<$))+import Data.Maybe (Maybe)+import Data.Ord ((<=))+import Data.String (String)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import Papa.Internal.Char8 (latin1, latin1s)+import System.IO (FilePath, Handle)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Bytestring.Data.ByteString.Builder as Builder+-- >>> import qualified Data.ByteString.Lazy as LB+-- >>> import qualified System.IO.Error as IO+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genChar = Gen.frequency [(9, Gen.latin1), (1, Gen.element "\256\1000\1114111")]+-- >>> let genString = Gen.string (Range.linear 0 20) genChar++-- | Checked 'B.char7': a character as a 7-bit byte. 'Data.Maybe.Nothing' for a+-- character above @\'\\127\'@.+--+-- ==== __Examples__+--+-- >>> Builder.toLazyByteString <$> Builder.char7 'a'+-- Just "a"+--+-- >>> Builder.toLazyByteString <$> Builder.char7 '\128'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; fmap Builder.toLazyByteString (Builder.char7 c) === (Builder.toLazyByteString (Builder.charUtf8 c) <$ guard (c <= '\127'))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+char7 :: Char -> Maybe Builder+char7 c =+  B.char7 c <$ guard (ascii c)+{-# INLINE char7 #-}++-- | Checked 'B.string7': a string as 7-bit bytes. 'Data.Maybe.Nothing' if a character+-- is above @\'\\127\'@.+--+-- ==== __Examples__+--+-- >>> Builder.toLazyByteString <$> Builder.string7 "abc"+-- Just "abc"+--+-- >>> Builder.toLazyByteString <$> Builder.string7 "caf\233"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; fmap Builder.toLazyByteString (Builder.string7 s) === (Builder.toLazyByteString (Builder.stringUtf8 s) <$ guard (all (<= '\127') s))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+string7 :: String -> Maybe Builder+string7 s =+  B.string7 s <$ guard (all ascii s)+{-# INLINE string7 #-}++-- | Checked 'B.char8': a character as a byte. 'Data.Maybe.Nothing' for a character+-- above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Builder.toLazyByteString <$> Builder.char8 '\233'+-- Just "\233"+--+-- >>> Builder.toLazyByteString <$> Builder.char8 '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; fmap Builder.toLazyByteString (Builder.char8 c) === fmap Builder.toLazyByteString (Builder.string8 [c])+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+char8 :: Char -> Maybe Builder+char8 c =+  B.char8 c <$ guard (latin1 c)+{-# INLINE char8 #-}++-- | Checked 'B.string8': a string as bytes. 'Data.Maybe.Nothing' if a character is+-- above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Builder.toLazyByteString <$> Builder.string8 "caf\233"+-- Just "caf\233"+--+-- >>> Builder.toLazyByteString <$> Builder.string8 "\256"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; fmap (\b -> LB.length (Builder.toLazyByteString b)) (Builder.string8 s) === (intCast (length s) <$ guard (all (<= '\255') s))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+string8 :: String -> Maybe Builder+string8 s =+  B.string8 s <$ latin1s s+{-# INLINE string8 #-}++-- | Write a builder to a handle.+--+-- @since 0.7.0+hPutBuilder :: Handle -> Builder -> IOExcept ()+hPutBuilder h =+  exceptIO . B.hPutBuilder h+{-# INLINE hPutBuilder #-}++-- | Write a builder to a file, replacing it.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (Builder.writeFile "/nonexistent/papa" mempty)+-- True+--+-- @since 0.7.0+writeFile :: FilePath -> Builder -> IOExcept ()+writeFile p =+  exceptIO . B.writeFile p+{-# INLINE writeFile #-}++-- | Whether a character is ASCII: @\'\\0\'@ to @\'\\127\'@.+ascii :: Char -> Bool+ascii c =+  c <= '\127'+{-# INLINE ascii #-}
+ src/Papa/Bytestring/Data/ByteString/Char8.hs view
@@ -0,0 +1,930 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Redundant lambda" -}+-- Reason: a function whose byte string follows other arguments (@map f@,+-- @split c@) takes the byte string in a lambda, because GHC inlines a+-- function only once it is applied to the arguments on the left of its+-- definition: so a partial application, passed to a higher-order+-- function, is inlined too.++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total head, last, tail, init, maximum and+-- minimum, whose names HLint restricts whatever module they come from; and+-- calls "Data.ByteString"'s maximum and minimum only on a byte string that is+-- not empty, for their speed.++-- | Strict byte strings as characters @\'\\0\'@ to @\'\\255\'@, with total+-- versions of the partial functions of "Data.ByteString.Char8", no silent+-- truncation, and I/O that returns its errors. Import qualified:+--+-- > import qualified Papa.Bytestring.Data.ByteString.Char8 as Char8+--+-- "Data.ByteString.Char8" stores a character as its code point modulo 256,+-- so that @pack "\\256"@ is @"\\NUL"@, and @elem \'\\256\' "\\NUL"@ is+-- 'Data.Bool.True'. Here:+--+-- * the functions that build a byte string from characters return 'Data.Maybe.Nothing'+--   for a character above @\'\\255\'@: 'pack', 'singleton', 'cons', 'snoc',+--   'intersperse', 'replicate', 'map', 'unfoldr', 'unzip';+-- * the functions that look for a character do not find one above+--   @\'\\255\'@: 'elem', 'notElem', 'elemIndex', 'elemIndices',+--   'elemIndexEnd', 'count', 'split';+-- * the folds 'foldl1', 'foldl1'', 'foldr1', 'foldr1'' fold characters, not+--   bytes, so that an intermediate character above @\'\\255\'@ is kept;+-- * the functions whose function argument builds characters into a byte+--   string are not exported: @mapAccumL@, @mapAccumR@, @scanl@, @scanl1@,+--   @scanr@, @scanr1@, @unfoldrN@, @packZipWith@. Use+--   "Papa.Bytestring.Data.ByteString"'s, on bytes.+--+-- The functions that throw are replaced by functions of the same names that+-- return 'Data.Maybe.Nothing' there instead: 'head', 'last', 'tail', 'init', 'foldl1',+-- 'foldl1'', 'foldr1', 'foldr1'', 'maximum', 'minimum' for an empty byte+-- string, and 'index' for an index out of range.+--+-- Its I/O actions are replaced by actions of the same names that return+-- their 'Control.Exception.IOException' ('Papa.Base.System.IO.Except.IOExcept').+--+-- For text, use "Papa.Text.Data.Text" and UTF-8.+--+-- @since 0.7.0+module Papa.Bytestring.Data.ByteString.Char8 (+  module X,+  head,+  last,+  tail,+  init,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  minimum,+  index,+  pack,+  singleton,+  cons,+  snoc,+  intersperse,+  replicate,+  map,+  unfoldr,+  unzip,+  elem,+  notElem,+  elemIndex,+  elemIndices,+  elemIndexEnd,+  count,+  split,+  getLine,+  getContents,+  putStr,+  putStrLn,+  interact,+  readFile,+  writeFile,+  appendFile,+  hGetLine,+  hGetContents,+  hGet,+  hGetSome,+  hGetNonBlocking,+  hPut,+  hPutNonBlocking,+  hPutStr,+  hPutStrLn,+  packCString,+  packCStringLen,+) where++import Control.Applicative (liftA2, (*>))+import Control.Monad (guard)+import Data.Bool (Bool (False), bool, not, (&&))+import qualified Data.ByteString as B+import Data.ByteString.Char8 as X hiding (+  appendFile,+  cons,+  count,+  elem,+  elemIndex,+  elemIndexEnd,+  elemIndices,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  getContents,+  getLine,+  hGet,+  hGetContents,+  hGetLine,+  hGetNonBlocking,+  hGetSome,+  hPut,+  hPutNonBlocking,+  hPutStr,+  hPutStrLn,+  head,+  index,+  init,+  interact,+  intersperse,+  last,+  map,+  mapAccumL,+  mapAccumR,+  maximum,+  minimum,+  notElem,+  pack,+  packCString,+  packCStringLen,+  packZipWith,+  putStr,+  putStrLn,+  readFile,+  replicate,+  scanl,+  scanl1,+  scanr,+  scanr1,+  singleton,+  snoc,+  split,+  tail,+  unfoldr,+  unfoldrN,+  unzip,+  writeFile,+ )+import qualified Data.ByteString.Char8 as C+import Data.Char (Char)+import Data.Function (const, (.))+import Data.Functor (fmap, (<$))+import Data.Int (Int)+import qualified Data.List as List+import Data.Maybe (Maybe)+import Data.Tuple (fst, snd, uncurry)+import Foreign.C.String (CString, CStringLen)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import Papa.Internal.Char8 (latin1, latin1s)+import System.IO (FilePath, Handle)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Data.List as L+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Bytestring.Data.ByteString.Char8 as Char8+-- >>> import qualified Data.ByteString.Char8 as C+-- >>> import qualified System.IO.Error as IO+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genChar = Gen.frequency [(9, Gen.latin1), (1, Gen.element "\256\1000\1114111")]+-- >>> let genString = Gen.string (Range.linear 0 20) genChar+-- >>> let genBytes = C.pack <$> Gen.string (Range.linear 0 20) Gen.latin1++-- | Total 'C.head': the first character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> Char8.head "abc"+-- Just 'a'+--+-- >>> Char8.head ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.head b === preview _head (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: ByteString -> Maybe Char+head =+  fmap fst . C.uncons+{-# INLINE head #-}++-- | Total 'C.last': the last character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> Char8.last "abc"+-- Just 'c'+--+-- >>> Char8.last ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.last b === preview _last (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: ByteString -> Maybe Char+last =+  fmap snd . C.unsnoc+{-# INLINE last #-}++-- | Total 'C.tail': all but the first character. 'Data.Maybe.Nothing' for the empty+-- byte string.+--+-- ==== __Examples__+--+-- >>> Char8.tail "abc"+-- Just "bc"+--+-- >>> Char8.tail ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap Char8.unpack (Char8.tail b) === preview _tail (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: ByteString -> Maybe ByteString+tail =+  fmap snd . C.uncons+{-# INLINE tail #-}++-- | Total 'C.init': all but the last character. 'Data.Maybe.Nothing' for the empty+-- byte string.+--+-- ==== __Examples__+--+-- >>> Char8.init "abc"+-- Just "ab"+--+-- >>> Char8.init ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap Char8.unpack (Char8.init b) === preview _init (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: ByteString -> Maybe ByteString+init =+  fmap fst . C.unsnoc+{-# INLINE init #-}++-- | Total 'C.foldl1': a left fold of the characters, seeded with the first.+-- 'Data.Maybe.Nothing' for the empty byte string. Unlike "Data.ByteString.Char8"'s, an+-- intermediate character above @\'\\255\'@ is kept.+--+-- ==== __Examples__+--+-- >>> Char8.foldl1 max "abca"+-- Just 'c'+--+-- >>> Char8.foldl1 (\a c -> bool a '\300' (c == 'b')) "ab"+-- Just '\300'+--+-- >>> Char8.foldl1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.foldl1 max b === maximumOf folded (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldl1 f =+  fmap (uncurry (C.foldl f)) . C.uncons+{-# INLINE foldl1 #-}++-- | Total 'C.foldl1'': a strict left fold of the characters, seeded with the+-- first. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> Char8.foldl1' max "abca"+-- Just 'c'+--+-- >>> Char8.foldl1' max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.foldl1' min b === Char8.foldl1 min b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldl1' f =+  fmap (uncurry (C.foldl' f)) . C.uncons+{-# INLINE foldl1' #-}++-- | Total 'C.foldr1': a right fold of the characters, seeded with the last.+-- 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> Char8.foldr1 max "abca"+-- Just 'c'+--+-- >>> Char8.foldr1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.foldr1 min b === minimumOf folded (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldr1 f =+  fmap (\(b, c) -> C.foldr f c b) . C.unsnoc+{-# INLINE foldr1 #-}++-- | Total 'C.foldr1'': a strict right fold of the characters, seeded with the+-- last. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> Char8.foldr1' max "abca"+-- Just 'c'+--+-- >>> Char8.foldr1' max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.foldr1' min b === Char8.foldr1 min b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldr1' f =+  fmap (\(b, c) -> C.foldr' f c b) . C.unsnoc+{-# INLINE foldr1' #-}++-- | Total 'C.maximum': the greatest character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> Char8.maximum "abca"+-- Just 'c'+--+-- >>> Char8.maximum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.maximum b === maximumOf folded (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: ByteString -> Maybe Char+maximum b =+  C.maximum b <$ guard (not (B.null b))+{-# INLINE maximum #-}++-- | Total 'C.minimum': the least character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> Char8.minimum "bcab"+-- Just 'a'+--+-- >>> Char8.minimum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; Char8.minimum b === minimumOf folded (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: ByteString -> Maybe Char+minimum b =+  C.minimum b <$ guard (not (B.null b))+{-# INLINE minimum #-}++-- | Total 'C.index': the character at a position, counting from 0. 'Data.Maybe.Nothing'+-- for a negative index or one past the end.+--+-- ==== __Examples__+--+-- >>> Char8.index "abc" 1+-- Just 'b'+--+-- >>> Char8.index "abc" 3+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; i <- forAll (Gen.int (Range.linear (-3) 25)); Char8.index b i === (Char8.unpack b !! i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+index :: ByteString -> Int -> Maybe Char+index =+  C.indexMaybe+{-# INLINE index #-}++-- | Checked 'C.pack': the byte string of some characters. 'Data.Maybe.Nothing' if one is+-- above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.pack "caf\233"+-- Just "caf\233"+--+-- >>> Char8.pack "\256"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; fmap Char8.unpack (Char8.pack s) === (s <$ guard (P.all (<= '\255') s))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+pack :: [Char] -> Maybe ByteString+pack s =+  C.pack s <$ latin1s s+{-# INLINE pack #-}++-- | Checked 'C.singleton': the byte string of a character. 'Data.Maybe.Nothing' for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.singleton 'a'+-- Just "a"+--+-- >>> Char8.singleton '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; Char8.singleton c === Char8.pack [c]+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+singleton :: Char -> Maybe ByteString+singleton c =+  C.singleton c <$ guard (latin1 c)+{-# INLINE singleton #-}++-- | Checked 'C.cons': a character before a byte string. 'Data.Maybe.Nothing' for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.cons 'a' "bc"+-- Just "abc"+--+-- >>> Char8.cons '\256' "bc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.cons c b === fmap (<> b) (Char8.singleton c)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+cons :: Char -> ByteString -> Maybe ByteString+cons c =+  \b -> C.cons c b <$ guard (latin1 c)+{-# INLINE cons #-}++-- | Checked 'C.snoc': a character after a byte string. 'Data.Maybe.Nothing' for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.snoc "ab" 'c'+-- Just "abc"+--+-- >>> Char8.snoc "ab" '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.snoc b c === fmap (b <>) (Char8.singleton c)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+snoc :: ByteString -> Char -> Maybe ByteString+snoc b c =+  C.snoc b c <$ guard (latin1 c)+{-# INLINE snoc #-}++-- | Checked 'C.intersperse': a character between each two of a byte+-- string's. 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.intersperse ',' "abc"+-- Just "a,b,c"+--+-- >>> Char8.intersperse '\256' "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; fmap Char8.unpack (Char8.intersperse c b) === (P.intersperse c (Char8.unpack b) <$ guard (c <= '\255'))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+intersperse :: Char -> ByteString -> Maybe ByteString+intersperse c =+  \b -> C.intersperse c b <$ guard (latin1 c)+{-# INLINE intersperse #-}++-- | Checked 'C.replicate': a character repeated a number of times (none for+-- a number below 1). 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.replicate 3 'a'+-- Just "aaa"+--+-- >>> Char8.replicate 3 '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-2) 10)); c <- forAll genChar; Char8.replicate n c === (Char8.pack (P.replicate n c) <* guard (c <= '\255'))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+replicate :: Int -> Char -> Maybe ByteString+replicate n c =+  C.replicate n c <$ guard (latin1 c)+{-# INLINE replicate #-}++-- | Checked 'C.map': a function of each character. 'Data.Maybe.Nothing' if it gives a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.map toUpper "abc"+-- Just "ABC"+--+-- >>> Char8.map (P.const '\256') "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; c <- forAll genChar; Char8.map (\x -> bool c 'x' (x == 'a')) b === Char8.pack (fmap (\x -> bool c 'x' (x == 'a')) (Char8.unpack b))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+map :: (Char -> Char) -> ByteString -> Maybe ByteString+map f =+  \b -> C.map f b <$ guard (C.all (latin1 . f) b)+{-# INLINE map #-}++-- | Checked 'C.unfoldr': the byte string of the characters that a function+-- unfolds from a seed. 'Data.Maybe.Nothing' if one is above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.unfoldr P.uncons "abc"+-- Just "abc"+--+-- >>> Char8.unfoldr P.uncons "a\256"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; Char8.unfoldr P.uncons s === Char8.pack s+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+unfoldr :: (a -> Maybe (Char, a)) -> a -> Maybe ByteString+unfoldr f =+  pack . List.unfoldr f+{-# INLINE unfoldr #-}++-- | Checked 'C.unzip': the byte strings of the first and second characters+-- of some pairs. 'Data.Maybe.Nothing' if one is above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.unzip [('a', 'b'), ('c', 'd')]+-- Just ("ac","bd")+--+-- >>> Char8.unzip [('a', '\256')]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; t <- forAll genString; Char8.unzip (P.zip s t) === liftA2 (,) (Char8.pack (fmap P.fst (P.zip s t))) (Char8.pack (fmap P.snd (P.zip s t)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+unzip :: [(Char, Char)] -> Maybe (ByteString, ByteString)+unzip ps =+  liftA2 (,) (pack (fmap fst ps)) (pack (fmap snd ps))+{-# INLINE unzip #-}++-- | Checked 'C.elem': whether a character is in a byte string; never for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.elem 'b' "abc"+-- True+--+-- >>> Char8.elem '\256' "\NUL"+-- False+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.elem c b === P.elem c (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elem :: Char -> ByteString -> Bool+elem c =+  \b -> latin1 c && C.elem c b+{-# INLINE elem #-}++-- | Checked 'C.notElem': whether a character is not in a byte string; always+-- for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.notElem 'd' "abc"+-- True+--+-- >>> Char8.notElem '\256' "\NUL"+-- True+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.notElem c b === P.notElem c (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+notElem :: Char -> ByteString -> Bool+notElem c =+  not . elem c+{-# INLINE notElem #-}++-- | Checked 'C.elemIndex': the position of the first occurrence of a+-- character; 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.elemIndex 'b' "abcb"+-- Just 1+--+-- >>> Char8.elemIndex '\256' "\NUL"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.elemIndex c b === L.elemIndex c (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elemIndex :: Char -> ByteString -> Maybe Int+elemIndex c =+  \b -> guard (latin1 c) *> C.elemIndex c b+{-# INLINE elemIndex #-}++-- | Checked 'C.elemIndices': the positions of the occurrences of a+-- character; none for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.elemIndices 'b' "abcb"+-- [1,3]+--+-- >>> Char8.elemIndices '\256' "\NUL"+-- []+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.elemIndices c b === L.elemIndices c (Char8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elemIndices :: Char -> ByteString -> [Int]+elemIndices c =+  \b -> bool [] (C.elemIndices c b) (latin1 c)+{-# INLINE elemIndices #-}++-- | Checked 'C.elemIndexEnd': the position of the last occurrence of a+-- character; 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.elemIndexEnd 'b' "abcb"+-- Just 3+--+-- >>> Char8.elemIndexEnd '\256' "\NUL"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.elemIndexEnd c b === preview _last (L.elemIndices c (Char8.unpack b))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elemIndexEnd :: Char -> ByteString -> Maybe Int+elemIndexEnd c =+  \b -> guard (latin1 c) *> C.elemIndexEnd c b+{-# INLINE elemIndexEnd #-}++-- | Checked 'C.count': the number of occurrences of a character; 0 for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.count 'b' "abcb"+-- 2+--+-- >>> Char8.count '\256' "\NUL"+-- 0+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.count c b === P.length (L.elemIndices c (Char8.unpack b))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+count :: Char -> ByteString -> Int+count c =+  \b -> bool 0 (C.count c b) (latin1 c)+{-# INLINE count #-}++-- | Checked 'C.split': the pieces of a byte string between occurrences of a+-- character (none for the empty byte string); the whole byte string for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> Char8.split ',' "a,b,,c"+-- ["a","b","","c"]+--+-- >>> Char8.split '\256' "a\NULb"+-- ["a\NULb"]+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; Char8.split c b === bool (Char8.splitWith (== c) b) [] (Char8.null b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+split :: Char -> ByteString -> [ByteString]+split c =+  \b -> bool (B.splitWith (const False) b) (C.split c b) (latin1 c)+{-# INLINE split #-}++-- | Read a line from 'System.IO.stdin', up to a newline byte, which is+-- removed. See 'hGetLine'.+--+-- @since 0.7.0+getLine :: IOExcept ByteString+getLine =+  exceptIO C.getLine+{-# INLINE getLine #-}++-- | Read all of 'System.IO.stdin'.+--+-- @since 0.7.0+getContents :: IOExcept ByteString+getContents =+  exceptIO C.getContents+{-# INLINE getContents #-}++-- | Write to 'System.IO.stdout'.+--+-- @since 0.7.0+putStr :: ByteString -> IOExcept ()+putStr =+  exceptIO . C.putStr+{-# INLINE putStr #-}++-- | Write to 'System.IO.stdout', and a newline byte.+--+-- @since 0.7.0+putStrLn :: ByteString -> IOExcept ()+putStrLn =+  exceptIO . C.putStrLn+{-# INLINE putStrLn #-}++-- | Read all of 'System.IO.stdin', and write a function of it to+-- 'System.IO.stdout'.+--+-- @since 0.7.0+interact :: (ByteString -> ByteString) -> IOExcept ()+interact =+  exceptIO . C.interact+{-# INLINE interact #-}++-- | Read a file.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (P.const False) <$> runExceptT (Char8.readFile "/nonexistent/papa")+-- True+--+-- @since 0.7.0+readFile :: FilePath -> IOExcept ByteString+readFile =+  exceptIO . C.readFile+{-# INLINE readFile #-}++-- | Write a file, replacing it.+--+-- @since 0.7.0+writeFile :: FilePath -> ByteString -> IOExcept ()+writeFile p =+  exceptIO . C.writeFile p+{-# INLINE writeFile #-}++-- | Append to a file.+--+-- @since 0.7.0+appendFile :: FilePath -> ByteString -> IOExcept ()+appendFile p =+  exceptIO . C.appendFile p+{-# INLINE appendFile #-}++-- | Read a line from a handle, up to a newline byte (@\\n@), which is+-- removed; a carriage return before it is kept. An end-of-file error at the+-- end of the handle.+--+-- @since 0.7.0+hGetLine :: Handle -> IOExcept ByteString+hGetLine =+  exceptIO . C.hGetLine+{-# INLINE hGetLine #-}++-- | Read the rest of a handle, and close it.+--+-- @since 0.7.0+hGetContents :: Handle -> IOExcept ByteString+hGetContents =+  exceptIO . C.hGetContents+{-# INLINE hGetContents #-}++-- | Read up to the given number of bytes from a handle, waiting for all of+-- them unless the end is reached. An error for a negative number.+--+-- @since 0.7.0+hGet :: Handle -> Int -> IOExcept ByteString+hGet h =+  exceptIO . C.hGet h+{-# INLINE hGet #-}++-- | Read up to the given number of bytes from a handle, waiting for at least+-- one unless the end is reached. An error for a negative number.+--+-- @since 0.7.0+hGetSome :: Handle -> Int -> IOExcept ByteString+hGetSome h =+  exceptIO . C.hGetSome h+{-# INLINE hGetSome #-}++-- | Read up to the given number of bytes from a handle, without waiting. An+-- error for a negative number.+--+-- @since 0.7.0+hGetNonBlocking :: Handle -> Int -> IOExcept ByteString+hGetNonBlocking h =+  exceptIO . C.hGetNonBlocking h+{-# INLINE hGetNonBlocking #-}++-- | Write to a handle.+--+-- @since 0.7.0+hPut :: Handle -> ByteString -> IOExcept ()+hPut h =+  exceptIO . C.hPut h+{-# INLINE hPut #-}++-- | Write to a handle without waiting, and return what was not written.+--+-- @since 0.7.0+hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString+hPutNonBlocking h =+  exceptIO . C.hPutNonBlocking h+{-# INLINE hPutNonBlocking #-}++-- | Write to a handle. This is 'hPut'.+--+-- @since 0.7.0+hPutStr :: Handle -> ByteString -> IOExcept ()+hPutStr h =+  exceptIO . C.hPutStr h+{-# INLINE hPutStr #-}++-- | Write to a handle, and a newline byte.+--+-- @since 0.7.0+hPutStrLn :: Handle -> ByteString -> IOExcept ()+hPutStrLn h =+  exceptIO . C.hPutStrLn h+{-# INLINE hPutStrLn #-}++-- | Copy a NUL-terminated C string. The pointer must point to one.+--+-- @since 0.7.0+packCString :: CString -> IOExcept ByteString+packCString =+  exceptIO . C.packCString+{-# INLINE packCString #-}++-- | Copy a C string of the given length. An error for a negative length; the+-- pointer must point to that many bytes.+--+-- @since 0.7.0+packCStringLen :: CStringLen -> IOExcept ByteString+packCStringLen =+  exceptIO . C.packCStringLen+{-# INLINE packCStringLen #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Bytestring/Data/ByteString/Lazy.hs view
@@ -0,0 +1,433 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total head, last, tail, init, maximum and+-- minimum, whose names HLint restricts whatever module they come from; and+-- calls "Data.ByteString.Lazy"'s maximum and minimum only on a byte string+-- that is not empty, for their speed.++-- | Lazy byte strings, with total versions of the partial functions of+-- "Data.ByteString.Lazy", and I/O that returns its errors. Import qualified:+--+-- > import qualified Papa.Bytestring.Data.ByteString.Lazy as LazyByteString+--+-- The functions of "Data.ByteString.Lazy" that throw are replaced by+-- functions of the same names that return 'Data.Maybe.Nothing' there instead:+--+-- * for an empty byte string: 'head', 'last', 'tail', 'init', 'foldl1',+--   'foldl1'', 'foldr1', 'foldr1'', 'maximum', 'minimum', 'cycle';+-- * for an index out of range: 'index' (which is 'X.indexMaybe').+--+-- Its I/O actions that write, or read a given number of bytes, are replaced+-- by actions of the same names that return their+-- 'Control.Exception.IOException' ('Papa.Base.System.IO.Except.IOExcept'):+-- 'putStr', 'writeFile', 'appendFile', 'hPut', 'hPutNonBlocking', 'hPutStr',+-- 'hGet', 'hGetNonBlocking'.+--+-- Its lazy readers (@readFile@, @getContents@, @hGetContents@, @interact@)+-- are lazy I/O, which throws from pure code once the handle fails, and are+-- not exported: read a strict byte string with+-- "Papa.Bytestring.Data.ByteString" and convert it with 'X.fromStrict'.+--+-- 'X.repeat', 'X.iterate' and 'cycle' build an infinite byte string: a+-- function that reads all of it does not return.+--+-- @since 0.7.0+module Papa.Bytestring.Data.ByteString.Lazy (+  module X,+  head,+  last,+  tail,+  init,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  minimum,+  cycle,+  index,+  putStr,+  writeFile,+  appendFile,+  hPut,+  hPutNonBlocking,+  hPutStr,+  hGet,+  hGetNonBlocking,+) where++import Control.Monad (guard)+import Data.Bool (not)+import Data.ByteString.Lazy as X hiding (+  appendFile,+  cycle,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  getContents,+  hGet,+  hGetContents,+  hGetNonBlocking,+  hPut,+  hPutNonBlocking,+  hPutStr,+  head,+  index,+  init,+  interact,+  last,+  maximum,+  minimum,+  putStr,+  readFile,+  tail,+  writeFile,+ )+import qualified Data.ByteString.Lazy as L+import Data.Function ((.))+import Data.Functor (fmap, (<$))+import Data.Int (Int, Int64)+import Data.Maybe (Maybe)+import Data.Tuple (fst, snd, uncurry)+import Data.Word (Word8)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import System.IO (FilePath, Handle)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Bytestring.Data.ByteString.Lazy as LazyByteString+-- >>> import qualified System.IO.Error as IO+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genBytes = LazyByteString.fromChunks <$> Gen.list (Range.linear 0 4) (Gen.bytes (Range.linear 0 6))++-- | Total 'L.head': the first byte. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.head "abc"+-- Just 97+--+-- >>> LazyByteString.head ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.head b === preview _head (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: ByteString -> Maybe Word8+head =+  fmap fst . L.uncons+{-# INLINE head #-}++-- | Total 'L.last': the last byte. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.last "abc"+-- Just 99+--+-- >>> LazyByteString.last ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.last b === preview _last (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: ByteString -> Maybe Word8+last =+  fmap snd . L.unsnoc+{-# INLINE last #-}++-- | Total 'L.tail': all but the first byte. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.tail "abc"+-- Just "bc"+--+-- >>> LazyByteString.tail ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap LazyByteString.unpack (LazyByteString.tail b) === preview _tail (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: ByteString -> Maybe ByteString+tail =+  fmap snd . L.uncons+{-# INLINE tail #-}++-- | Total 'L.init': all but the last byte. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.init "abc"+-- Just "ab"+--+-- >>> LazyByteString.init ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap LazyByteString.unpack (LazyByteString.init b) === preview _init (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: ByteString -> Maybe ByteString+init =+  fmap fst . L.unsnoc+{-# INLINE init #-}++-- | Total 'L.foldl1': a left fold seeded with the first byte. 'Data.Maybe.Nothing' for+-- the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.foldl1 (-) "\10\3\2"+-- Just 5+--+-- >>> LazyByteString.foldl1 (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.foldl1 max b === maximumOf folded (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldl1 f =+  fmap (uncurry (L.foldl f)) . L.uncons+{-# INLINE foldl1 #-}++-- | Total 'L.foldl1'': a strict left fold seeded with the first byte.+-- 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.foldl1' (-) "\10\3\2"+-- Just 5+--+-- >>> LazyByteString.foldl1' (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.foldl1' (-) b === LazyByteString.foldl1 (-) b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldl1' f =+  fmap (uncurry (L.foldl' f)) . L.uncons+{-# INLINE foldl1' #-}++-- | Total 'L.foldr1': a right fold seeded with the last byte. 'Data.Maybe.Nothing' for+-- the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.foldr1 (-) "\10\3\2"+-- Just 9+--+-- >>> LazyByteString.foldr1 (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.foldr1 min b === minimumOf folded (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldr1 f =+  fmap (\(b, w) -> L.foldr f w b) . L.unsnoc+{-# INLINE foldr1 #-}++-- | Total 'L.foldr1'': a strict right fold seeded with the last byte.+-- 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.foldr1' (-) "\10\3\2"+-- Just 9+--+-- >>> LazyByteString.foldr1' (-) ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.foldr1' (-) b === LazyByteString.foldr1 (-) b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Word8 -> Word8 -> Word8) -> ByteString -> Maybe Word8+foldr1' f =+  fmap (\(b, w) -> L.foldr' f w b) . L.unsnoc+{-# INLINE foldr1' #-}++-- | Total 'L.maximum': the greatest byte. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.maximum "abca"+-- Just 99+--+-- >>> LazyByteString.maximum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.maximum b === maximumOf folded (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: ByteString -> Maybe Word8+maximum b =+  L.maximum b <$ guard (not (L.null b))+{-# INLINE maximum #-}++-- | Total 'L.minimum': the least byte. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.minimum "bcab"+-- Just 97+--+-- >>> LazyByteString.minimum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyByteString.minimum b === minimumOf folded (LazyByteString.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: ByteString -> Maybe Word8+minimum b =+  L.minimum b <$ guard (not (L.null b))+{-# INLINE minimum #-}++-- | Total 'L.cycle': the infinite repetition of a byte string. 'Data.Maybe.Nothing' for+-- the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyByteString.take 7 <$> LazyByteString.cycle "abc"+-- Just "abcabca"+--+-- >>> LazyByteString.cycle ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap (LazyByteString.take (LazyByteString.length b)) (LazyByteString.cycle b) === (b <$ guard (not (LazyByteString.null b)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+cycle :: ByteString -> Maybe ByteString+cycle b =+  L.cycle b <$ guard (not (L.null b))+{-# INLINE cycle #-}++-- | Total 'L.index': the byte at a position, counting from 0. 'Data.Maybe.Nothing' for+-- a negative index or one past the end. This is 'X.indexMaybe'.+--+-- ==== __Examples__+--+-- >>> LazyByteString.index "abc" 1+-- Just 98+--+-- >>> LazyByteString.index "abc" 3+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; i <- forAll (Gen.int (Range.linear (-3) 25)); LazyByteString.index b (intCast i) === (LazyByteString.unpack b !! i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+index :: ByteString -> Int64 -> Maybe Word8+index =+  L.indexMaybe+{-# INLINE index #-}++-- | Write to 'System.IO.stdout'.+--+-- @since 0.7.0+putStr :: ByteString -> IOExcept ()+putStr =+  exceptIO . L.putStr+{-# INLINE putStr #-}++-- | Write a file, replacing it.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (LazyByteString.writeFile "/nonexistent/papa" "x")+-- True+--+-- @since 0.7.0+writeFile :: FilePath -> ByteString -> IOExcept ()+writeFile p =+  exceptIO . L.writeFile p+{-# INLINE writeFile #-}++-- | Append to a file.+--+-- @since 0.7.0+appendFile :: FilePath -> ByteString -> IOExcept ()+appendFile p =+  exceptIO . L.appendFile p+{-# INLINE appendFile #-}++-- | Write to a handle.+--+-- @since 0.7.0+hPut :: Handle -> ByteString -> IOExcept ()+hPut h =+  exceptIO . L.hPut h+{-# INLINE hPut #-}++-- | Write to a handle without waiting, and return what was not written.+--+-- @since 0.7.0+hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString+hPutNonBlocking h =+  exceptIO . L.hPutNonBlocking h+{-# INLINE hPutNonBlocking #-}++-- | Write to a handle. This is 'hPut'.+--+-- @since 0.7.0+hPutStr :: Handle -> ByteString -> IOExcept ()+hPutStr h =+  exceptIO . L.hPutStr h+{-# INLINE hPutStr #-}++-- | Read up to the given number of bytes from a handle, waiting for all of+-- them unless the end is reached. An error for a negative number.+--+-- @since 0.7.0+hGet :: Handle -> Int -> IOExcept ByteString+hGet h =+  exceptIO . L.hGet h+{-# INLINE hGet #-}++-- | Read up to the given number of bytes from a handle, without waiting. An+-- error for a negative number.+--+-- @since 0.7.0+hGetNonBlocking :: Handle -> Int -> IOExcept ByteString+hGetNonBlocking h =+  exceptIO . L.hGetNonBlocking h+{-# INLINE hGetNonBlocking #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Bytestring/Data/ByteString/Lazy/Char8.hs view
@@ -0,0 +1,907 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Redundant lambda" -}+-- Reason: a function whose byte string follows other arguments (@map f@,+-- @split c@) takes the byte string in a lambda, because GHC inlines a+-- function only once it is applied to the arguments on the left of its+-- definition: so a partial application, passed to a higher-order+-- function, is inlined too.++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total head, last, tail, init, maximum and+-- minimum, whose names HLint restricts whatever module they come from; and+-- calls "Data.ByteString.Lazy"'s maximum and minimum only on a byte string that is+-- not empty, for their speed.++-- | Lazy byte strings as characters @\'\\0\'@ to @\'\\255\'@, with total+-- versions of the partial functions of "Data.ByteString.Lazy.Char8", no silent+-- truncation, and I/O that returns its errors. Import qualified:+--+-- > import qualified Papa.Bytestring.Data.ByteString.Lazy.Char8 as LazyChar8+--+-- "Data.ByteString.Lazy.Char8" stores a character as its code point modulo 256,+-- so that @pack "\\256"@ is @"\\NUL"@, and @elem \'\\256\' "\\NUL"@ is+-- 'Data.Bool.True'. Here:+--+-- * the functions that build a byte string from characters return 'Data.Maybe.Nothing'+--   for a character above @\'\\255\'@: 'pack', 'singleton', 'cons', 'cons'', 'snoc', 'repeat',+--   'intersperse', 'replicate', 'map', 'unfoldr', 'unzip';+-- * the functions that look for a character do not find one above+--   @\'\\255\'@: 'elem', 'notElem', 'elemIndex', 'elemIndices',+--   'elemIndexEnd', 'count', 'split';+-- * the folds 'foldl1', 'foldl1'', 'foldr1', 'foldr1'' fold characters, not+--   bytes, so that an intermediate character above @\'\\255\'@ is kept;+-- * the functions whose function argument builds characters into a byte+--   string are not exported: @mapAccumL@, @mapAccumR@, @scanl@, @scanl1@,+--   @scanr@, @scanr1@, @iterate@, @packZipWith@. Use+--   "Papa.Bytestring.Data.ByteString.Lazy"'s, on bytes.+--+-- The functions that throw are replaced by functions of the same names that+-- return 'Data.Maybe.Nothing' there instead: 'head', 'last', 'tail', 'init', 'foldl1',+-- 'foldl1'', 'foldr1', 'foldr1'', 'maximum', 'minimum', 'cycle' for an empty+-- byte string, and 'index' for an index out of range.+--+-- Its I/O actions that write, or read a given number of bytes, are replaced+-- by actions of the same names that return their+-- 'Control.Exception.IOException' ('Papa.Base.System.IO.Except.IOExcept').+-- Its lazy readers (@readFile@, @getContents@, @hGetContents@, @interact@)+-- are lazy I/O, which throws from pure code once the handle fails, and are+-- not exported: read a strict byte string with+-- "Papa.Bytestring.Data.ByteString.Char8" and convert it with+-- 'X.fromStrict'.+--+-- For text, use "Papa.Text.Data.Text" and UTF-8.+--+-- @since 0.7.0+module Papa.Bytestring.Data.ByteString.Lazy.Char8 (+  module X,+  head,+  last,+  tail,+  init,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  minimum,+  index,+  cons',+  repeat,+  cycle,+  pack,+  singleton,+  cons,+  snoc,+  intersperse,+  replicate,+  map,+  unfoldr,+  unzip,+  elem,+  notElem,+  elemIndex,+  elemIndices,+  elemIndexEnd,+  count,+  split,+  putStr,+  putStrLn,+  writeFile,+  appendFile,+  hGet,+  hGetNonBlocking,+  hPut,+  hPutNonBlocking,+  hPutStr,+  hPutStrLn,+) where++import Control.Applicative (liftA2, (*>))+import Control.Monad (guard)+import Data.Bool (Bool (False), bool, not, (&&))+import qualified Data.ByteString.Lazy as B+import Data.ByteString.Lazy.Char8 as X hiding (+  appendFile,+  cons,+  cons',+  count,+  cycle,+  elem,+  elemIndex,+  elemIndexEnd,+  elemIndices,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  getContents,+  hGet,+  hGetContents,+  hGetNonBlocking,+  hPut,+  hPutNonBlocking,+  hPutStr,+  hPutStrLn,+  head,+  index,+  init,+  interact,+  intersperse,+  iterate,+  last,+  map,+  mapAccumL,+  mapAccumR,+  maximum,+  minimum,+  notElem,+  pack,+  packZipWith,+  putStr,+  putStrLn,+  readFile,+  repeat,+  replicate,+  scanl,+  scanl1,+  scanr,+  scanr1,+  singleton,+  snoc,+  split,+  tail,+  unfoldr,+  unzip,+  writeFile,+ )+import qualified Data.ByteString.Lazy.Char8 as C+import Data.Char (Char)+import Data.Function (const, (.))+import Data.Functor (fmap, (<$))+import Data.Int (Int, Int64)+import qualified Data.List as List+import Data.Maybe (Maybe)+import Data.Tuple (fst, snd, uncurry)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import Papa.Internal.Char8 (latin1, latin1s)+import System.IO (FilePath, Handle)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Data.List as L+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Bytestring.Data.ByteString.Lazy.Char8 as LazyChar8+-- >>> import qualified Data.ByteString.Lazy.Char8 as C+-- >>> import qualified System.IO.Error as IO+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genChar = Gen.frequency [(9, Gen.latin1), (1, Gen.element "\256\1000\1114111")]+-- >>> let genString = Gen.string (Range.linear 0 20) genChar+-- >>> let genBytes = C.pack <$> Gen.string (Range.linear 0 20) Gen.latin1++-- | Total 'C.head': the first character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.head "abc"+-- Just 'a'+--+-- >>> LazyChar8.head ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.head b === preview _head (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: ByteString -> Maybe Char+head =+  fmap fst . C.uncons+{-# INLINE head #-}++-- | Total 'C.last': the last character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.last "abc"+-- Just 'c'+--+-- >>> LazyChar8.last ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.last b === preview _last (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: ByteString -> Maybe Char+last =+  fmap snd . C.unsnoc+{-# INLINE last #-}++-- | Total 'C.tail': all but the first character. 'Data.Maybe.Nothing' for the empty+-- byte string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.tail "abc"+-- Just "bc"+--+-- >>> LazyChar8.tail ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap LazyChar8.unpack (LazyChar8.tail b) === preview _tail (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: ByteString -> Maybe ByteString+tail =+  fmap snd . C.uncons+{-# INLINE tail #-}++-- | Total 'C.init': all but the last character. 'Data.Maybe.Nothing' for the empty+-- byte string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.init "abc"+-- Just "ab"+--+-- >>> LazyChar8.init ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap LazyChar8.unpack (LazyChar8.init b) === preview _init (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: ByteString -> Maybe ByteString+init =+  fmap fst . C.unsnoc+{-# INLINE init #-}++-- | Total 'C.foldl1': a left fold of the characters, seeded with the first.+-- 'Data.Maybe.Nothing' for the empty byte string. Unlike "Data.ByteString.Char8"'s, an+-- intermediate character above @\'\\255\'@ is kept.+--+-- ==== __Examples__+--+-- >>> LazyChar8.foldl1 max "abca"+-- Just 'c'+--+-- >>> LazyChar8.foldl1 (\a c -> bool a '\300' (c == 'b')) "ab"+-- Just '\300'+--+-- >>> LazyChar8.foldl1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.foldl1 max b === maximumOf folded (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldl1 f =+  fmap (uncurry (C.foldl f)) . C.uncons+{-# INLINE foldl1 #-}++-- | Total 'C.foldl1'': a strict left fold of the characters, seeded with the+-- first. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.foldl1' max "abca"+-- Just 'c'+--+-- >>> LazyChar8.foldl1' max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.foldl1' min b === LazyChar8.foldl1 min b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldl1' f =+  fmap (uncurry (C.foldl' f)) . C.uncons+{-# INLINE foldl1' #-}++-- | Total 'C.foldr1': a right fold of the characters, seeded with the last.+-- 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.foldr1 max "abca"+-- Just 'c'+--+-- >>> LazyChar8.foldr1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.foldr1 min b === minimumOf folded (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldr1 f =+  fmap (\(b, c) -> C.foldr f c b) . C.unsnoc+{-# INLINE foldr1 #-}++-- | Total 'C.foldr1'': a strict right fold of the characters, seeded with the+-- last. 'Data.Maybe.Nothing' for the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.foldr1' max "abca"+-- Just 'c'+--+-- >>> LazyChar8.foldr1' max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.foldr1' min b === LazyChar8.foldr1 min b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Char -> Char -> Char) -> ByteString -> Maybe Char+foldr1' f =+  fmap (\(b, c) -> C.foldr' f c b) . C.unsnoc+{-# INLINE foldr1' #-}++-- | Total 'C.maximum': the greatest character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.maximum "abca"+-- Just 'c'+--+-- >>> LazyChar8.maximum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.maximum b === maximumOf folded (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: ByteString -> Maybe Char+maximum b =+  C.maximum b <$ guard (not (B.null b))+{-# INLINE maximum #-}++-- | Total 'C.minimum': the least character. 'Data.Maybe.Nothing' for the empty byte+-- string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.minimum "bcab"+-- Just 'a'+--+-- >>> LazyChar8.minimum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; LazyChar8.minimum b === minimumOf folded (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: ByteString -> Maybe Char+minimum b =+  C.minimum b <$ guard (not (B.null b))+{-# INLINE minimum #-}++-- | Total 'C.index': the character at a position, counting from 0. 'Data.Maybe.Nothing'+-- for a negative index or one past the end.+--+-- ==== __Examples__+--+-- >>> LazyChar8.index "abc" 1+-- Just 'b'+--+-- >>> LazyChar8.index "abc" 3+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; i <- forAll (Gen.int (Range.linear (-3) 25)); LazyChar8.index b (intCast i) === (LazyChar8.unpack b !! i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+index :: ByteString -> Int64 -> Maybe Char+index =+  C.indexMaybe+{-# INLINE index #-}++-- | Checked 'C.cons'': a character before a byte string, strictly in the+-- first chunk. 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.cons' 'a' "bc"+-- Just "abc"+--+-- >>> LazyChar8.cons' '\256' "bc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.cons' c b === LazyChar8.cons c b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+cons' :: Char -> ByteString -> Maybe ByteString+cons' c =+  \b -> C.cons' c b <$ guard (latin1 c)+{-# INLINE cons' #-}++-- | Checked 'C.repeat': the infinite repetition of a character. 'Data.Maybe.Nothing'+-- for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.take 3 <$> LazyChar8.repeat 'a'+-- Just "aaa"+--+-- >>> LazyChar8.repeat '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; fmap (LazyChar8.take 5) (LazyChar8.repeat c) === LazyChar8.replicate 5 c+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+repeat :: Char -> Maybe ByteString+repeat c =+  C.repeat c <$ guard (latin1 c)+{-# INLINE repeat #-}++-- | Total 'C.cycle': the infinite repetition of a byte string. 'Data.Maybe.Nothing' for+-- the empty byte string.+--+-- ==== __Examples__+--+-- >>> LazyChar8.take 7 <$> LazyChar8.cycle "abc"+-- Just "abcabca"+--+-- >>> LazyChar8.cycle ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; fmap (LazyChar8.take (LazyChar8.length b)) (LazyChar8.cycle b) === (b <$ guard (not (LazyChar8.null b)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+cycle :: ByteString -> Maybe ByteString+cycle b =+  C.cycle b <$ guard (not (B.null b))+{-# INLINE cycle #-}++-- | Checked 'C.pack': the byte string of some characters. 'Data.Maybe.Nothing' if one is+-- above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.pack "caf\233"+-- Just "caf\233"+--+-- >>> LazyChar8.pack "\256"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; fmap LazyChar8.unpack (LazyChar8.pack s) === (s <$ guard (P.all (<= '\255') s))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+pack :: [Char] -> Maybe ByteString+pack s =+  C.pack s <$ latin1s s+{-# INLINE pack #-}++-- | Checked 'C.singleton': the byte string of a character. 'Data.Maybe.Nothing' for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.singleton 'a'+-- Just "a"+--+-- >>> LazyChar8.singleton '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; LazyChar8.singleton c === LazyChar8.pack [c]+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+singleton :: Char -> Maybe ByteString+singleton c =+  C.singleton c <$ guard (latin1 c)+{-# INLINE singleton #-}++-- | Checked 'C.cons': a character before a byte string. 'Data.Maybe.Nothing' for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.cons 'a' "bc"+-- Just "abc"+--+-- >>> LazyChar8.cons '\256' "bc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.cons c b === fmap (<> b) (LazyChar8.singleton c)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+cons :: Char -> ByteString -> Maybe ByteString+cons c =+  \b -> C.cons c b <$ guard (latin1 c)+{-# INLINE cons #-}++-- | Checked 'C.snoc': a character after a byte string. 'Data.Maybe.Nothing' for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.snoc "ab" 'c'+-- Just "abc"+--+-- >>> LazyChar8.snoc "ab" '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.snoc b c === fmap (b <>) (LazyChar8.singleton c)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+snoc :: ByteString -> Char -> Maybe ByteString+snoc b c =+  C.snoc b c <$ guard (latin1 c)+{-# INLINE snoc #-}++-- | Checked 'C.intersperse': a character between each two of a byte+-- string's. 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.intersperse ',' "abc"+-- Just "a,b,c"+--+-- >>> LazyChar8.intersperse '\256' "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; fmap LazyChar8.unpack (LazyChar8.intersperse c b) === (P.intersperse c (LazyChar8.unpack b) <$ guard (c <= '\255'))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+intersperse :: Char -> ByteString -> Maybe ByteString+intersperse c =+  \b -> C.intersperse c b <$ guard (latin1 c)+{-# INLINE intersperse #-}++-- | Checked 'C.replicate': a character repeated a number of times (none for+-- a number below 1). 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.replicate 3 'a'+-- Just "aaa"+--+-- >>> LazyChar8.replicate 3 '\256'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-2) 10)); c <- forAll genChar; LazyChar8.replicate (intCast n) c === (LazyChar8.pack (P.replicate n c) <* guard (c <= '\255'))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+replicate :: Int64 -> Char -> Maybe ByteString+replicate n c =+  C.replicate n c <$ guard (latin1 c)+{-# INLINE replicate #-}++-- | Checked 'C.map': a function of each character. 'Data.Maybe.Nothing' if it gives a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.map toUpper "abc"+-- Just "ABC"+--+-- >>> LazyChar8.map (P.const '\256') "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; c <- forAll genChar; LazyChar8.map (\x -> bool c 'x' (x == 'a')) b === LazyChar8.pack (fmap (\x -> bool c 'x' (x == 'a')) (LazyChar8.unpack b))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+map :: (Char -> Char) -> ByteString -> Maybe ByteString+map f =+  \b -> C.map f b <$ guard (C.all (latin1 . f) b)+{-# INLINE map #-}++-- | Checked 'C.unfoldr': the byte string of the characters that a function+-- unfolds from a seed. 'Data.Maybe.Nothing' if one is above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.unfoldr P.uncons "abc"+-- Just "abc"+--+-- >>> LazyChar8.unfoldr P.uncons "a\256"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; LazyChar8.unfoldr P.uncons s === LazyChar8.pack s+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+unfoldr :: (a -> Maybe (Char, a)) -> a -> Maybe ByteString+unfoldr f =+  pack . List.unfoldr f+{-# INLINE unfoldr #-}++-- | Checked 'C.unzip': the byte strings of the first and second characters+-- of some pairs. 'Data.Maybe.Nothing' if one is above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.unzip [('a', 'b'), ('c', 'd')]+-- Just ("ac","bd")+--+-- >>> LazyChar8.unzip [('a', '\256')]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genString; t <- forAll genString; LazyChar8.unzip (P.zip s t) === liftA2 (,) (LazyChar8.pack (fmap P.fst (P.zip s t))) (LazyChar8.pack (fmap P.snd (P.zip s t)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+unzip :: [(Char, Char)] -> Maybe (ByteString, ByteString)+unzip ps =+  liftA2 (,) (pack (fmap fst ps)) (pack (fmap snd ps))+{-# INLINE unzip #-}++-- | Checked 'C.elem': whether a character is in a byte string; never for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.elem 'b' "abc"+-- True+--+-- >>> LazyChar8.elem '\256' "\NUL"+-- False+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.elem c b === P.elem c (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elem :: Char -> ByteString -> Bool+elem c =+  \b -> latin1 c && C.elem c b+{-# INLINE elem #-}++-- | Checked 'C.notElem': whether a character is not in a byte string; always+-- for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.notElem 'd' "abc"+-- True+--+-- >>> LazyChar8.notElem '\256' "\NUL"+-- True+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.notElem c b === P.notElem c (LazyChar8.unpack b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+notElem :: Char -> ByteString -> Bool+notElem c =+  not . elem c+{-# INLINE notElem #-}++-- | Checked 'C.elemIndex': the position of the first occurrence of a+-- character; 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.elemIndex 'b' "abcb"+-- Just 1+--+-- >>> LazyChar8.elemIndex '\256' "\NUL"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.elemIndex c b === fmap intCast (L.elemIndex c (LazyChar8.unpack b))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elemIndex :: Char -> ByteString -> Maybe Int64+elemIndex c =+  \b -> guard (latin1 c) *> C.elemIndex c b+{-# INLINE elemIndex #-}++-- | Checked 'C.elemIndices': the positions of the occurrences of a+-- character; none for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.elemIndices 'b' "abcb"+-- [1,3]+--+-- >>> LazyChar8.elemIndices '\256' "\NUL"+-- []+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.elemIndices c b === fmap intCast (L.elemIndices c (LazyChar8.unpack b))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elemIndices :: Char -> ByteString -> [Int64]+elemIndices c =+  \b -> bool [] (C.elemIndices c b) (latin1 c)+{-# INLINE elemIndices #-}++-- | Checked 'C.elemIndexEnd': the position of the last occurrence of a+-- character; 'Data.Maybe.Nothing' for a character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.elemIndexEnd 'b' "abcb"+-- Just 3+--+-- >>> LazyChar8.elemIndexEnd '\256' "\NUL"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.elemIndexEnd c b === fmap intCast (preview _last (L.elemIndices c (LazyChar8.unpack b)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+elemIndexEnd :: Char -> ByteString -> Maybe Int64+elemIndexEnd c =+  \b -> guard (latin1 c) *> C.elemIndexEnd c b+{-# INLINE elemIndexEnd #-}++-- | Checked 'C.count': the number of occurrences of a character; 0 for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.count 'b' "abcb"+-- 2+--+-- >>> LazyChar8.count '\256' "\NUL"+-- 0+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.count c b === intCast (P.length (L.elemIndices c (LazyChar8.unpack b)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+count :: Char -> ByteString -> Int64+count c =+  \b -> bool 0 (C.count c b) (latin1 c)+{-# INLINE count #-}++-- | Checked 'C.split': the pieces of a byte string between occurrences of a+-- character (none for the empty byte string); the whole byte string for a+-- character above @\'\\255\'@.+--+-- ==== __Examples__+--+-- >>> LazyChar8.split ',' "a,b,,c"+-- ["a","b","","c"]+--+-- >>> LazyChar8.split '\256' "a\NULb"+-- ["a\NULb"]+--+-- >>> check $ withTests 100 $ property $ do c <- forAll genChar; b <- forAll genBytes; LazyChar8.split c b === bool (LazyChar8.splitWith (== c) b) [] (LazyChar8.null b)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+split :: Char -> ByteString -> [ByteString]+split c =+  \b -> bool (B.splitWith (const False) b) (C.split c b) (latin1 c)+{-# INLINE split #-}++-- | Write to 'System.IO.stdout'.+--+-- @since 0.7.0+putStr :: ByteString -> IOExcept ()+putStr =+  exceptIO . C.putStr+{-# INLINE putStr #-}++-- | Write to 'System.IO.stdout', and a newline byte.+--+-- @since 0.7.0+putStrLn :: ByteString -> IOExcept ()+putStrLn =+  exceptIO . C.putStrLn+{-# INLINE putStrLn #-}++-- | Write a file, replacing it.+--+-- @since 0.7.0+writeFile :: FilePath -> ByteString -> IOExcept ()+writeFile p =+  exceptIO . C.writeFile p+{-# INLINE writeFile #-}++-- | Append to a file.+--+-- @since 0.7.0+appendFile :: FilePath -> ByteString -> IOExcept ()+appendFile p =+  exceptIO . C.appendFile p+{-# INLINE appendFile #-}++-- | Read up to the given number of bytes from a handle, waiting for all of+-- them unless the end is reached. An error for a negative number.+--+-- @since 0.7.0+hGet :: Handle -> Int -> IOExcept ByteString+hGet h =+  exceptIO . C.hGet h+{-# INLINE hGet #-}++-- | Read up to the given number of bytes from a handle, without waiting. An+-- error for a negative number.+--+-- @since 0.7.0+hGetNonBlocking :: Handle -> Int -> IOExcept ByteString+hGetNonBlocking h =+  exceptIO . C.hGetNonBlocking h+{-# INLINE hGetNonBlocking #-}++-- | Write to a handle.+--+-- @since 0.7.0+hPut :: Handle -> ByteString -> IOExcept ()+hPut h =+  exceptIO . C.hPut h+{-# INLINE hPut #-}++-- | Write to a handle without waiting, and return what was not written.+--+-- @since 0.7.0+hPutNonBlocking :: Handle -> ByteString -> IOExcept ByteString+hPutNonBlocking h =+  exceptIO . C.hPutNonBlocking h+{-# INLINE hPutNonBlocking #-}++-- | Write to a handle. This is 'hPut'.+--+-- @since 0.7.0+hPutStr :: Handle -> ByteString -> IOExcept ()+hPutStr h =+  exceptIO . C.hPutStr h+{-# INLINE hPutStr #-}++-- | Write to a handle, and a newline byte.+--+-- @since 0.7.0+hPutStrLn :: Handle -> ByteString -> IOExcept ()+hPutStrLn h =+  exceptIO . C.hPutStrLn h+{-# INLINE hPutStrLn #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
src/Papa/Containers.hs view
@@ -1,15 +1,21 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} --- | This module cannot re-export all submodules due to name conflicts.--- Import the specific container types qualified instead:+-- | The types of the containers, unqualified. Their functions are in+-- "Papa.Containers.Data.Map", "Papa.Containers.Data.Set",+-- "Papa.Containers.Data.IntMap", "Papa.Containers.Data.IntSet" and+-- "Papa.Containers.Data.Seq", to import qualified. ----- > import qualified Papa.Containers.Data.Map as Map--- > import qualified Papa.Containers.Data.Set as Set--- > import qualified Papa.Containers.Data.IntMap as IntMap--- > import qualified Papa.Containers.Data.IntSet as IntSet--- > import qualified Papa.Containers.Data.Seq as Seq--- > import qualified Papa.Containers.Data.Tree as Tree-module Papa.Containers () where+-- @since 0.7.0+module Papa.Containers (+  module P,+  module Papa.Containers.Data.Containers.ListUtils,+) where --- Intentionally empty due to name conflicts between Map, IntMap, Set, IntSet, etc.+import Papa.Containers.Data.Containers.ListUtils++import Data.IntMap.Strict as P (IntMap)+import Data.IntSet as P (IntSet)+import Data.Map.Strict as P (Map)+import Data.Sequence as P (Seq)+import Data.Set as P (Set)
+ src/Papa/Containers/Data/Containers/ListUtils.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Removing duplicates from a list in /O(n log n)/ time+-- ('nubOrd', 'nubOrdOn') or /O(n min(n, W))/ time ('nubInt', 'nubIntOn'),+-- keeping the first of each, as "Data.List"'s @nub@ does in /O(n²)/.+--+-- @since 0.7.0+module Papa.Containers.Data.Containers.ListUtils (+  module P,+) where++import Data.Containers.ListUtils as P (+  nubInt,+  nubIntOn,+  nubOrd,+  nubOrdOn,+ )
src/Papa/Containers/Data/IntMap.hs view
@@ -1,8 +1,298 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-}+-- Reason: fromDescList is hidden from the library module, which exports it+-- from containers 0.8, and not before; hiding it where it is not exported+-- is a dodgy import, and the alternative is CPP in the import list.+{-# OPTIONS_GHC -Wno-dodgy-imports #-} +-- | Strict maps from 'Int', with total versions of the partial functions of+-- "Data.IntMap.Strict". Import qualified:+--+-- > import qualified Papa.Containers.Data.IntMap as IntMap+--+-- The functions of "Data.IntMap.Strict" that throw (@(!)@, @findMin@,+-- @findMax@, @deleteFindMin@, @deleteFindMax@) are replaced by functions of+-- the same names that return 'Data.Maybe.Nothing' there instead.+--+-- The functions that build a map from an ordered list, or map its keys+-- with a monotonic function, check the order in the same linear time, and+-- return 'Data.Maybe.Nothing' where it does not hold, where "Data.IntMap.Strict"'s+-- build a map that breaks its invariant. module Papa.Containers.Data.IntMap (   module X,+  (!),+  findMin,+  findMax,+  deleteFindMin,+  deleteFindMax,+  fromAscList,+  fromAscListWith,+  fromAscListWithKey,+  fromDistinctAscList,+  fromDescList,+  mapKeysMonotonic, ) where -import Data.IntMap.Strict as X+import Control.Lens (over, _1)+import Control.Monad (guard)+import Data.Functor (fmap, (<$))+import Data.Int (Int)+import Data.IntMap.Strict as X hiding (+  deleteFindMax,+  deleteFindMin,+  findMax,+  findMin,+  fromAscList,+  fromAscListWith,+  fromAscListWithKey,+  fromDescList,+  fromDistinctAscList,+  mapKeysMonotonic,+  (!),+ )+import qualified Data.IntMap.Strict as M+import Data.List (reverse)+import Data.Maybe (Maybe)+import Data.Ord (Ord ((<), (<=), (>=)))+import Data.Tuple (fst)+import Papa.Internal.Order (pairwise)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Containers.Data.IntMap as IntMap+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genKVs0 = Gen.list (Range.linear 0 10) ((,) <$> Gen.int (Range.linear 0 9) <*> Gen.alpha)+-- >>> let genKVs = Gen.choice [P.sortOn P.fst <$> genKVs0, P.sortOn (Down . P.fst) <$> genKVs0, P.nubBy (\a b -> P.fst a == P.fst b) . P.sortOn P.fst <$> genKVs0, genKVs0]+-- >>> let genIntMap = IntMap.fromList <$> Gen.list (Range.linear 0 20) ((,) <$> Gen.int (Range.linear (-30) 30) <*> Gen.alpha)++-- | Total 'M.!': the value at a key. 'Data.Maybe.Nothing' where the key is not in the+-- map. This is 'M.!?'.+--+-- ==== __Examples__+--+-- >>> IntMap.fromList [(1, 'a')] IntMap.! 1+-- Just 'a'+--+-- >>> IntMap.fromList [(1, 'a')] IntMap.! 2+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genIntMap; k <- forAll (Gen.int (Range.linear (-30) 30)); (m IntMap.! k) === IntMap.lookup k m+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+(!) :: IntMap a -> Int -> Maybe a+(!) =+  (M.!?)+{-# INLINE (!) #-}++infixl 9 !++-- | Total 'M.findMin': the smallest key and its value. 'Data.Maybe.Nothing' for the+-- empty map. This is 'M.lookupMin'.+--+-- ==== __Examples__+--+-- >>> IntMap.findMin (IntMap.fromList [(2, 'b'), (-1, 'a')])+-- Just (-1,'a')+--+-- >>> IntMap.findMin (IntMap.empty :: IntMap Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genIntMap; IntMap.findMin m === preview _head (IntMap.toAscList m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMin :: IntMap a -> Maybe (Int, a)+findMin =+  M.lookupMin+{-# INLINE findMin #-}++-- | Total 'M.findMax': the largest key and its value. 'Data.Maybe.Nothing' for the+-- empty map. This is 'M.lookupMax'.+--+-- ==== __Examples__+--+-- >>> IntMap.findMax (IntMap.fromList [(2, 'b'), (-1, 'a')])+-- Just (2,'b')+--+-- >>> IntMap.findMax (IntMap.empty :: IntMap Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genIntMap; IntMap.findMax m === preview _last (IntMap.toAscList m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMax :: IntMap a -> Maybe (Int, a)+findMax =+  M.lookupMax+{-# INLINE findMax #-}++-- | Total 'M.deleteFindMin': the smallest key and its value, and the map+-- without them. 'Data.Maybe.Nothing' for the empty map. This is 'M.minViewWithKey'.+--+-- ==== __Examples__+--+-- >>> IntMap.deleteFindMin (IntMap.fromList [(2, 'b'), (1, 'a')])+-- Just ((1,'a'),fromList [(2,'b')])+--+-- >>> IntMap.deleteFindMin (IntMap.empty :: IntMap Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genIntMap; fmap (\(kv, m') -> IntMap.insert (P.fst kv) (P.snd kv) m') (IntMap.deleteFindMin m) === (m <$ IntMap.findMin m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMin :: IntMap a -> Maybe ((Int, a), IntMap a)+deleteFindMin =+  M.minViewWithKey+{-# INLINE deleteFindMin #-}++-- | Total 'M.deleteFindMax': the largest key and its value, and the map+-- without them. 'Data.Maybe.Nothing' for the empty map. This is 'M.maxViewWithKey'.+--+-- ==== __Examples__+--+-- >>> IntMap.deleteFindMax (IntMap.fromList [(2, 'b'), (1, 'a')])+-- Just ((2,'b'),fromList [(1,'a')])+--+-- >>> IntMap.deleteFindMax (IntMap.empty :: IntMap Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genIntMap; fmap (\(kv, m') -> IntMap.insert (P.fst kv) (P.snd kv) m') (IntMap.deleteFindMax m) === (m <$ IntMap.findMax m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMax :: IntMap a -> Maybe ((Int, a), IntMap a)+deleteFindMax =+  M.maxViewWithKey+{-# INLINE deleteFindMax #-}++-- | Total @fromAscList@: build a map from a list in ascending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntMap.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntMap.fromAscList [(1, 'a'), (2, 'b')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> IntMap.fromAscList [(2, 'b'), (1, 'a')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; IntMap.fromAscList kvs === bool Nothing (Just (IntMap.fromList kvs)) (P.sortOn P.fst kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscList :: [(Int, a)] -> Maybe (IntMap a)+fromAscList kvs =+  M.fromAscList kvs <$ guard (pairwise (<=) (fmap fst kvs))+{-# INLINE fromAscList #-}++-- | Total @fromAscListWith@: build a map from a list in ascending order of keys, combining the values of equal keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntMap.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntMap.fromAscListWith (<>) [(1, "a"), (1, "b"), (2, "c")]+-- Just (fromList [(1,"ba"),(2,"c")])+--+-- >>> IntMap.fromAscListWith (<>) [(2, "a"), (1, "b")]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs }; IntMap.fromAscListWith (<>) kss === bool Nothing (Just (IntMap.fromListWith (<>) kss)) (P.sortOn P.fst kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscListWith :: (a -> a -> a) -> [(Int, a)] -> Maybe (IntMap a)+fromAscListWith f kvs =+  M.fromAscListWith f kvs <$ guard (pairwise (<=) (fmap fst kvs))+{-# INLINE fromAscListWith #-}++-- | Total @fromAscListWithKey@: build a map from a list in ascending order of keys, combining the values of equal keys with the key, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntMap.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntMap.fromAscListWithKey (\k a b -> show k <> a <> b) [(1, "a"), (1, "b")]+-- Just (fromList [(1,"1ba")])+--+-- >>> IntMap.fromAscListWithKey (\_ a _ -> a) [(2, "a"), (1, "b")]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs; f k a b = show k <> a <> b }; IntMap.fromAscListWithKey f kss === bool Nothing (Just (IntMap.fromListWithKey f kss)) (P.sortOn P.fst kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscListWithKey :: (Int -> a -> a -> a) -> [(Int, a)] -> Maybe (IntMap a)+fromAscListWithKey f kvs =+  M.fromAscListWithKey f kvs <$ guard (pairwise (<=) (fmap fst kvs))+{-# INLINE fromAscListWithKey #-}++-- | Total @fromDistinctAscList@: build a map from a list in strictly ascending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntMap.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntMap.fromDistinctAscList [(1, 'a'), (2, 'b')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> IntMap.fromDistinctAscList [(1, 'a'), (1, 'b')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; IntMap.fromDistinctAscList kvs === bool Nothing (Just (IntMap.fromList kvs)) (P.sortOn P.fst kvs == kvs && P.nub (fmap P.fst kvs) == fmap P.fst kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDistinctAscList :: [(Int, a)] -> Maybe (IntMap a)+fromDistinctAscList kvs =+  M.fromDistinctAscList kvs <$ guard (pairwise (<) (fmap fst kvs))+{-# INLINE fromDistinctAscList #-}++-- | Total @fromDescList@: build a map from a list in descending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntMap.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntMap.fromDescList [(2, 'b'), (1, 'a')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> IntMap.fromDescList [(1, 'a'), (2, 'b')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; IntMap.fromDescList kvs === bool Nothing (Just (IntMap.fromList kvs)) (P.sortOn (Down . P.fst) kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDescList :: [(Int, a)] -> Maybe (IntMap a)+fromDescList kvs =+  M.fromAscListWith (\_ old -> old) (reverse kvs) <$ guard (pairwise (>=) (fmap fst kvs))+{-# INLINE fromDescList #-}++-- | Total @mapKeysMonotonic@: map the keys with a strictly increasing function, in linear time. 'Data.Maybe.Nothing' where the function is not strictly increasing on the keys of the map, where "Data.IntMap.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntMap.mapKeysMonotonic (* 2) (IntMap.fromList [(1, 'a'), (2, 'b')])+-- Just (fromList [(2,'a'),(4,'b')])+--+-- >>> IntMap.mapKeysMonotonic negate (IntMap.fromList [(1, 'a'), (2, 'b')])+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do m <- forAll (fmap IntMap.fromList genKVs); c <- forAll (Gen.int (Range.linear (-2) 2)); IntMap.mapKeysMonotonic (* c) m === bool Nothing (Just (IntMap.mapKeys (* c) m)) (c > 0 || IntMap.size m <= 1)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+mapKeysMonotonic :: (Int -> Int) -> IntMap a -> Maybe (IntMap a)+mapKeysMonotonic f m =+  let kvs = fmap (over _1 f) (M.toAscList m)+   in M.fromDistinctAscList kvs <$ guard (pairwise (<) (fmap fst kvs))+{-# INLINE mapKeysMonotonic #-}
src/Papa/Containers/Data/IntSet.hs view
@@ -1,8 +1,227 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-}+-- Reason: fromDescList is hidden from the library module, which exports it+-- from containers 0.8, and not before; hiding it where it is not exported+-- is a dodgy import, and the alternative is CPP in the import list.+{-# OPTIONS_GHC -Wno-dodgy-imports #-} +-- | Sets of 'Int', with total versions of the partial functions of+-- "Data.IntSet". Import qualified:+--+-- > import qualified Papa.Containers.Data.IntSet as IntSet+--+-- The functions of "Data.IntSet" that throw (@findMin@, @findMax@,+-- @deleteFindMin@, @deleteFindMax@) are replaced by functions of the same+-- names that return 'Data.Maybe.Nothing' there instead.+--+-- The functions that build a set from an ordered list, or map it+-- with a monotonic function, check the order in the same linear time, and+-- return 'Data.Maybe.Nothing' where it does not hold, where "Data.IntSet"'s+-- build a set that breaks its invariant. module Papa.Containers.Data.IntSet (   module X,+  findMin,+  findMax,+  deleteFindMin,+  deleteFindMax,+  fromAscList,+  fromDescList,+  fromDistinctAscList,+  mapMonotonic, ) where -import Data.IntSet as X+import Control.Category ((.))+import Control.Monad (guard)+import Data.Functor (fmap, (<$))+import Data.Int (Int)+import Data.IntSet as X hiding (+  deleteFindMax,+  deleteFindMin,+  findMax,+  findMin,+  fromAscList,+  fromDescList,+  fromDistinctAscList,+  mapMonotonic,+ )+import qualified Data.IntSet as S+import Data.List (reverse)+import Data.Maybe (Maybe)+import Data.Ord (Ord ((<), (<=), (>=)))+import Data.Tuple (fst)+import Papa.Internal.Order (pairwise)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Containers.Data.IntSet as IntSet+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genXs0 = Gen.list (Range.linear 0 10) (Gen.int (Range.linear 0 9))+-- >>> let genXs = Gen.choice [P.sort <$> genXs0, P.sortOn Down <$> genXs0, P.nub . P.sort <$> genXs0, genXs0]+-- >>> let genIntSet = IntSet.fromList <$> Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-30) 30))++-- | Total 'S.findMin': the smallest element. 'Data.Maybe.Nothing' for the empty set.+--+-- ==== __Examples__+--+-- >>> IntSet.findMin (IntSet.fromList [2, -1])+-- Just (-1)+--+-- >>> IntSet.findMin IntSet.empty+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genIntSet; IntSet.findMin s === preview _head (IntSet.toAscList s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMin :: IntSet -> Maybe Int+findMin =+  fmap fst . S.minView+{-# INLINE findMin #-}++-- | Total 'S.findMax': the largest element. 'Data.Maybe.Nothing' for the empty set.+--+-- ==== __Examples__+--+-- >>> IntSet.findMax (IntSet.fromList [2, -1])+-- Just 2+--+-- >>> IntSet.findMax IntSet.empty+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genIntSet; IntSet.findMax s === preview _head (IntSet.toDescList s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMax :: IntSet -> Maybe Int+findMax =+  fmap fst . S.maxView+{-# INLINE findMax #-}++-- | Total 'S.deleteFindMin': the smallest element, and the set without it.+-- 'Data.Maybe.Nothing' for the empty set. This is 'S.minView'.+--+-- ==== __Examples__+--+-- >>> IntSet.deleteFindMin (IntSet.fromList [2, 1])+-- Just (1,fromList [2])+--+-- >>> IntSet.deleteFindMin IntSet.empty+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genIntSet; fmap (\(a, s') -> IntSet.insert a s') (IntSet.deleteFindMin s) === (s <$ IntSet.findMin s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMin :: IntSet -> Maybe (Int, IntSet)+deleteFindMin =+  S.minView+{-# INLINE deleteFindMin #-}++-- | Total 'S.deleteFindMax': the largest element, and the set without it.+-- 'Data.Maybe.Nothing' for the empty set. This is 'S.maxView'.+--+-- ==== __Examples__+--+-- >>> IntSet.deleteFindMax (IntSet.fromList [2, 1])+-- Just (2,fromList [1])+--+-- >>> IntSet.deleteFindMax IntSet.empty+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genIntSet; fmap (\(a, s') -> IntSet.insert a s') (IntSet.deleteFindMax s) === (s <$ IntSet.findMax s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMax :: IntSet -> Maybe (Int, IntSet)+deleteFindMax =+  S.maxView+{-# INLINE deleteFindMax #-}++-- | Total @fromAscList@: build a set from a list in ascending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntSet"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntSet.fromAscList [1, 2, 2, 3]+-- Just (fromList [1,2,3])+--+-- >>> IntSet.fromAscList [2, 1]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; IntSet.fromAscList xs === bool Nothing (Just (IntSet.fromList xs)) (P.sort xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscList :: [Int] -> Maybe (IntSet)+fromAscList xs =+  S.fromAscList xs <$ guard (pairwise (<=) xs)+{-# INLINE fromAscList #-}++-- | Total @fromDescList@: build a set from a list in descending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntSet"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntSet.fromDescList [3, 2, 2, 1]+-- Just (fromList [1,2,3])+--+-- >>> IntSet.fromDescList [1, 2]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; IntSet.fromDescList xs === bool Nothing (Just (IntSet.fromList xs)) (P.sortOn Down xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDescList :: [Int] -> Maybe (IntSet)+fromDescList xs =+  S.fromAscList (reverse xs) <$ guard (pairwise (>=) xs)+{-# INLINE fromDescList #-}++-- | Total @fromDistinctAscList@: build a set from a list in strictly ascending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.IntSet"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntSet.fromDistinctAscList [1, 2, 3]+-- Just (fromList [1,2,3])+--+-- >>> IntSet.fromDistinctAscList [1, 1]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; IntSet.fromDistinctAscList xs === bool Nothing (Just (IntSet.fromList xs)) (P.sort xs == xs && P.nub xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDistinctAscList :: [Int] -> Maybe (IntSet)+fromDistinctAscList xs =+  S.fromDistinctAscList xs <$ guard (pairwise (<) xs)+{-# INLINE fromDistinctAscList #-}++-- | Total @mapMonotonic@: map the elements with a strictly increasing function, in linear time. 'Data.Maybe.Nothing' where the function is not strictly increasing on the elements of the set, where "Data.IntSet"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> IntSet.mapMonotonic (* 2) (IntSet.fromList [1, 2])+-- Just (fromList [2,4])+--+-- >>> IntSet.mapMonotonic negate (IntSet.fromList [1, 2])+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do s <- forAll (fmap IntSet.fromList genXs); c <- forAll (Gen.int (Range.linear (-2) 2)); IntSet.mapMonotonic (* c) s === bool Nothing (Just (IntSet.map (* c) s)) (c > 0 || IntSet.size s <= 1)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+mapMonotonic :: (Int -> Int) -> IntSet -> Maybe IntSet+mapMonotonic f s =+  let xs = fmap f (S.toAscList s)+   in S.fromDistinctAscList xs <$ guard (pairwise (<) xs)+{-# INLINE mapMonotonic #-}
src/Papa/Containers/Data/Map.hs view
@@ -1,8 +1,459 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Strict maps, with total versions of the partial functions of+-- "Data.Map.Strict". Import qualified:+--+-- > import qualified Papa.Containers.Data.Map as Map+--+-- The functions of "Data.Map.Strict" that throw (@(!)@, @findMin@,+-- @findMax@, @deleteFindMin@, @deleteFindMax@, @elemAt@, @findIndex@,+-- @deleteAt@, @updateAt@) are replaced by functions of the same names that+-- return 'Data.Maybe.Nothing' there instead.+--+-- The functions that build a map from an ordered list, or map its keys+-- with a monotonic function, check the order in the same linear time, and+-- return 'Data.Maybe.Nothing' where it does not hold, where "Data.Map.Strict"'s build+-- a map that breaks its invariant. module Papa.Containers.Data.Map (   module X,+  (!),+  findMin,+  findMax,+  deleteFindMin,+  deleteFindMax,+  elemAt,+  findIndex,+  deleteAt,+  updateAt,+  fromAscList,+  fromAscListWith,+  fromAscListWithKey,+  fromDistinctAscList,+  fromDescList,+  fromDescListWith,+  fromDescListWithKey,+  fromDistinctDescList,+  mapKeysMonotonic, ) where -import Data.Map.Strict as X+import Control.Monad (guard)+import Data.Bool (Bool, (&&))+import Data.Functor (fmap, (<$))+import Data.Int (Int)+import Data.Map.Strict as X hiding (+  deleteAt,+  deleteFindMax,+  deleteFindMin,+  elemAt,+  findIndex,+  findMax,+  findMin,+  fromAscList,+  fromAscListWith,+  fromAscListWithKey,+  fromDescList,+  fromDescListWith,+  fromDescListWithKey,+  fromDistinctAscList,+  fromDistinctDescList,+  mapKeysMonotonic,+  updateAt,+  (!),+ )+import qualified Data.Map.Strict as M+import Data.Maybe (Maybe)+import Data.Ord (Ord ((<), (<=), (>), (>=)))+import Data.Tuple (fst)+import Papa.Internal.Order (pairwise)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Containers.Data.Map as Map+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genKVs0 = Gen.list (Range.linear 0 10) ((,) <$> Gen.int (Range.linear 0 9) <*> Gen.alpha)+-- >>> let genKVs = Gen.choice [P.sortOn P.fst <$> genKVs0, P.sortOn (Down . P.fst) <$> genKVs0, P.nubBy (\a b -> P.fst a == P.fst b) . P.sortOn P.fst <$> genKVs0, genKVs0]+-- >>> let genMap = Map.fromList <$> Gen.list (Range.linear 0 20) ((,) <$> Gen.int (Range.linear 0 30) <*> Gen.alpha)+-- >>> let genIndex = Gen.int (Range.linear (-5) 25)++-- | Whether an index is a position in a map.+inRange :: Int -> Map k a -> Bool+inRange i m =+  0 <= i && i < M.size m+{-# INLINE inRange #-}++-- | Total 'M.!': the value at a key. 'Data.Maybe.Nothing' where the key is not in the+-- map. This is 'M.!?'.+--+-- ==== __Examples__+--+-- >>> Map.fromList [(1, 'a')] Map.! (1 :: Int)+-- Just 'a'+--+-- >>> Map.fromList [(1, 'a')] Map.! (2 :: Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; k <- forAll (Gen.int (Range.linear 0 30)); (m Map.! k) === Map.lookup k m+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+(!) :: (Ord k) => Map k a -> k -> Maybe a+(!) =+  (M.!?)+{-# INLINE (!) #-}++infixl 9 !++-- | Total 'M.findMin': the smallest key and its value. 'Data.Maybe.Nothing' for the+-- empty map. This is 'M.lookupMin'.+--+-- ==== __Examples__+--+-- >>> Map.findMin (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just (1,'a')+--+-- >>> Map.findMin (Map.empty :: Map Int Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; Map.findMin m === preview _head (Map.toList m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMin :: Map k a -> Maybe (k, a)+findMin =+  M.lookupMin+{-# INLINE findMin #-}++-- | Total 'M.findMax': the largest key and its value. 'Data.Maybe.Nothing' for the+-- empty map. This is 'M.lookupMax'.+--+-- ==== __Examples__+--+-- >>> Map.findMax (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just (2,'b')+--+-- >>> Map.findMax (Map.empty :: Map Int Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; Map.findMax m === preview _last (Map.toList m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMax :: Map k a -> Maybe (k, a)+findMax =+  M.lookupMax+{-# INLINE findMax #-}++-- | Total 'M.deleteFindMin': the smallest key and its value, and the map+-- without them. 'Data.Maybe.Nothing' for the empty map. This is 'M.minViewWithKey'.+--+-- ==== __Examples__+--+-- >>> Map.deleteFindMin (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just ((1,'a'),fromList [(2,'b')])+--+-- >>> Map.deleteFindMin (Map.empty :: Map Int Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; fmap (\(kv, m') -> Map.insert (P.fst kv) (P.snd kv) m') (Map.deleteFindMin m) === (m <$ Map.findMin m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMin :: Map k a -> Maybe ((k, a), Map k a)+deleteFindMin =+  M.minViewWithKey+{-# INLINE deleteFindMin #-}++-- | Total 'M.deleteFindMax': the largest key and its value, and the map+-- without them. 'Data.Maybe.Nothing' for the empty map. This is 'M.maxViewWithKey'.+--+-- ==== __Examples__+--+-- >>> Map.deleteFindMax (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just ((2,'b'),fromList [(1,'a')])+--+-- >>> Map.deleteFindMax (Map.empty :: Map Int Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; fmap (\(kv, m') -> Map.insert (P.fst kv) (P.snd kv) m') (Map.deleteFindMax m) === (m <$ Map.findMax m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMax :: Map k a -> Maybe ((k, a), Map k a)+deleteFindMax =+  M.maxViewWithKey+{-# INLINE deleteFindMax #-}++-- | Total 'M.elemAt': the key and value at an index of the map in key+-- order. 'Data.Maybe.Nothing' for an index out of range.+--+-- ==== __Examples__+--+-- >>> Map.elemAt 1 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just (2,'b')+--+-- >>> Map.elemAt 2 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; i <- forAll genIndex; Map.elemAt i m === (Map.toList m P.!? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+elemAt :: Int -> Map k a -> Maybe (k, a)+elemAt i m =+  M.elemAt i m <$ guard (inRange i m)+{-# INLINE elemAt #-}++-- | Total 'M.findIndex': the index of a key in key order. 'Data.Maybe.Nothing' where+-- the key is not in the map. This is 'M.lookupIndex'.+--+-- ==== __Examples__+--+-- >>> Map.findIndex 2 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just 1+--+-- >>> Map.findIndex 3 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; k <- forAll (Gen.int (Range.linear 0 30)); (Map.findIndex k m >>= \i -> Map.elemAt i m) === fmap (\v -> (k, v)) (Map.lookup k m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findIndex :: (Ord k) => k -> Map k a -> Maybe Int+findIndex =+  M.lookupIndex+{-# INLINE findIndex #-}++-- | Total 'M.deleteAt': the map without the key at an index in key order.+-- 'Data.Maybe.Nothing' for an index out of range.+--+-- ==== __Examples__+--+-- >>> Map.deleteAt 0 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just (fromList [(2,'b')])+--+-- >>> Map.deleteAt 2 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; i <- forAll genIndex; Map.deleteAt i m === fmap (\(k, _) -> Map.delete k m) (Map.elemAt i m)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteAt :: Int -> Map k a -> Maybe (Map k a)+deleteAt i m =+  M.deleteAt i m <$ guard (inRange i m)+{-# INLINE deleteAt #-}++-- | Total 'M.updateAt': update or delete the value at an index in key+-- order. 'Data.Maybe.Nothing' for an index out of range.+--+-- ==== __Examples__+--+-- >>> Map.updateAt (\_ _ -> Just 'z') 0 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Just (fromList [(1,'z'),(2,'b')])+--+-- >>> Map.updateAt (\_ _ -> Nothing) 5 (Map.fromList [(2, 'b'), (1 :: Int, 'a')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; i <- forAll genIndex; Map.updateAt (\_ _ -> Nothing) i m === Map.deleteAt i m+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Maybe (Map k a)+updateAt f i m =+  M.updateAt f i m <$ guard (inRange i m)+{-# INLINE updateAt #-}++-- | Total @fromAscList@: build a map from a list in ascending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromAscList [(1, 'a'), (2, 'b')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> Map.fromAscList [(2, 'b'), (1, 'a')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; Map.fromAscList kvs === bool Nothing (Just (Map.fromList kvs)) (P.sortOn P.fst kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscList :: (Ord k) => [(k, a)] -> Maybe (Map k a)+fromAscList kvs =+  M.fromAscList kvs <$ guard (pairwise (<=) (fmap fst kvs))+{-# INLINE fromAscList #-}++-- | Total @fromAscListWith@: build a map from a list in ascending order of keys, combining the values of equal keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromAscListWith (<>) [(1, "a"), (1, "b"), (2, "c")]+-- Just (fromList [(1,"ba"),(2,"c")])+--+-- >>> Map.fromAscListWith (<>) [(2, "a"), (1, "b")]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs }; Map.fromAscListWith (<>) kss === bool Nothing (Just (Map.fromListWith (<>) kss)) (P.sortOn P.fst kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscListWith :: (Ord k) => (a -> a -> a) -> [(k, a)] -> Maybe (Map k a)+fromAscListWith f kvs =+  M.fromAscListWith f kvs <$ guard (pairwise (<=) (fmap fst kvs))+{-# INLINE fromAscListWith #-}++-- | Total @fromAscListWithKey@: build a map from a list in ascending order of keys, combining the values of equal keys with the key, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromAscListWithKey (\k a b -> show k <> a <> b) [(1, "a"), (1, "b")]+-- Just (fromList [(1,"1ba")])+--+-- >>> Map.fromAscListWithKey (\_ a _ -> a) [(2, "a"), (1, "b")]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs; f k a b = show k <> a <> b }; Map.fromAscListWithKey f kss === bool Nothing (Just (Map.fromListWithKey f kss)) (P.sortOn P.fst kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscListWithKey :: (Ord k) => (k -> a -> a -> a) -> [(k, a)] -> Maybe (Map k a)+fromAscListWithKey f kvs =+  M.fromAscListWithKey f kvs <$ guard (pairwise (<=) (fmap fst kvs))+{-# INLINE fromAscListWithKey #-}++-- | Total @fromDistinctAscList@: build a map from a list in strictly ascending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromDistinctAscList [(1, 'a'), (2, 'b')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> Map.fromDistinctAscList [(1, 'a'), (1, 'b')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; Map.fromDistinctAscList kvs === bool Nothing (Just (Map.fromList kvs)) (P.sortOn P.fst kvs == kvs && P.nub (fmap P.fst kvs) == fmap P.fst kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDistinctAscList :: (Ord k) => [(k, a)] -> Maybe (Map k a)+fromDistinctAscList kvs =+  M.fromDistinctAscList kvs <$ guard (pairwise (<) (fmap fst kvs))+{-# INLINE fromDistinctAscList #-}++-- | Total @fromDescList@: build a map from a list in descending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromDescList [(2, 'b'), (1, 'a')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> Map.fromDescList [(1, 'a'), (2, 'b')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; Map.fromDescList kvs === bool Nothing (Just (Map.fromList kvs)) (P.sortOn (Down . P.fst) kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDescList :: (Ord k) => [(k, a)] -> Maybe (Map k a)+fromDescList kvs =+  M.fromDescList kvs <$ guard (pairwise (>=) (fmap fst kvs))+{-# INLINE fromDescList #-}++-- | Total @fromDescListWith@: build a map from a list in descending order of keys, combining the values of equal keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromDescListWith (<>) [(2, "c"), (1, "a"), (1, "b")]+-- Just (fromList [(1,"ba"),(2,"c")])+--+-- >>> Map.fromDescListWith (<>) [(1, "a"), (2, "b")]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs }; Map.fromDescListWith (<>) kss === bool Nothing (Just (Map.fromListWith (<>) kss)) (P.sortOn (Down . P.fst) kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDescListWith :: (Ord k) => (a -> a -> a) -> [(k, a)] -> Maybe (Map k a)+fromDescListWith f kvs =+  M.fromDescListWith f kvs <$ guard (pairwise (>=) (fmap fst kvs))+{-# INLINE fromDescListWith #-}++-- | Total @fromDescListWithKey@: build a map from a list in descending order of keys, combining the values of equal keys with the key, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromDescListWithKey (\k a b -> show k <> a <> b) [(1, "a"), (1, "b")]+-- Just (fromList [(1,"1ba")])+--+-- >>> Map.fromDescListWithKey (\_ a _ -> a) [(1, "a"), (2, "b")]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs; f k a b = show k <> a <> b }; Map.fromDescListWithKey f kss === bool Nothing (Just (Map.fromListWithKey f kss)) (P.sortOn (Down . P.fst) kvs == kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDescListWithKey :: (Ord k) => (k -> a -> a -> a) -> [(k, a)] -> Maybe (Map k a)+fromDescListWithKey f kvs =+  M.fromDescListWithKey f kvs <$ guard (pairwise (>=) (fmap fst kvs))+{-# INLINE fromDescListWithKey #-}++-- | Total @fromDistinctDescList@: build a map from a list in strictly descending order of keys, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.fromDistinctDescList [(2, 'b'), (1, 'a')]+-- Just (fromList [(1,'a'),(2,'b')])+--+-- >>> Map.fromDistinctDescList [(1, 'a'), (1, 'b')]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do kvs <- forAll genKVs; Map.fromDistinctDescList kvs === bool Nothing (Just (Map.fromList kvs)) (P.sortOn (Down . P.fst) kvs == kvs && P.nub (fmap P.fst kvs) == fmap P.fst kvs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDistinctDescList :: (Ord k) => [(k, a)] -> Maybe (Map k a)+fromDistinctDescList kvs =+  M.fromDistinctDescList kvs <$ guard (pairwise (>) (fmap fst kvs))+{-# INLINE fromDistinctDescList #-}++-- | Total @mapKeysMonotonic@: map the keys with a strictly increasing function, in linear time. 'Data.Maybe.Nothing' where the function is not strictly increasing on the keys of the map, where "Data.Map.Strict"'s builds a map that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Map.mapKeysMonotonic (* 2) (Map.fromList [(1, 'a'), (2, 'b')])+-- Just (fromList [(2,'a'),(4,'b')])+--+-- >>> Map.mapKeysMonotonic negate (Map.fromList [(1, 'a'), (2, 'b')])+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do m <- forAll (fmap Map.fromList genKVs); c <- forAll (Gen.int (Range.linear (-2) 2)); Map.mapKeysMonotonic (* c) m === bool Nothing (Just (Map.mapKeys (* c) m)) (c > 0 || Map.size m <= 1)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+mapKeysMonotonic :: (Ord k2) => (k1 -> k2) -> Map k1 a -> Maybe (Map k2 a)+mapKeysMonotonic f m =+  let r = M.mapKeysMonotonic f m+   in r <$ guard (pairwise (<) (M.keys r))+{-# INLINE mapKeysMonotonic #-}
src/Papa/Containers/Data/Seq.hs view
@@ -1,8 +1,276 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Finite sequences, with total versions of the partial functions of+-- "Data.Sequence". Import qualified:+--+-- > import qualified Papa.Containers.Data.Seq as Seq+--+-- The functions of "Data.Sequence" that throw (@index@ out of range;+-- @replicate@, @replicateA@, @replicateM@, @iterateN@ and @fromFunction@+-- with a negative length; @chunksOf@ with a non-positive size;+-- @cycleTaking@ of an empty sequence; @scanl1@ and @scanr1@ of an empty+-- sequence) are replaced by functions of the same names that return+-- 'Data.Maybe.Nothing' there instead. module Papa.Containers.Data.Seq (   module X,+  index,+  replicate,+  replicateA,+  replicateM,+  iterateN,+  fromFunction,+  chunksOf,+  cycleTaking,+  scanl1,+  scanr1, ) where -import Data.Sequence as X+import Control.Applicative (Applicative)+import Control.Monad (Monad, guard)+import Data.Bool (not, (||))+import Data.Function (flip)+import Data.Functor ((<$))+import Data.Int (Int)+import Data.Maybe (Maybe)+import Data.Ord (Ord ((<=), (>)))+import Data.Sequence as X hiding (+  chunksOf,+  cycleTaking,+  fromFunction,+  index,+  iterateN,+  replicate,+  replicateA,+  replicateM,+  scanl1,+  scanr1,+ )+import qualified Data.Sequence as S++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Containers.Data.Seq as Seq+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)+-- >>> let genSeq = Seq.fromList <$> Gen.list (Range.linear 0 20) genInt+-- >>> let genLength = Gen.int (Range.linear (-5) 20)++-- | Total 'S.index': the element at an index. 'Data.Maybe.Nothing' for an index out of+-- range. This is 'S.lookup', with the arguments of 'S.index'.+--+-- ==== __Examples__+--+-- >>> Seq.index (Seq.fromList "abc") 1+-- Just 'b'+--+-- >>> Seq.index (Seq.fromList "abc") 3+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSeq; i <- forAll genLength; Seq.index s i === (toList s P.!? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+index :: Seq a -> Int -> Maybe a+index =+  flip S.lookup+{-# INLINE index #-}++-- | Total 'S.replicate': a sequence of a value repeated. 'Data.Maybe.Nothing' for a+-- negative length.+--+-- ==== __Examples__+--+-- >>> Seq.replicate 3 'a'+-- Just (fromList "aaa")+--+-- >>> Seq.replicate (-1) 'a'+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genLength; a <- forAll genInt; fmap toList (Seq.replicate n a) === bool Nothing (Just (P.replicate n a)) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+replicate :: Int -> a -> Maybe (Seq a)+replicate n a =+  S.replicate n a <$ guard (0 <= n)+{-# INLINE replicate #-}++-- | Total 'S.replicateA': an action repeated, collecting the results in a+-- sequence. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> Seq.replicateA 2 (Just 'a')+-- Just (Just (fromList "aa"))+--+-- >>> Seq.replicateA (-1) (Just 'a')+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genLength; a <- forAll genInt; Seq.replicateA n (Just a) === fmap Just (Seq.replicate n a)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+replicateA :: (Applicative f) => Int -> f a -> Maybe (f (Seq a))+replicateA n fa =+  S.replicateA n fa <$ guard (0 <= n)+{-# INLINE replicateA #-}++-- | Total 'S.replicateM': 'replicateA' at a 'Monad'. 'Data.Maybe.Nothing' for a+-- negative length.+--+-- ==== __Examples__+--+-- >>> Seq.replicateM 2 [0, 1 :: Int]+-- Just [fromList [0,0],fromList [0,1],fromList [1,0],fromList [1,1]]+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-3) 4)); Seq.replicateM n "ab" === Seq.replicateA n "ab"+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+replicateM :: (Monad m) => Int -> m a -> Maybe (m (Seq a))+replicateM n ma =+  S.replicateM n ma <$ guard (0 <= n)+{-# INLINE replicateM #-}++-- | Total 'S.iterateN': the first @n@ iterations of a function. 'Data.Maybe.Nothing'+-- for a negative length.+--+-- ==== __Examples__+--+-- >>> Seq.iterateN 4 (* 2) (1 :: Int)+-- Just (fromList [1,2,4,8])+--+-- >>> Seq.iterateN (-1) (* 2) (1 :: Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genLength; f <- forAll (fn genInt); a <- forAll genInt; fmap toList (Seq.iterateN n (apply f) a) === bool Nothing (Just (P.take n (toList (iterate (apply f) a)))) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+iterateN :: Int -> (a -> a) -> a -> Maybe (Seq a)+iterateN n f a =+  S.iterateN n f a <$ guard (0 <= n)+{-# INLINE iterateN #-}++-- | Total 'S.fromFunction': the sequence of a function at @0@ to @n - 1@.+-- 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> Seq.fromFunction 3 (* 10)+-- Just (fromList [0,10,20])+--+-- >>> Seq.fromFunction (-1) (* 10)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genLength; f <- forAll (fn genInt); fmap toList (Seq.fromFunction n (apply f)) === bool Nothing (Just (fmap (apply f) (P.take n (toList (iterate (+ 1) 0))))) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+fromFunction :: Int -> (Int -> a) -> Maybe (Seq a)+fromFunction n f =+  S.fromFunction n f <$ guard (0 <= n)+{-# INLINE fromFunction #-}++-- | Total 'S.chunksOf': a sequence split into chunks of a size (the last+-- may be smaller). 'Data.Maybe.Nothing' for a size that is not positive, unless the+-- sequence is empty.+--+-- ==== __Examples__+--+-- >>> Seq.chunksOf 2 (Seq.fromList "abcde")+-- Just (fromList [fromList "ab",fromList "cd",fromList "e"])+--+-- >>> Seq.chunksOf 0 (Seq.fromList "abcde")+-- Nothing+--+-- >>> Seq.chunksOf 0 (Seq.empty :: Seq Char)+-- Just (fromList [])+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genLength; s <- forAll genSeq; fmap (foldMap id) (Seq.chunksOf n s) === bool Nothing (Just s) (n > 0 || S.null s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+chunksOf :: Int -> Seq a -> Maybe (Seq (Seq a))+chunksOf n s =+  S.chunksOf n s <$ guard (n > 0 || S.null s)+{-# INLINE chunksOf #-}++-- | Total 'S.cycleTaking': the first @n@ elements of a sequence repeated+-- forever. 'Data.Maybe.Nothing' for a positive length and an empty sequence.+--+-- ==== __Examples__+--+-- >>> Seq.cycleTaking 5 (Seq.fromList "ab")+-- Just (fromList "ababa")+--+-- >>> Seq.cycleTaking 5 (Seq.empty :: Seq Char)+-- Nothing+--+-- >>> Seq.cycleTaking 0 (Seq.empty :: Seq Char)+-- Just (fromList "")+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genLength; s <- forAll genSeq; fmap toList (Seq.cycleTaking n s) === bool (fmap (P.take n) (cycle (toList s))) (Just []) (n <= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+cycleTaking :: Int -> Seq a -> Maybe (Seq a)+cycleTaking n s =+  S.cycleTaking n s <$ guard (n <= 0 || not (S.null s))+{-# INLINE cycleTaking #-}++-- | Total 'S.scanl1': the left scan of a non-empty sequence. 'Data.Maybe.Nothing' for+-- the empty sequence.+--+-- ==== __Examples__+--+-- >>> Seq.scanl1 (+) (Seq.fromList [1, 2, 3 :: Int])+-- Just (fromList [1,3,6])+--+-- >>> Seq.scanl1 (+) (Seq.empty :: Seq Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSeq; fmap toList (Seq.scanl1 (+) s) === fmap (\(h :| t) -> toList (P.scanl (+) h t)) (nonEmpty (toList s))+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+scanl1 :: (a -> a -> a) -> Seq a -> Maybe (Seq a)+scanl1 f s =+  S.scanl1 f s <$ guard (not (S.null s))+{-# INLINE scanl1 #-}++-- | Total 'S.scanr1': the right scan of a non-empty sequence. 'Data.Maybe.Nothing' for+-- the empty sequence.+--+-- ==== __Examples__+--+-- >>> Seq.scanr1 (+) (Seq.fromList [1, 2, 3 :: Int])+-- Just (fromList [6,5,3])+--+-- >>> Seq.scanr1 (+) (Seq.empty :: Seq Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSeq; fmap (toList . Seq.reverse) (Seq.scanr1 (+) s) === fmap (\(h :| t) -> toList (P.scanl (+) h t)) (nonEmpty (toList (Seq.reverse s)))+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+scanr1 :: (a -> a -> a) -> Seq a -> Maybe (Seq a)+scanr1 f s =+  S.scanr1 f s <$ guard (not (S.null s))+{-# INLINE scanr1 #-}
src/Papa/Containers/Data/Set.hs view
@@ -1,8 +1,322 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | Sets, with total versions of the partial functions of "Data.Set".+-- Import qualified:+--+-- > import qualified Papa.Containers.Data.Set as Set+--+-- The functions of "Data.Set" that throw (@findMin@, @findMax@,+-- @deleteFindMin@, @deleteFindMax@, @elemAt@, @findIndex@, @deleteAt@) are+-- replaced by functions of the same names that return 'Data.Maybe.Nothing' there+-- instead.+--+-- The functions that build a set from an ordered list, or map it with a+-- monotonic function, check the order in the same linear time, and return+-- 'Data.Maybe.Nothing' where it does not hold, where "Data.Set"'s build a set that+-- breaks its invariant. module Papa.Containers.Data.Set (   module X,+  findMin,+  findMax,+  deleteFindMin,+  deleteFindMax,+  elemAt,+  findIndex,+  deleteAt,+  fromAscList,+  fromDescList,+  fromDistinctAscList,+  fromDistinctDescList,+  mapMonotonic, ) where -import Data.Set as X+import Control.Monad (guard)+import Data.Bool (Bool, (&&))+import Data.Functor ((<$))+import Data.Int (Int)+import Data.Maybe (Maybe)+import Data.Ord (Ord ((<), (<=), (>), (>=)))+import Data.Set as X hiding (+  deleteAt,+  deleteFindMax,+  deleteFindMin,+  elemAt,+  findIndex,+  findMax,+  findMin,+  fromAscList,+  fromDescList,+  fromDistinctAscList,+  fromDistinctDescList,+  mapMonotonic,+ )+import qualified Data.Set as S+import Papa.Internal.Order (pairwise)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Containers.Data.Set as Set+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genXs0 = Gen.list (Range.linear 0 10) (Gen.int (Range.linear 0 9))+-- >>> let genXs = Gen.choice [P.sort <$> genXs0, P.sortOn Down <$> genXs0, P.nub . P.sort <$> genXs0, genXs0]+-- >>> let genSet = Set.fromList <$> Gen.list (Range.linear 0 20) (Gen.int (Range.linear 0 30))+-- >>> let genIndex = Gen.int (Range.linear (-5) 25)++-- | Whether an index is a position in a set.+inRange :: Int -> Set a -> Bool+inRange i s =+  0 <= i && i < S.size s+{-# INLINE inRange #-}++-- | Total 'S.findMin': the smallest element. 'Data.Maybe.Nothing' for the empty set.+-- This is 'S.lookupMin'.+--+-- ==== __Examples__+--+-- >>> Set.findMin (Set.fromList [2, 1 :: Int])+-- Just 1+--+-- >>> Set.findMin (Set.empty :: Set Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; Set.findMin s === preview _head (Set.toAscList s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMin :: Set a -> Maybe a+findMin =+  S.lookupMin+{-# INLINE findMin #-}++-- | Total 'S.findMax': the largest element. 'Data.Maybe.Nothing' for the empty set.+-- This is 'S.lookupMax'.+--+-- ==== __Examples__+--+-- >>> Set.findMax (Set.fromList [2, 1 :: Int])+-- Just 2+--+-- >>> Set.findMax (Set.empty :: Set Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; Set.findMax s === preview _last (Set.toAscList s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findMax :: Set a -> Maybe a+findMax =+  S.lookupMax+{-# INLINE findMax #-}++-- | Total 'S.deleteFindMin': the smallest element, and the set without it.+-- 'Data.Maybe.Nothing' for the empty set. This is 'S.minView'.+--+-- ==== __Examples__+--+-- >>> Set.deleteFindMin (Set.fromList [2, 1 :: Int])+-- Just (1,fromList [2])+--+-- >>> Set.deleteFindMin (Set.empty :: Set Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; fmap (\(a, s') -> Set.insert a s') (Set.deleteFindMin s) === (s <$ Set.findMin s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMin :: Set a -> Maybe (a, Set a)+deleteFindMin =+  S.minView+{-# INLINE deleteFindMin #-}++-- | Total 'S.deleteFindMax': the largest element, and the set without it.+-- 'Data.Maybe.Nothing' for the empty set. This is 'S.maxView'.+--+-- ==== __Examples__+--+-- >>> Set.deleteFindMax (Set.fromList [2, 1 :: Int])+-- Just (2,fromList [1])+--+-- >>> Set.deleteFindMax (Set.empty :: Set Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; fmap (\(a, s') -> Set.insert a s') (Set.deleteFindMax s) === (s <$ Set.findMax s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteFindMax :: Set a -> Maybe (a, Set a)+deleteFindMax =+  S.maxView+{-# INLINE deleteFindMax #-}++-- | Total 'S.elemAt': the element at an index in ascending order.+-- 'Data.Maybe.Nothing' for an index out of range.+--+-- ==== __Examples__+--+-- >>> Set.elemAt 1 (Set.fromList [2, 1 :: Int])+-- Just 2+--+-- >>> Set.elemAt 2 (Set.fromList [2, 1 :: Int])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; i <- forAll genIndex; Set.elemAt i s === (Set.toAscList s !? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+elemAt :: Int -> Set a -> Maybe a+elemAt i s =+  S.elemAt i s <$ guard (inRange i s)+{-# INLINE elemAt #-}++-- | Total 'S.findIndex': the index of an element in ascending order.+-- 'Data.Maybe.Nothing' where it is not in the set. This is 'S.lookupIndex'.+--+-- ==== __Examples__+--+-- >>> Set.findIndex 2 (Set.fromList [2, 1 :: Int])+-- Just 1+--+-- >>> Set.findIndex 3 (Set.fromList [2, 1 :: Int])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; a <- forAll (Gen.int (Range.linear 0 30)); (Set.findIndex a s >>= \i -> Set.elemAt i s) === bool Nothing (Just a) (Set.member a s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+findIndex :: (Ord a) => a -> Set a -> Maybe Int+findIndex =+  S.lookupIndex+{-# INLINE findIndex #-}++-- | Total 'S.deleteAt': the set without the element at an index in+-- ascending order. 'Data.Maybe.Nothing' for an index out of range.+--+-- ==== __Examples__+--+-- >>> Set.deleteAt 0 (Set.fromList [2, 1 :: Int])+-- Just (fromList [2])+--+-- >>> Set.deleteAt 2 (Set.fromList [2, 1 :: Int])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; i <- forAll genIndex; Set.deleteAt i s === fmap (\a -> Set.delete a s) (Set.elemAt i s)+-- ...passed 100 tests.+-- True+--+-- @since 0.6.0+deleteAt :: Int -> Set a -> Maybe (Set a)+deleteAt i s =+  S.deleteAt i s <$ guard (inRange i s)+{-# INLINE deleteAt #-}++-- | Total @fromAscList@: build a set from a list in ascending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Set"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Set.fromAscList [1, 2, 2, 3]+-- Just (fromList [1,2,3])+--+-- >>> Set.fromAscList [2, 1]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; Set.fromAscList xs === bool Nothing (Just (Set.fromList xs)) (P.sort xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromAscList :: (Ord a) => [a] -> Maybe (Set a)+fromAscList xs =+  S.fromAscList xs <$ guard (pairwise (<=) xs)+{-# INLINE fromAscList #-}++-- | Total @fromDescList@: build a set from a list in descending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Set"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Set.fromDescList [3, 2, 2, 1]+-- Just (fromList [1,2,3])+--+-- >>> Set.fromDescList [1, 2]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; Set.fromDescList xs === bool Nothing (Just (Set.fromList xs)) (P.sortOn Down xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDescList :: (Ord a) => [a] -> Maybe (Set a)+fromDescList xs =+  S.fromDescList xs <$ guard (pairwise (>=) xs)+{-# INLINE fromDescList #-}++-- | Total @fromDistinctAscList@: build a set from a list in strictly ascending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Set"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Set.fromDistinctAscList [1, 2, 3]+-- Just (fromList [1,2,3])+--+-- >>> Set.fromDistinctAscList [1, 1]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; Set.fromDistinctAscList xs === bool Nothing (Just (Set.fromList xs)) (P.sort xs == xs && P.nub xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDistinctAscList :: (Ord a) => [a] -> Maybe (Set a)+fromDistinctAscList xs =+  S.fromDistinctAscList xs <$ guard (pairwise (<) xs)+{-# INLINE fromDistinctAscList #-}++-- | Total @fromDistinctDescList@: build a set from a list in strictly descending order, in linear time. 'Data.Maybe.Nothing' where it is not, where "Data.Set"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Set.fromDistinctDescList [3, 2, 1]+-- Just (fromList [1,2,3])+--+-- >>> Set.fromDistinctDescList [1, 1]+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do xs <- forAll genXs; Set.fromDistinctDescList xs === bool Nothing (Just (Set.fromList xs)) (P.sortOn Down xs == xs && P.nub xs == xs)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+fromDistinctDescList :: (Ord a) => [a] -> Maybe (Set a)+fromDistinctDescList xs =+  S.fromDistinctDescList xs <$ guard (pairwise (>) xs)+{-# INLINE fromDistinctDescList #-}++-- | Total @mapMonotonic@: map the elements with a strictly increasing function, in linear time. 'Data.Maybe.Nothing' where the function is not strictly increasing on the elements of the set, where "Data.Set"'s builds a set that breaks its invariant.+--+-- ==== __Examples__+--+-- >>> Set.mapMonotonic (* 2) (Set.fromList [1, 2])+-- Just (fromList [2,4])+--+-- >>> Set.mapMonotonic negate (Set.fromList [1, 2])+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do s <- forAll (fmap Set.fromList genXs); c <- forAll (Gen.int (Range.linear (-2) 2)); Set.mapMonotonic (* c) s === bool Nothing (Just (Set.map (* c) s)) (c > 0 || Set.size s <= 1)+-- ...passed 200 tests.+-- True+--+-- @since 0.6.0+mapMonotonic :: (Ord b) => (a -> b) -> Set a -> Maybe (Set b)+mapMonotonic f s =+  let r = S.mapMonotonic f s+   in r <$ guard (pairwise (<) (S.toAscList r))+{-# INLINE mapMonotonic #-}
+ src/Papa/Directory/System/Directory.hs view
@@ -0,0 +1,775 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Files and directories ("System.Directory"), returning their failures in+-- 'IOExcept' instead of throwing them.+--+-- Every action of "System.Directory" is here, at the same name, with its+-- result in 'IOExcept'. That includes the actions that do not fail, such as+-- 'doesFileExist' (which returns 'Data.Bool.False' when it cannot tell), so+-- that every action of the file system composes in 'IOExcept' alike.+--+-- Left out:+--+-- * @getDirectoryContents@, which includes @.@ and @..@: use 'listDirectory'.+-- * @isSymbolicLink@, deprecated: use 'pathIsSymbolicLink'.+-- * @findFileWith@ and @findFilesWith@, whose predicate is an action that+--   throws: use 'findFiles' and filter its result.+--+-- The current directory ('getCurrentDirectory', 'setCurrentDirectory',+-- 'withCurrentDirectory') is the process's, shared by all of its threads.+--+-- @since 0.7.0+module Papa.Directory.System.Directory (+  -- * Directories+  createDirectory,+  createDirectoryIfMissing,+  removeDirectory,+  removeDirectoryRecursive,+  removePathForcibly,+  renameDirectory,+  listDirectory,++  -- * The current directory+  getCurrentDirectory,+  setCurrentDirectory,+  withCurrentDirectory,++  -- * Special directories+  getHomeDirectory,+  XdgDirectory (XdgData, XdgConfig, XdgCache, XdgState),+  getXdgDirectory,+  XdgDirectoryList (XdgDataDirs, XdgConfigDirs),+  getXdgDirectoryList,+  getAppUserDataDirectory,+  getUserDocumentsDirectory,+  getTemporaryDirectory,++  -- * Files+  removeFile,+  renameFile,+  renamePath,+  copyFile,+  copyFileWithMetadata,+  getFileSize,+  canonicalizePath,+  makeAbsolute,+  makeRelativeToCurrentDirectory,++  -- * Existence+  doesPathExist,+  doesFileExist,+  doesDirectoryExist,++  -- * Finding files+  findExecutable,+  findExecutables,+  findExecutablesInDirectories,+  findFile,+  findFiles,+  exeExtension,++  -- * Symbolic links+  createFileLink,+  createDirectoryLink,+  removeDirectoryLink,+  pathIsSymbolicLink,+  getSymbolicLinkTarget,++  -- * Permissions+  Permissions,+  emptyPermissions,+  readable,+  writable,+  executable,+  searchable,+  setOwnerReadable,+  setOwnerWritable,+  setOwnerExecutable,+  setOwnerSearchable,+  getPermissions,+  setPermissions,+  copyPermissions,++  -- * Timestamps+  getAccessTime,+  getModificationTime,+  setAccessTime,+  setModificationTime,+) where++import Control.Category ((.))+import Control.Monad ((>>=))+import Control.Monad.Except (liftEither, runExceptT)+import Data.Bool (Bool)+import Data.Maybe (Maybe)+import Data.String (String)+import Data.Time.Clock (UTCTime)+import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import System.Directory (+  Permissions,+  XdgDirectory (XdgCache, XdgConfig, XdgData, XdgState),+  XdgDirectoryList (XdgConfigDirs, XdgDataDirs),+  emptyPermissions,+  exeExtension,+  executable,+  readable,+  searchable,+  setOwnerExecutable,+  setOwnerReadable,+  setOwnerSearchable,+  setOwnerWritable,+  writable,+ )+import qualified System.Directory as D+import System.IO (FilePath)+import Prelude (Integer)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified System.Directory as D+-- >>> import qualified Data.Time as Time+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> import qualified Data.Version as V+-- >>> import qualified System.Info as I+-- >>> dir <- (</> ("papa-directory-doctest-" <> V.showVersion I.fullCompilerVersion)) <$> D.getTemporaryDirectory+-- >>> D.removePathForcibly dir >> D.createDirectory dir+-- >>> let file = dir </> "a.txt"+-- >>> _ <- runExceptT (writeFile file (pack "abc"))++-- | Create a directory. Its parent must exist.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectory (dir </> "c") >> doesDirectoryExist (dir </> "c"))+-- Right True+--+-- >>> either (anyOf _IOException (\i -> has _AlreadyExists (the errorType i))) (const False) <$> runExceptT (createDirectory (dir </> "c"))+-- True+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (createDirectory (dir </> "x" </> "y"))+-- True+--+-- @since 0.7.0+createDirectory :: FilePath -> IOExcept ()+createDirectory =+  exceptIO . D.createDirectory+{-# INLINE createDirectory #-}++-- | Create a directory, and, if the flag is 'Data.Bool.True', its missing+-- parents. A directory that exists is not a failure.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectoryIfMissing True (dir </> "p" </> "q") >> createDirectoryIfMissing True (dir </> "p" </> "q") >> doesDirectoryExist (dir </> "p" </> "q"))+-- Right True+--+-- >>> check $ withTests 20 $ property $ do { n <- forAll (Gen.string (Range.linear 1 8) Gen.alphaNum); r <- evalIO (runExceptT (createDirectoryIfMissing True (dir </> "i" </> n) >> createDirectoryIfMissing True (dir </> "i" </> n) >> doesDirectoryExist (dir </> "i" </> n))); r === Right True }+-- ...passed 20 tests.+-- True+--+-- @since 0.7.0+createDirectoryIfMissing :: Bool -> FilePath -> IOExcept ()+createDirectoryIfMissing b =+  exceptIO . D.createDirectoryIfMissing b+{-# INLINE createDirectoryIfMissing #-}++-- | Remove an empty directory.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectory (dir </> "e") >> removeDirectory (dir </> "e") >> doesDirectoryExist (dir </> "e"))+-- Right False+--+-- >>> isLeft <$> runExceptT (removeDirectory dir)+-- True+--+-- @since 0.7.0+removeDirectory :: FilePath -> IOExcept ()+removeDirectory =+  exceptIO . D.removeDirectory+{-# INLINE removeDirectory #-}++-- | Remove a directory and all that it contains. Symbolic links in it are+-- removed, not followed.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectoryIfMissing True (dir </> "r" </> "s") >> removeDirectoryRecursive (dir </> "r") >> doesPathExist (dir </> "r"))+-- Right False+--+-- @since 0.7.0+removeDirectoryRecursive :: FilePath -> IOExcept ()+removeDirectoryRecursive =+  exceptIO . D.removeDirectoryRecursive+{-# INLINE removeDirectoryRecursive #-}++-- | Remove a file or directory and all that it contains, if it exists, and+-- even if it is not writable. A path that does not exist is not a failure.+--+-- ==== __Examples__+--+-- >>> runExceptT (removePathForcibly (dir </> "nothing"))+-- Right ()+--+-- @since 0.7.0+removePathForcibly :: FilePath -> IOExcept ()+removePathForcibly =+  exceptIO . D.removePathForcibly+{-# INLINE removePathForcibly #-}++-- | Rename a directory.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectory (dir </> "m") >> renameDirectory (dir </> "m") (dir </> "n") >> traverse doesDirectoryExist [dir </> "m", dir </> "n"])+-- Right [False,True]+--+-- @since 0.7.0+renameDirectory :: FilePath -> FilePath -> IOExcept ()+renameDirectory a =+  exceptIO . D.renameDirectory a+{-# INLINE renameDirectory #-}++-- | The names in a directory, without @.@ and @..@, in no order.+--+-- ==== __Examples__+--+-- >>> fmap sort <$> runExceptT (writeFile (dir </> "b") (pack "") >> createDirectory (dir </> "a") >> listDirectory dir)+-- Right ["a","a.txt","b"]+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (listDirectory "/nonexistent/papa")+-- True+--+-- @since 0.7.0+listDirectory :: FilePath -> IOExcept [FilePath]+listDirectory =+  exceptIO . D.listDirectory+{-# INLINE listDirectory #-}++-- | The current directory of the process.+--+-- ==== __Examples__+--+-- >>> (==) <$> runExceptT getCurrentDirectory <*> fmap Right D.getCurrentDirectory+-- True+--+-- @since 0.7.0+getCurrentDirectory :: IOExcept FilePath+getCurrentDirectory =+  exceptIO D.getCurrentDirectory+{-# INLINE getCurrentDirectory #-}++-- | Set the current directory of the process, for all of its threads.+--+-- ==== __Examples__+--+-- >>> isLeft <$> runExceptT (setCurrentDirectory "/nonexistent/papa")+-- True+--+-- @since 0.7.0+setCurrentDirectory :: FilePath -> IOExcept ()+setCurrentDirectory =+  exceptIO . D.setCurrentDirectory+{-# INLINE setCurrentDirectory #-}++-- | Run an action in a directory, and then return to the current directory,+-- whether or not the action fails. The failure of the change of directory,+-- of the action, or of the return is returned.+--+-- The current directory is the process's: other threads see the change while+-- the action runs.+--+-- ==== __Examples__+--+-- >>> c <- D.getCurrentDirectory+-- >>> (\r d -> r == Right d) <$> runExceptT (withCurrentDirectory dir (getCurrentDirectory >>= canonicalizePath)) <*> D.canonicalizePath dir+-- True+--+-- >>> (\r d -> (isLeft r, d == c)) <$> runExceptT (withCurrentDirectory dir (listDirectory "/nonexistent/papa")) <*> D.getCurrentDirectory+-- (True,True)+--+-- >>> isLeft <$> runExceptT (withCurrentDirectory "/nonexistent/papa" (pure ()))+-- True+--+-- @since 0.7.0+withCurrentDirectory :: FilePath -> IOExcept a -> IOExcept a+withCurrentDirectory d a =+  exceptIO (D.withCurrentDirectory d (runExceptT a)) >>= liftEither+{-# INLINE withCurrentDirectory #-}++-- | The home directory of the user.+--+-- ==== __Examples__+--+-- >>> isRight <$> runExceptT getHomeDirectory+-- True+--+-- @since 0.7.0+getHomeDirectory :: IOExcept FilePath+getHomeDirectory =+  exceptIO D.getHomeDirectory+{-# INLINE getHomeDirectory #-}++-- | A directory of the XDG Base Directory Specification, for an+-- application's files.+--+-- ==== __Examples__+--+-- >>> fmap (isSuffixOf "papa") <$> runExceptT (getXdgDirectory XdgConfig "papa")+-- Right True+--+-- @since 0.7.0+getXdgDirectory :: XdgDirectory -> FilePath -> IOExcept FilePath+getXdgDirectory x =+  exceptIO . D.getXdgDirectory x+{-# INLINE getXdgDirectory #-}++-- | The search path of the XDG Base Directory Specification.+--+-- ==== __Examples__+--+-- >>> isRight <$> runExceptT (getXdgDirectoryList XdgDataDirs)+-- True+--+-- @since 0.7.0+getXdgDirectoryList :: XdgDirectoryList -> IOExcept [FilePath]+getXdgDirectoryList =+  exceptIO . D.getXdgDirectoryList+{-# INLINE getXdgDirectoryList #-}++-- | The directory of an application's data, in the home directory (on+-- POSIX, @~/.app@).+--+-- ==== __Examples__+--+-- >>> fmap (isSuffixOf ".papa") <$> runExceptT (getAppUserDataDirectory "papa")+-- Right True+--+-- @since 0.7.0+getAppUserDataDirectory :: FilePath -> IOExcept FilePath+getAppUserDataDirectory =+  exceptIO . D.getAppUserDataDirectory+{-# INLINE getAppUserDataDirectory #-}++-- | The directory of the user's documents (on POSIX, the home directory).+--+-- ==== __Examples__+--+-- >>> isRight <$> runExceptT getUserDocumentsDirectory+-- True+--+-- @since 0.7.0+getUserDocumentsDirectory :: IOExcept FilePath+getUserDocumentsDirectory =+  exceptIO D.getUserDocumentsDirectory+{-# INLINE getUserDocumentsDirectory #-}++-- | The directory for temporary files: @TMPDIR@, or else @\/tmp@, on POSIX.+--+-- ==== __Examples__+--+-- >>> (==) <$> runExceptT getTemporaryDirectory <*> fmap Right D.getTemporaryDirectory+-- True+--+-- @since 0.7.0+getTemporaryDirectory :: IOExcept FilePath+getTemporaryDirectory =+  exceptIO D.getTemporaryDirectory+{-# INLINE getTemporaryDirectory #-}++-- | Remove a file.+--+-- ==== __Examples__+--+-- >>> runExceptT (writeFile (dir </> "rm") (pack "") >> removeFile (dir </> "rm") >> doesFileExist (dir </> "rm"))+-- Right False+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (removeFile (dir </> "rm"))+-- True+--+-- @since 0.7.0+removeFile :: FilePath -> IOExcept ()+removeFile =+  exceptIO . D.removeFile+{-# INLINE removeFile #-}++-- | Rename a file, replacing the file at the new path, if any.+--+-- ==== __Examples__+--+-- >>> runExceptT (writeFile (dir </> "f") (pack "f") >> renameFile (dir </> "f") (dir </> "g") >> readFile (dir </> "g"))+-- Right "f"+--+-- @since 0.7.0+renameFile :: FilePath -> FilePath -> IOExcept ()+renameFile a =+  exceptIO . D.renameFile a+{-# INLINE renameFile #-}++-- | Rename a file or directory.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectory (dir </> "t") >> renamePath (dir </> "t") (dir </> "u") >> doesDirectoryExist (dir </> "u"))+-- Right True+--+-- @since 0.7.0+renamePath :: FilePath -> FilePath -> IOExcept ()+renamePath a =+  exceptIO . D.renamePath a+{-# INLINE renamePath #-}++-- | Copy a file and its permissions.+--+-- ==== __Examples__+--+-- >>> runExceptT (copyFile file (dir </> "copy") >> readFile (dir </> "copy"))+-- Right "abc"+--+-- @since 0.7.0+copyFile :: FilePath -> FilePath -> IOExcept ()+copyFile a =+  exceptIO . D.copyFile a+{-# INLINE copyFile #-}++-- | Copy a file, its permissions and its timestamps.+--+-- ==== __Examples__+--+-- >>> runExceptT (copyFileWithMetadata file (dir </> "copy2") >> ((==) <$> getModificationTime file <*> getModificationTime (dir </> "copy2")))+-- Right True+--+-- @since 0.7.0+copyFileWithMetadata :: FilePath -> FilePath -> IOExcept ()+copyFileWithMetadata a =+  exceptIO . D.copyFileWithMetadata a+{-# INLINE copyFileWithMetadata #-}++-- | The size of a file, in bytes.+--+-- ==== __Examples__+--+-- >>> runExceptT (getFileSize file)+-- Right 3+--+-- @since 0.7.0+getFileSize :: FilePath -> IOExcept Integer+getFileSize =+  exceptIO . D.getFileSize+{-# INLINE getFileSize #-}++-- | The absolute path, with symbolic links, @.@ and @..@ resolved, of a path,+-- which need not exist.+--+-- ==== __Examples__+--+-- >>> (==) <$> runExceptT (canonicalizePath (dir </> "." </> "a.txt")) <*> fmap Right (D.canonicalizePath file)+-- True+--+-- @since 0.7.0+canonicalizePath :: FilePath -> IOExcept FilePath+canonicalizePath =+  exceptIO . D.canonicalizePath+{-# INLINE canonicalizePath #-}++-- | The absolute path of a path, relative to the current directory, which+-- need not exist. Symbolic links are not resolved.+--+-- ==== __Examples__+--+-- >>> fmap isAbsolute <$> runExceptT (makeAbsolute "x")+-- Right True+--+-- @since 0.7.0+makeAbsolute :: FilePath -> IOExcept FilePath+makeAbsolute =+  exceptIO . D.makeAbsolute+{-# INLINE makeAbsolute #-}++-- | A path relative to the current directory, if it is in it.+--+-- ==== __Examples__+--+-- >>> runExceptT (getCurrentDirectory >>= \c -> makeRelativeToCurrentDirectory (c </> "x"))+-- Right "x"+--+-- @since 0.7.0+makeRelativeToCurrentDirectory :: FilePath -> IOExcept FilePath+makeRelativeToCurrentDirectory =+  exceptIO . D.makeRelativeToCurrentDirectory+{-# INLINE makeRelativeToCurrentDirectory #-}++-- | Whether a file or directory exists.+--+-- ==== __Examples__+--+-- >>> runExceptT (traverse doesPathExist [dir, file, dir </> "nothing"])+-- Right [True,True,False]+--+-- @since 0.7.0+doesPathExist :: FilePath -> IOExcept Bool+doesPathExist =+  exceptIO . D.doesPathExist+{-# INLINE doesPathExist #-}++-- | Whether a file exists (and is not a directory).+--+-- ==== __Examples__+--+-- >>> runExceptT (traverse doesFileExist [dir, file, dir </> "nothing"])+-- Right [False,True,False]+--+-- @since 0.7.0+doesFileExist :: FilePath -> IOExcept Bool+doesFileExist =+  exceptIO . D.doesFileExist+{-# INLINE doesFileExist #-}++-- | Whether a directory exists.+--+-- ==== __Examples__+--+-- >>> runExceptT (traverse doesDirectoryExist [dir, file, dir </> "nothing"])+-- Right [True,False,False]+--+-- @since 0.7.0+doesDirectoryExist :: FilePath -> IOExcept Bool+doesDirectoryExist =+  exceptIO . D.doesDirectoryExist+{-# INLINE doesDirectoryExist #-}++-- | The path of an executable on the search path (@PATH@), if any.+--+-- ==== __Examples__+--+-- >>> fmap (fmap takeFileName) <$> runExceptT (findExecutable "sh")+-- Right (Just "sh")+--+-- >>> runExceptT (findExecutable "papa-no-such-executable")+-- Right Nothing+--+-- @since 0.7.0+findExecutable :: String -> IOExcept (Maybe FilePath)+findExecutable =+  exceptIO . D.findExecutable+{-# INLINE findExecutable #-}++-- | The paths of every executable of a name on the search path.+--+-- ==== __Examples__+--+-- >>> runExceptT (findExecutables "papa-no-such-executable")+-- Right []+--+-- @since 0.7.0+findExecutables :: String -> IOExcept [FilePath]+findExecutables =+  exceptIO . D.findExecutables+{-# INLINE findExecutables #-}++-- | The paths of every executable of a name in the given directories.+--+-- ==== __Examples__+--+-- >>> runExceptT (findExecutablesInDirectories [dir] "a.txt")+-- Right []+--+-- @since 0.7.0+findExecutablesInDirectories :: [FilePath] -> String -> IOExcept [FilePath]+findExecutablesInDirectories ds =+  exceptIO . D.findExecutablesInDirectories ds+{-# INLINE findExecutablesInDirectories #-}++-- | The path of the first file of a name in the given directories, if any.+--+-- ==== __Examples__+--+-- >>> (==) <$> runExceptT (findFile ["/nonexistent/papa", dir] "a.txt") <*> pure (Right (Just file))+-- True+--+-- @since 0.7.0+findFile :: [FilePath] -> String -> IOExcept (Maybe FilePath)+findFile ds =+  exceptIO . D.findFile ds+{-# INLINE findFile #-}++-- | The paths of every file of a name in the given directories.+--+-- ==== __Examples__+--+-- >>> (==) <$> runExceptT (findFiles [dir, dir] "a.txt") <*> pure (Right [file, file])+-- True+--+-- @since 0.7.0+findFiles :: [FilePath] -> String -> IOExcept [FilePath]+findFiles ds =+  exceptIO . D.findFiles ds+{-# INLINE findFiles #-}++-- | Create a symbolic link to a file.+--+-- ==== __Examples__+--+-- >>> runExceptT (createFileLink file (dir </> "link") >> pathIsSymbolicLink (dir </> "link"))+-- Right True+--+-- @since 0.7.0+createFileLink :: FilePath -> FilePath -> IOExcept ()+createFileLink a =+  exceptIO . D.createFileLink a+{-# INLINE createFileLink #-}++-- | Create a symbolic link to a directory.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectoryLink dir (dir </> "dlink") >> pathIsSymbolicLink (dir </> "dlink"))+-- Right True+--+-- @since 0.7.0+createDirectoryLink :: FilePath -> FilePath -> IOExcept ()+createDirectoryLink a =+  exceptIO . D.createDirectoryLink a+{-# INLINE createDirectoryLink #-}++-- | Remove a symbolic link to a directory, not the directory.+--+-- ==== __Examples__+--+-- >>> runExceptT (createDirectoryLink dir (dir </> "dlink2") >> removeDirectoryLink (dir </> "dlink2") >> traverse doesPathExist [dir </> "dlink2", dir])+-- Right [False,True]+--+-- @since 0.7.0+removeDirectoryLink :: FilePath -> IOExcept ()+removeDirectoryLink =+  exceptIO . D.removeDirectoryLink+{-# INLINE removeDirectoryLink #-}++-- | Whether a path is a symbolic link. A path that does not exist is a+-- failure.+--+-- ==== __Examples__+--+-- >>> runExceptT (pathIsSymbolicLink file)+-- Right False+--+-- >>> isLeft <$> runExceptT (pathIsSymbolicLink (dir </> "nothing"))+-- True+--+-- @since 0.7.0+pathIsSymbolicLink :: FilePath -> IOExcept Bool+pathIsSymbolicLink =+  exceptIO . D.pathIsSymbolicLink+{-# INLINE pathIsSymbolicLink #-}++-- | The target of a symbolic link.+--+-- ==== __Examples__+--+-- >>> (==) <$> runExceptT (createFileLink file (dir </> "link2") >> getSymbolicLinkTarget (dir </> "link2")) <*> pure (Right file)+-- True+--+-- @since 0.7.0+getSymbolicLinkTarget :: FilePath -> IOExcept FilePath+getSymbolicLinkTarget =+  exceptIO . D.getSymbolicLinkTarget+{-# INLINE getSymbolicLinkTarget #-}++-- | The permissions of a file or directory.+--+-- ==== __Examples__+--+-- >>> fmap readable <$> runExceptT (getPermissions file)+-- Right True+--+-- @since 0.7.0+getPermissions :: FilePath -> IOExcept Permissions+getPermissions =+  exceptIO . D.getPermissions+{-# INLINE getPermissions #-}++-- | Set the permissions of a file or directory.+--+-- ==== __Examples__+--+-- >>> runExceptT (writeFile (dir </> "perm1") (pack "") >> getPermissions (dir </> "perm1") >>= \p -> setPermissions (dir </> "perm1") (setOwnerExecutable True p) >> fmap executable (getPermissions (dir </> "perm1")))+-- Right True+--+-- @since 0.7.0+setPermissions :: FilePath -> Permissions -> IOExcept ()+setPermissions p =+  exceptIO . D.setPermissions p+{-# INLINE setPermissions #-}++-- | Copy the permissions of one file or directory to another.+--+-- ==== __Examples__+--+-- >>> runExceptT (writeFile (dir </> "perm2") (pack "") >> getPermissions (dir </> "perm2") >>= \p -> setPermissions (dir </> "perm2") (setOwnerExecutable True p) >> writeFile (dir </> "perm3") (pack "") >> copyPermissions (dir </> "perm2") (dir </> "perm3") >> fmap executable (getPermissions (dir </> "perm3")))+-- Right True+--+-- @since 0.7.0+copyPermissions :: FilePath -> FilePath -> IOExcept ()+copyPermissions a =+  exceptIO . D.copyPermissions a+{-# INLINE copyPermissions #-}++-- | The time a file or directory was last read.+--+-- ==== __Examples__+--+-- >>> isRight <$> runExceptT (getAccessTime file)+-- True+--+-- @since 0.7.0+getAccessTime :: FilePath -> IOExcept UTCTime+getAccessTime =+  exceptIO . D.getAccessTime+{-# INLINE getAccessTime #-}++-- | The time a file or directory was last written.+--+-- ==== __Examples__+--+-- >>> either (anyOf _IOException (\i -> has _NoSuchThing (the errorType i))) (const False) <$> runExceptT (getModificationTime (dir </> "nothing"))+-- True+--+-- @since 0.7.0+getModificationTime :: FilePath -> IOExcept UTCTime+getModificationTime =+  exceptIO . D.getModificationTime+{-# INLINE getModificationTime #-}++-- | Set the time a file or directory was last read.+--+-- ==== __Examples__+--+-- >>> let t = Time.UTCTime (Time.fromGregorian 2000 1 1) 0+-- >>> runExceptT (setAccessTime file t >> getAccessTime file)+-- Right 2000-01-01 00:00:00 UTC+--+-- @since 0.7.0+setAccessTime :: FilePath -> UTCTime -> IOExcept ()+setAccessTime p =+  exceptIO . D.setAccessTime p+{-# INLINE setAccessTime #-}++-- | Set the time a file or directory was last written.+--+-- ==== __Examples__+--+-- >>> let t = Time.UTCTime (Time.fromGregorian 2000 1 1) 0+-- >>> runExceptT (setModificationTime file t >> getModificationTime file)+-- Right 2000-01-01 00:00:00 UTC+--+-- >>> D.removeDirectoryRecursive dir+--+-- @since 0.7.0+setModificationTime :: FilePath -> UTCTime -> IOExcept ()+setModificationTime p =+  exceptIO . D.setModificationTime p+{-# INLINE setModificationTime #-}
+ src/Papa/Filepath/System/FilePath.hs view
@@ -0,0 +1,70 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Paths ("System.FilePath"): the functions of the @filepath@ package, at+-- 'FilePath' ('Data.String.String'), for the platform's paths.+--+-- They are all total. Two names differ from @filepath@'s:+--+-- * @(\<.\>)@ is left out, because its name is lens's indexed composition,+--   which "Papa" exports: use 'addExtension' (or '-<.>' to replace the+--   extension).+-- * 'getSearchPath', which reads the environment variable @PATH@, returns its+--   failure in 'IOExcept'.+--+-- ==== __Examples__+--+-- >>> "dir" </> "file" -<.> "txt"+-- "dir/file.txt"+--+-- >>> addExtension "file" "txt"+-- "file.txt"+--+-- >>> (splitExtension "dir/file.tar.gz", splitExtensions "dir/file.tar.gz")+-- (("dir/file.tar",".gz"),("dir/file",".tar.gz"))+--+-- >>> (takeDirectory "/a/b/c", takeFileName "/a/b/c", takeBaseName "/a/b/c.d", takeExtension "/a/b/c.d")+-- ("/a/b","c","c",".d")+--+-- >>> (splitDirectories "/a/b/c", joinPath ["a", "b"], normalise "/a/./b//c")+-- (["/","a","b","c"],"a/b","/a/b/c")+--+-- >>> (isAbsolute "/a", isRelative "a", makeRelative "/a" "/a/b", stripExtension "gz" "x.gz")+-- (True,True,"b",Just "x")+--+-- The functions are total, at every 'Data.String.String':+--+-- >>> check $ property $ do { p <- forAll (Gen.string (Range.linear 0 20) (Gen.element "/.a\0 ")); length (splitPath p <> splitDirectories p <> [normalise p, takeDirectory p, takeFileName p, dropExtension p, makeValid p]) === length (splitPath p) + length (splitDirectories p) + 5 }+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+module Papa.Filepath.System.FilePath (+  module P,+  getSearchPath,+) where++import Papa.Base.System.IO.Except (IOExcept, exceptIO)+import System.FilePath as P hiding (getSearchPath, (<.>))+import qualified System.FilePath as F++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | The directories of the environment variable @PATH@. A @PATH@ that is not+-- set is a failure.+--+-- ==== __Examples__+--+-- >>> isRight <$> runExceptT getSearchPath+-- True+--+-- @since 0.7.0+getSearchPath :: IOExcept [FilePath]+getSearchPath =+  exceptIO F.getSearchPath+{-# INLINE getSearchPath #-}
+ src/Papa/Hashable/Data/Hashable.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Hashing: the class of the keys of 'Data.HashMap.Strict.HashMap' and the+-- elements of 'Data.HashSet.HashSet', and values cached with their hashes.+--+-- Not exported: @hashPtr@, @hashPtrWithSalt@, @hashByteArray@ and+-- @hashByteArrayWithSalt@, which read the memory at a pointer or an offset+-- that they do not check, outside the value for a bad length.+module Papa.Hashable.Data.Hashable (+  module X,+) where++import Data.Hashable as X hiding (+  hashByteArray,+  hashByteArrayWithSalt,+  hashPtr,+  hashPtrWithSalt,+ )++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Papa.Hashable.Data.Hashable+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- $examples+--+-- ==== __Examples__+--+-- >>> unhashed (hashed "papa")+-- "papa"+--+-- >>> check $ withTests 100 $ property $ do a <- forAll (Gen.int (Range.linear 0 100)); b <- forAll (Gen.int (Range.linear 0 100)); (a == b) === (a == b && hash a == hash b)+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do a <- forAll (Gen.string (Range.linear 0 10) Gen.alpha); hashedHash (hashed a) === hash a+-- ...passed 100 tests.+-- True
+ src/Papa/Internal/Char8.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The characters that fit in a byte, for the checked functions of the+-- Char8 modules.+module Papa.Internal.Char8 (+  latin1,+  latin1s,+) where++import Control.Monad (guard)+import Data.Bool (Bool)+import Data.Char (Char)+import Data.Foldable (all)+import Data.Function ((.))+import Data.Maybe (Maybe)+import Data.Ord ((<=))+import Data.String (String)++-- | Whether a character fits in a byte: @\'\\0\'@ to @\'\\255\'@, which the+-- Char8 functions store as its code point, where they store any other+-- character's code point modulo 256.+latin1 :: Char -> Bool+latin1 c =+  c <= '\255'+{-# INLINE latin1 #-}++-- | 'Data.Maybe.Just' for a string whose characters all fit in a byte.+latin1s :: String -> Maybe ()+latin1s =+  guard . all latin1+{-# INLINE latin1s #-}
+ src/Papa/Internal/Order.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Checks of the order of a list, for the preconditions of the+-- containers functions that build from an ordered list.+--+-- Internal to papa: not exported.+module Papa.Internal.Order (+  pairwise,+) where++import Data.Bool (Bool (True), (&&))++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Papa.Internal.Order+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Whether a relation holds between every element of a list and the next.+-- 'Data.Bool.True' for a list of fewer than two elements.+--+-- ==== __Examples__+--+-- >>> pairwise (<=) [1, 2, 2, 3 :: Int]+-- True+--+-- >>> pairwise (<) [1, 2, 2, 3 :: Int]+-- False+--+-- >>> pairwise (<) ([] :: [Int])+-- True+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll (Gen.list (Range.linear 0 20) (Gen.int (Range.linear 0 9))); pairwise (<=) xs === (sort xs == xs)+-- ...passed 100 tests.+-- True+pairwise :: (a -> a -> Bool) -> [a] -> Bool+pairwise r =+  go+ where+  go (x : xs@(y : _)) =+    r x y && go xs+  go _ =+    True+{-# INLINE pairwise #-}
+ src/Papa/Internal/Read.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The shared parts of the strict and lazy number readers.+module Papa.Internal.Read (+  fits,+  signedWith,+  leading,+) where++import Control.Monad ((>>=))+import Data.Bifunctor (first)+import Data.Bits (Bits, toIntegralSized)+import Data.Bool (Bool (False), bool)+import Data.Char (Char)+import Data.Either (Either (Left, Right))+import Data.Eq ((==))+import Data.Functor (fmap)+import Data.Maybe (Maybe, maybe)+import Data.String (String)+import Prelude (Integer, Integral, negate)++-- | A number read as an 'Integer', at a type that holds it; an error where+-- it does not fit.+fits :: (Integral a, Bits a) => Either String (Integer, t) -> Either String (a, t)+fits r =+  r >>= \(n, rest) -> maybe (Left "number out of range") (\a -> Right (a, rest)) (toIntegralSized n)+{-# INLINE fits #-}++-- | Read an optional @+@ or @-@, then a number, negated after a @-@.+signedWith :: (t -> Maybe (Char, t)) -> (t -> Either String (Integer, t)) -> t -> Either String (Integer, t)+signedWith uncons r t =+  maybe+    (r t)+    ( \(c, t') ->+        bool+          (bool (r t) (r t') (c == '+'))+          (fmap (first negate) (r t'))+          (c == '-')+    )+    (uncons t)+{-# INLINE signedWith #-}++-- | A reader's result, or an error where the text does not start with a+-- character that the reader reads.+leading :: (t -> Maybe (Char, t)) -> (Char -> Bool) -> String -> t -> Either String a -> Either String a+leading uncons p message t r =+  bool (Left message) r (maybe False (\(c, _) -> p c) (uncons t))+{-# INLINE leading #-}
src/Papa/Lens.hs view
@@ -1,6 +1,25 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | All of "Control.Lens" and "Control.Lens.Extras", without the partial+-- combinators, with total @(!!)@, @fst@ and @snd@.+--+-- These are not exported, because they throw:+--+-- * @(^?!)@ and @(^\@?!)@ throw for an empty fold. Use 'preview' ('^?') and+--   'ipreview' ('^@?').+-- * @foldr1Of@, @foldl1Of@, @foldr1Of'@ and @foldl1Of'@ throw for an empty+--   fold. Use 'foldrOf' and 'foldlOf' with a seed, or 'foldMapOf' into a+--   semigroup through 'preview'.+-- * @singular@ and @unsafeSingular@ throw for a traversal with no target+--   (and @unsafeSingular@ for one with many). Use 'preview' to read, and the+--   traversal itself to write.+-- * @unsafePartsOf@, @unsafePartsOf'@, @iunsafePartsOf@ and+--   @iunsafePartsOf'@ throw when the new list is shorter than the old. Use+--   'partsOf'.+--+-- @(.>)@, @(<.)@ and @(<.>)@ are not exported either: those of+-- "Data.Functor.Apply" are, through "Papa.Semigroupoids". module Papa.Lens (   module P,   (!!),@@ -8,8 +27,23 @@   snd, ) where -import Control.Lens as P hiding ((.>), (<.), (<.>))+import Control.Lens as P hiding (+  foldl1Of,+  foldl1Of',+  foldr1Of,+  foldr1Of',+  iunsafePartsOf,+  iunsafePartsOf',+  singular,+  unsafePartsOf,+  unsafePartsOf',+  unsafeSingular,+  (.>),+  (<.),+  (<.>),+  (^?!),+  (^@?!),+ ) import Control.Lens.Extras as P- import Papa.Lens.Data.List import Papa.Lens.Data.Tuple
+ src/Papa/Lens/Control/Exception.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Exceptions as optics: a prism into 'Control.Exception.SomeException' for+-- each exception type of base ('_IOException', '_ArithException',+-- '_ErrorCall', '_ThreadKilled', …, and 'exception' for any type), and the+-- combinators that catch through a prism ('catching', 'handling', 'trying')+-- or throw in a monad through one ('throwingM', 'throwingTo').+--+-- > trying _IOException (throwIO (userError "u"))+--+-- 'catching', 'handling' and 'trying' catch what their prism matches, and+-- match an asynchronous exception if the prism does: through+-- '_ThreadKilled', '_AsyncException' or @'exception' \@SomeException@ they+-- catch a 'Papa.Base.Control.Exception.ThreadKilled', unlike+-- 'Papa.Base.Control.Exception.catch'. Through the prism of a synchronous+-- exception type they never do.+--+-- The classes of their constraints, 'MonadThrow', 'MonadCatch' and+-- 'MonadMask' (from the @exceptions@ package), are exported without their+-- methods: their @catch@, @try@ and @mask@ are not "Papa"'s.+--+-- Not exported: @throwing@ and @throwing_@, which throw from pure code (they+-- are in "Papa.Unsafe.Exception"), and @mappedException@ and+-- @mappedException'@, which rewrite the exceptions that pure code throws.+--+-- @since 0.7.0+module Papa.Lens.Control.Exception (+  module P,+  MonadThrow,+  MonadCatch,+  MonadMask,+) where++import Control.Monad.Catch (MonadCatch, MonadMask, MonadThrow)++import Control.Exception.Lens as P hiding (+  mappedException,+  mappedException',+  throwing,+  throwing_,+ )
+ src/Papa/Lens/Core.hs view
@@ -0,0 +1,578 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The optics that "Papa" exports: the types, classes, constructors and+-- combinators of "Control.Lens" that everyday code uses, and the+-- profunctor and contravariant classes that classy optics instances+-- constrain.+--+-- The rest of "Control.Lens" is in "Papa.Lens". It is not exported from+-- "Papa", because its names clash with other libraries ('Data.Functor.Rep.index',+-- @levels@, @op@, @Over@) and with user code. Left out on purpose:+--+-- * every partial combinator (see "Papa.Lens");+-- * @(^~)@, @(^^~)@ and @(\/\/~)@, which throw for a negative exponent or a+--   zero divisor;+-- * @enum@, which throws outside the range of 'Data.Int.Int';+-- * @non@ and @nearly@, which are not lawful.+--+-- @since 0.7.0+module Papa.Lens.Core (+  -- * Types+  Lens,+  Lens',+  Traversal,+  Traversal',+  Traversal1,+  Traversal1',+  Prism,+  Prism',+  Iso,+  Iso',+  Getter,+  Fold,+  Fold1,+  Setter,+  Setter',+  Review,+  Optic,+  Optic',+  LensLike,+  LensLike',+  Getting,+  ASetter,+  ASetter',+  ALens,+  ALens',+  ATraversal,+  ATraversal',+  APrism,+  APrism',+  AnIso,+  AnIso',+  IndexedLens,+  IndexedLens',+  IndexedTraversal,+  IndexedTraversal',+  IndexedFold,+  IndexedGetter,+  IndexedSetter,+  Indexed (Indexed, runIndexed),+  Indexable (indexed),++  -- * Classes of profunctors and functors (for the instances of optics)+  Profunctor (dimap, lmap, rmap),+  Choice (left', right'),+  Strong (first', second'),+  Contravariant (contramap, (>$)),+  phantom,++  -- * Classes of containers+  Field1 (_1),+  Field2 (_2),+  Field3 (_3),+  Field4 (_4),+  Field5 (_5),+  Field6 (_6),+  Field7 (_7),+  Field8 (_8),+  Field9 (_9),+  Ixed (ix),+  At (at),+  Contains (contains),+  Index,+  IxValue,+  Cons (_Cons),+  Snoc (_Snoc),+  Each (each),+  AsEmpty (_Empty),+  Reversing (reversing),+  Plated (plate),+  Wrapped (_Wrapped'),+  Unwrapped,+  Rewrapped,+  Prefixed (prefixed),+  Suffixed (suffixed),+  TraverseMin (traverseMin),+  TraverseMax (traverseMax),+  FunctorWithIndex (imap),+  FoldableWithIndex (ifoldMap, ifoldr, ifoldl),+  TraversableWithIndex (itraverse),++  -- * Building optics+  lens,+  iso,+  prism,+  prism',+  to,+  ito,+  like,+  folding,+  setting,+  sets,+  unto,+  un,+  re,+  from,+  mapping,+  coerced,+  involuted,+  reversed,+  firsting,+  seconding,+  bimapping,+  cloneLens,+  cloneTraversal,+  cloneIso,+  clonePrism,+  withIso,+  withPrism,+  simple,++  -- * Optics of containers+  folded,+  traversed,+  traversed1,+  ifolded,+  itraversed,+  imapped,+  mapped,+  both,+  both1,+  beside,+  alongside,+  choosing,+  chosen,+  devoid,+  united,+  ignored,+  only,+  filtered,+  filteredBy,+  indices,+  taking,+  dropping,+  takingWhile,+  droppingWhile,+  partsOf,+  partsOf',+  ipartsOf,+  holesOf,+  _Just,+  _Nothing,+  _Left,+  _Right,+  _Void,+  _head,+  _tail,+  _init,+  _last,+  _Wrapped,+  _Unwrapped,+  _Wrapping,+  _Unwrapping,+  _Unwrapped',+  cons,+  snoc,+  uncons,+  unsnoc,+  (<|),+  (|>),+  sans,+  ala,+  alaf,+  au,+  auf,+  under,++  -- * Reading+  view,+  views,+  (^.),+  preview,+  previews,+  (^?),+  toListOf,+  (^..),+  toNonEmptyOf,+  has,+  hasn't,+  isn't,+  matching,+  review,+  reviews,+  (#),+  iview,+  ipreview,+  (^@.),+  (^@?),+  (^@..),+  itoListOf,++  -- * Folding+  foldMapOf,+  foldOf,+  foldrOf,+  foldlOf,+  foldrOf',+  foldlOf',+  lengthOf,+  nullOf,+  notNullOf,+  elemOf,+  notElemOf,+  anyOf,+  allOf,+  noneOf,+  andOf,+  orOf,+  sumOf,+  productOf,+  firstOf,+  first1Of,+  lastOf,+  last1Of,+  findOf,+  lookupOf,+  maximumOf,+  minimumOf,+  maximum1Of,+  minimum1Of,+  maximumByOf,+  minimumByOf,+  concatOf,+  concatMapOf,+  traverseOf_,+  forOf_,+  sequenceAOf_,+  ifoldMapOf,+  ifoldrOf,+  ifoldlOf,+  itraverseOf_,+  iforOf_,+  ianyOf,+  iallOf,+  ifindOf,++  -- * Writing+  set,+  (.~),+  set',+  over,+  (%~),+  (?~),+  (<>~),+  (+~),+  (-~),+  (*~),+  (||~),+  (&&~),+  iover,+  (%@~),+  iset,+  (.@~),+  traverseOf,+  forOf,+  sequenceAOf,+  itraverseOf,+  iforOf,+  mapAccumLOf,+  mapAccumROf,++  -- * Recursion+  children,+  universe,+  universeOf,+  transform,+  transformOf,+  rewrite,+  rewriteOf,+  cosmos,+  cosmosOf,++  -- * In a 'Control.Monad.State.Class.MonadState' or 'Control.Monad.Reader.Class.MonadReader'+  use,+  uses,+  preuse,+  assign,+  modifying,+  (.=),+  (%=),+  (?=),+  (<>=),+  (+=),+  (-=),+  zoom,+  magnify,+  locally,+) where++import Control.Lens (+  ALens,+  ALens',+  APrism,+  APrism',+  ASetter,+  ASetter',+  ATraversal,+  ATraversal',+  AnIso,+  AnIso',+  AsEmpty (_Empty),+  At (at),+  Choice (left', right'),+  Cons (_Cons),+  Contains (contains),+  Each (each),+  Field1 (_1),+  Field2 (_2),+  Field3 (_3),+  Field4 (_4),+  Field5 (_5),+  Field6 (_6),+  Field7 (_7),+  Field8 (_8),+  Field9 (_9),+  Fold,+  Fold1,+  FoldableWithIndex (ifoldMap, ifoldl, ifoldr),+  FunctorWithIndex (imap),+  Getter,+  Getting,+  Index,+  Indexable (indexed),+  Indexed (Indexed, runIndexed),+  IndexedFold,+  IndexedGetter,+  IndexedLens,+  IndexedLens',+  IndexedSetter,+  IndexedTraversal,+  IndexedTraversal',+  Iso,+  Iso',+  IxValue,+  Ixed (ix),+  Lens,+  Lens',+  LensLike,+  LensLike',+  Optic,+  Optic',+  Plated (plate),+  Prefixed (prefixed),+  Prism,+  Prism',+  Profunctor (dimap, lmap, rmap),+  Reversing (reversing),+  Review,+  Rewrapped,+  Setter,+  Setter',+  Snoc (_Snoc),+  Suffixed (suffixed),+  TraversableWithIndex (itraverse),+  Traversal,+  Traversal',+  Traversal1,+  Traversal1',+  TraverseMax (traverseMax),+  TraverseMin (traverseMin),+  Unwrapped,+  Wrapped (_Wrapped'),+  ala,+  alaf,+  allOf,+  alongside,+  andOf,+  anyOf,+  assign,+  au,+  auf,+  beside,+  bimapping,+  both,+  both1,+  children,+  choosing,+  chosen,+  cloneIso,+  cloneLens,+  clonePrism,+  cloneTraversal,+  coerced,+  concatMapOf,+  concatOf,+  cons,+  cosmos,+  cosmosOf,+  devoid,+  dropping,+  droppingWhile,+  elemOf,+  filtered,+  filteredBy,+  findOf,+  first1Of,+  firstOf,+  firsting,+  foldMapOf,+  foldOf,+  folded,+  folding,+  foldlOf,+  foldlOf',+  foldrOf,+  foldrOf',+  forOf,+  forOf_,+  from,+  has,+  hasn't,+  holesOf,+  iallOf,+  ianyOf,+  ifindOf,+  ifoldMapOf,+  ifolded,+  ifoldlOf,+  ifoldrOf,+  iforOf,+  iforOf_,+  ignored,+  imapped,+  indices,+  involuted,+  iover,+  ipartsOf,+  ipreview,+  iset,+  isn't,+  iso,+  ito,+  itoListOf,+  itraverseOf,+  itraverseOf_,+  itraversed,+  iview,+  last1Of,+  lastOf,+  lengthOf,+  lens,+  like,+  locally,+  lookupOf,+  magnify,+  mapAccumLOf,+  mapAccumROf,+  mapped,+  mapping,+  matching,+  maximum1Of,+  maximumByOf,+  maximumOf,+  minimum1Of,+  minimumByOf,+  minimumOf,+  modifying,+  noneOf,+  notElemOf,+  notNullOf,+  nullOf,+  only,+  orOf,+  over,+  partsOf,+  partsOf',+  preuse,+  preview,+  previews,+  prism,+  prism',+  productOf,+  re,+  reversed,+  review,+  reviews,+  rewrite,+  rewriteOf,+  sans,+  seconding,+  sequenceAOf,+  sequenceAOf_,+  set,+  set',+  sets,+  setting,+  simple,+  snoc,+  sumOf,+  taking,+  takingWhile,+  to,+  toListOf,+  toNonEmptyOf,+  transform,+  transformOf,+  traverseOf,+  traverseOf_,+  traversed,+  traversed1,+  un,+  uncons,+  under,+  united,+  universe,+  universeOf,+  unsnoc,+  unto,+  use,+  uses,+  view,+  views,+  withIso,+  withPrism,+  zoom,+  (#),+  (%=),+  (%@~),+  (%~),+  (&&~),+  (*~),+  (+=),+  (+~),+  (-=),+  (-~),+  (.=),+  (.@~),+  (.~),+  (<>=),+  (<>~),+  (<|),+  (?=),+  (?~),+  (^.),+  (^..),+  (^?),+  (^@.),+  (^@..),+  (^@?),+  _Just,+  _Left,+  _Nothing,+  _Right,+  _Unwrapped,+  _Unwrapped',+  _Unwrapping,+  _Void,+  _Wrapped,+  _Wrapping,+  _head,+  _init,+  _last,+  _tail,+  (|>),+  (||~),+ )+import Data.Functor.Contravariant (Contravariant (contramap, (>$)), phantom)+import Data.Profunctor (Strong (first', second'))
src/Papa/Lens/Data/List.hs view
@@ -2,36 +2,47 @@ {-# OPTIONS_GHC -Wall #-}  {- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines Papa's total (!!) (to a Maybe), whose name+-- HLint restricts whatever module it comes from. +-- | Total indexing of any 'Ixed' container. module Papa.Lens.Data.List (   (!!), ) where -import Control.Lens (Index, IxValue, Ixed, ix, (^?))-import Data.Int (Int)+import Control.Lens (Index, IxValue, Ixed (ix), (^?)) import Data.Maybe (Maybe) --- | Safe list indexing. Returns 'Nothing' if the index is out of bounds.+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInts = Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-100) 100))++-- | The element at an index of any 'Ixed' container. 'Data.Maybe.Nothing' for an+-- index that is not there. ----- >>> import Data.Maybe (Maybe(..))--- >>> [1,2,3,4] !! 0--- Just 1--- >>> [1,2,3,4] !! 2--- Just 3--- >>> [1,2,3,4] !! 10+-- ==== __Examples__+--+-- >>> [10, 20, 30 :: Int] !! (1 :: Int)+-- Just 20+--+-- >>> ([] :: [Int]) !! (0 :: Int) -- Nothing-{-# INLINE (!!) #-}-{-# SPECIALIZE (!!) ::-  [a] ->-  Int ->-  Maybe a-  #-}-(!!) ::-  (Ixed s) =>-  s ->-  Index s ->-  Maybe (IxValue s)+--+-- >>> (1 :| [2, 3 :: Int]) !! (2 :: Int)+-- Just 3+--+-- >>> check $ withTests 100 $ property $ do xs <- forAll genInts; i <- forAll (Gen.int (Range.linear (-5) 25)); (xs !! i) === (xs !? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0+(!!) :: (Ixed s) => s -> Index s -> Maybe (IxValue s) q !! n =   q ^? ix n+{-# INLINE (!!) #-}  infixl 9 !!
src/Papa/Lens/Data/Tuple.hs view
@@ -1,45 +1,59 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | The first and second components of any tuple. module Papa.Lens.Data.Tuple (   fst,   snd, ) where -import Control.Lens (Field1, Field2, (^.), _1, _2)+import Control.Lens (Field1, Field2, _1, _2)+import Papa.Lens.Optic (the) --- | Extract the first component of a pair.+-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)++-- | The first component of any tuple ('Field1'). ----- >>> fst (1, 2)+-- ==== __Examples__+--+-- >>> fst (1 :: Int, 'a') -- 1--- >>> fst ('a', "hello")+--+-- >>> fst ('a', True, ()) -- 'a'-{-# INLINE fst #-}-{-# SPECIALIZE fst ::-  (a, b) ->-  a-  #-}-fst ::-  (Field1 s s b b) =>-  s ->-  b+--+-- >>> check $ withTests 100 $ property $ do a <- forAll genInt; b <- forAll Gen.alpha; fst (a, b) === a+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0+fst :: (Field1 s s b b) => s -> b fst =-  (^. _1)+  the _1+{-# INLINE fst #-} --- | Extract the second component of a pair.+-- | The second component of any tuple ('Field2'). ----- >>> snd (1, 2)--- 2--- >>> snd ('a', "hello")--- "hello"-{-# INLINE snd #-}-{-# SPECIALIZE snd ::-  (a, b) ->-  b-  #-}-snd ::-  (Field2 s s b b) =>-  s ->-  b+-- ==== __Examples__+--+-- >>> snd (1 :: Int, 'a')+-- 'a'+--+-- >>> snd ('a', True, ())+-- True+--+-- >>> check $ withTests 100 $ property $ do a <- forAll genInt; b <- forAll Gen.alpha; snd (a, b) === b+-- ...passed 100 tests.+-- True+--+-- @since 0.4.0+snd :: (Field2 s s b b) => s -> b snd =-  (^. _2)+  the _2+{-# INLINE snd #-}
+ src/Papa/Lens/Optic.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Reading exactly one value through an optic.+--+-- 'Control.Lens.view' alone accepts an affine traversal whose target is a+-- 'Data.Monoid.Monoid', and gives 'Data.Monoid.mempty' where there is no+-- target. 'the' accepts only an optic that always has exactly one target,+-- a lens or a getter, and rejects a prism, an affine traversal or an+-- affine fold at compile time.+--+-- A name is read with 'the', never with 'Control.Lens.view' or+-- 'Control.Lens.^.' alone (classy optics, rule 8).+--+-- @since 0.7.0+module Papa.Lens.Optic (+  the,+) where++import Control.Lens (LensLike', ReifiedGetter (Getter, runGetter), view)+import Data.Functor (Functor)+import Data.Functor.Contravariant (Contravariant)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | The one value through an iso, a lens or a getter.+--+-- @since 0.7.0+--+-- ==== __Examples__+--+-- >>> the _1 ('a', True)+-- 'a'+--+-- >>> check $ withTests 100 $ property $ do a <- forAll Gen.alpha; b <- forAll Gen.bool; the _2 (a, b) === view _2 (a, b)+-- ...passed 100 tests.+-- True+the :: (forall f. (Contravariant f, Functor f) => LensLike' f s a) -> s -> a+the n =+  view (runGetter (Getter n))+{-# INLINE the #-}
+ src/Papa/Lens/System/IO/Error.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | 'IOException's as optics: lenses on their fields ('errorType',+-- 'location', 'description', 'fileName', 'errno', 'errorHandle') and a prism+-- for each kind of error ('_NoSuchThing', '_PermissionDenied',+-- '_AlreadyExists', '_EOF', …), for the 'IOException' that+-- 'Papa.Base.System.IO.Except.IOExcept' returns.+--+-- > has (errorType . _NoSuchThing)+--+-- "System.IO.Error.Lens"'s @handle@ is exported as 'errorHandle': "Papa"'s+-- 'Papa.Base.Control.Exception.handle' catches.+--+-- @since 0.7.0+module Papa.Lens.System.IO.Error (+  module P,+  errorHandle,+) where++import Control.Exception (IOException)+import Control.Lens (Lens')+import Data.Maybe (Maybe)+import System.IO (Handle)+import System.IO.Error.Lens as P hiding (handle)+import qualified System.IO.Error.Lens as L++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Unsafe.IO as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen++-- | The handle of an 'IOException', if it has one: "System.IO.Error.Lens"'s+-- @handle@.+--+-- ==== __Examples__+--+-- >>> the errorHandle (userError "u")+-- Nothing+--+-- >>> do { h <- U.openFile "/dev/null" U.WriteMode; U.hClose h; e <- runExceptT (hFlush h); pure (fmap (the errorHandle) (preview (_Left . _IOException) e) == Just (Just h)) }+-- True+--+-- >>> check $ withTests 10 $ property $ do b <- forAll Gen.bool; let { h = bool Nothing (Just stdout) b }; the errorHandle (set errorHandle h (userError "u")) === h+-- ...passed 10 tests.+-- True+--+-- @since 0.7.0+errorHandle :: Lens' IOException (Maybe Handle)+errorHandle =+  L.handle+{-# INLINE errorHandle #-}
src/Papa/One/Renamed.hs view
@@ -3,7 +3,7 @@  -- | Re-exports from Papa.One with conflicting identifiers hidden. ----- The 'nonEmpty' function from Control.One.One conflicts with Data.List.NonEmpty.nonEmpty.+-- The @nonEmpty@ function from Control.One.One conflicts with Data.List.NonEmpty.nonEmpty. -- It is hidden from this module. Use 'Control.One.One.nonEmpty' directly when needed, -- or import qualified: -- > import qualified Control.One.One as One
− src/Papa/Polytree/Renamed.hs
@@ -1,19 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# OPTIONS_GHC -Wall #-}---- | Re-exports from Papa.Polytree with renamed conflicting identifiers.------ This module provides alternative names for exports that conflict with Papa.Lens:--- - levels → treeLevels-module Papa.Polytree.Renamed (-  -- * Polytree re-exports without conflicts-  module Papa.Polytree.Data.Polytree,--  -- * Note on conflicts-) where---- The 'levels' function from Data.PolyTree conflicts with Control.Lens.Level.levels--- Use 'Data.PolyTree.levels' directly when needed, or import qualified:--- > import qualified Data.PolyTree as Tree--import Papa.Polytree.Data.Polytree hiding (levels)
src/Papa/Profunctors/Renamed.hs view
@@ -3,7 +3,7 @@  -- | Re-exports from Papa.Profunctors with conflicting identifiers hidden. ----- The 'WrappedArrow' type from Data.Profunctor.Types conflicts with+-- The @WrappedArrow@ type from Data.Profunctor.Types conflicts with -- Control.Applicative.WrappedArrow. It is hidden from this module. -- Use 'Data.Profunctor.Types.WrappedArrow' directly when needed, or import qualified: -- > import qualified Data.Profunctor.Types as Prof
− src/Papa/Selective/Renamed.hs
@@ -1,14 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# OPTIONS_GHC -Wall #-}---- | Re-exports from Papa.Selective with conflicting identifiers hidden.------ The 'Over' type from Control.Selective conflicts with Control.Lens.Type.Over.--- It is hidden from this module. Use 'Control.Selective.Over' directly when needed,--- or import qualified:--- > import qualified Control.Selective as Sel-module Papa.Selective.Renamed (-  module Papa.Selective.Control.Selective,-) where--import Papa.Selective.Control.Selective hiding (Over)
src/Papa/Semigroupoids.hs view
@@ -1,12 +1,14 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} +-- | The classes of semigroupoids.+--+-- 'Plus' is exported without its method @zero@, which semigroupoids'+-- instance for 'Prelude.IO' defines as @error@. Use 'Control.Applicative.empty'+-- for an 'Control.Applicative.Alternative', and 'Data.Monoid.mempty' for a+-- map. module Papa.Semigroupoids (   module P,-  concat,-  concatMap,-  maximum,-  minimum, ) where  import Data.Bifunctor.Apply as P (Biapply ((.>>), (<<.), (<<.>>)), Bifunctor (bimap, first, second), bilift2, bilift3, (<<$>>), (<<..>>))@@ -15,7 +17,7 @@ import Data.Functor.Bind as P (Bind (join, (>>-)), apDefault, returning, (-<-), (-<<), (->-)) import Data.Functor.Bind.Trans as P (BindTrans (liftB)) import Data.Functor.Extend as P (Extend (duplicated, extended))-import Data.Functor.Plus as P (Plus (zero))+import Data.Functor.Plus as P (Plus) import Data.Groupoid as P (Groupoid (inv)) import Data.Semigroup.Bifoldable as P (Bifoldable1 (bifold1, bifoldMap1), bifoldMapDefault1, bifor1_, bisequenceA1_, bitraverse1_) import Data.Semigroup.Bitraversable as P (Bitraversable1 (bisequence1, bitraverse1), bifoldMap1Default)@@ -24,6 +26,3 @@ import Data.Semigroupoid as P (Semi (getSemi), Semigroupoid (o), WrappedCategory (unwrapCategory)) import Data.Semigroupoid.Ob as P (Ob (semiid)) import Data.Semigroupoid.Static as P (Static (runStatic))--import Papa.Semigroupoids.Data.Functor.Bind-import Papa.Semigroupoids.Data.Semigroup.Foldable
− src/Papa/Semigroupoids/Data/Functor/Bind.hs
@@ -1,39 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# OPTIONS_GHC -Wall #-}--module Papa.Semigroupoids.Data.Functor.Bind (-  concat,-  concatMap,-) where--import Data.Functor.Bind (Bind (join), (-<<))--{-# INLINE concat #-}---- | Flatten a nested structure.------ >>> concat [[1,2], [3,4], [5,6]]--- [1,2,3,4,5,6]--- >>> import Data.Maybe (Maybe(..))--- >>> concat (Just (Just 5))--- Just 5-concat ::-  (Bind f) =>-  f (f a) ->-  f a-concat =-  join--{-# INLINE concatMap #-}---- | Map a function over a structure and flatten.------ >>> concatMap (\x -> [x, x]) [1,2,3]--- [1,1,2,2,3,3]-concatMap ::-  (Bind f) =>-  (a -> f b) ->-  f a ->-  f b-concatMap =-  (-<<)
− src/Papa/Semigroupoids/Data/Semigroup/Foldable.hs
@@ -1,44 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# OPTIONS_GHC -Wall #-}--module Papa.Semigroupoids.Data.Semigroup.Foldable (-  maximum,-  minimum,-) where--import Control.Category ((.))-import Data.Ord (Ord)-import Data.Semigroup (Max (Max, getMax), Min (Min, getMin))-import Data.Semigroup.Foldable--{-# INLINE maximum #-}---- | Find the maximum element in a non-empty structure.------ >>> import Data.List.NonEmpty (NonEmpty(..))--- >>> maximum (1 :| [2,3,4])--- 4--- >>> maximum (10 :| [5,20,3])--- 20-maximum ::-  (Ord a, Foldable1 f) =>-  f a ->-  a-maximum =-  getMax . foldMap1 Max--{-# INLINE minimum #-}---- | Find the minimum element in a non-empty structure.------ >>> import Data.List.NonEmpty (NonEmpty(..))--- >>> minimum (1 :| [2,3,4])--- 1--- >>> minimum (10 :| [5,20,3])--- 3-minimum ::-  (Ord a, Foldable1 f) =>-  f a ->-  a-minimum =-  getMin . foldMap1 Min
+ src/Papa/Stm/Control/Concurrent/STM.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Software transactional memory.+--+-- @check@ is not exported: its name clashes with Hedgehog's, and it is+-- 'Control.Monad.guard' at 'STM' (which retries).+--+-- @since 0.7.0+module Papa.Stm.Control.Concurrent.STM (+  module P,+) where++import Control.Concurrent.STM as P (+  STM,+  TVar,+  atomically,+  modifyTVar',+  newTVar,+  newTVarIO,+  orElse,+  readTVar,+  readTVarIO,+  retry,+  writeTVar,+ )
+ src/Papa/Text/Data/Text.hs view
@@ -0,0 +1,588 @@+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Redundant lambda" -}+-- Reason: a function whose text follows other arguments (@splitOn p@,+-- @replace p r@) takes the text in a lambda, because GHC inlines a+-- function only once it is applied to the arguments on the left of its+-- definition: so a partial application, passed to a higher-order+-- function, is inlined too.++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total head, last, tail, init, maximum and+-- minimum, whose names HLint restricts whatever module they come from.++-- | Strict text, with total versions of the partial functions of+-- "Data.Text". Import qualified:+--+-- > import qualified Papa.Text.Data.Text as Text+--+-- The functions of "Data.Text" that throw are replaced by functions of the+-- same names that return 'Data.Maybe.Nothing' there instead:+--+-- * for an empty text: 'head', 'last', 'tail', 'init', 'foldl1', 'foldl1'',+--   'foldr1', 'maximum', 'minimum';+-- * for an index out of range: 'index';+-- * for an empty needle: 'splitOn', 'breakOn', 'breakOnEnd', 'breakOnAll',+--   'count', 'replace'.+--+-- @unpackCString#@ and @unpackCStringAscii#@, which read a C string from a+-- raw address, are not exported.+--+-- The optics of @lens@ work on 'Text' too: @'Control.Lens.preview'+-- 'Control.Lens._head'@, @'Control.Lens.preview' 'Control.Lens._last'@ and+-- @'Control.Lens.preview' ('Control.Lens.ix' i)@ read a character, and+-- "Data.Text.Lens"'s @packed@, @unpacked@ and @text@ convert and traverse.+--+-- A function whose result would be longer than @'Prelude.maxBound' :: 'Int'@ bytes+-- (@replicate@, @concat@, @intercalate@ and the like) throws a size overflow,+-- like an allocation that cannot fit in memory.+--+-- @since 0.7.0+module Papa.Text.Data.Text (+  module X,+  display,+  displayFixed,+  displayExponent,+  readMaybe,+  readEither,+  head,+  last,+  tail,+  init,+  foldl1,+  foldl1',+  foldr1,+  maximum,+  minimum,+  index,+  splitOn,+  breakOn,+  breakOnEnd,+  breakOnAll,+  count,+  replace,+) where++import Control.Applicative ((*>))+import Control.Monad (guard)+import Data.Bifunctor (first)+import Data.Bits (toIntegralSized)+import Data.Bool (not)+import Data.Char (Char)+import Data.Either (Either)+import Data.Function ((.))+import Data.Functor (fmap, (<$))+import Data.Int (Int)+import Data.Maybe (Maybe (Just), fromMaybe)+import Data.Ord (Ord (max, min, (>=)))+import Data.Text as X hiding (+  breakOn,+  breakOnAll,+  breakOnEnd,+  count,+  foldl1,+  foldl1',+  foldr1,+  head,+  index,+  init,+  last,+  maximum,+  minimum,+  replace,+  splitOn,+  tail,+  unpackCString#,+  unpackCStringAscii#,+ )+import qualified Data.Text as T+import Data.Tuple (fst, snd, uncurry)+import Data.Word (Word)+import Numeric (showEFloat, showFFloat)+import Text.Read (Read)+import qualified Text.Read as Read+import Text.Show (Show)+import qualified Text.Show as Show+import Prelude (RealFloat)+import qualified Prelude as P++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Prelude+-- >>> import Numeric (showFFloat)+-- >>> import qualified Papa.Text.Data.Text as Text+-- >>> import qualified Data.Text as DT+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genText = Gen.text (Range.linear 0 20) (Gen.element "abc")+-- >>> let genNeedle = Gen.text (Range.linear 0 3) (Gen.element "abc")++-- | The 'Text' of a value's 'Show.show'.+--+-- ==== __Examples__+--+-- >>> display (3 :: Int)+-- "3"+--+-- >>> display (Just 'x')+-- "Just 'x'"+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-100) 100)); Text.unpack (display n) === P.show n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+display :: (Show a) => a -> Text+display =+  T.pack . Show.show+{-# INLINE display #-}++-- | A floating-point number with the given number of digits after the+-- decimal point, as C's @%.2f@ and the like show it. It rounds the+-- shortest decimal digits that 'Show.show' gives, a half to the even digit+-- (@displayFixed 2 0.125@ is @0.12@). @NaN@ and the infinities are+-- @NaN@, @Infinity@ and @-Infinity@. "Numeric"'s @showFFloat@, returning+-- 'Text'; 'Papa.Unsafe.Format.printf' is in "Papa.Unsafe.Format".+--+-- ==== __Examples__+--+-- >>> displayFixed 2 (3.14159 :: Double)+-- "3.14"+--+-- >>> displayFixed 2 (2 :: Double)+-- "2.00"+--+-- >>> displayFixed 0 (2.7 :: Double)+-- "3"+--+-- >>> displayFixed 2 (-0.001 :: Double)+-- "-0.00"+--+-- >>> check $ withTests 200 $ property $ do x <- forAll (Gen.double (Range.linearFracFrom 0 (-1e6) 1e6)); n <- forAll (Gen.word (Range.linear 0 10)); Text.unpack (displayFixed n x) === showFFloat (Just (Prelude.fromIntegral n)) x ""+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+displayFixed :: (RealFloat a) => Word -> a -> Text+displayFixed n x =+  T.pack (showFFloat (Just (digits n)) x "")+{-# INLINE displayFixed #-}++-- | A floating-point number in scientific notation, with the given number of+-- digits after the decimal point. "Numeric"'s @showEFloat@, returning+-- 'Text'.+--+-- ==== __Examples__+--+-- >>> displayExponent 2 (1234.5 :: Double)+-- "1.23e3"+--+-- >>> displayExponent 1 (0.00012 :: Double)+-- "1.2e-4"+--+-- @since 0.7.0+displayExponent :: (RealFloat a) => Word -> a -> Text+displayExponent n x =+  T.pack (showEFloat (Just (digits n)) x "")+{-# INLINE displayExponent #-}++-- | A number of digits as an 'Int'. A 'Word' beyond the 'Int's is more digits+-- than any number has, so it is the largest 'Int'.+digits :: Word -> Int+digits n =+  fromMaybe P.maxBound (toIntegralSized n)+{-# INLINE digits #-}++-- | Parse the 'Show.show' of a value: 'Data.Maybe.Nothing' where it does not+-- parse. "Text.Read"'s @readMaybe@, for 'Text'.+--+-- ==== __Examples__+--+-- >>> readMaybe "42" :: Maybe Int+-- Just 42+--+-- >>> readMaybe " 2.5 " :: Maybe Double+-- Just 2.5+--+-- >>> readMaybe "forty-two" :: Maybe Int+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-1000) 1000)); readMaybe (display n) === Just n+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+readMaybe :: (Read a) => Text -> Maybe a+readMaybe =+  Read.readMaybe . T.unpack+{-# INLINE readMaybe #-}++-- | Parse the 'Show.show' of a value, or say why it does not parse.+-- "Text.Read"'s @readEither@, for 'Text'.+--+-- ==== __Examples__+--+-- >>> readEither "42" :: Either Text Int+-- Right 42+--+-- >>> readEither "x" :: Either Text Int+-- Left "Prelude.read: no parse"+--+-- @since 0.7.0+readEither :: (Read a) => Text -> Either Text a+readEither =+  first T.pack . Read.readEither . T.unpack+{-# INLINE readEither #-}++-- | Total 'T.head': the first character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.head "abc"+-- Just 'a'+--+-- >>> Text.head ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.head t === preview _head (Text.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: Text -> Maybe Char+head =+  fmap fst . T.uncons+{-# INLINE head #-}++-- | Total 'T.last': the last character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.last "abc"+-- Just 'c'+--+-- >>> Text.last ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.last t === preview _last (Text.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: Text -> Maybe Char+last =+  fmap snd . T.unsnoc+{-# INLINE last #-}++-- | Total 'T.tail': all but the first character. 'Data.Maybe.Nothing' for the empty+-- text.+--+-- ==== __Examples__+--+-- >>> Text.tail "abc"+-- Just "bc"+--+-- >>> Text.tail ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; fmap Text.unpack (Text.tail t) === preview _tail (Text.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: Text -> Maybe Text+tail =+  fmap snd . T.uncons+{-# INLINE tail #-}++-- | Total 'T.init': all but the last character. 'Data.Maybe.Nothing' for the empty+-- text.+--+-- ==== __Examples__+--+-- >>> Text.init "abc"+-- Just "ab"+--+-- >>> Text.init ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; fmap Text.unpack (Text.init t) === preview _init (Text.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: Text -> Maybe Text+init =+  fmap fst . T.unsnoc+{-# INLINE init #-}++-- | Total 'T.foldl1': a left fold seeded with the first character. 'Data.Maybe.Nothing'+-- for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.foldl1 max "abca"+-- Just 'c'+--+-- >>> Text.foldl1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.foldl1 min t === fmap (\(c, r) -> Text.foldl min c r) (Text.uncons t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Char -> Char -> Char) -> Text -> Maybe Char+foldl1 f =+  fmap (uncurry (T.foldl f)) . T.uncons+{-# INLINE foldl1 #-}++-- | Total 'T.foldl1'': a strict left fold seeded with the first character.+-- 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.foldl1' max "abca"+-- Just 'c'+--+-- >>> Text.foldl1' max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.foldl1' min t === Text.foldl1 min t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Char -> Char -> Char) -> Text -> Maybe Char+foldl1' f =+  fmap (uncurry (T.foldl' f)) . T.uncons+{-# INLINE foldl1' #-}++-- | Total 'T.foldr1': a right fold seeded with the last character. 'Data.Maybe.Nothing'+-- for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.foldr1 max "abca"+-- Just 'c'+--+-- >>> Text.foldr1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.foldr1 min t === Text.foldl1 min t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Char -> Char -> Char) -> Text -> Maybe Char+foldr1 f =+  fmap (\(t, c) -> T.foldr f c t) . T.unsnoc+{-# INLINE foldr1 #-}++-- | Total 'T.maximum': the greatest character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.maximum "abca"+-- Just 'c'+--+-- >>> Text.maximum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.maximum t === maximumOf folded (Text.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: Text -> Maybe Char+maximum =+  foldl1' max+{-# INLINE maximum #-}++-- | Total 'T.minimum': the least character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> Text.minimum "bcab"+-- Just 'a'+--+-- >>> Text.minimum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Text.minimum t === minimumOf folded (Text.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: Text -> Maybe Char+minimum =+  foldl1' min+{-# INLINE minimum #-}++-- | Total 'T.index': the character at a position, counting from 0.+-- 'Data.Maybe.Nothing' for a negative index or one past the end. /O(n)/.+--+-- ==== __Examples__+--+-- >>> Text.index "abc" 1+-- Just 'b'+--+-- >>> Text.index "abc" 3+-- Nothing+--+-- >>> Text.index "abc" (-1)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; i <- forAll (Gen.int (Range.linear (-3) 25)); Text.index t i === (Text.unpack t !! i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+index :: Text -> Int -> Maybe Char+index t i =+  guard (i >= 0) *> head (T.drop i t)+{-# INLINE index #-}++-- | Total 'T.splitOn': the pieces of a text between occurrences of a+-- needle. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> Text.splitOn "," "a,b,,c"+-- Just ["a","b","","c"]+--+-- >>> Text.splitOn "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (Text.intercalate p) (Text.splitOn p t) === (t <$ guard (not (Text.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+splitOn :: Text -> Text -> Maybe [Text]+splitOn p =+  \t -> T.splitOn p t <$ needle p+{-# INLINE splitOn #-}++-- | Total 'T.breakOn': the text before the first occurrence of a needle, and+-- the rest. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> Text.breakOn "::" "a::b::c"+-- Just ("a","::b::c")+--+-- >>> Text.breakOn "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (uncurry (<>)) (Text.breakOn p t) === (t <$ guard (not (Text.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+breakOn :: Text -> Text -> Maybe (Text, Text)+breakOn p =+  \t -> T.breakOn p t <$ needle p+{-# INLINE breakOn #-}++-- | Total 'T.breakOnEnd': the text up to and including the last occurrence+-- of a needle, and the rest. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> Text.breakOnEnd "::" "a::b::c"+-- Just ("a::b::","c")+--+-- >>> Text.breakOnEnd "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (uncurry (<>)) (Text.breakOnEnd p t) === (t <$ guard (not (Text.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+breakOnEnd :: Text -> Text -> Maybe (Text, Text)+breakOnEnd p =+  \t -> T.breakOnEnd p t <$ needle p+{-# INLINE breakOnEnd #-}++-- | Total 'T.breakOnAll': each split of a text at an occurrence of a needle.+-- 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> Text.breakOnAll "/" "a/b/c"+-- Just [("a","/b/c"),("a/b","/c")]+--+-- >>> Text.breakOnAll "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (P.all (\(a, b) -> a <> b == t)) (Text.breakOnAll p t) === (True <$ guard (not (Text.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+breakOnAll :: Text -> Text -> Maybe [(Text, Text)]+breakOnAll p =+  \t -> T.breakOnAll p t <$ needle p+{-# INLINE breakOnAll #-}++-- | Total 'T.count': the number of non-overlapping occurrences of a needle.+-- 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> Text.count "aa" "aaaaa"+-- Just 2+--+-- >>> Text.count "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; Text.count p t === fmap (\xs -> P.length xs - 1) (Text.splitOn p t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+count :: Text -> Text -> Maybe Int+count p =+  \t -> T.count p t <$ needle p+{-# INLINE count #-}++-- | Total 'T.replace': replace every non-overlapping occurrence of a needle+-- (the first argument) with a replacement (the second). 'Data.Maybe.Nothing' for the+-- empty needle.+--+-- ==== __Examples__+--+-- >>> Text.replace "ofo" "bar" "ofofo"+-- Just "barfo"+--+-- >>> Text.replace "" "x" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; r <- forAll genNeedle; t <- forAll genText; Text.replace p r t === fmap (Text.intercalate r) (Text.splitOn p t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+replace :: Text -> Text -> Text -> Maybe Text+replace p r =+  \t -> T.replace p r t <$ needle p+{-# INLINE replace #-}++-- | 'Data.Maybe.Just' for a needle that is not empty.+needle :: Text -> Maybe ()+needle =+  guard . not . T.null+{-# INLINE needle #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/Encoding.hs view
@@ -0,0 +1,222 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Encoding strict text to bytes and decoding it from them, with total+-- decoders. Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Encoding as Encoding+--+-- The decoders of "Data.Text.Encoding" that throw on invalid input are+-- replaced by decoders of the same names that return the error instead:+-- 'decodeUtf8', 'decodeUtf16LE', 'decodeUtf16BE', 'decodeUtf32LE',+-- 'decodeUtf32BE' return 'Either' a 'UnicodeException', and 'decodeASCII'+-- returns 'Maybe'.+--+-- @streamDecodeUtf8@, whose continuation throws on invalid input, is not+-- exported: 'X.decodeUtf8Chunk' and 'X.decodeUtf8More' decode UTF-8+-- incrementally and return the invalid bytes, and 'X.streamDecodeUtf8With'+-- takes a handler.+--+-- The handlers of "Data.Text.Encoding.Error" that a @…With@ decoder takes are+-- exported, except @strictDecode@ and @strictEncode@, which throw:+-- 'lenientDecode' replaces invalid input with U+FFFD, 'ignore' drops it.+--+-- @since 0.7.0+module Papa.Text.Data.Text.Encoding (+  module X,+  UnicodeException (DecodeError),+  OnDecodeError,+  OnError,+  lenientDecode,+  ignore,+  replace,+  decodeUtf8,+  decodeASCII,+  decodeUtf16LE,+  decodeUtf16BE,+  decodeUtf32LE,+  decodeUtf32BE,+) where++import Data.Bool (bool)+import Data.ByteString (ByteString)+import Data.Either (Either (Left, Right))+import Data.Eq ((==))+import Data.Maybe (Maybe (Nothing))+import Data.Semigroup ((<>))+import Data.String (String)+import Data.Text (Text)+import Data.Text.Encoding as X hiding (+  decodeASCII,+  decodeUtf16BE,+  decodeUtf16LE,+  decodeUtf32BE,+  decodeUtf32LE,+  decodeUtf8,+  streamDecodeUtf8,+ )+import qualified Data.Text.Encoding as E+import Data.Text.Encoding.Error (+  OnDecodeError,+  OnError,+  UnicodeException (DecodeError),+  ignore,+  lenientDecode,+  replace,+ )++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text.Encoding as Encoding+-- >>> import qualified Data.ByteString as B+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genText = Gen.text (Range.linear 0 20) Gen.unicode+-- >>> let genBytes = Gen.bytes (Range.linear 0 20)++-- | Total 'E.decodeUtf8': decode UTF-8, or the error for invalid UTF-8. This+-- is 'X.decodeUtf8''.+--+-- ==== __Examples__+--+-- >>> Encoding.decodeUtf8 "caf\195\169"+-- Right "caf\233"+--+-- >>> Encoding.decodeUtf8 "\255"+-- Left Cannot decode byte '\xff': ...Invalid UTF-8 stream+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Encoding.decodeUtf8 (Encoding.encodeUtf8 t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf8 :: ByteString -> Either UnicodeException Text+decodeUtf8 =+  E.decodeUtf8'+{-# INLINE decodeUtf8 #-}++-- | Total 'E.decodeASCII': decode ASCII, or 'Data.Maybe.Nothing' for a byte above 127.+-- This is 'X.decodeASCII''.+--+-- ==== __Examples__+--+-- >>> Encoding.decodeASCII "abc"+-- Just "abc"+--+-- >>> Encoding.decodeASCII "caf\195\169"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; isJust (Encoding.decodeASCII b) === B.all (< 128) b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeASCII :: ByteString -> Maybe Text+decodeASCII =+  E.decodeASCII'+{-# INLINE decodeASCII #-}++-- | Total 'E.decodeUtf16LE': decode little-endian UTF-16, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> Encoding.decodeUtf16LE "a\NULb\NUL"+-- Right "ab"+--+-- >>> isLeft (Encoding.decodeUtf16LE "a")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Encoding.decodeUtf16LE (Encoding.encodeUtf16LE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf16LE :: ByteString -> Either UnicodeException Text+decodeUtf16LE =+  checked "decodeUtf16LE" E.decodeUtf16LEWith+{-# INLINE decodeUtf16LE #-}++-- | Total 'E.decodeUtf16BE': decode big-endian UTF-16, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> Encoding.decodeUtf16BE "\NULa\NULb"+-- Right "ab"+--+-- >>> isLeft (Encoding.decodeUtf16BE "a")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Encoding.decodeUtf16BE (Encoding.encodeUtf16BE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf16BE :: ByteString -> Either UnicodeException Text+decodeUtf16BE =+  checked "decodeUtf16BE" E.decodeUtf16BEWith+{-# INLINE decodeUtf16BE #-}++-- | Total 'E.decodeUtf32LE': decode little-endian UTF-32, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> Encoding.decodeUtf32LE "a\NUL\NUL\NUL"+-- Right "a"+--+-- >>> isLeft (Encoding.decodeUtf32LE "a\NUL")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Encoding.decodeUtf32LE (Encoding.encodeUtf32LE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf32LE :: ByteString -> Either UnicodeException Text+decodeUtf32LE =+  checked "decodeUtf32LE" E.decodeUtf32LEWith+{-# INLINE decodeUtf32LE #-}++-- | Total 'E.decodeUtf32BE': decode big-endian UTF-32, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> Encoding.decodeUtf32BE "\NUL\NUL\NULa"+-- Right "a"+--+-- >>> isLeft (Encoding.decodeUtf32BE "\NUL\NUL")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; Encoding.decodeUtf32BE (Encoding.encodeUtf32BE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf32BE :: ByteString -> Either UnicodeException Text+decodeUtf32BE =+  checked "decodeUtf32BE" E.decodeUtf32BEWith+{-# INLINE decodeUtf32BE #-}++-- | Decode with a handler-taking decoder, or an error where the input is+-- invalid: there the decoder calls its handler, so the text that replaces+-- invalid input ('lenientDecode') differs from the text that drops it+-- ('ignore').+checked :: String -> (OnDecodeError -> ByteString -> Text) -> ByteString -> Either UnicodeException Text+checked name decode b =+  let t = decode lenientDecode b+   in bool+        (Left (DecodeError ("Papa.Text.Data.Text.Encoding." <> name <> ": invalid input") Nothing))+        (Right t)+        (decode ignore b == t)+{-# INLINE checked #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/IO.hs view
@@ -0,0 +1,389 @@+{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Reading and writing text, always as UTF-8, returning errors instead of+-- throwing them. Import qualified:+--+-- > import qualified Papa.Text.Data.Text.IO as TextIO+--+-- Every action reads or writes the bytes of the UTF-8 encoding of its text,+-- whatever the handle's encoding, newline mode or the locale: a program+-- reads and writes the same bytes under @LANG=C@ as under @LANG=en_US.UTF-8@.+-- A line ends with a newline byte (@\\n@) on every platform.+--+-- Every action returns its failure as a 'Data.Either.Left' of+-- 'Control.Monad.Trans.Except.runExceptT' ('IOExcept'): an+-- 'Papa.Base.System.IO.Except.IOFailed' 'Control.Exception.IOException', or,+-- for bytes that are not UTF-8, a 'Papa.Base.System.IO.Except.DecodeFailed'+-- with the file name or the handle.+--+-- Every reader is strict: it reads all that it returns before it returns.+--+-- @since 0.7.0+module Papa.Text.Data.Text.IO (+  readFile,+  writeFile,+  appendFile,+  hGetContents,+  hGetLine,+  hPutStr,+  hPutStrLn,+  putStr,+  putStrLn,+  getLine,+  getContents,+  interact,+  print,+  hPrint,+  readIO,+  die,+) where++import Control.Applicative (pure, (*>), (<*))+import Control.DeepSeq (force)+import Control.Exception (evaluate)+import qualified Control.Exception as E+import Control.Monad ((>>=))+import Control.Monad.Trans.Except (ExceptT (ExceptT), except, runExceptT)+import Data.Bifunctor (first)+import Data.Bool (bool)+import Data.ByteString (ByteString)+import qualified Data.ByteString as B+import Data.ByteString.Builder (hPutBuilder, word8)+import Data.ByteString.Internal (ByteString (BS))+import Data.Either (Either (Left, Right), either)+import Data.Eq ((==))+import Data.Foldable (null)+import Data.Function ((.))+import Data.Functor (fmap)+import Data.IORef (readIORef, writeIORef)+import Data.Int (Int)+import Data.List (reverse)+import Data.Maybe (Maybe, maybe)+import Data.Semigroup ((<>))+import Data.Text (Text)+import Data.Text.Encoding (decodeUtf8', encodeUtf8, encodeUtf8Builder)+import Data.Text.Encoding.Error (UnicodeException)+import Data.Text.Foreign (fromPtr)+import Data.Word (Word8)+import GHC.ForeignPtr (ForeignPtr, plusForeignPtr, withForeignPtr)+import GHC.IO.Buffer (Buffer (Buffer, bufL, bufR, bufRaw), isEmptyBuffer)+import qualified GHC.IO.BufferedIO as Buffered+import GHC.IO.Exception (IOException)+import GHC.IO.Handle.Internals (flushCharReadBuffer, ioe_EOF, wantReadableHandle_)+import GHC.IO.Handle.Types (Handle, Handle__ (Handle__, haByteBuffer, haDevice))+import GHC.Num ((+), (-))+import GHC.Real (fromIntegral)+import Papa.Base.System.IO.Except (IOExcept, IOFailure (DecodeFailed, IOFailed), exceptIO)+import Papa.Text.Data.Text (display, readMaybe)+import System.Exit (exitFailure)+import System.IO (FilePath, IO, stderr, stdin, stdout)+import Text.Read (Read)+import Text.Show (Show)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> :set -XTypeApplications+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text.IO as TextIO+-- >>> import qualified Data.ByteString as B+-- >>> import qualified System.IO as IO+-- >>> import qualified System.IO.Error as IO+-- >>> import qualified System.Directory as D+-- >>> (path, h) <- D.getTemporaryDirectory >>= \d -> IO.openTempFile d "papa-text-io.txt"+-- >>> IO.hClose h++-- | Decode UTF-8, or a 'DecodeFailed' of the handle or file.+decode :: Either Handle FilePath -> ByteString -> IOExcept Text+decode w =+  except . first (DecodeFailed w) . decodeUtf8'+{-# INLINE decode #-}++-- | Read a file.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.writeFile path "caf\233\n" >> TextIO.readFile path)+-- Right "caf\233\n"+--+-- >>> B.writeFile path "\255" >> either (has _DecodeFailed) (const False) <$> runExceptT (TextIO.readFile path)+-- True+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (TextIO.readFile "/nonexistent/papa")+-- True+--+-- @since 0.7.0+readFile :: FilePath -> IOExcept Text+readFile p =+  exceptIO (B.readFile p) >>= decode (Right p)+{-# INLINE readFile #-}++-- | Write a file, replacing it.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.writeFile path "\955") >> B.readFile path+-- "\206\187"+--+-- >>> either (anyOf _IOException IO.isDoesNotExistError) (const False) <$> runExceptT (TextIO.writeFile "/nonexistent/papa" "x")+-- True+--+-- @since 0.7.0+writeFile :: FilePath -> Text -> IOExcept ()+writeFile p =+  exceptIO . B.writeFile p . encodeUtf8+{-# INLINE writeFile #-}++-- | Append to a file.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.writeFile path "a" >> TextIO.appendFile path "b" >> TextIO.readFile path)+-- Right "ab"+--+-- @since 0.7.0+appendFile :: FilePath -> Text -> IOExcept ()+appendFile p =+  exceptIO . B.appendFile p . encodeUtf8+{-# INLINE appendFile #-}++-- | Read the rest of a handle, and close it.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.writeFile path "a\nb") >> IO.openFile path IO.ReadMode >>= \h' -> runExceptT (TextIO.hGetContents h')+-- Right "a\nb"+--+-- @since 0.7.0+hGetContents :: Handle -> IOExcept Text+hGetContents h =+  exceptIO (B.hGetContents h) >>= decode (Left h)+{-# INLINE hGetContents #-}++-- | Read a line from a handle, up to a newline byte (@\\n@), which is+-- removed. A carriage return before it is kept: a line of a file with+-- @\\r\\n@ line endings ends with @\\r@. An end-of-file error+-- ('System.IO.Error.isEOFError') at the end of the handle.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.writeFile path "a\r\nb") >> IO.withFile path IO.ReadMode (\h' -> traverse (const (runExceptT (TextIO.hGetLine h'))) [1, 2, 3 :: Int])+-- [Right "a\r",Right "b",Left (IOFailed ...end of file)]+--+-- @since 0.7.0+hGetLine :: Handle -> IOExcept Text+hGetLine h =+  ExceptT (fmap (either (Left . IOFailed) (first (DecodeFailed (Left h)))) (tryIO (wantReadableHandle_ "hGetLine" h lineOf)))+{-# INLINE hGetLine #-}++-- | 'E.try' at 'IOException'.+tryIO :: IO a -> IO (Either IOException a)+tryIO =+  E.try+{-# INLINE tryIO #-}++-- | The next line of a handle whose lock is held, as UTF-8.+--+-- The bytes of the line are found in the handle's byte buffer, as+-- "Data.ByteString"'s @hGetLine@ finds them. A line within the buffer, the+-- usual case, is checked as UTF-8 and copied from the buffer into the text+-- at once ('decodeBuffered'), with no copy of its bytes; a line across+-- buffers is copied a piece at a time, and then decoded ('decodePieces').+lineOf :: Handle__ -> IO (Either UnicodeException Text)+lineOf h_@Handle__{haByteBuffer} =+  flushCharReadBuffer h_+    *> readIORef haByteBuffer+    >>= \buf -> bool (scanLine h_ buf []) (refillLine h_ buf []) (isEmptyBuffer buf)+{-# NOINLINE lineOf #-}++-- | Fill the empty byte buffer from the device. At the end of the file, the+-- pieces read so far are the line; with none, it is an end-of-file error.+refillLine :: Handle__ -> Buffer Word8 -> [ByteString] -> IO (Either UnicodeException Text)+refillLine h_@Handle__{haByteBuffer, haDevice} buf pieces =+  Buffered.fillReadBuffer haDevice buf+    >>= \(n, buf') ->+      bool+        (scanLine h_ buf' pieces)+        ( writeIORef haByteBuffer buf{bufL = 0, bufR = 0}+            *> bool (decodePieces pieces) ioe_EOF (null pieces)+        )+        (n == 0)++-- | Look for a newline in the buffered bytes. Where there is one, the line+-- ends there, and the buffer keeps the bytes after it. Where there is not,+-- the bytes are a piece of the line, and the buffer is refilled.+scanLine :: Handle__ -> Buffer Word8 -> [ByteString] -> IO (Either UnicodeException Text)+scanLine h_@Handle__{haByteBuffer} buf@Buffer{bufRaw, bufL, bufR} pieces =+  let start = bufRaw `plusForeignPtr` bufL+      bytes = BS start (bufR - bufL)+   in maybe+        (evaluate (B.copy bytes) >>= \piece -> refillLine h_ buf{bufL = 0, bufR = 0} (piece : pieces))+        ( \k ->+            bool (decodePieces (B.copy (B.take k bytes) : pieces)) (decodeBuffered start k) (null pieces)+              <* writeIORef haByteBuffer (bool buf{bufL = bufL + k + 1} buf{bufL = 0, bufR = 0} (bufL + k + 1 == bufR))+        )+        (B.elemIndex 10 bytes)++-- | The given number of bytes of the handle's buffer, from the given place,+-- as text, or why they are not UTF-8: evaluated in full, since the buffer+-- changes after.+decodeBuffered :: ForeignPtr Word8 -> Int -> IO (Either UnicodeException Text)+decodeBuffered start k =+  let bytes = BS start k+   in bool+        (evaluate (force (decodeUtf8' bytes)))+        -- I8 is a newtype of Int, so fromIntegral is exact.+        (fmap Right (withForeignPtr start (\ptr -> fromPtr ptr (fromIntegral k))))+        (B.isValidUtf8 bytes)++-- | The pieces of a line, last first, as text.+decodePieces :: [ByteString] -> IO (Either UnicodeException Text)+decodePieces =+  pure . decodeUtf8' . B.concat . reverse++-- | Write to a handle.+--+-- ==== __Examples__+--+-- >>> IO.withFile path IO.WriteMode (\h' -> runExceptT (TextIO.hPutStr h' "\955")) >> B.readFile path+-- "\206\187"+--+-- @since 0.7.0+hPutStr :: Handle -> Text -> IOExcept ()+hPutStr h =+  exceptIO . hPutBuilder h . encodeUtf8Builder+{-# INLINE hPutStr #-}++-- | Write to a handle, and a newline byte, in one write.+--+-- ==== __Examples__+--+-- >>> IO.withFile path IO.WriteMode (\h' -> runExceptT (TextIO.hPutStrLn h' "a")) >> B.readFile path+-- "a\n"+--+-- @since 0.7.0+hPutStrLn :: Handle -> Text -> IOExcept ()+hPutStrLn h t =+  exceptIO (hPutBuilder h (encodeUtf8Builder t <> word8 10))+{-# INLINE hPutStrLn #-}++-- | Write to 'stdout'.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.putStr "a\n")+-- a+-- Right ()+--+-- @since 0.7.0+putStr :: Text -> IOExcept ()+putStr =+  hPutStr stdout+{-# INLINE putStr #-}++-- | Write to 'stdout', and a newline byte.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.putStrLn "cafe")+-- cafe+-- Right ()+--+-- @since 0.7.0+putStrLn :: Text -> IOExcept ()+putStrLn =+  hPutStrLn stdout+{-# INLINE putStrLn #-}++-- | Read a line from 'stdin'. See 'hGetLine'.+--+-- @since 0.7.0+getLine :: IOExcept Text+getLine =+  hGetLine stdin+{-# INLINE getLine #-}++-- | Read all of 'stdin'.+--+-- @since 0.7.0+getContents :: IOExcept Text+getContents =+  hGetContents stdin+{-# INLINE getContents #-}++-- | Read all of 'stdin', and write a function of it to 'stdout'.+--+-- @since 0.7.0+interact :: (Text -> Text) -> IOExcept ()+interact f =+  getContents >>= putStr . f+{-# INLINE interact #-}++-- | Write a value's 'Text.Show.show' to 'stdout', and a newline byte.+--+-- ==== __Examples__+--+-- >>> runExceptT (TextIO.print (Just 'x'))+-- Just 'x'+-- Right ()+--+-- @since 0.7.0+print :: (Show a) => a -> IOExcept ()+print =+  putStrLn . display+{-# INLINE print #-}++-- | Write a value's 'Text.Show.show' to a handle, and a newline byte.+--+-- ==== __Examples__+--+-- >>> IO.withFile path IO.WriteMode (\h' -> runExceptT (TextIO.hPrint h' (3 :: Int))) >> B.readFile path+-- "3\n"+--+-- >>> D.removeFile path+--+-- @since 0.7.0+hPrint :: (Show a) => Handle -> a -> IOExcept ()+hPrint h =+  hPutStrLn h . display+{-# INLINE hPrint #-}++-- | Parse the 'Text.Show.show' of a value in 'IO': 'Data.Maybe.Nothing' where it+-- does not parse, where "Prelude"'s @readIO@ throws an 'IOException'.+--+-- ==== __Examples__+--+-- >>> TextIO.readIO "42" :: IO (Maybe Int)+-- Just 42+--+-- >>> TextIO.readIO "forty-two" :: IO (Maybe Int)+-- Nothing+--+-- @since 0.7.0+readIO :: (Read a) => Text -> IO (Maybe a)+readIO =+  pure . readMaybe+{-# INLINE readIO #-}++-- | Write a message and a newline byte to 'stderr', as UTF-8, and exit with+-- 'System.Exit.ExitFailure' 1. "System.Exit"'s @die@, for 'Text'. The+-- program exits whether or not the message could be written.+--+-- ==== __Examples__+--+-- >>> try @ExitCode (TextIO.die "papa: done")+-- papa: done+-- Left (ExitFailure 1)+--+-- @since 0.7.0+die :: Text -> IO a+die t =+  runExceptT (hPutStrLn stderr t) *> exitFailure+{-# INLINE die #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/Lazy.hs view
@@ -0,0 +1,469 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Redundant lambda" -}+-- Reason: a function whose text follows other arguments (@splitOn p@,+-- @replace p r@) takes the text in a lambda, because GHC inlines a+-- function only once it is applied to the arguments on the left of its+-- definition: so a partial application, passed to a higher-order+-- function, is inlined too.++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total head, last, tail, init, maximum and+-- minimum, whose names HLint restricts whatever module they come from.++-- | Lazy text, with total versions of the partial functions of+-- "Data.Text.Lazy". Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Lazy as LazyText+--+-- The functions of "Data.Text.Lazy" that throw are replaced by functions of+-- the same names that return 'Data.Maybe.Nothing' there instead:+--+-- * for an empty text: 'head', 'last', 'tail', 'init', 'foldl1', 'foldl1'',+--   'foldr1', 'maximum', 'minimum', 'cycle';+-- * for an index out of range: 'index';+-- * for an empty needle: 'splitOn', 'breakOn', 'breakOnEnd', 'breakOnAll',+--   'count', 'replace'.+--+-- 'X.repeat', 'X.iterate' and 'cycle' build an infinite text: a function+-- that reads all of it ('X.length', 'X.toStrict', …) does not return.+--+-- Lazy text read from a handle ("Data.Text.Lazy.IO") is lazy I/O, which+-- throws from pure code once the handle fails, and is not wrapped: read a+-- strict text with "Papa.Text.Data.Text.IO" and convert it with+-- 'X.fromStrict'.+--+-- @since 0.7.0+module Papa.Text.Data.Text.Lazy (+  module X,+  head,+  last,+  tail,+  init,+  foldl1,+  foldl1',+  foldr1,+  maximum,+  minimum,+  cycle,+  index,+  splitOn,+  breakOn,+  breakOnEnd,+  breakOnAll,+  count,+  replace,+) where++import Control.Applicative ((*>))+import Control.Monad (guard)+import Data.Bool (not)+import Data.Char (Char)+import Data.Function ((.))+import Data.Functor (fmap, (<$))+import Data.Int (Int64)+import Data.Maybe (Maybe)+import Data.Ord (Ord (max, min, (>=)))+import Data.Text.Lazy as X hiding (+  breakOn,+  breakOnAll,+  breakOnEnd,+  count,+  cycle,+  foldl1,+  foldl1',+  foldr1,+  head,+  index,+  init,+  last,+  maximum,+  minimum,+  replace,+  splitOn,+  tail,+ )+import qualified Data.Text.Lazy as L+import Data.Tuple (fst, snd, uncurry)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Text.Data.Text.Lazy as LazyText+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genText = LazyText.fromChunks <$> Gen.list (Range.linear 0 4) (Gen.text (Range.linear 0 6) (Gen.element "abc"))+-- >>> let genNeedle = LazyText.fromStrict <$> Gen.text (Range.linear 0 3) (Gen.element "abc")++-- | Total 'L.head': the first character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.head "abc"+-- Just 'a'+--+-- >>> LazyText.head ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.head t === preview _head (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: Text -> Maybe Char+head =+  fmap fst . L.uncons+{-# INLINE head #-}++-- | Total 'L.last': the last character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.last "abc"+-- Just 'c'+--+-- >>> LazyText.last ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.last t === preview _last (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: Text -> Maybe Char+last =+  fmap snd . L.unsnoc+{-# INLINE last #-}++-- | Total 'L.tail': all but the first character. 'Data.Maybe.Nothing' for the empty+-- text.+--+-- ==== __Examples__+--+-- >>> LazyText.tail "abc"+-- Just "bc"+--+-- >>> LazyText.tail ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; fmap LazyText.unpack (LazyText.tail t) === preview _tail (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: Text -> Maybe Text+tail =+  fmap snd . L.uncons+{-# INLINE tail #-}++-- | Total 'L.init': all but the last character. 'Data.Maybe.Nothing' for the empty+-- text.+--+-- ==== __Examples__+--+-- >>> LazyText.init "abc"+-- Just "ab"+--+-- >>> LazyText.init ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; fmap LazyText.unpack (LazyText.init t) === preview _init (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: Text -> Maybe Text+init =+  fmap fst . L.unsnoc+{-# INLINE init #-}++-- | Total 'L.foldl1': a left fold seeded with the first character. 'Data.Maybe.Nothing'+-- for the empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.foldl1 max "abca"+-- Just 'c'+--+-- >>> LazyText.foldl1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.foldl1 min t === minimumOf folded (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Char -> Char -> Char) -> Text -> Maybe Char+foldl1 f =+  fmap (uncurry (L.foldl f)) . L.uncons+{-# INLINE foldl1 #-}++-- | Total 'L.foldl1'': a strict left fold seeded with the first character.+-- 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.foldl1' max "abca"+-- Just 'c'+--+-- >>> LazyText.foldl1' max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.foldl1' min t === LazyText.foldl1 min t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Char -> Char -> Char) -> Text -> Maybe Char+foldl1' f =+  fmap (uncurry (L.foldl' f)) . L.uncons+{-# INLINE foldl1' #-}++-- | Total 'L.foldr1': a right fold seeded with the last character. 'Data.Maybe.Nothing'+-- for the empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.foldr1 max "abca"+-- Just 'c'+--+-- >>> LazyText.foldr1 max ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.foldr1 min t === LazyText.foldl1 min t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Char -> Char -> Char) -> Text -> Maybe Char+foldr1 f =+  fmap (\(t, c) -> L.foldr f c t) . L.unsnoc+{-# INLINE foldr1 #-}++-- | Total 'L.maximum': the greatest character. 'Data.Maybe.Nothing' for the empty+-- text.+--+-- ==== __Examples__+--+-- >>> LazyText.maximum "abca"+-- Just 'c'+--+-- >>> LazyText.maximum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.maximum t === maximumOf folded (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: Text -> Maybe Char+maximum =+  foldl1' max+{-# INLINE maximum #-}++-- | Total 'L.minimum': the least character. 'Data.Maybe.Nothing' for the empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.minimum "bcab"+-- Just 'a'+--+-- >>> LazyText.minimum ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyText.minimum t === minimumOf folded (LazyText.unpack t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: Text -> Maybe Char+minimum =+  foldl1' min+{-# INLINE minimum #-}++-- | Total 'L.cycle': the infinite repetition of a text. 'Data.Maybe.Nothing' for the+-- empty text.+--+-- ==== __Examples__+--+-- >>> LazyText.take 7 <$> LazyText.cycle "abc"+-- Just "abcabca"+--+-- >>> LazyText.cycle ""+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; fmap (LazyText.take (LazyText.length t)) (LazyText.cycle t) === (t <$ guard (not (LazyText.null t)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+cycle :: Text -> Maybe Text+cycle t =+  L.cycle t <$ guard (not (L.null t))+{-# INLINE cycle #-}++-- | Total 'L.index': the character at a position, counting from 0.+-- 'Data.Maybe.Nothing' for a negative index or one past the end.+--+-- ==== __Examples__+--+-- >>> LazyText.index "abc" 1+-- Just 'b'+--+-- >>> LazyText.index "abc" 3+-- Nothing+--+-- >>> LazyText.index "abc" (-1)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; i <- forAll (Gen.int (Range.linear (-3) 25)); LazyText.index t (intCast i) === (LazyText.unpack t !! i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+index :: Text -> Int64 -> Maybe Char+index t i =+  guard (i >= 0) *> head (L.drop i t)+{-# INLINE index #-}++-- | Total 'L.splitOn': the pieces of a text between occurrences of a+-- needle. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> LazyText.splitOn "," "a,b,,c"+-- Just ["a","b","","c"]+--+-- >>> LazyText.splitOn "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (LazyText.intercalate p) (LazyText.splitOn p t) === (t <$ guard (not (LazyText.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+splitOn :: Text -> Text -> Maybe [Text]+splitOn p =+  \t -> L.splitOn p t <$ needle p+{-# INLINE splitOn #-}++-- | Total 'L.breakOn': the text before the first occurrence of a needle,+-- and the rest. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> LazyText.breakOn "::" "a::b::c"+-- Just ("a","::b::c")+--+-- >>> LazyText.breakOn "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (uncurry (<>)) (LazyText.breakOn p t) === (t <$ guard (not (LazyText.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+breakOn :: Text -> Text -> Maybe (Text, Text)+breakOn p =+  \t -> L.breakOn p t <$ needle p+{-# INLINE breakOn #-}++-- | Total 'L.breakOnEnd': the text up to and including the last occurrence+-- of a needle, and the rest. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> LazyText.breakOnEnd "::" "a::b::c"+-- Just ("a::b::","c")+--+-- >>> LazyText.breakOnEnd "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (uncurry (<>)) (LazyText.breakOnEnd p t) === (t <$ guard (not (LazyText.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+breakOnEnd :: Text -> Text -> Maybe (Text, Text)+breakOnEnd p =+  \t -> L.breakOnEnd p t <$ needle p+{-# INLINE breakOnEnd #-}++-- | Total 'L.breakOnAll': each split of a text at an occurrence of a+-- needle. 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> LazyText.breakOnAll "/" "a/b/c"+-- Just [("a","/b/c"),("a/b","/c")]+--+-- >>> LazyText.breakOnAll "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; fmap (P.all (\(a, b) -> a <> b == t)) (LazyText.breakOnAll p t) === (True <$ guard (not (LazyText.null p)))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+breakOnAll :: Text -> Text -> Maybe [(Text, Text)]+breakOnAll p =+  \t -> L.breakOnAll p t <$ needle p+{-# INLINE breakOnAll #-}++-- | Total 'L.count': the number of non-overlapping occurrences of a needle.+-- 'Data.Maybe.Nothing' for the empty needle.+--+-- ==== __Examples__+--+-- >>> LazyText.count "aa" "aaaaa"+-- Just 2+--+-- >>> LazyText.count "" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; t <- forAll genText; LazyText.count p t === fmap (\xs -> intCast (P.length xs) - 1) (LazyText.splitOn p t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+count :: Text -> Text -> Maybe Int64+count p =+  \t -> L.count p t <$ needle p+{-# INLINE count #-}++-- | Total 'L.replace': replace every non-overlapping occurrence of a needle+-- (the first argument) with a replacement (the second). 'Data.Maybe.Nothing' for the+-- empty needle.+--+-- ==== __Examples__+--+-- >>> LazyText.replace "ofo" "bar" "ofofo"+-- Just "barfo"+--+-- >>> LazyText.replace "" "x" "abc"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do p <- forAll genNeedle; r <- forAll genNeedle; t <- forAll genText; LazyText.replace p r t === fmap (LazyText.intercalate r) (LazyText.splitOn p t)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+replace :: Text -> Text -> Text -> Maybe Text+replace p r =+  \t -> L.replace p r t <$ needle p+{-# INLINE replace #-}++-- | 'Data.Maybe.Just' for a needle that is not empty.+needle :: Text -> Maybe ()+needle =+  guard . not . L.null+{-# INLINE needle #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/Lazy/Builder.hs view
@@ -0,0 +1,63 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Building lazy text. Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Lazy.Builder as Builder+--+-- This is "Data.Text.Lazy.Builder", but 'toLazyTextWith' takes a negative+-- chunk size as @0@, where "Data.Text.Lazy.Builder"'s allocates an array of+-- negative size. The numbers of "Papa.Text.Data.Text.Lazy.Builder.Int" and+-- "Data.Text.Lazy.Builder.RealFloat" (which is total) build into it.+--+-- @since 0.7.0+module Papa.Text.Data.Text.Lazy.Builder (+  module X,+  toLazyTextWith,+) where++import Data.Function ((.))+import Data.Int (Int)+import Data.Ord (max)+import Data.Text.Lazy (Text)+import Data.Text.Lazy.Builder as X hiding (+  toLazyTextWith,+ )+import qualified Data.Text.Lazy.Builder as B++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text.Lazy.Builder as Builder+-- >>> import qualified Data.Text.Lazy as L+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Build lazy text, in chunks of about the given number of characters+-- (UTF-8 bytes); a size of @0@ or less is @0@, which leaves the chunk sizes to+-- the builder.+--+-- ==== __Examples__+--+-- >>> Builder.toLazyTextWith 4 (Builder.fromText "abc" <> Builder.singleton 'd')+-- "abcd"+--+-- >>> Builder.toLazyTextWith (-5) (Builder.fromText "abc")+-- "abc"+--+-- >>> check $ withTests 100 $ property $ do n <- forAll (Gen.int (Range.linear (-10) 10)); t <- forAll (Gen.text (Range.linear 0 50) Gen.unicode); Builder.toLazyTextWith n (Builder.fromText t) === L.fromStrict t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+toLazyTextWith :: Int -> Builder -> Text+toLazyTextWith =+  B.toLazyTextWith . max 0+{-# INLINE toLazyTextWith #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/Lazy/Builder/Int.hs view
@@ -0,0 +1,59 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Building the text of an integral number. Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Lazy.Builder.Int as BuilderInt+--+-- "Data.Text.Lazy.Builder.Int"'s @hexadecimal@ throws for a negative number;+-- 'hexadecimal' returns 'Data.Maybe.Nothing' there instead. 'X.decimal' is+-- "Data.Text.Lazy.Builder.Int"'s.+--+-- @since 0.7.0+module Papa.Text.Data.Text.Lazy.Builder.Int (+  module X,+  hexadecimal,+) where++import Control.Monad (guard)+import Data.Functor ((<$))+import Data.Maybe (Maybe)+import Data.Ord ((>=))+import Data.Text.Lazy.Builder (Builder)+import Data.Text.Lazy.Builder.Int as X (+  decimal,+ )+import qualified Data.Text.Lazy.Builder.Int as BI+import Prelude (Integral)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text.Lazy.Builder.Int as BuilderInt+-- >>> import qualified Data.Text.Lazy.Builder as B+-- >>> import qualified Data.Text.Read as TR+-- >>> import qualified Data.Text.Lazy as L+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | The lower-case hexadecimal digits of a number, without a @0x@.+-- 'Data.Maybe.Nothing' for a negative number.+--+-- ==== __Examples__+--+-- >>> B.toLazyText <$> BuilderInt.hexadecimal (255 :: Int)+-- Just "ff"+--+-- >>> B.toLazyText <$> BuilderInt.hexadecimal (-1 :: Int)+-- Nothing+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.int (Range.linear (-1000) 100000)); fmap (TR.hexadecimal . L.toStrict . B.toLazyText) (BuilderInt.hexadecimal n) === (Right (n, mempty) <$ guard (n >= 0))+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+hexadecimal :: (Integral a) => a -> Maybe Builder+hexadecimal n =+  BI.hexadecimal n <$ guard (n >= 0)+{-# INLINE hexadecimal #-}
+ src/Papa/Text/Data/Text/Lazy/Encoding.hs view
@@ -0,0 +1,211 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Encoding lazy text to lazy bytes and decoding it from them, with total+-- decoders. Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Lazy.Encoding as LazyEncoding+--+-- The decoders of "Data.Text.Lazy.Encoding" that throw on invalid input+-- (lazily, from pure code, once the invalid bytes are reached) are replaced by+-- decoders of the same names that return the error instead: 'decodeUtf8',+-- 'decodeUtf16LE', 'decodeUtf16BE', 'decodeUtf32LE', 'decodeUtf32BE' return+-- 'Either' a 'UnicodeException', and 'decodeASCII' returns 'Maybe'. Each must+-- read all of its input before it returns, so none is lazy.+--+-- "Data.Text.Lazy.Encoding"'s @decodeUtf16LEWith@, @decodeUtf16BEWith@,+-- @decodeUtf32LEWith@ and @decodeUtf32BEWith@ do not return for input that+-- ends part of the way through a code unit, with a handler that does not+-- throw ('Papa.Text.Data.Text.Encoding.lenientDecode' builds an infinite text+-- of U+FFFD), and are not exported: 'decodeUtf16LE' and the like decode in+-- one strict chunk.+--+-- The handlers that 'X.decodeUtf8With' takes are exported by+-- "Papa.Text.Data.Text.Encoding".+--+-- @since 0.7.0+module Papa.Text.Data.Text.Lazy.Encoding (+  module X,+  decodeUtf8,+  decodeASCII,+  decodeUtf16LE,+  decodeUtf16BE,+  decodeUtf32LE,+  decodeUtf32BE,+) where++import qualified Data.ByteString as SB+import qualified Data.ByteString.Lazy as LB+import Data.Either (Either)+import Data.Function ((.))+import Data.Functor (fmap)+import Data.Maybe (Maybe)+import qualified Data.Text as ST+import qualified Data.Text.Encoding as E+import Data.Text.Encoding.Error (UnicodeException)+import Data.Text.Lazy (Text)+import qualified Data.Text.Lazy as L+import Data.Text.Lazy.Encoding as X hiding (+  decodeASCII,+  decodeUtf16BE,+  decodeUtf16BEWith,+  decodeUtf16LE,+  decodeUtf16LEWith,+  decodeUtf32BE,+  decodeUtf32BEWith,+  decodeUtf32LE,+  decodeUtf32LEWith,+  decodeUtf8,+ )+import qualified Data.Text.Lazy.Encoding as LE+import Data.Traversable (traverse)+import qualified Papa.Text.Data.Text.Encoding as TE++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text.Lazy.Encoding as LazyEncoding+-- >>> import qualified Data.ByteString.Lazy as LB+-- >>> import qualified Data.Text.Lazy as L+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genText = L.fromChunks <$> Gen.list (Range.linear 0 4) (Gen.text (Range.linear 0 6) Gen.unicode)+-- >>> let genBytes = LB.fromChunks <$> Gen.list (Range.linear 0 4) (Gen.bytes (Range.linear 0 6))++-- | Total 'LE.decodeUtf8': decode UTF-8, or the error for invalid UTF-8.+-- This is 'X.decodeUtf8''.+--+-- ==== __Examples__+--+-- >>> LazyEncoding.decodeUtf8 "caf\195\169"+-- Right "caf\233"+--+-- >>> isLeft (LazyEncoding.decodeUtf8 "\255")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyEncoding.decodeUtf8 (LazyEncoding.encodeUtf8 t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf8 :: LB.ByteString -> Either UnicodeException Text+decodeUtf8 =+  LE.decodeUtf8'+{-# INLINE decodeUtf8 #-}++-- | Total 'LE.decodeASCII': decode ASCII, or 'Data.Maybe.Nothing' for a byte above 127.+--+-- ==== __Examples__+--+-- >>> LazyEncoding.decodeASCII "abc"+-- Just "abc"+--+-- >>> LazyEncoding.decodeASCII "caf\195\169"+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do b <- forAll genBytes; isJust (LazyEncoding.decodeASCII b) === LB.all (< 128) b+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeASCII :: LB.ByteString -> Maybe Text+decodeASCII =+  fmap L.fromChunks . traverse E.decodeASCII' . LB.toChunks+{-# INLINE decodeASCII #-}++-- | Total 'LE.decodeUtf16LE': decode little-endian UTF-16, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> LazyEncoding.decodeUtf16LE "a\NULb\NUL"+-- Right "ab"+--+-- >>> isLeft (LazyEncoding.decodeUtf16LE "a")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyEncoding.decodeUtf16LE (LazyEncoding.encodeUtf16LE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf16LE :: LB.ByteString -> Either UnicodeException Text+decodeUtf16LE =+  strictly TE.decodeUtf16LE+{-# INLINE decodeUtf16LE #-}++-- | Total 'LE.decodeUtf16BE': decode big-endian UTF-16, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> LazyEncoding.decodeUtf16BE "\NULa\NULb"+-- Right "ab"+--+-- >>> isLeft (LazyEncoding.decodeUtf16BE "a")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyEncoding.decodeUtf16BE (LazyEncoding.encodeUtf16BE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf16BE :: LB.ByteString -> Either UnicodeException Text+decodeUtf16BE =+  strictly TE.decodeUtf16BE+{-# INLINE decodeUtf16BE #-}++-- | Total 'LE.decodeUtf32LE': decode little-endian UTF-32, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> LazyEncoding.decodeUtf32LE "a\NUL\NUL\NUL"+-- Right "a"+--+-- >>> isLeft (LazyEncoding.decodeUtf32LE "a\NUL")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyEncoding.decodeUtf32LE (LazyEncoding.encodeUtf32LE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf32LE :: LB.ByteString -> Either UnicodeException Text+decodeUtf32LE =+  strictly TE.decodeUtf32LE+{-# INLINE decodeUtf32LE #-}++-- | Total 'LE.decodeUtf32BE': decode big-endian UTF-32, or an error for+-- invalid input.+--+-- ==== __Examples__+--+-- >>> LazyEncoding.decodeUtf32BE "\NUL\NUL\NULa"+-- Right "a"+--+-- >>> isLeft (LazyEncoding.decodeUtf32BE "\NUL\NUL")+-- True+--+-- >>> check $ withTests 100 $ property $ do t <- forAll genText; LazyEncoding.decodeUtf32BE (LazyEncoding.encodeUtf32BE t) === Right t+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+decodeUtf32BE :: LB.ByteString -> Either UnicodeException Text+decodeUtf32BE =+  strictly TE.decodeUtf32BE+{-# INLINE decodeUtf32BE #-}++-- | Decode lazy bytes with a decoder of strict bytes, in one chunk.+strictly :: (SB.ByteString -> Either UnicodeException ST.Text) -> LB.ByteString -> Either UnicodeException Text+strictly decode =+  fmap L.fromStrict . decode . LB.toStrict+{-# INLINE strictly #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/Lazy/Read.hs view
@@ -0,0 +1,147 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Reading numbers from the start of a lazy text, without overflow.+-- Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Lazy.Read as LazyRead+--+-- "Data.Text.Lazy.Read"'s @decimal@ and @hexadecimal@ wrap around a number too+-- large for their type (@decimal "300"@ reads @44 :: Word8@), and its+-- @signed@ wraps around, or throws, at an unsigned type (@signed decimal+-- "-1"@ reads @255 :: Word8@, and throws at 'Numeric.Natural.Natural'). They+-- are replaced by readers of the same names that read an 'Integer' and return+-- an error where it does not fit the type.+--+-- "Data.Text.Lazy.Read"'s @decimal@ and @hexadecimal@ (text 2.0) read @0@+-- from a text that does not start with a digit, where "Data.Text.Read"'s+-- return an error; these return the error.+--+-- 'X.rational' and 'X.double' are "Data.Text.Lazy.Read"'s. 'X.rational' returns+-- 'Prelude.fromRational' of what it reads, which wraps around at a ratio of a+-- bounded type such as @Ratio Int@.+--+-- @since 0.7.0+module Papa.Text.Data.Text.Lazy.Read (+  module X,+  decimal,+  hexadecimal,+  signed,+) where++import Control.Applicative ((<|>))+import Data.Bits (Bits)+import Data.Char (isDigit, isHexDigit)+import Data.Function ((.))+import Data.Maybe (fromMaybe)+import qualified Data.Text.Lazy as T+import Data.Text.Lazy.Read as X (+  Reader,+  double,+  rational,+ )+import qualified Data.Text.Lazy.Read as TR+import Papa.Internal.Read (fits, leading, signedWith)+import Prelude (Integer, Integral)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text.Lazy as Text+-- >>> import qualified Papa.Text.Data.Text as StrictText+-- >>> import qualified Papa.Text.Data.Text.Lazy.Read as LazyRead+-- >>> import qualified Data.Text.Lazy.Read as TR+-- >>> import qualified Papa.Unsafe.Numeric as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Read a decimal number: one or more digits, and the text after them. An+-- error for no digit, or for a number that does not fit the type.+--+-- ==== __Examples__+--+-- >>> LazyRead.decimal "123abc" :: Either String (Int, Text.Text)+-- Right (123,"abc")+--+-- >>> LazyRead.decimal "300" :: Either String (Word8, Text.Text)+-- Left "number out of range"+--+-- >>> LazyRead.decimal "x" :: Either String (Int, Text.Text)+-- Left "input does not start with a digit"+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.integral (Range.linear 0 1000) :: Gen Integer); fmap fst (LazyRead.decimal (Text.fromStrict (StrictText.display n)) :: Either String (Word8, Text.Text)) === bool (Left "number out of range") (Right (U.fromInteger n)) (n <= 255)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+decimal :: (Integral a, Bits a) => TR.Reader a+decimal t =+  fits (leading T.uncons isDigit "input does not start with a digit" t (TR.decimal t))+{-# INLINE decimal #-}++-- | Read a hexadecimal number: an optional @0x@ or @0X@, one or more hex+-- digits, and the text after them. An error for no digit, or for a number+-- that does not fit the type.+--+-- ==== __Examples__+--+-- >>> LazyRead.hexadecimal "0xff!" :: Either String (Word8, Text.Text)+-- Right (255,"!")+--+-- >>> LazyRead.hexadecimal "100" :: Either String (Word8, Text.Text)+-- Left "number out of range"+--+-- >>> LazyRead.hexadecimal "0xg" :: Either String (Word8, Text.Text)+-- Left "input does not start with a hexadecimal digit"+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.integral (Range.linear 0 100000) :: Gen Integer); (LazyRead.hexadecimal (Text.fromStrict (StrictText.display n)) :: Either String (Integer, Text.Text)) === TR.hexadecimal (Text.fromStrict (StrictText.display n))+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+hexadecimal :: (Integral a, Bits a) => TR.Reader a+hexadecimal t =+  fits+    ( leading+        T.uncons+        isHexDigit+        "input does not start with a hexadecimal digit"+        (fromMaybe t (T.stripPrefix (T.pack "0x") t <|> T.stripPrefix (T.pack "0X") t))+        (TR.hexadecimal t)+    )+{-# INLINE hexadecimal #-}++-- | Read an optional @+@ or @-@, then a number with a reader of 'Integer's+-- ('decimal' or 'hexadecimal'), negated after a @-@. An error for a number+-- that does not fit the type.+--+-- ==== __Examples__+--+-- >>> LazyRead.signed LazyRead.decimal "-12 rest" :: Either String (Int, Text.Text)+-- Right (-12," rest")+--+-- >>> LazyRead.signed LazyRead.decimal "+12" :: Either String (Int, Text.Text)+-- Right (12,"")+--+-- >>> LazyRead.signed LazyRead.decimal "-1" :: Either String (Word8, Text.Text)+-- Left "number out of range"+--+-- >>> LazyRead.signed LazyRead.decimal "-1" :: Either String (U.Natural, Text.Text)+-- Left "number out of range"+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.integral (Range.linear (-1000) 1000) :: Gen Integer); (LazyRead.signed LazyRead.decimal (Text.fromStrict (StrictText.display n)) :: Either String (Integer, Text.Text)) === Right (n, "")+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+signed :: (Integral a, Bits a) => TR.Reader Integer -> TR.Reader a+signed r =+  fits . signedWith T.uncons r+{-# INLINE signed #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Text/Data/Text/Read.hs view
@@ -0,0 +1,129 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Reading numbers from the start of a strict text, without overflow.+-- Import qualified:+--+-- > import qualified Papa.Text.Data.Text.Read as Read+--+-- "Data.Text.Read"'s @decimal@ and @hexadecimal@ wrap around a number too+-- large for their type (@decimal "300"@ reads @44 :: Word8@), and its+-- @signed@ wraps around, or throws, at an unsigned type (@signed decimal+-- "-1"@ reads @255 :: Word8@, and throws at 'Numeric.Natural.Natural'). They+-- are replaced by readers of the same names that read an 'Integer' and return+-- an error where it does not fit the type.+--+-- 'X.rational' and 'X.double' are "Data.Text.Read"'s. 'X.rational' returns+-- 'Prelude.fromRational' of what it reads, which wraps around at a ratio of a+-- bounded type such as @Ratio Int@.+--+-- @since 0.7.0+module Papa.Text.Data.Text.Read (+  module X,+  decimal,+  hexadecimal,+  signed,+) where++import Data.Bits (Bits)+import Data.Function ((.))+import qualified Data.Text as T+import Data.Text.Read as X (+  Reader,+  double,+  rational,+ )+import qualified Data.Text.Read as TR+import Papa.Internal.Read (fits, signedWith)+import Prelude (Integer, Integral)++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> :set -XOverloadedStrings+-- >>> import Papa+-- >>> import qualified Papa.Text.Data.Text as Text+-- >>> import qualified Papa.Text.Data.Text.Read as Read+-- >>> import qualified Data.Text.Read as TR+-- >>> import qualified Papa.Unsafe.Numeric as U+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range++-- | Read a decimal number: one or more digits, and the text after them. An+-- error for no digit, or for a number that does not fit the type.+--+-- ==== __Examples__+--+-- >>> Read.decimal "123abc" :: Either String (Int, Text)+-- Right (123,"abc")+--+-- >>> Read.decimal "300" :: Either String (Word8, Text)+-- Left "number out of range"+--+-- >>> Read.decimal "x" :: Either String (Int, Text)+-- Left "input does not start with a digit"+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.integral (Range.linear 0 1000) :: Gen Integer); fmap fst (Read.decimal (Text.display n) :: Either String (Word8, Text)) === bool (Left "number out of range") (Right (U.fromInteger n)) (n <= 255)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+decimal :: (Integral a, Bits a) => TR.Reader a+decimal =+  fits . TR.decimal+{-# INLINE decimal #-}++-- | Read a hexadecimal number: an optional @0x@ or @0X@, one or more hex+-- digits, and the text after them. An error for no digit, or for a number+-- that does not fit the type.+--+-- ==== __Examples__+--+-- >>> Read.hexadecimal "0xff!" :: Either String (Word8, Text)+-- Right (255,"!")+--+-- >>> Read.hexadecimal "100" :: Either String (Word8, Text)+-- Left "number out of range"+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.integral (Range.linear 0 100000) :: Gen Integer); (Read.hexadecimal (Text.display n) :: Either String (Integer, Text)) === TR.hexadecimal (Text.display n)+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+hexadecimal :: (Integral a, Bits a) => TR.Reader a+hexadecimal =+  fits . TR.hexadecimal+{-# INLINE hexadecimal #-}++-- | Read an optional @+@ or @-@, then a number with a reader of 'Integer's+-- ('decimal' or 'hexadecimal'), negated after a @-@. An error for a number+-- that does not fit the type.+--+-- ==== __Examples__+--+-- >>> Read.signed Read.decimal "-12 rest" :: Either String (Int, Text)+-- Right (-12," rest")+--+-- >>> Read.signed Read.decimal "+12" :: Either String (Int, Text)+-- Right (12,"")+--+-- >>> Read.signed Read.decimal "-1" :: Either String (Word8, Text)+-- Left "number out of range"+--+-- >>> Read.signed Read.decimal "-1" :: Either String (U.Natural, Text)+-- Left "number out of range"+--+-- >>> check $ withTests 200 $ property $ do n <- forAll (Gen.integral (Range.linear (-1000) 1000) :: Gen Integer); (Read.signed Read.decimal (Text.display n) :: Either String (Integer, Text)) === Right (n, "")+-- ...passed 200 tests.+-- True+--+-- @since 0.7.0+signed :: (Integral a, Bits a) => TR.Reader Integer -> TR.Reader a+signed r =+  fits . signedWith T.uncons r+{-# INLINE signed #-}++-- $teardown+-- The doctests of the other modules do not take string literals as text.+--+-- >>> :set -XNoOverloadedStrings
+ src/Papa/Time/Data/Time.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Clock time. For the rest of "Data.Time", import it qualified.+--+-- @since 0.7.0+module Papa.Time.Data.Time (+  module P,+) where++import Data.Time as P (+  Day,+  NominalDiffTime,+  UTCTime,+  addUTCTime,+  diffUTCTime,+  getCurrentTime,+ )
+ src/Papa/UnorderedContainers/Data/HashMap.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Hash maps, strict in their values, without the partial function of+-- "Data.HashMap.Strict". Import qualified:+--+-- > import qualified Papa.UnorderedContainers.Data.HashMap as HashMap+--+-- Every function of "Data.HashMap.Strict" is total but @(!)@, which throws+-- for a key that is not in the map, and is not exported. Read, insert, change+-- and delete the value at a key with lens's 'Control.Lens.At' and+-- 'Control.Lens.Ixed' instances:+--+-- * @'Papa.Lens.Optic.the' (at k) m@ (a 'Data.Maybe.Maybe'), @m ^? ix k@,+--   or 'HashMap.!?' and 'HashMap.lookup', to read;+-- * @m & at k ?~ v@ to insert, @'Control.Lens.sans' k m@+--   (@m & at k .~ Nothing@) to delete;+-- * @m & ix k %~ f@ to change the value at a key that is in the map.+--+-- lens's instances for 'HashMap': 'Control.Lens.At', 'Control.Lens.Ixed',+-- 'Control.Lens.Each', 'Control.Lens.AsEmpty',+-- 'Control.Lens.FunctorWithIndex', 'Control.Lens.FoldableWithIndex',+-- 'Control.Lens.TraversableWithIndex'.+--+-- The deprecated @lookupDefault@ is not exported: use 'HashMap.findWithDefault'.+module Papa.UnorderedContainers.Data.HashMap (+  module X,+) where++import Data.HashMap.Strict as X hiding (+  lookupDefault,+  (!),+ )++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.UnorderedContainers.Data.HashMap as HashMap+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genKey = Gen.int (Range.linear 0 20)+-- >>> let genMap = HashMap.fromList <$> Gen.list (Range.linear 0 10) ((,) <$> genKey <*> Gen.alpha)++-- $examples+--+-- ==== __Examples__+--+-- >>> the (at (1 :: Int)) (HashMap.fromList [(1, 'a')])+-- Just 'a'+--+-- >>> HashMap.fromList [(1, 'a')] ^? ix (2 :: Int)+-- Nothing+--+-- >>> HashMap.toList (sans 1 (HashMap.fromList [(1 :: Int, 'a')] & at 2 ?~ 'b'))+-- [(2,'b')]+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; k <- forAll genKey; the (at k) m === HashMap.lookup k m+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do m <- forAll genMap; k <- forAll genKey; v <- forAll Gen.alpha; (m & at k ?~ v) === HashMap.insert k v m+-- ...passed 100 tests.+-- True
+ src/Papa/UnorderedContainers/Data/HashSet.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Hash sets. Every function of "Data.HashSet" is total, and all are+-- exported. Import qualified:+--+-- > import qualified Papa.UnorderedContainers.Data.HashSet as HashSet+--+-- Test, insert and delete an element with lens's 'Control.Lens.Contains' and+-- 'Control.Lens.At' instances: @'Papa.Lens.Optic.the' (contains a) s@,+-- @s & contains a .~ True@, @s & contains a .~ False@.+--+-- lens's instances for 'HashSet': 'Control.Lens.Contains', 'Control.Lens.At',+-- 'Control.Lens.Ixed', 'Control.Lens.AsEmpty'.+module Papa.UnorderedContainers.Data.HashSet (+  module X,+) where++import Data.HashSet as X++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa.UnorderedContainers.Data.HashSet as HashSet+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genElem = Gen.int (Range.linear 0 20)+-- >>> let genSet = HashSet.fromList <$> Gen.list (Range.linear 0 10) genElem++-- $examples+--+-- ==== __Examples__+--+-- >>> the (contains 2) (HashSet.fromList [1, 2 :: Int])+-- True+--+-- >>> HashSet.toList (HashSet.fromList [1 :: Int] & contains 1 .~ False)+-- []+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; a <- forAll genElem; the (contains a) s === HashSet.member a s+-- ...passed 100 tests.+-- True+--+-- >>> check $ withTests 100 $ property $ do s <- forAll genSet; a <- forAll genElem; (s & contains a .~ True) === HashSet.insert a s+-- ...passed 100 tests.+-- True
+ src/Papa/Unsafe.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | "Papa", with the partial functions of base that it replaces, under their+-- own names and types, for code that is moving to "Papa" one module at a+-- time.+--+-- > import Papa.Unsafe+--+-- instead of @import Papa@. "Papa" does not import this module. Each partial+-- function is also in a module of its own area, which exports only the+-- partial functions and so combines with @import Papa@:+--+-- * "Papa.Unsafe.Numeric": @div@, @mod@, @divMod@, @quot@, @rem@, @quotRem@,+--   @(^)@, @(/)@, @recip@, @(^^)@, @(%)@, @fromIntegral@, @fromInteger@,+--   @truncate@, @round@, @ceiling@, @floor@, @properFraction@, @toRational@,+--   @realToFrac@, and the types @Natural@ and @Ratio@;+-- * "Papa.Unsafe.Format": @printf@, @hPrintf@;+-- * "Papa.Unsafe.Exception": @throw@, @error@, @errorWithoutStackTrace@,+--   @undefined@, @throwing@, @throwing_@;+-- * "Papa.Unsafe.Async": @wait@, @waitAny@, @waitEither@, @waitBoth@ and+--   their forms, which rethrow a thread's exception, and @link@, @link2@.+--+-- "Papa.Unsafe.IO", "System.IO"'s functions that throw their+-- 'Prelude.IOError's, is not re-exported: its names are those of "Papa"'s+-- functions that return them, so it is imported qualified.+--+-- @since 0.7.0+module Papa.Unsafe (+  module Papa,+  module Papa.Unsafe.Async,+  module Papa.Unsafe.Exception,+  module Papa.Unsafe.Format,+  module Papa.Unsafe.Numeric,+) where++import Papa+import Papa.Unsafe.Async+import Papa.Unsafe.Exception+import Papa.Unsafe.Format+import Papa.Unsafe.Numeric
+ src/Papa/Unsafe/Async.hs view
@@ -0,0 +1,79 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The functions of "Control.Concurrent.Async" that rethrow one thread's+-- exception in another:+--+-- * @wait@, @waitAny@, @waitEither@, @waitEither_@, @waitBoth@, their @…STM@+--   forms and @waitAnyCancel@, @waitEitherCancel@, which rethrow the+--   exception of the thread waited for in the waiting thread;+-- * @link@, @link2@, @linkOnly@, @link2Only@, which throw it asynchronously,+--   wrapped in 'ExceptionInLinkedThread', into the linked thread, at any+--   point of whatever it is doing.+--+-- "Papa.Async.Control.Concurrent.Async" returns the exception as a value:+-- 'Papa.Async.Control.Concurrent.Async.waitCatch',+-- 'Papa.Async.Control.Concurrent.Async.waitExcept' and the @…Catch@+-- functions.+--+-- @waitAny@, @waitAnySTM@ and @waitAnyCancel@ also wait forever at an empty+-- list.+--+-- This module exports only these functions, and so combines with+-- @import Papa@.+--+-- ==== __Examples__+--+-- @wait@ rethrows the thread's exception:+--+-- >>> E.try (withAsync (E.throwIO (userError "x") :: IO ()) wait) :: IO (Either IOException ())+-- Left user error (x)+--+-- >>> withAsync (pure 3) wait+-- 3+--+-- @since 0.7.0+module Papa.Unsafe.Async (+  wait,+  waitSTM,+  waitAny,+  waitAnySTM,+  waitAnyCancel,+  waitEither,+  waitEitherSTM,+  waitEither_,+  waitEitherSTM_,+  waitEitherCancel,+  waitBoth,+  waitBothSTM,+  link,+  link2,+  linkOnly,+  link2Only,+  ExceptionInLinkedThread (ExceptionInLinkedThread),+) where++import Control.Concurrent.Async (+  ExceptionInLinkedThread (ExceptionInLinkedThread),+  link,+  link2,+  link2Only,+  linkOnly,+  wait,+  waitAny,+  waitAnyCancel,+  waitAnySTM,+  waitBoth,+  waitBothSTM,+  waitEither,+  waitEitherCancel,+  waitEitherSTM,+  waitEitherSTM_,+  waitEither_,+  waitSTM,+ )++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa.Unsafe+-- >>> import qualified Control.Exception as E
+ src/Papa/Unsafe/Exception.hs view
@@ -0,0 +1,27 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The functions that throw an exception from pure code, and so make the+-- function that calls them partial.+--+-- In "Papa", an exception is thrown only in 'Prelude.IO'+-- ('Papa.Base.Control.Exception.throwIO', 'Control.Lens.throwingM'), and an+-- expected failure is a value ('Data.Maybe.Maybe', 'Data.Either.Either',+-- 'Papa.Base.System.IO.Except.IOExcept').+--+-- This module exports only partial functions, and so combines with+-- @import Papa@.+--+-- @since 0.7.0+module Papa.Unsafe.Exception (+  throw,+  error,+  errorWithoutStackTrace,+  undefined,+  throwing,+  throwing_,+) where++import Control.Exception (throw)+import Control.Exception.Lens (throwing, throwing_)+import Prelude (error, errorWithoutStackTrace, undefined)
+ src/Papa/Unsafe/Format.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | Formatting with a format string. 'printf' and 'hPrintf' throw at run+-- time where the format string does not match the arguments.+--+-- This module exports only these functions, so it combines with "Papa".+-- "Papa.Unsafe" is "Papa" with every partial function, these included.+--+-- @since 0.7.0+module Papa.Unsafe.Format (+  printf,+  hPrintf,+) where++import Text.Printf (hPrintf, printf)
+ src/Papa/Unsafe/IO.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | "System.IO", whose functions throw their 'System.IO.IOError's, and read+-- and write 'Data.String.String's in the locale's encoding; some+-- (@readFile@, @getContents@, @interact@, @hGetContents@) read lazily, so+-- that their handle may be closed, or fail, after the action has returned.+--+-- > import qualified Papa.Unsafe.IO as U+--+-- Import it qualified: "Papa" has functions of the same names (@openFile@,+-- @putStrLn@, @readFile@, …) that return their exceptions in+-- 'Papa.Base.System.IO.Except.IOExcept', so this module does not combine+-- with @import Papa@, and "Papa.Unsafe" does not re-export it.+--+-- @since 0.7.0+module Papa.Unsafe.IO (+  module System.IO,+) where++import System.IO
+ src/Papa/Unsafe/Numeric.hs view
@@ -0,0 +1,104 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The partial numeric functions of base that "Papa" replaces, under their+-- own names and types. Each can throw, or silently lose information. The+-- total replacement in "Papa" is named in each group.+--+-- This module exports only these functions, so it combines with "Papa":+--+-- > import Papa+-- > import qualified Papa.Unsafe.Numeric as Unsafe+--+-- "Papa.Unsafe" is "Papa" with every partial function, these included.+--+-- @since 0.7.0+module Papa.Unsafe.Numeric (+  -- * Integral division (total: 'Papa.Base.Data.Integral.divNonZero', ...)++  -- | Throw for a divisor of zero, and for @minBound \`div\` (-1)@ on a+  -- bounded type.+  div,+  mod,+  divMod,+  quot,+  rem,+  quotRem,++  -- * Exponentiation (total: 'Papa.Base.Data.Integral.pow')++  -- | Throws for a negative exponent.+  (^),++  -- * Fractional division (total: 'Papa.Base.Data.Fractional.divideNonZero', ...; at a floating type, 'Papa.Base.Data.RealFloat.divideFloating', 'Papa.Base.Data.RealFloat.recipFloating')++  -- | Throw for a divisor of zero at 'Data.Ratio.Ratio'.+  (/),+  recip,+  (^^),++  -- * Ratios (total: 'Papa.Base.Data.Ratio.ratioNonZero')++  -- | Throws for a denominator of zero.+  (%),++  -- * Integral conversion (total: 'Papa.Base.Data.IntCast.intCast', 'Papa.Base.Data.Integral.toIntegralSized')++  -- | Wraps around where the value does not fit in the target type+  -- (@fromIntegral (300 :: Int) :: Word8@ is @44@), and throws converting a+  -- negative number to 'Numeric.Natural.Natural'.+  fromIntegral,++  -- * Conversion from fractional types (total: 'Papa.Base.Data.RealFrac.truncateMaybe', ...; to the same floating type, 'Papa.Base.Data.RealFloat.floorFloating', ...)++  -- | Return an arbitrary number for @NaN@ and the infinities of 'Prelude.Double'+  -- and 'Prelude.Float', and wrap around where the result does not fit in the target+  -- type (@truncate (300.5 :: Double) :: Word8@ is @44@).+  truncate,+  round,+  ceiling,+  floor,+  properFraction,+  toRational,+  -- | Returns an arbitrary number for @NaN@ and the infinities+  -- (total: 'Papa.Base.Data.RealFrac.approxRationalMaybe').+  approxRational,++  -- * Conversion between fractional types (total: 'Papa.Base.Data.RealFrac.floatToDouble', 'Papa.Base.Data.RealFrac.doubleToFloat', 'Papa.Base.Data.RealFrac.toRationalMaybe')++  -- | Goes through 'Prelude.Rational', which has no @NaN@ or infinity: at+  -- @Double -> Double@ it may turn @NaN@ into a number, depending on+  -- optimisation.+  realToFrac,++  -- * Conversion from 'Prelude.Integer' (total: 'Papa.Base.Data.IntCast.intCast', 'Papa.Base.Data.Integral.toIntegralSized')++  -- | Wraps around where the value does not fit in the target type+  -- (@fromInteger 300 :: Word8@ is @44@), and throws for a negative number+  -- at 'Natural'. "Papa" does not export it, but numeric literals still+  -- work: GHC calls it for them whether or not it is in scope, and warns+  -- for a literal that does not fit (@-Woverflowed-literals@).+  fromInteger,++  -- * Natural numbers++  -- | The 'Prelude.Num' instance of 'Natural' throws @arithmetic underflow@ for+  -- a negative result: of @-@, 'Prelude.negate' and 'fromInteger'+  -- (@1 - 2 :: Natural@, and the literal @-1 :: Natural@, which is+  -- @'Prelude.negate' 1@). 'minusNaturalMaybe' subtracts without throwing.+  -- 'Papa.Base.Data.Integral.pow' takes a 'Data.Word.Word' exponent.+  Natural,+  minusNaturalMaybe,++  -- * Ratios of any integral type++  -- | A 'Ratio' of a bounded type such as 'Data.Int.Int' wraps around on+  -- overflow, and so returns a wrong number (@'Prelude.negate' (minBound %+  -- 1 :: Ratio Int)@ is @minBound % 1@). "Papa" exports 'Prelude.Rational',+  -- @Ratio Integer@, which cannot overflow.+  Ratio,+) where++import Data.Ratio (Ratio, approxRational, (%))+import Numeric.Natural (Natural, minusNaturalMaybe)+import Prelude (ceiling, div, divMod, floor, fromInteger, fromIntegral, mod, properFraction, quot, quotRem, realToFrac, recip, rem, round, toRational, truncate, (/), (^), (^^))
+ src/Papa/Vector/Data/Vector.hs view
@@ -0,0 +1,886 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total versions of head, last, init, tail,+-- maximum and minimum, whose names HLint restricts whatever module they come+-- from.++{- HLINT ignore "Eta reduce" -}+-- Reason: each function takes, on the left of its definition, the arguments+-- before its vector (none for most): GHC inlines a function only once it is+-- applied to those, so @foldl1' (+)@, passed to a higher-order function,+-- is inlined and runs at the speed of vector's. A function with no such+-- arguments applies its generic version to all its arguments, so that the+-- generic one is specialised to this vector type in the compiled function+-- too.++-- | Boxed vectors, with total versions of the partial functions of+-- "Data.Vector". Import qualified:+--+-- > import qualified Papa.Vector.Data.Vector as V+--+-- The functions of "Data.Vector" that throw (for an index out of range, an+-- empty vector, a negative length, or vectors of different lengths) are+-- replaced by functions of the same names that return+-- 'Data.Maybe.Nothing' there instead, in the same time and with one copy of+-- the vector, as the originals. They are those of+-- "Papa.Vector.Data.Vector.Generic", at this vector type.+--+-- Read and set elements with the traversal @'Control.Lens.ix' i@ of lens's+-- 'Control.Lens.Ixed' instance (@v ^? ix i@, @v & ix i .~ a@), or read with+-- '!?'. Setting an element with 'Control.Lens.ix' copies the vector: set many+-- at once with '//'. lens's instances for this vector type: Ixed, Cons, Snoc, Each, AsEmpty, Reversing, FunctorWithIndex, FoldableWithIndex, TraversableWithIndex.+--+-- Not exported:+--+-- * @(!)@, which throws for an index out of range: use '!?' or+--   'Control.Lens.ix';+-- * the functions without bounds checks (@unsafeIndex@, @unsafeSlice@,+--   @unsafeUpd@, …), which read or write outside the vector for a bad+--   index, and @unsafeFreeze@, @unsafeThaw@, which let a mutable vector+--   change an immutable one;+-- * @unsafeFromArraySlice@, which reads outside the array for a bad slice.+--+-- The mutable vectors (@MVector@) are exported as a type; their functions+-- (in "Data.Vector.Mutable") are not wrapped.+module Papa.Vector.Data.Vector (+  module X,+  head,+  last,+  indexM,+  headM,+  lastM,+  slice,+  init,+  tail,+  constructN,+  constructrN,+  (//),+  update,+  update_,+  accum,+  accumulate,+  accumulate_,+  backpermute,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  maximumBy,+  maximumOn,+  minimum,+  minimumBy,+  minimumOn,+  maxIndex,+  maxIndexBy,+  minIndex,+  minIndexBy,+  fold1M,+  fold1M',+  fold1M_,+  fold1M'_,+  copy,+) where++import Control.Monad (Monad)+import Control.Monad.Primitive (PrimMonad, PrimState)+import Data.Int (Int)+import Data.Maybe (Maybe)+import Data.Ord (Ord, Ordering)+import Data.Vector as X hiding (+  accum,+  accumulate,+  accumulate_,+  backpermute,+  constructN,+  constructrN,+  copy,+  fold1M,+  fold1M',+  fold1M'_,+  fold1M_,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  head,+  headM,+  indexM,+  init,+  last,+  lastM,+  maxIndex,+  maxIndexBy,+  maximum,+  maximumBy,+  maximumOn,+  minIndex,+  minIndexBy,+  minimum,+  minimumBy,+  minimumOn,+  slice,+  tail,+  unsafeAccum,+  unsafeAccumulate,+  unsafeAccumulate_,+  unsafeBackpermute,+  unsafeCopy,+  unsafeDrop,+  unsafeFreeze,+  unsafeFromArraySlice,+  unsafeHead,+  unsafeHeadM,+  unsafeIndex,+  unsafeIndexM,+  unsafeInit,+  unsafeLast,+  unsafeLastM,+  unsafeSlice,+  unsafeTail,+  unsafeTake,+  unsafeThaw,+  unsafeUpd,+  unsafeUpdate,+  unsafeUpdate_,+  update,+  update_,+  (!),+  (//),+ )+import qualified Papa.Vector.Data.Vector.Generic as G++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Vector.Data.Vector as V+-- >>> import qualified Data.Vector.Mutable as MV+-- >>> import Control.Monad.ST (runST)+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)+-- >>> let genIndex = Gen.int (Range.linear (-3) 12)+-- >>> let genVector = V.fromList <$> Gen.list (Range.linear 0 10) genInt+-- >>> let genUpdates = Gen.list (Range.linear 0 5) ((,) <$> genIndex <*> genInt)++-- | Total @head@: the first element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.head (V.fromList "abc")+-- Just 'a'+--+-- >>> V.head (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.head v === listToMaybe (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: Vector a -> Maybe a+head v =+  G.head v+{-# INLINE head #-}++-- | Total @last@: the last element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.last (V.fromList "abc")+-- Just 'c'+--+-- >>> V.last (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.last v === listToMaybe (P.reverse (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: Vector a -> Maybe a+last v =+  G.last v+{-# INLINE last #-}++-- | Total @indexM@: the element at an index, read in a monad (so that the+-- vector is not retained by an unevaluated read). 'Data.Maybe.Nothing' for an index out+-- of range.+--+-- ==== __Examples__+--+-- >>> V.indexM (V.fromList "abc") 1 :: Identity (Maybe Char)+-- Identity (Just 'b')+--+-- >>> V.indexM (V.fromList "abc") 3 :: Identity (Maybe Char)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; runIdentity (V.indexM v i) === (v V.!? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+indexM :: (Monad m) => Vector a -> Int -> m (Maybe a)+indexM v i =+  G.indexM v i+{-# INLINE indexM #-}++-- | Total @headM@: the first element, read in a monad. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.headM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'a')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.headM v) === V.head v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+headM :: (Monad m) => Vector a -> m (Maybe a)+headM v =+  G.headM v+{-# INLINE headM #-}++-- | Total @lastM@: the last element, read in a monad. 'Data.Maybe.Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> V.lastM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'c')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.lastM v) === V.last v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+lastM :: (Monad m) => Vector a -> m (Maybe a)+lastM v =+  G.lastM v+{-# INLINE lastM #-}++-- | Total @slice@: the slice of a length from an index, in constant time.+-- 'Data.Maybe.Nothing' unless the slice is within the vector.+--+-- ==== __Examples__+--+-- >>> V.slice 1 2 (V.fromList "abcd")+-- Just "bc"+--+-- >>> V.slice 3 2 (V.fromList "abcd")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; n <- forAll genIndex; fmap V.toList (V.slice i n v) === bool Nothing (Just (P.take n (P.drop i (V.toList v)))) (i >= 0 && n >= 0 && i + n <= V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+slice :: Int -> Int -> Vector a -> Maybe (Vector a)+slice i n =+  G.slice i n+{-# INLINE slice #-}++-- | Total @init@: every element but the last, in constant time. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.init (V.fromList "abc")+-- Just "ab"+--+-- >>> V.init (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (V.init v) === bool Nothing (Just (P.take (V.length v - 1) (V.toList v))) (not (V.null v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: Vector a -> Maybe (Vector a)+init v =+  G.init v+{-# INLINE init #-}++-- | Total @tail@: every element but the first, in constant time. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.tail (V.fromList "abc")+-- Just "bc"+--+-- >>> V.tail (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (V.tail v) === fmap snd (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: Vector a -> Maybe (Vector a)+tail v =+  G.tail v+{-# INLINE tail #-}++-- | Total @constructN@: a vector of a length, each element computed from+-- those before it. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> V.constructN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [0,10,20,30]+--+-- >>> V.constructN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (V.constructN n V.sum :: Maybe (V.Vector Int)) === bool Nothing (Just (P.replicate n 0)) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructN :: Int -> (Vector a -> a) -> Maybe (Vector a)+constructN i f =+  G.constructN i f+{-# INLINE constructN #-}++-- | Total @constructrN@: a vector of a length, each element computed from+-- those after it. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> V.constructrN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [30,20,10,0]+--+-- >>> V.constructrN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (V.constructrN n V.length :: Maybe (V.Vector Int)) === fmap (\w -> P.reverse (V.toList w)) (V.constructN n V.length :: Maybe (V.Vector Int))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructrN :: Int -> (Vector a -> a) -> Maybe (Vector a)+constructrN i f =+  G.constructrN i f+{-# INLINE constructrN #-}++-- | Total @(//)@: a vector with the elements at the indices of a list of+-- updates replaced, in one copy. 'Data.Maybe.Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.fromList "abc" V.// [(0, 'x'), (2, 'z')]+-- Just "xbz"+--+-- >>> V.fromList "abc" V.// [(3, 'x')]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; (v V.// us) === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i .~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+(//) :: Vector a -> [(Int, a)] -> Maybe (Vector a)+(//) v us =+  (G.//) v us+{-# INLINE (//) #-}++infixl 9 //++-- | Total @update@: '//' with the updates in a vector. 'Data.Maybe.Nothing' if an index+-- is out of range.+--+-- ==== __Examples__+--+-- >>> V.update (V.fromList "abc") (V.fromList [(1, 'x')])+-- Just "axc"+--+-- >>> V.update (V.fromList "abc") (V.fromList [(-1, 'x')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.update v (V.fromList us) === (v V.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update :: Vector a -> Vector (Int, a) -> Maybe (Vector a)+update v w =+  G.update v w+{-# INLINE update #-}++-- | Total @update_@: 'update' with the indices and the values in two+-- vectors, paired up to the shorter. 'Data.Maybe.Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [2, 0]) (V.fromList "xy")+-- Just "ybx"+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [2, 9]) (V.fromList "x")+-- Just "abx"+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [9]) (V.fromList "x")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.update_ v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === (v V.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update_ :: Vector a -> Vector Int -> Vector a -> Maybe (Vector a)+update_ v w xs =+  G.update_ v w xs+{-# INLINE update_ #-}++-- | Total @accum@: a vector with each element at the indices of a list of+-- updates combined with the update, in one copy. 'Data.Maybe.Nothing' if an index is+-- out of range.+--+-- ==== __Examples__+--+-- >>> V.accum (+) (V.fromList [10, 20, 30 :: Int]) [(0, 1), (2, 3), (0, 4)]+-- Just [15,20,33]+--+-- >>> V.accum (+) (V.fromList [10, 20, 30 :: Int]) [(3, 1)]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accum (+) v us === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i +~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Maybe (Vector a)+accum f =+  G.accum f+{-# INLINE accum #-}++-- | Total @accumulate@: 'accum' with the updates in a vector. 'Data.Maybe.Nothing' if+-- an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.accumulate (+) (V.fromList [10, 20 :: Int]) (V.fromList [(1, 5)])+-- Just [10,25]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accumulate (+) v (V.fromList us) === V.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Maybe (Vector a)+accumulate f =+  G.accumulate f+{-# INLINE accumulate #-}++-- | Total @accumulate_@: 'accumulate' with the indices and the values in two+-- vectors, paired up to the shorter. 'Data.Maybe.Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> V.accumulate_ (+) (V.fromList [10, 20 :: Int]) (V.fromList [1, 1]) (V.fromList [5, 6])+-- Just [10,31]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accumulate_ (+) v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === V.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Maybe (Vector a)+accumulate_ f =+  G.accumulate_ f+{-# INLINE accumulate_ #-}++-- | Total @backpermute@: the elements at the indices of a vector of indices.+-- 'Data.Maybe.Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.backpermute (V.fromList "abcd") (V.fromList [3, 0, 3])+-- Just "dad"+--+-- >>> V.backpermute (V.fromList "abcd") (V.fromList [4])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; is <- forAll (Gen.list (Range.linear 0 5) genIndex); fmap V.toList (V.backpermute v (V.fromList is)) === traverse (v V.!?) is+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+backpermute :: Vector a -> Vector Int -> Maybe (Vector a)+backpermute v w =+  G.backpermute v w+{-# INLINE backpermute #-}++-- | Total @foldl1@: a left fold with no starting value. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldl1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> V.foldl1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldl1 (-) v === fmap (\(a, as) -> P.foldl (-) a as) (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (a -> a -> a) -> Vector a -> Maybe a+foldl1 f =+  G.foldl1 f+{-# INLINE foldl1 #-}++-- | Total @foldl1'@: 'foldl1', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldl1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldl1' (-) v === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (a -> a -> a) -> Vector a -> Maybe a+foldl1' f =+  G.foldl1' f+{-# INLINE foldl1' #-}++-- | Total @foldr1@: a right fold with no starting value. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldr1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> V.foldr1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldr1 (-) v === fmap (\(as, a) -> P.foldr (-) a as) (P.unsnoc (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (a -> a -> a) -> Vector a -> Maybe a+foldr1 f =+  G.foldr1 f+{-# INLINE foldr1 #-}++-- | Total @foldr1'@: 'foldr1', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldr1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldr1' (-) v === V.foldr1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (a -> a -> a) -> Vector a -> Maybe a+foldr1' f =+  G.foldr1' f+{-# INLINE foldr1' #-}++-- | Total @maximum@: the greatest element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximum (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> V.maximum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximum v === maximumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: (Ord a) => Vector a -> Maybe a+maximum v =+  G.maximum v+{-# INLINE maximum #-}++-- | Total @maximumBy@: the greatest element by a comparison; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximumBy compare v === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumBy :: (a -> a -> Ordering) -> Vector a -> Maybe a+maximumBy f =+  G.maximumBy f+{-# INLINE maximumBy #-}++-- | Total @maximumOn@: the element with the greatest image under a+-- function; the first of equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximumOn id v === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumOn :: (Ord b) => (a -> b) -> Vector a -> Maybe a+maximumOn f =+  G.maximumOn f+{-# INLINE maximumOn #-}++-- | Total @minimum@: the least element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimum (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> V.minimum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimum v === minimumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: (Ord a) => Vector a -> Maybe a+minimum v =+  G.minimum v+{-# INLINE minimum #-}++-- | Total @minimumBy@: the least element by a comparison; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimumBy compare v === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumBy :: (a -> a -> Ordering) -> Vector a -> Maybe a+minimumBy f =+  G.minimumBy f+{-# INLINE minimumBy #-}++-- | Total @minimumOn@: the element with the least image under a function;+-- the first of equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimumOn id v === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumOn :: (Ord b) => (a -> b) -> Vector a -> Maybe a+minimumOn f =+  G.minimumOn f+{-# INLINE minimumOn #-}++-- | Total @maxIndex@: the index of the greatest element; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maxIndex (V.fromList [3, 4, 1, 4 :: Int])+-- Just 1+--+-- >>> V.maxIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (V.maxIndex v >>= (v V.!?)) === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndex :: (Ord a) => Vector a -> Maybe Int+maxIndex v =+  G.maxIndex v+{-# INLINE maxIndex #-}++-- | Total @maxIndexBy@: the index of the greatest element by a comparison.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maxIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maxIndexBy compare v === V.maxIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Maybe Int+maxIndexBy f =+  G.maxIndexBy f+{-# INLINE maxIndexBy #-}++-- | Total @minIndex@: the index of the least element; the first of equals.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minIndex (V.fromList [3, 1, 4, 1 :: Int])+-- Just 1+--+-- >>> V.minIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (V.minIndex v >>= (v V.!?)) === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndex :: (Ord a) => Vector a -> Maybe Int+minIndex v =+  G.minIndex v+{-# INLINE minIndex #-}++-- | Total @minIndexBy@: the index of the least element by a comparison.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 2+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minIndexBy compare v === V.minIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndexBy :: (a -> a -> Ordering) -> Vector a -> Maybe Int+minIndexBy f =+  G.minIndexBy f+{-# INLINE minIndexBy #-}++-- | Total @fold1M@: a monadic left fold with no starting value. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> V.fold1M (\a b -> Identity (a - b)) (V.empty :: V.Vector Int)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M (\a b -> Identity (a - b)) v) === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M :: (Monad m) => (a -> a -> m a) -> Vector a -> m (Maybe a)+fold1M f =+  G.fold1M f+{-# INLINE fold1M #-}++-- | Total @fold1M'@: 'fold1M', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M' (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M' (\a b -> Identity (a - b)) v) === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M' :: (Monad m) => (a -> a -> m a) -> Vector a -> m (Maybe a)+fold1M' f =+  G.fold1M' f+{-# INLINE fold1M' #-}++-- | Total @fold1M_@: 'fold1M' for its effects. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> V.fold1M_ (\a b -> [a + b]) (V.empty :: V.Vector Int)+-- [Nothing]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M_ (\a b -> Identity (a - b)) v) === (() <$ V.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M_ :: (Monad m) => (a -> a -> m a) -> Vector a -> m (Maybe ())+fold1M_ f =+  G.fold1M_ f+{-# INLINE fold1M_ #-}++-- | Total @fold1M'_@: 'fold1M'' for its effects. 'Data.Maybe.Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M'_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M'_ (\a b -> Identity (a - b)) v) === (() <$ V.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M'_ :: (Monad m) => (a -> a -> m a) -> Vector a -> m (Maybe ())+fold1M'_ f =+  G.fold1M'_ f+{-# INLINE fold1M'_ #-}++-- | Total @copy@: copy an immutable vector into a mutable one of the same+-- length. 'Data.Maybe.Nothing', and no copy, for vectors of different lengths.+--+-- ==== __Examples__+--+-- >>> runST (do m <- MV.replicate 2 'x'; r <- V.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Just (),"ab")+--+-- >>> runST (do m <- MV.replicate 3 'x'; r <- V.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Nothing,"xxx")+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; n <- forAll genIndex; runST (do m <- MV.replicate (max 0 n) 0; r <- V.copy m v; fmap ((,) r) (V.freeze m)) === bool (Nothing, V.replicate n 0) (Just (), v) (max 0 n == V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+copy :: (PrimMonad m) => MVector (PrimState m) a -> Vector a -> m (Maybe ())+copy dst =+  G.copy dst+{-# INLINE copy #-}
+ src/Papa/Vector/Data/Vector/Generic.hs view
@@ -0,0 +1,930 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Redundant lambda" -}+-- Reason: a function whose vector follows other arguments (@foldl1' f@,+-- @slice i n@) takes the vector in a lambda, because GHC inlines a function+-- only once it is applied to the arguments on the left of its definition:+-- so @foldl1' (+)@, passed to a higher-order function, is inlined, and+-- specialised to its function, as vector's is.++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total versions of head, last, init, tail,+-- maximum and minimum, whose names HLint restricts whatever module they come+-- from.++-- | Generic vectors, with total versions of the partial functions of+-- "Data.Vector.Generic". Import qualified:+--+-- > import qualified Papa.Vector.Data.Vector.Generic as G+--+-- This is the implementation that "Papa.Vector.Data.Vector",+-- "Papa.Vector.Data.Vector.Unboxed" and "Papa.Vector.Data.Vector.Storable"+-- specialise to their vector types.+--+-- The functions of "Data.Vector.Generic" that throw are replaced by functions+-- of the same names that return 'Data.Maybe.Nothing' there instead, in the+-- same time and with one copy of the vector, as the originals:+--+-- * for an index out of range: 'indexM', 'slice', '//', 'update',+--   'update_', 'accum', 'accumulate', 'accumulate_', 'backpermute';+-- * for an empty vector: 'head', 'last', 'headM', 'lastM', 'init', 'tail',+--   'foldl1', 'foldl1'', 'foldr1', 'foldr1'', 'maximum', 'maximumBy',+--   'maximumOn', 'minimum', 'minimumBy', 'minimumOn', 'maxIndex',+--   'maxIndexBy', 'minIndex', 'minIndexBy', 'fold1M', 'fold1M'', 'fold1M_',+--   'fold1M'_';+-- * for a negative length: 'constructN', 'constructrN';+-- * for vectors of different lengths: 'copy'.+--+-- As in "Data.Vector.Generic", the strict folds ('foldl1'', 'foldr1'', and+-- the maxima, minima and their indices) compute their result when the+-- 'Data.Maybe.Maybe' is evaluated, so that it does not hold on to the vector.+--+-- Not exported:+--+-- * @(!)@, which throws for an index out of range: use 'Data.Vector.Generic.!?',+--   or the traversal @'Control.Lens.ix' i@ of lens's 'Control.Lens.Ixed'+--   instances for "Data.Vector", "Data.Vector.Unboxed" and+--   "Data.Vector.Storable", which also sets the element (in a copy of the+--   vector: use '//' to set many);+-- * the functions without bounds checks (@unsafeIndex@, @unsafeHead@,+--   @unsafeLast@, @unsafeIndexM@, @unsafeHeadM@, @unsafeLastM@,+--   @unsafeSlice@, @unsafeInit@, @unsafeTail@, @unsafeTake@, @unsafeDrop@,+--   @unsafeUpd@, @unsafeUpdate@, @unsafeUpdate_@, @unsafeAccum@,+--   @unsafeAccumulate@, @unsafeAccumulate_@, @unsafeBackpermute@,+--   @unsafeCopy@), which read or write outside the vector for a bad index,+--   and @unsafeFreeze@, @unsafeThaw@, which let a mutable vector change an+--   immutable one;+-- * the methods of the class 'Vector', which do not check their arguments+--   (the class is exported, for its constraint);+-- * @gunfold@, which throws for a constructor that is not a vector's, and the+--   deprecated @mkType@.+module Papa.Vector.Data.Vector.Generic (+  module X,+  Vector,+  head,+  last,+  indexM,+  headM,+  lastM,+  slice,+  init,+  tail,+  constructN,+  constructrN,+  (//),+  update,+  update_,+  accum,+  accumulate,+  accumulate_,+  backpermute,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  maximumBy,+  maximumOn,+  minimum,+  minimumBy,+  minimumOn,+  maxIndex,+  maxIndexBy,+  minIndex,+  minIndexBy,+  fold1M,+  fold1M',+  fold1M_,+  fold1M'_,+  copy,+) where++import Control.Applicative (pure)+import Control.Monad (Monad, guard)+import Control.Monad.Primitive (PrimMonad, PrimState)+import Data.Bool (Bool, bool, not, (&&))+import Data.Eq ((==))+import qualified Data.Foldable as F+import Data.Function ((.))+import Data.Functor ((<$), (<$>))+import Data.Int (Int)+import Data.Maybe (Maybe (Just, Nothing))+import Data.Ord (Ord ((<), (<=)), Ordering)+import Data.Tuple (fst)+import Data.Vector.Generic (Vector)+import Data.Vector.Generic as X hiding (+  Vector (..),+  accum,+  accumulate,+  accumulate_,+  backpermute,+  constructN,+  constructrN,+  copy,+  fold1M,+  fold1M',+  fold1M'_,+  fold1M_,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  gunfold,+  head,+  headM,+  indexM,+  init,+  last,+  lastM,+  maxIndex,+  maxIndexBy,+  maximum,+  maximumBy,+  maximumOn,+  minIndex,+  minIndexBy,+  minimum,+  minimumBy,+  minimumOn,+  mkType,+  slice,+  tail,+  unsafeAccum,+  unsafeAccumulate,+  unsafeAccumulate_,+  unsafeBackpermute,+  unsafeCopy,+  unsafeDrop,+  unsafeFreeze,+  unsafeHead,+  unsafeHeadM,+  unsafeIndex,+  unsafeIndexM,+  unsafeInit,+  unsafeLast,+  unsafeLastM,+  unsafeSlice,+  unsafeTail,+  unsafeTake,+  unsafeThaw,+  unsafeUpd,+  unsafeUpdate,+  unsafeUpdate_,+  update,+  update_,+  (!),+  (//),+ )+import qualified Data.Vector.Generic as DVG+import qualified Data.Vector.Generic.Mutable as DVGM+import GHC.Num ((-))+import Prelude (($!))++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Vector.Data.Vector.Generic as G+-- >>> import qualified Data.Vector as V+-- >>> import qualified Data.Vector.Mutable as MV+-- >>> import Control.Monad.ST (runST)+-- >>> import Hedgehog+-- >>> import Hedgehog.Function (fn, apply)+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)+-- >>> let genIndex = Gen.int (Range.linear (-3) 12)+-- >>> let genVector = V.fromList <$> Gen.list (Range.linear 0 10) genInt+-- >>> let genUpdates = Gen.list (Range.linear 0 5) ((,) <$> genIndex <*> genInt)++-- | Whether an index is in range for a vector.+inRange :: (Vector v a) => v a -> Int -> Bool+inRange v i =+  0 <= i && i < DVG.length v+{-# INLINE inRange #-}++-- | Whether a vector is not empty.+nonEmpty :: (Vector v a) => v a -> Bool+nonEmpty =+  not . DVG.null+{-# INLINE nonEmpty #-}++-- | Total @head@: the first element. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.head (V.fromList "abc")+-- Just 'a'+--+-- >>> G.head (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.head v === listToMaybe (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: (Vector v a) => v a -> Maybe a+head v =+  v DVG.!? 0+{-# INLINE head #-}++-- | Total @last@: the last element. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.last (V.fromList "abc")+-- Just 'c'+--+-- >>> G.last (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.last v === listToMaybe (P.reverse (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: (Vector v a) => v a -> Maybe a+last v =+  v DVG.!? (DVG.length v - 1)+{-# INLINE last #-}++-- | Total @indexM@: the element at an index, read in a monad (so that the+-- vector is not retained by an unevaluated read). 'Nothing' for an index out+-- of range.+--+-- ==== __Examples__+--+-- >>> G.indexM (V.fromList "abc") 1 :: Identity (Maybe Char)+-- Identity (Just 'b')+--+-- >>> G.indexM (V.fromList "abc") 3 :: Identity (Maybe Char)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; runIdentity (G.indexM v i) === (v V.!? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+indexM :: (Vector v a, Monad m) => v a -> Int -> m (Maybe a)+indexM v i =+  bool (pure Nothing) (Just <$> DVG.unsafeIndexM v i) (inRange v i)+{-# INLINE indexM #-}++-- | Total @headM@: the first element, read in a monad. 'Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> G.headM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'a')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (G.headM v) === G.head v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+headM :: (Vector v a, Monad m) => v a -> m (Maybe a)+headM v =+  indexM v 0+{-# INLINE headM #-}++-- | Total @lastM@: the last element, read in a monad. 'Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> G.lastM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'c')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (G.lastM v) === G.last v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+lastM :: (Vector v a, Monad m) => v a -> m (Maybe a)+lastM v =+  indexM v (DVG.length v - 1)+{-# INLINE lastM #-}++-- | Total @slice@: the slice of a length from an index, in constant time.+-- 'Nothing' unless the slice is within the vector.+--+-- ==== __Examples__+--+-- >>> G.slice 1 2 (V.fromList "abcd")+-- Just "bc"+--+-- >>> G.slice 3 2 (V.fromList "abcd")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; n <- forAll genIndex; fmap V.toList (G.slice i n v) === bool Nothing (Just (P.take n (P.drop i (V.toList v)))) (i >= 0 && n >= 0 && i + n <= V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+slice :: (Vector v a) => Int -> Int -> v a -> Maybe (v a)+slice i n =+  \v -> DVG.unsafeSlice i n v <$ guard (0 <= i && 0 <= n && n <= DVG.length v - i)+{-# INLINE slice #-}++-- | Total @init@: every element but the last, in constant time. 'Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.init (V.fromList "abc")+-- Just "ab"+--+-- >>> G.init (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (G.init v) === bool Nothing (Just (P.take (V.length v - 1) (V.toList v))) (not (V.null v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: (Vector v a) => v a -> Maybe (v a)+init v =+  DVG.unsafeInit v <$ guard (nonEmpty v)+{-# INLINE init #-}++-- | Total @tail@: every element but the first, in constant time. 'Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.tail (V.fromList "abc")+-- Just "bc"+--+-- >>> G.tail (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (G.tail v) === fmap snd (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: (Vector v a) => v a -> Maybe (v a)+tail v =+  DVG.unsafeTail v <$ guard (nonEmpty v)+{-# INLINE tail #-}++-- | Total @constructN@: a vector of a length, each element computed from+-- those before it. 'Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> G.constructN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [0,10,20,30]+--+-- >>> G.constructN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (G.constructN n V.sum :: Maybe (V.Vector Int)) === bool Nothing (Just (P.replicate n 0)) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructN :: (Vector v a) => Int -> (v a -> a) -> Maybe (v a)+constructN n f =+  DVG.constructN n f <$ guard (0 <= n)+{-# INLINE constructN #-}++-- | Total @constructrN@: a vector of a length, each element computed from+-- those after it. 'Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> G.constructrN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [30,20,10,0]+--+-- >>> G.constructrN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (G.constructrN n V.length :: Maybe (V.Vector Int)) === fmap (\w -> P.reverse (V.toList w)) (G.constructN n V.length :: Maybe (V.Vector Int))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructrN :: (Vector v a) => Int -> (v a -> a) -> Maybe (v a)+constructrN n f =+  DVG.constructrN n f <$ guard (0 <= n)+{-# INLINE constructrN #-}++-- | Total @(//)@: a vector with the elements at the indices of a list of+-- updates replaced, in one copy. 'Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.fromList "abc" G.// [(0, 'x'), (2, 'z')]+-- Just "xbz"+--+-- >>> V.fromList "abc" G.// [(3, 'x')]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; (v G.// us) === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i .~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+(//) :: (Vector v a) => v a -> [(Int, a)] -> Maybe (v a)+v // us =+  DVG.unsafeUpd v us <$ guard (F.all (inRange v . fst) us)+{-# INLINE (//) #-}++infixl 9 //++-- | Total @update@: '//' with the updates in a vector. 'Nothing' if an index+-- is out of range.+--+-- ==== __Examples__+--+-- >>> G.update (V.fromList "abc") (V.fromList [(1, 'x')])+-- Just "axc"+--+-- >>> G.update (V.fromList "abc") (V.fromList [(-1, 'x')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; G.update v (V.fromList us) === (v G.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> Maybe (v a)+update v us =+  DVG.unsafeUpdate v us <$ guard (DVG.all (inRange v . fst) us)+{-# INLINE update #-}++-- | Total @update_@: 'update' with the indices and the values in two+-- vectors, paired up to the shorter. 'Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> G.update_ (V.fromList "abc") (V.fromList [2, 0]) (V.fromList "xy")+-- Just "ybx"+--+-- >>> G.update_ (V.fromList "abc") (V.fromList [2, 9]) (V.fromList "x")+-- Just "abx"+--+-- >>> G.update_ (V.fromList "abc") (V.fromList [9]) (V.fromList "x")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; G.update_ v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === (v G.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> Maybe (v a)+update_ v is w =+  DVG.unsafeUpdate_ v is w <$ guard (DVG.all (inRange v) (DVG.take (DVG.length w) is))+{-# INLINE update_ #-}++-- | Total @accum@: a vector with each element at the indices of a list of+-- updates combined with the update, in one copy. 'Nothing' if an index is+-- out of range.+--+-- ==== __Examples__+--+-- >>> G.accum (+) (V.fromList [10, 20, 30 :: Int]) [(0, 1), (2, 3), (0, 4)]+-- Just [15,20,33]+--+-- >>> G.accum (+) (V.fromList [10, 20, 30 :: Int]) [(3, 1)]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; G.accum (+) v us === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i +~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accum :: (Vector v a) => (a -> b -> a) -> v a -> [(Int, b)] -> Maybe (v a)+accum f =+  \v us -> DVG.unsafeAccum f v us <$ guard (F.all (inRange v . fst) us)+{-# INLINE accum #-}++-- | Total @accumulate@: 'accum' with the updates in a vector. 'Nothing' if+-- an index is out of range.+--+-- ==== __Examples__+--+-- >>> G.accumulate (+) (V.fromList [10, 20 :: Int]) (V.fromList [(1, 5)])+-- Just [10,25]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; G.accumulate (+) v (V.fromList us) === G.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> Maybe (v a)+accumulate f =+  \v us -> DVG.unsafeAccumulate f v us <$ guard (DVG.all (inRange v . fst) us)+{-# INLINE accumulate #-}++-- | Total @accumulate_@: 'accumulate' with the indices and the values in two+-- vectors, paired up to the shorter. 'Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> G.accumulate_ (+) (V.fromList [10, 20 :: Int]) (V.fromList [1, 1]) (V.fromList [5, 6])+-- Just [10,31]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; G.accumulate_ (+) v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === G.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> Maybe (v a)+accumulate_ f =+  \v is w -> DVG.unsafeAccumulate_ f v is w <$ guard (DVG.all (inRange v) (DVG.take (DVG.length w) is))+{-# INLINE accumulate_ #-}++-- | Total @backpermute@: the elements at the indices of a vector of indices.+-- 'Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> G.backpermute (V.fromList "abcd") (V.fromList [3, 0, 3])+-- Just "dad"+--+-- >>> G.backpermute (V.fromList "abcd") (V.fromList [4])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; is <- forAll (Gen.list (Range.linear 0 5) genIndex); fmap V.toList (G.backpermute v (V.fromList is)) === traverse (v V.!?) is+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+backpermute :: (Vector v a, Vector v Int) => v a -> v Int -> Maybe (v a)+backpermute v is =+  DVG.unsafeBackpermute v is <$ guard (DVG.all (inRange v) is)+{-# INLINE backpermute #-}++-- | Total @foldl1@: a left fold with no starting value. 'Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> G.foldl1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> G.foldl1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.foldl1 (-) v === fmap (\(a, as) -> P.foldl (-) a as) (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Vector v a) => (a -> a -> a) -> v a -> Maybe a+foldl1 f =+  \v -> DVG.foldl1 f v <$ guard (nonEmpty v)+{-# INLINE foldl1 #-}++-- | Total @foldl1'@: 'foldl1', strict in the accumulator. 'Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> G.foldl1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.foldl1' (-) v === G.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Vector v a) => (a -> a -> a) -> v a -> Maybe a+foldl1' f =+  \v -> bool Nothing (Just $! DVG.foldl1' f v) (nonEmpty v)+{-# INLINE foldl1' #-}++-- | Total @foldr1@: a right fold with no starting value. 'Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> G.foldr1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> G.foldr1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.foldr1 (-) v === fmap (\(as, a) -> P.foldr (-) a as) (P.unsnoc (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Vector v a) => (a -> a -> a) -> v a -> Maybe a+foldr1 f =+  \v -> DVG.foldr1 f v <$ guard (nonEmpty v)+{-# INLINE foldr1 #-}++-- | Total @foldr1'@: 'foldr1', strict in the accumulator. 'Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> G.foldr1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.foldr1' (-) v === G.foldr1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Vector v a) => (a -> a -> a) -> v a -> Maybe a+foldr1' f =+  \v -> bool Nothing (Just $! DVG.foldr1' f v) (nonEmpty v)+{-# INLINE foldr1' #-}++-- | Total @maximum@: the greatest element. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.maximum (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> G.maximum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.maximum v === maximumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: (Vector v a, Ord a) => v a -> Maybe a+maximum v =+  bool Nothing (Just $! DVG.maximum v) (nonEmpty v)+{-# INLINE maximum #-}++-- | Total @maximumBy@: the greatest element by a comparison; the first of+-- equals. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.maximumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.maximumBy compare v === G.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumBy :: (Vector v a) => (a -> a -> Ordering) -> v a -> Maybe a+maximumBy f =+  \v -> bool Nothing (Just $! DVG.maximumBy f v) (nonEmpty v)+{-# INLINE maximumBy #-}++-- | Total @maximumOn@: the element with the greatest image under a+-- function; the first of equals. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.maximumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.maximumOn id v === G.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumOn :: (Ord b, Vector v a) => (a -> b) -> v a -> Maybe a+maximumOn f =+  \v -> bool Nothing (Just $! DVG.maximumOn f v) (nonEmpty v)+{-# INLINE maximumOn #-}++-- | Total @minimum@: the least element. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.minimum (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> G.minimum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.minimum v === minimumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: (Vector v a, Ord a) => v a -> Maybe a+minimum v =+  bool Nothing (Just $! DVG.minimum v) (nonEmpty v)+{-# INLINE minimum #-}++-- | Total @minimumBy@: the least element by a comparison; the first of+-- equals. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.minimumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.minimumBy compare v === G.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumBy :: (Vector v a) => (a -> a -> Ordering) -> v a -> Maybe a+minimumBy f =+  \v -> bool Nothing (Just $! DVG.minimumBy f v) (nonEmpty v)+{-# INLINE minimumBy #-}++-- | Total @minimumOn@: the element with the least image under a function;+-- the first of equals. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.minimumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.minimumOn id v === G.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumOn :: (Ord b, Vector v a) => (a -> b) -> v a -> Maybe a+minimumOn f =+  \v -> bool Nothing (Just $! DVG.minimumOn f v) (nonEmpty v)+{-# INLINE minimumOn #-}++-- | Total @maxIndex@: the index of the greatest element; the first of+-- equals. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.maxIndex (V.fromList [3, 4, 1, 4 :: Int])+-- Just 1+--+-- >>> G.maxIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (G.maxIndex v >>= (v V.!?)) === G.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndex :: (Vector v a, Ord a) => v a -> Maybe Int+maxIndex v =+  bool Nothing (Just $! DVG.maxIndex v) (nonEmpty v)+{-# INLINE maxIndex #-}++-- | Total @maxIndexBy@: the index of the greatest element by a comparison.+-- 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.maxIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.maxIndexBy compare v === G.maxIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndexBy :: (Vector v a) => (a -> a -> Ordering) -> v a -> Maybe Int+maxIndexBy f =+  \v -> bool Nothing (Just $! DVG.maxIndexBy f v) (nonEmpty v)+{-# INLINE maxIndexBy #-}++-- | Total @minIndex@: the index of the least element; the first of equals.+-- 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.minIndex (V.fromList [3, 1, 4, 1 :: Int])+-- Just 1+--+-- >>> G.minIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (G.minIndex v >>= (v V.!?)) === G.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndex :: (Vector v a, Ord a) => v a -> Maybe Int+minIndex v =+  bool Nothing (Just $! DVG.minIndex v) (nonEmpty v)+{-# INLINE minIndex #-}++-- | Total @minIndexBy@: the index of the least element by a comparison.+-- 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.minIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 2+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; G.minIndexBy compare v === G.minIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndexBy :: (Vector v a) => (a -> a -> Ordering) -> v a -> Maybe Int+minIndexBy f =+  \v -> bool Nothing (Just $! DVG.minIndexBy f v) (nonEmpty v)+{-# INLINE minIndexBy #-}++-- | Total @fold1M@: a monadic left fold with no starting value. 'Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.fold1M (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> G.fold1M (\a b -> Identity (a - b)) (V.empty :: V.Vector Int)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (G.fold1M (\a b -> Identity (a - b)) v) === G.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe a)+fold1M f =+  \v -> bool (pure Nothing) (Just <$> DVG.fold1M f v) (nonEmpty v)+{-# INLINE fold1M #-}++-- | Total @fold1M'@: 'fold1M', strict in the accumulator. 'Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> G.fold1M' (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (G.fold1M' (\a b -> Identity (a - b)) v) === G.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M' :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe a)+fold1M' f =+  \v -> bool (pure Nothing) (Just <$> DVG.fold1M' f v) (nonEmpty v)+{-# INLINE fold1M' #-}++-- | Total @fold1M_@: 'fold1M' for its effects. 'Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> G.fold1M_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> G.fold1M_ (\a b -> [a + b]) (V.empty :: V.Vector Int)+-- [Nothing]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (G.fold1M_ (\a b -> Identity (a - b)) v) === (() <$ G.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe ())+fold1M_ f =+  \v -> bool (pure Nothing) (Just <$> DVG.fold1M_ f v) (nonEmpty v)+{-# INLINE fold1M_ #-}++-- | Total @fold1M'_@: 'fold1M'' for its effects. 'Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> G.fold1M'_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (G.fold1M'_ (\a b -> Identity (a - b)) v) === (() <$ G.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M'_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m (Maybe ())+fold1M'_ f =+  \v -> bool (pure Nothing) (Just <$> DVG.fold1M'_ f v) (nonEmpty v)+{-# INLINE fold1M'_ #-}++-- | Total @copy@: copy an immutable vector into a mutable one of the same+-- length. 'Nothing', and no copy, for vectors of different lengths.+--+-- ==== __Examples__+--+-- >>> runST (do m <- MV.replicate 2 'x'; r <- G.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Just (),"ab")+--+-- >>> runST (do m <- MV.replicate 3 'x'; r <- G.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Nothing,"xxx")+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; n <- forAll genIndex; runST (do m <- MV.replicate (max 0 n) 0; r <- G.copy m v; fmap ((,) r) (V.freeze m)) === bool (Nothing, V.replicate n 0) (Just (), v) (max 0 n == V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+copy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m (Maybe ())+copy dst =+  \src -> bool (pure Nothing) (Just <$> DVG.unsafeCopy dst src) (DVGM.length dst == DVG.length src)+{-# INLINE copy #-}
+ src/Papa/Vector/Data/Vector/Storable.hs view
@@ -0,0 +1,851 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total versions of head, last, init, tail,+-- maximum and minimum, whose names HLint restricts whatever module they come+-- from.++{- HLINT ignore "Eta reduce" -}+-- Reason: each function takes, on the left of its definition, the arguments+-- before its vector (none for most): GHC inlines a function only once it is+-- applied to those, so @foldl1' (+)@, passed to a higher-order function,+-- is inlined and runs at the speed of vector's. A function with no such+-- arguments applies its generic version to all its arguments, so that the+-- generic one is specialised to this vector type in the compiled function+-- too.++-- | Storable vectors, with total versions of the partial functions of+-- "Data.Vector.Storable". Import qualified:+--+-- > import qualified Papa.Vector.Data.Vector.Storable as V+--+-- The functions of "Data.Vector.Storable" that throw (for an index out of range, an+-- empty vector, a negative length, or vectors of different lengths) are+-- replaced by functions of the same names that return+-- 'Data.Maybe.Nothing' there instead, in the same time and with one copy of+-- the vector, as the originals. They are those of+-- "Papa.Vector.Data.Vector.Generic", at this vector type.+--+-- Read and set elements with the traversal @'Control.Lens.ix' i@ of lens's+-- 'Control.Lens.Ixed' instance (@v ^? ix i@, @v & ix i .~ a@), or read with+-- '!?'. Setting an element with 'Control.Lens.ix' copies the vector: set many+-- at once with '//'. lens's instances for this vector type: Ixed, AsEmpty, Reversing.+--+-- Not exported:+--+-- * @(!)@, which throws for an index out of range: use '!?' or+--   'Control.Lens.ix';+-- * the functions without bounds checks (@unsafeIndex@, @unsafeSlice@,+--   @unsafeUpd@, …), which read or write outside the vector for a bad+--   index, and @unsafeFreeze@, @unsafeThaw@, which let a mutable vector+--   change an immutable one;+-- * @unsafeCast@ and @unsafeCoerceVector@, which reinterpret the memory of a+--   vector at another type, and @unsafeFromForeignPtr@,+--   @unsafeFromForeignPtr0@, @unsafeToForeignPtr@, @unsafeToForeignPtr0@ and+--   @unsafeWith@, which share the memory of a vector with a pointer that may+--   write to it or outlive it.+--+-- The mutable vectors (@MVector@) are exported as a type; their functions+-- (in "Data.Vector.Storable.Mutable") are not wrapped.+module Papa.Vector.Data.Vector.Storable (+  module X,+  head,+  last,+  indexM,+  headM,+  lastM,+  slice,+  init,+  tail,+  constructN,+  constructrN,+  (//),+  update_,+  accum,+  accumulate_,+  backpermute,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  maximumBy,+  maximumOn,+  minimum,+  minimumBy,+  minimumOn,+  maxIndex,+  maxIndexBy,+  minIndex,+  minIndexBy,+  fold1M,+  fold1M',+  fold1M_,+  fold1M'_,+  copy,+) where++import Control.Monad (Monad)+import Control.Monad.Primitive (PrimMonad, PrimState)+import Data.Int (Int)+import Data.Maybe (Maybe)+import Data.Ord (Ord, Ordering)+import Data.Vector.Storable as X hiding (+  accum,+  accumulate_,+  backpermute,+  constructN,+  constructrN,+  copy,+  fold1M,+  fold1M',+  fold1M'_,+  fold1M_,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  head,+  headM,+  indexM,+  init,+  last,+  lastM,+  maxIndex,+  maxIndexBy,+  maximum,+  maximumBy,+  maximumOn,+  minIndex,+  minIndexBy,+  minimum,+  minimumBy,+  minimumOn,+  slice,+  tail,+  unsafeAccum,+  unsafeAccumulate_,+  unsafeBackpermute,+  unsafeCast,+  unsafeCoerceVector,+  unsafeCopy,+  unsafeDrop,+  unsafeFreeze,+  unsafeFromForeignPtr,+  unsafeFromForeignPtr0,+  unsafeHead,+  unsafeHeadM,+  unsafeIndex,+  unsafeIndexM,+  unsafeInit,+  unsafeLast,+  unsafeLastM,+  unsafeSlice,+  unsafeTail,+  unsafeTake,+  unsafeThaw,+  unsafeToForeignPtr,+  unsafeToForeignPtr0,+  unsafeUpd,+  unsafeUpdate_,+  unsafeWith,+  update_,+  (!),+  (//),+ )+import qualified Papa.Vector.Data.Vector.Generic as G++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Vector.Data.Vector.Storable as V+-- >>> import qualified Data.Vector.Storable.Mutable as MV+-- >>> import Control.Monad.ST (runST)+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)+-- >>> let genIndex = Gen.int (Range.linear (-3) 12)+-- >>> let genVector = V.fromList <$> Gen.list (Range.linear 0 10) genInt+-- >>> let genUpdates = Gen.list (Range.linear 0 5) ((,) <$> genIndex <*> genInt)++-- | Total @head@: the first element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.head (V.fromList "abc")+-- Just 'a'+--+-- >>> V.head (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.head v === listToMaybe (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: (Storable a) => Vector a -> Maybe a+head v =+  G.head v+{-# INLINE head #-}++-- | Total @last@: the last element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.last (V.fromList "abc")+-- Just 'c'+--+-- >>> V.last (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.last v === listToMaybe (P.reverse (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: (Storable a) => Vector a -> Maybe a+last v =+  G.last v+{-# INLINE last #-}++-- | Total @indexM@: the element at an index, read in a monad (so that the+-- vector is not retained by an unevaluated read). 'Data.Maybe.Nothing' for an index out+-- of range.+--+-- ==== __Examples__+--+-- >>> V.indexM (V.fromList "abc") 1 :: Identity (Maybe Char)+-- Identity (Just 'b')+--+-- >>> V.indexM (V.fromList "abc") 3 :: Identity (Maybe Char)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; runIdentity (V.indexM v i) === (v V.!? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+indexM :: (Storable a, Monad m) => Vector a -> Int -> m (Maybe a)+indexM v i =+  G.indexM v i+{-# INLINE indexM #-}++-- | Total @headM@: the first element, read in a monad. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.headM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'a')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.headM v) === V.head v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+headM :: (Storable a, Monad m) => Vector a -> m (Maybe a)+headM v =+  G.headM v+{-# INLINE headM #-}++-- | Total @lastM@: the last element, read in a monad. 'Data.Maybe.Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> V.lastM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'c')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.lastM v) === V.last v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+lastM :: (Storable a, Monad m) => Vector a -> m (Maybe a)+lastM v =+  G.lastM v+{-# INLINE lastM #-}++-- | Total @slice@: the slice of a length from an index, in constant time.+-- 'Data.Maybe.Nothing' unless the slice is within the vector.+--+-- ==== __Examples__+--+-- >>> V.slice 1 2 (V.fromList "abcd")+-- Just "bc"+--+-- >>> V.slice 3 2 (V.fromList "abcd")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; n <- forAll genIndex; fmap V.toList (V.slice i n v) === bool Nothing (Just (P.take n (P.drop i (V.toList v)))) (i >= 0 && n >= 0 && i + n <= V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+slice :: (Storable a) => Int -> Int -> Vector a -> Maybe (Vector a)+slice i n =+  G.slice i n+{-# INLINE slice #-}++-- | Total @init@: every element but the last, in constant time. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.init (V.fromList "abc")+-- Just "ab"+--+-- >>> V.init (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (V.init v) === bool Nothing (Just (P.take (V.length v - 1) (V.toList v))) (not (V.null v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: (Storable a) => Vector a -> Maybe (Vector a)+init v =+  G.init v+{-# INLINE init #-}++-- | Total @tail@: every element but the first, in constant time. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.tail (V.fromList "abc")+-- Just "bc"+--+-- >>> V.tail (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (V.tail v) === fmap snd (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: (Storable a) => Vector a -> Maybe (Vector a)+tail v =+  G.tail v+{-# INLINE tail #-}++-- | Total @constructN@: a vector of a length, each element computed from+-- those before it. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> V.constructN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [0,10,20,30]+--+-- >>> V.constructN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (V.constructN n V.sum :: Maybe (V.Vector Int)) === bool Nothing (Just (P.replicate n 0)) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructN :: (Storable a) => Int -> (Vector a -> a) -> Maybe (Vector a)+constructN i f =+  G.constructN i f+{-# INLINE constructN #-}++-- | Total @constructrN@: a vector of a length, each element computed from+-- those after it. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> V.constructrN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [30,20,10,0]+--+-- >>> V.constructrN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (V.constructrN n V.length :: Maybe (V.Vector Int)) === fmap (\w -> P.reverse (V.toList w)) (V.constructN n V.length :: Maybe (V.Vector Int))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructrN :: (Storable a) => Int -> (Vector a -> a) -> Maybe (Vector a)+constructrN i f =+  G.constructrN i f+{-# INLINE constructrN #-}++-- | Total @(//)@: a vector with the elements at the indices of a list of+-- updates replaced, in one copy. 'Data.Maybe.Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.fromList "abc" V.// [(0, 'x'), (2, 'z')]+-- Just "xbz"+--+-- >>> V.fromList "abc" V.// [(3, 'x')]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; (v V.// us) === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i .~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+(//) :: (Storable a) => Vector a -> [(Int, a)] -> Maybe (Vector a)+(//) v us =+  (G.//) v us+{-# INLINE (//) #-}++infixl 9 //++-- | Total @update_@: @update@ with the indices and the values in two+-- vectors, paired up to the shorter. 'Data.Maybe.Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [2, 0]) (V.fromList "xy")+-- Just "ybx"+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [2, 9]) (V.fromList "x")+-- Just "abx"+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [9]) (V.fromList "x")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.update_ v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === (v V.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update_ :: (Storable a) => Vector a -> Vector Int -> Vector a -> Maybe (Vector a)+update_ v w xs =+  G.update_ v w xs+{-# INLINE update_ #-}++-- | Total @accum@: a vector with each element at the indices of a list of+-- updates combined with the update, in one copy. 'Data.Maybe.Nothing' if an index is+-- out of range.+--+-- ==== __Examples__+--+-- >>> V.accum (+) (V.fromList [10, 20, 30 :: Int]) [(0, 1), (2, 3), (0, 4)]+-- Just [15,20,33]+--+-- >>> V.accum (+) (V.fromList [10, 20, 30 :: Int]) [(3, 1)]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accum (+) v us === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i +~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accum :: (Storable a) => (a -> b -> a) -> Vector a -> [(Int, b)] -> Maybe (Vector a)+accum f =+  G.accum f+{-# INLINE accum #-}++-- | Total @accumulate_@: @accumulate@ with the indices and the values in two+-- vectors, paired up to the shorter. 'Data.Maybe.Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> V.accumulate_ (+) (V.fromList [10, 20 :: Int]) (V.fromList [1, 1]) (V.fromList [5, 6])+-- Just [10,31]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accumulate_ (+) v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === V.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate_ :: (Storable a, Storable b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Maybe (Vector a)+accumulate_ f =+  G.accumulate_ f+{-# INLINE accumulate_ #-}++-- | Total @backpermute@: the elements at the indices of a vector of indices.+-- 'Data.Maybe.Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.backpermute (V.fromList "abcd") (V.fromList [3, 0, 3])+-- Just "dad"+--+-- >>> V.backpermute (V.fromList "abcd") (V.fromList [4])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; is <- forAll (Gen.list (Range.linear 0 5) genIndex); fmap V.toList (V.backpermute v (V.fromList is)) === traverse (v V.!?) is+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+backpermute :: (Storable a) => Vector a -> Vector Int -> Maybe (Vector a)+backpermute v w =+  G.backpermute v w+{-# INLINE backpermute #-}++-- | Total @foldl1@: a left fold with no starting value. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldl1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> V.foldl1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldl1 (-) v === fmap (\(a, as) -> P.foldl (-) a as) (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Storable a) => (a -> a -> a) -> Vector a -> Maybe a+foldl1 f =+  G.foldl1 f+{-# INLINE foldl1 #-}++-- | Total @foldl1'@: 'foldl1', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldl1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldl1' (-) v === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Storable a) => (a -> a -> a) -> Vector a -> Maybe a+foldl1' f =+  G.foldl1' f+{-# INLINE foldl1' #-}++-- | Total @foldr1@: a right fold with no starting value. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldr1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> V.foldr1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldr1 (-) v === fmap (\(as, a) -> P.foldr (-) a as) (P.unsnoc (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Storable a) => (a -> a -> a) -> Vector a -> Maybe a+foldr1 f =+  G.foldr1 f+{-# INLINE foldr1 #-}++-- | Total @foldr1'@: 'foldr1', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldr1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldr1' (-) v === V.foldr1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Storable a) => (a -> a -> a) -> Vector a -> Maybe a+foldr1' f =+  G.foldr1' f+{-# INLINE foldr1' #-}++-- | Total @maximum@: the greatest element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximum (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> V.maximum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximum v === maximumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: (Storable a, Ord a) => Vector a -> Maybe a+maximum v =+  G.maximum v+{-# INLINE maximum #-}++-- | Total @maximumBy@: the greatest element by a comparison; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximumBy compare v === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumBy :: (Storable a) => (a -> a -> Ordering) -> Vector a -> Maybe a+maximumBy f =+  G.maximumBy f+{-# INLINE maximumBy #-}++-- | Total @maximumOn@: the element with the greatest image under a+-- function; the first of equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximumOn id v === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumOn :: (Ord b, Storable a) => (a -> b) -> Vector a -> Maybe a+maximumOn f =+  G.maximumOn f+{-# INLINE maximumOn #-}++-- | Total @minimum@: the least element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimum (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> V.minimum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimum v === minimumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: (Storable a, Ord a) => Vector a -> Maybe a+minimum v =+  G.minimum v+{-# INLINE minimum #-}++-- | Total @minimumBy@: the least element by a comparison; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimumBy compare v === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumBy :: (Storable a) => (a -> a -> Ordering) -> Vector a -> Maybe a+minimumBy f =+  G.minimumBy f+{-# INLINE minimumBy #-}++-- | Total @minimumOn@: the element with the least image under a function;+-- the first of equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimumOn id v === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumOn :: (Ord b, Storable a) => (a -> b) -> Vector a -> Maybe a+minimumOn f =+  G.minimumOn f+{-# INLINE minimumOn #-}++-- | Total @maxIndex@: the index of the greatest element; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maxIndex (V.fromList [3, 4, 1, 4 :: Int])+-- Just 1+--+-- >>> V.maxIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (V.maxIndex v >>= (v V.!?)) === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndex :: (Storable a, Ord a) => Vector a -> Maybe Int+maxIndex v =+  G.maxIndex v+{-# INLINE maxIndex #-}++-- | Total @maxIndexBy@: the index of the greatest element by a comparison.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maxIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maxIndexBy compare v === V.maxIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndexBy :: (Storable a) => (a -> a -> Ordering) -> Vector a -> Maybe Int+maxIndexBy f =+  G.maxIndexBy f+{-# INLINE maxIndexBy #-}++-- | Total @minIndex@: the index of the least element; the first of equals.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minIndex (V.fromList [3, 1, 4, 1 :: Int])+-- Just 1+--+-- >>> V.minIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (V.minIndex v >>= (v V.!?)) === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndex :: (Storable a, Ord a) => Vector a -> Maybe Int+minIndex v =+  G.minIndex v+{-# INLINE minIndex #-}++-- | Total @minIndexBy@: the index of the least element by a comparison.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 2+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minIndexBy compare v === V.minIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndexBy :: (Storable a) => (a -> a -> Ordering) -> Vector a -> Maybe Int+minIndexBy f =+  G.minIndexBy f+{-# INLINE minIndexBy #-}++-- | Total @fold1M@: a monadic left fold with no starting value. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> V.fold1M (\a b -> Identity (a - b)) (V.empty :: V.Vector Int)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M (\a b -> Identity (a - b)) v) === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe a)+fold1M f =+  G.fold1M f+{-# INLINE fold1M #-}++-- | Total @fold1M'@: 'fold1M', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M' (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M' (\a b -> Identity (a - b)) v) === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M' :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe a)+fold1M' f =+  G.fold1M' f+{-# INLINE fold1M' #-}++-- | Total @fold1M_@: 'fold1M' for its effects. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> V.fold1M_ (\a b -> [a + b]) (V.empty :: V.Vector Int)+-- [Nothing]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M_ (\a b -> Identity (a - b)) v) === (() <$ V.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe ())+fold1M_ f =+  G.fold1M_ f+{-# INLINE fold1M_ #-}++-- | Total @fold1M'_@: 'fold1M'' for its effects. 'Data.Maybe.Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M'_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M'_ (\a b -> Identity (a - b)) v) === (() <$ V.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M'_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m (Maybe ())+fold1M'_ f =+  G.fold1M'_ f+{-# INLINE fold1M'_ #-}++-- | Total @copy@: copy an immutable vector into a mutable one of the same+-- length. 'Data.Maybe.Nothing', and no copy, for vectors of different lengths.+--+-- ==== __Examples__+--+-- >>> runST (do m <- MV.replicate 2 'x'; r <- V.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Just (),"ab")+--+-- >>> runST (do m <- MV.replicate 3 'x'; r <- V.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Nothing,"xxx")+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; n <- forAll genIndex; runST (do m <- MV.replicate (max 0 n) 0; r <- V.copy m v; fmap ((,) r) (V.freeze m)) === bool (Nothing, V.replicate n 0) (Just (), v) (max 0 n == V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+copy :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Vector a -> m (Maybe ())+copy dst =+  G.copy dst+{-# INLINE copy #-}
+ src/Papa/Vector/Data/Vector/Unboxed.hs view
@@ -0,0 +1,884 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: this module defines total versions of head, last, init, tail,+-- maximum and minimum, whose names HLint restricts whatever module they come+-- from.++{- HLINT ignore "Eta reduce" -}+-- Reason: each function takes, on the left of its definition, the arguments+-- before its vector (none for most): GHC inlines a function only once it is+-- applied to those, so @foldl1' (+)@, passed to a higher-order function,+-- is inlined and runs at the speed of vector's. A function with no such+-- arguments applies its generic version to all its arguments, so that the+-- generic one is specialised to this vector type in the compiled function+-- too.++-- | Unboxed vectors, with total versions of the partial functions of+-- "Data.Vector.Unboxed". Import qualified:+--+-- > import qualified Papa.Vector.Data.Vector.Unboxed as V+--+-- The functions of "Data.Vector.Unboxed" that throw (for an index out of range, an+-- empty vector, a negative length, or vectors of different lengths) are+-- replaced by functions of the same names that return+-- 'Data.Maybe.Nothing' there instead, in the same time and with one copy of+-- the vector, as the originals. They are those of+-- "Papa.Vector.Data.Vector.Generic", at this vector type.+--+-- Read and set elements with the traversal @'Control.Lens.ix' i@ of lens's+-- 'Control.Lens.Ixed' instance (@v ^? ix i@, @v & ix i .~ a@), or read with+-- '!?'. Setting an element with 'Control.Lens.ix' copies the vector: set many+-- at once with '//'. lens's instances for this vector type: Ixed, AsEmpty, Reversing.+--+-- Not exported:+--+-- * @(!)@, which throws for an index out of range: use '!?' or+--   'Control.Lens.ix';+-- * the functions without bounds checks (@unsafeIndex@, @unsafeSlice@,+--   @unsafeUpd@, …), which read or write outside the vector for a bad+--   index, and @unsafeFreeze@, @unsafeThaw@, which let a mutable vector+--   change an immutable one.+--+-- The mutable vectors (@MVector@) are exported as a type; their functions+-- (in "Data.Vector.Unboxed.Mutable") are not wrapped.+module Papa.Vector.Data.Vector.Unboxed (+  module X,+  head,+  last,+  indexM,+  headM,+  lastM,+  slice,+  init,+  tail,+  constructN,+  constructrN,+  (//),+  update,+  update_,+  accum,+  accumulate,+  accumulate_,+  backpermute,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  maximum,+  maximumBy,+  maximumOn,+  minimum,+  minimumBy,+  minimumOn,+  maxIndex,+  maxIndexBy,+  minIndex,+  minIndexBy,+  fold1M,+  fold1M',+  fold1M_,+  fold1M'_,+  copy,+) where++import Control.Monad (Monad)+import Control.Monad.Primitive (PrimMonad, PrimState)+import Data.Int (Int)+import Data.Maybe (Maybe)+import Data.Ord (Ord, Ordering)+import Data.Vector.Unboxed as X hiding (+  accum,+  accumulate,+  accumulate_,+  backpermute,+  constructN,+  constructrN,+  copy,+  fold1M,+  fold1M',+  fold1M'_,+  fold1M_,+  foldl1,+  foldl1',+  foldr1,+  foldr1',+  head,+  headM,+  indexM,+  init,+  last,+  lastM,+  maxIndex,+  maxIndexBy,+  maximum,+  maximumBy,+  maximumOn,+  minIndex,+  minIndexBy,+  minimum,+  minimumBy,+  minimumOn,+  slice,+  tail,+  unsafeAccum,+  unsafeAccumulate,+  unsafeAccumulate_,+  unsafeBackpermute,+  unsafeCopy,+  unsafeDrop,+  unsafeFreeze,+  unsafeHead,+  unsafeHeadM,+  unsafeIndex,+  unsafeIndexM,+  unsafeInit,+  unsafeLast,+  unsafeLastM,+  unsafeSlice,+  unsafeTail,+  unsafeTake,+  unsafeThaw,+  unsafeUpd,+  unsafeUpdate,+  unsafeUpdate_,+  update,+  update_,+  (!),+  (//),+ )+import qualified Papa.Vector.Data.Vector.Generic as G++-- $setup+-- >>> :set -XNoImplicitPrelude+-- >>> import Papa+-- >>> import qualified Papa as P+-- >>> import qualified Papa.Vector.Data.Vector.Unboxed as V+-- >>> import qualified Data.Vector.Unboxed.Mutable as MV+-- >>> import Control.Monad.ST (runST)+-- >>> import Hedgehog+-- >>> import qualified Hedgehog.Gen as Gen+-- >>> import qualified Hedgehog.Range as Range+-- >>> let genInt = Gen.int (Range.linear (-100) 100)+-- >>> let genIndex = Gen.int (Range.linear (-3) 12)+-- >>> let genVector = V.fromList <$> Gen.list (Range.linear 0 10) genInt+-- >>> let genUpdates = Gen.list (Range.linear 0 5) ((,) <$> genIndex <*> genInt)++-- | Total @head@: the first element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.head (V.fromList "abc")+-- Just 'a'+--+-- >>> V.head (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.head v === listToMaybe (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+head :: (Unbox a) => Vector a -> Maybe a+head v =+  G.head v+{-# INLINE head #-}++-- | Total @last@: the last element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.last (V.fromList "abc")+-- Just 'c'+--+-- >>> V.last (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.last v === listToMaybe (P.reverse (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+last :: (Unbox a) => Vector a -> Maybe a+last v =+  G.last v+{-# INLINE last #-}++-- | Total @indexM@: the element at an index, read in a monad (so that the+-- vector is not retained by an unevaluated read). 'Data.Maybe.Nothing' for an index out+-- of range.+--+-- ==== __Examples__+--+-- >>> V.indexM (V.fromList "abc") 1 :: Identity (Maybe Char)+-- Identity (Just 'b')+--+-- >>> V.indexM (V.fromList "abc") 3 :: Identity (Maybe Char)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; runIdentity (V.indexM v i) === (v V.!? i)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+indexM :: (Unbox a, Monad m) => Vector a -> Int -> m (Maybe a)+indexM v i =+  G.indexM v i+{-# INLINE indexM #-}++-- | Total @headM@: the first element, read in a monad. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.headM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'a')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.headM v) === V.head v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+headM :: (Unbox a, Monad m) => Vector a -> m (Maybe a)+headM v =+  G.headM v+{-# INLINE headM #-}++-- | Total @lastM@: the last element, read in a monad. 'Data.Maybe.Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> V.lastM (V.fromList "abc") :: Identity (Maybe Char)+-- Identity (Just 'c')+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.lastM v) === V.last v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+lastM :: (Unbox a, Monad m) => Vector a -> m (Maybe a)+lastM v =+  G.lastM v+{-# INLINE lastM #-}++-- | Total @slice@: the slice of a length from an index, in constant time.+-- 'Data.Maybe.Nothing' unless the slice is within the vector.+--+-- ==== __Examples__+--+-- >>> V.slice 1 2 (V.fromList "abcd")+-- Just "bc"+--+-- >>> V.slice 3 2 (V.fromList "abcd")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; i <- forAll genIndex; n <- forAll genIndex; fmap V.toList (V.slice i n v) === bool Nothing (Just (P.take n (P.drop i (V.toList v)))) (i >= 0 && n >= 0 && i + n <= V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+slice :: (Unbox a) => Int -> Int -> Vector a -> Maybe (Vector a)+slice i n =+  G.slice i n+{-# INLINE slice #-}++-- | Total @init@: every element but the last, in constant time. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.init (V.fromList "abc")+-- Just "ab"+--+-- >>> V.init (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (V.init v) === bool Nothing (Just (P.take (V.length v - 1) (V.toList v))) (not (V.null v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+init :: (Unbox a) => Vector a -> Maybe (Vector a)+init v =+  G.init v+{-# INLINE init #-}++-- | Total @tail@: every element but the first, in constant time. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.tail (V.fromList "abc")+-- Just "bc"+--+-- >>> V.tail (V.empty :: V.Vector Char)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; fmap V.toList (V.tail v) === fmap snd (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+tail :: (Unbox a) => Vector a -> Maybe (Vector a)+tail v =+  G.tail v+{-# INLINE tail #-}++-- | Total @constructN@: a vector of a length, each element computed from+-- those before it. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> V.constructN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [0,10,20,30]+--+-- >>> V.constructN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (V.constructN n V.sum :: Maybe (V.Vector Int)) === bool Nothing (Just (P.replicate n 0)) (n >= 0)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructN :: (Unbox a) => Int -> (Vector a -> a) -> Maybe (Vector a)+constructN i f =+  G.constructN i f+{-# INLINE constructN #-}++-- | Total @constructrN@: a vector of a length, each element computed from+-- those after it. 'Data.Maybe.Nothing' for a negative length.+--+-- ==== __Examples__+--+-- >>> V.constructrN 4 (\v -> V.length v * 10) :: Maybe (V.Vector Int)+-- Just [30,20,10,0]+--+-- >>> V.constructrN (-1) V.length :: Maybe (V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do n <- forAll genIndex; fmap V.toList (V.constructrN n V.length :: Maybe (V.Vector Int)) === fmap (\w -> P.reverse (V.toList w)) (V.constructN n V.length :: Maybe (V.Vector Int))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+constructrN :: (Unbox a) => Int -> (Vector a -> a) -> Maybe (Vector a)+constructrN i f =+  G.constructrN i f+{-# INLINE constructrN #-}++-- | Total @(//)@: a vector with the elements at the indices of a list of+-- updates replaced, in one copy. 'Data.Maybe.Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.fromList "abc" V.// [(0, 'x'), (2, 'z')]+-- Just "xbz"+--+-- >>> V.fromList "abc" V.// [(3, 'x')]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; (v V.// us) === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i .~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+(//) :: (Unbox a) => Vector a -> [(Int, a)] -> Maybe (Vector a)+(//) v us =+  (G.//) v us+{-# INLINE (//) #-}++infixl 9 //++-- | Total @update@: '//' with the updates in a vector. 'Data.Maybe.Nothing' if an index+-- is out of range.+--+-- ==== __Examples__+--+-- >>> V.update (V.fromList "abc") (V.fromList [(1, 'x')])+-- Just "axc"+--+-- >>> V.update (V.fromList "abc") (V.fromList [(-1, 'x')])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.update v (V.fromList us) === (v V.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update :: (Unbox a) => Vector a -> Vector (Int, a) -> Maybe (Vector a)+update v w =+  G.update v w+{-# INLINE update #-}++-- | Total @update_@: 'update' with the indices and the values in two+-- vectors, paired up to the shorter. 'Data.Maybe.Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [2, 0]) (V.fromList "xy")+-- Just "ybx"+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [2, 9]) (V.fromList "x")+-- Just "abx"+--+-- >>> V.update_ (V.fromList "abc") (V.fromList [9]) (V.fromList "x")+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.update_ v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === (v V.// us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+update_ :: (Unbox a) => Vector a -> Vector Int -> Vector a -> Maybe (Vector a)+update_ v w xs =+  G.update_ v w xs+{-# INLINE update_ #-}++-- | Total @accum@: a vector with each element at the indices of a list of+-- updates combined with the update, in one copy. 'Data.Maybe.Nothing' if an index is+-- out of range.+--+-- ==== __Examples__+--+-- >>> V.accum (+) (V.fromList [10, 20, 30 :: Int]) [(0, 1), (2, 3), (0, 4)]+-- Just [15,20,33]+--+-- >>> V.accum (+) (V.fromList [10, 20, 30 :: Int]) [(3, 1)]+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accum (+) v us === bool Nothing (Just (P.foldl (\w (i, a) -> w & ix i +~ a) v us)) (P.all (\(i, _) -> i >= 0 && i < V.length v) us)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accum :: (Unbox a) => (a -> b -> a) -> Vector a -> [(Int, b)] -> Maybe (Vector a)+accum f =+  G.accum f+{-# INLINE accum #-}++-- | Total @accumulate@: 'accum' with the updates in a vector. 'Data.Maybe.Nothing' if+-- an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.accumulate (+) (V.fromList [10, 20 :: Int]) (V.fromList [(1, 5)])+-- Just [10,25]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accumulate (+) v (V.fromList us) === V.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Maybe (Vector a)+accumulate f =+  G.accumulate f+{-# INLINE accumulate #-}++-- | Total @accumulate_@: 'accumulate' with the indices and the values in two+-- vectors, paired up to the shorter. 'Data.Maybe.Nothing' if a paired index is out of+-- range.+--+-- ==== __Examples__+--+-- >>> V.accumulate_ (+) (V.fromList [10, 20 :: Int]) (V.fromList [1, 1]) (V.fromList [5, 6])+-- Just [10,31]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; us <- forAll genUpdates; V.accumulate_ (+) v (V.fromList (fmap P.fst us)) (V.fromList (fmap P.snd us)) === V.accum (+) v us+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+accumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Maybe (Vector a)+accumulate_ f =+  G.accumulate_ f+{-# INLINE accumulate_ #-}++-- | Total @backpermute@: the elements at the indices of a vector of indices.+-- 'Data.Maybe.Nothing' if an index is out of range.+--+-- ==== __Examples__+--+-- >>> V.backpermute (V.fromList "abcd") (V.fromList [3, 0, 3])+-- Just "dad"+--+-- >>> V.backpermute (V.fromList "abcd") (V.fromList [4])+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; is <- forAll (Gen.list (Range.linear 0 5) genIndex); fmap V.toList (V.backpermute v (V.fromList is)) === traverse (v V.!?) is+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+backpermute :: (Unbox a) => Vector a -> Vector Int -> Maybe (Vector a)+backpermute v w =+  G.backpermute v w+{-# INLINE backpermute #-}++-- | Total @foldl1@: a left fold with no starting value. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldl1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> V.foldl1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldl1 (-) v === fmap (\(a, as) -> P.foldl (-) a as) (P.uncons (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1 :: (Unbox a) => (a -> a -> a) -> Vector a -> Maybe a+foldl1 f =+  G.foldl1 f+{-# INLINE foldl1 #-}++-- | Total @foldl1'@: 'foldl1', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldl1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 5+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldl1' (-) v === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldl1' :: (Unbox a) => (a -> a -> a) -> Vector a -> Maybe a+foldl1' f =+  G.foldl1' f+{-# INLINE foldl1' #-}++-- | Total @foldr1@: a right fold with no starting value. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldr1 (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> V.foldr1 (-) (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldr1 (-) v === fmap (\(as, a) -> P.foldr (-) a as) (P.unsnoc (V.toList v))+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1 :: (Unbox a) => (a -> a -> a) -> Vector a -> Maybe a+foldr1 f =+  G.foldr1 f+{-# INLINE foldr1 #-}++-- | Total @foldr1'@: 'foldr1', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.foldr1' (-) (V.fromList [10, 2, 3 :: Int])+-- Just 11+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.foldr1' (-) v === V.foldr1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+foldr1' :: (Unbox a) => (a -> a -> a) -> Vector a -> Maybe a+foldr1' f =+  G.foldr1' f+{-# INLINE foldr1' #-}++-- | Total @maximum@: the greatest element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximum (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> V.maximum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximum v === maximumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximum :: (Unbox a, Ord a) => Vector a -> Maybe a+maximum v =+  G.maximum v+{-# INLINE maximum #-}++-- | Total @maximumBy@: the greatest element by a comparison; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximumBy compare v === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumBy :: (Unbox a) => (a -> a -> Ordering) -> Vector a -> Maybe a+maximumBy f =+  G.maximumBy f+{-# INLINE maximumBy #-}++-- | Total @maximumOn@: the element with the greatest image under a+-- function; the first of equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maximumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maximumOn id v === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maximumOn :: (Ord b, Unbox a) => (a -> b) -> Vector a -> Maybe a+maximumOn f =+  G.maximumOn f+{-# INLINE maximumOn #-}++-- | Total @minimum@: the least element. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimum (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> V.minimum (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimum v === minimumOf folded (V.toList v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimum :: (Unbox a, Ord a) => Vector a -> Maybe a+minimum v =+  G.minimum v+{-# INLINE minimum #-}++-- | Total @minimumBy@: the least element by a comparison; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimumBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimumBy compare v === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumBy :: (Unbox a) => (a -> a -> Ordering) -> Vector a -> Maybe a+minimumBy f =+  G.minimumBy f+{-# INLINE minimumBy #-}++-- | Total @minimumOn@: the element with the least image under a function;+-- the first of equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minimumOn negate (V.fromList [3, 1, 4 :: Int])+-- Just 4+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minimumOn id v === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minimumOn :: (Ord b, Unbox a) => (a -> b) -> Vector a -> Maybe a+minimumOn f =+  G.minimumOn f+{-# INLINE minimumOn #-}++-- | Total @maxIndex@: the index of the greatest element; the first of+-- equals. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maxIndex (V.fromList [3, 4, 1, 4 :: Int])+-- Just 1+--+-- >>> V.maxIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (V.maxIndex v >>= (v V.!?)) === V.maximum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndex :: (Unbox a, Ord a) => Vector a -> Maybe Int+maxIndex v =+  G.maxIndex v+{-# INLINE maxIndex #-}++-- | Total @maxIndexBy@: the index of the greatest element by a comparison.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.maxIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 1+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.maxIndexBy compare v === V.maxIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+maxIndexBy :: (Unbox a) => (a -> a -> Ordering) -> Vector a -> Maybe Int+maxIndexBy f =+  G.maxIndexBy f+{-# INLINE maxIndexBy #-}++-- | Total @minIndex@: the index of the least element; the first of equals.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minIndex (V.fromList [3, 1, 4, 1 :: Int])+-- Just 1+--+-- >>> V.minIndex (V.empty :: V.Vector Int)+-- Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; (V.minIndex v >>= (v V.!?)) === V.minimum v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndex :: (Unbox a, Ord a) => Vector a -> Maybe Int+minIndex v =+  G.minIndex v+{-# INLINE minIndex #-}++-- | Total @minIndexBy@: the index of the least element by a comparison.+-- 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.minIndexBy (comparing negate) (V.fromList [3, 1, 4 :: Int])+-- Just 2+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; V.minIndexBy compare v === V.minIndex v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+minIndexBy :: (Unbox a) => (a -> a -> Ordering) -> Vector a -> Maybe Int+minIndexBy f =+  G.minIndexBy f+{-# INLINE minIndexBy #-}++-- | Total @fold1M@: a monadic left fold with no starting value. 'Data.Maybe.Nothing'+-- for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> V.fold1M (\a b -> Identity (a - b)) (V.empty :: V.Vector Int)+-- Identity Nothing+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M (\a b -> Identity (a - b)) v) === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe a)+fold1M f =+  G.fold1M f+{-# INLINE fold1M #-}++-- | Total @fold1M'@: 'fold1M', strict in the accumulator. 'Data.Maybe.Nothing' for an+-- empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M' (\a b -> Identity (a - b)) (V.fromList [10, 2, 3 :: Int])+-- Identity (Just 5)+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M' (\a b -> Identity (a - b)) v) === V.foldl1 (-) v+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M' :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe a)+fold1M' f =+  G.fold1M' f+{-# INLINE fold1M' #-}++-- | Total @fold1M_@: 'fold1M' for its effects. 'Data.Maybe.Nothing' for an empty vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> V.fold1M_ (\a b -> [a + b]) (V.empty :: V.Vector Int)+-- [Nothing]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M_ (\a b -> Identity (a - b)) v) === (() <$ V.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe ())+fold1M_ f =+  G.fold1M_ f+{-# INLINE fold1M_ #-}++-- | Total @fold1M'_@: 'fold1M'' for its effects. 'Data.Maybe.Nothing' for an empty+-- vector.+--+-- ==== __Examples__+--+-- >>> V.fold1M'_ (\a b -> [a + b]) (V.fromList [1, 2 :: Int])+-- [Just ()]+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; runIdentity (V.fold1M'_ (\a b -> Identity (a - b)) v) === (() <$ V.foldl1 (-) v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+fold1M'_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m (Maybe ())+fold1M'_ f =+  G.fold1M'_ f+{-# INLINE fold1M'_ #-}++-- | Total @copy@: copy an immutable vector into a mutable one of the same+-- length. 'Data.Maybe.Nothing', and no copy, for vectors of different lengths.+--+-- ==== __Examples__+--+-- >>> runST (do m <- MV.replicate 2 'x'; r <- V.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Just (),"ab")+--+-- >>> runST (do m <- MV.replicate 3 'x'; r <- V.copy m (V.fromList "ab"); fmap ((,) r) (V.freeze m))+-- (Nothing,"xxx")+--+-- >>> check $ withTests 100 $ property $ do v <- forAll genVector; n <- forAll genIndex; runST (do m <- MV.replicate (max 0 n) 0; r <- V.copy m v; fmap ((,) r) (V.freeze m)) === bool (Nothing, V.replicate n 0) (Just (), v) (max 0 n == V.length v)+-- ...passed 100 tests.+-- True+--+-- @since 0.7.0+copy :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Vector a -> m (Maybe ())+copy dst =+  G.copy dst+{-# INLINE copy #-}
src/Papa/Witherable/Renamed.hs view
@@ -4,9 +4,9 @@ -- | Re-exports from Papa.Witherable with conflicting identifiers hidden. -- -- Conflicts hidden:--- - 'filter' (conflicts with Data.List.filter)--- - 'catMaybes' (conflicts with Data.Maybe.catMaybes)--- - 'mapMaybe' (conflicts with Data.Maybe.mapMaybe)+-- - @filter@ (conflicts with Data.List.filter)+-- - @catMaybes@ (conflicts with Data.Maybe.catMaybes)+-- - @mapMaybe@ (conflicts with Data.Maybe.mapMaybe) -- -- Use qualified imports when needed: -- > import qualified Witherable as W
+ test/Agree.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The agreement of a total function with the partial one it replaces.+module Agree (+  agrees,+  agreesWhereDefined,+) where++import Control.Applicative ((*>))+import Control.DeepSeq (NFData, force)+import Control.Exception (SomeException, evaluate, try)+import Control.Monad.IO.Class (MonadIO)+import Data.Either (Either, either)+import Data.Eq (Eq)+import Data.Function (const)+import Data.Maybe (Maybe (Just, Nothing))+import Hedgehog (MonadTest, evalIO, label, (===))+import Text.Show (Show)++-- | The total result is 'Nothing' exactly where the partial one throws, and+-- 'Just' the partial one's result everywhere else.+--+-- The partial result is forced in full, so that an exception anywhere in it+-- counts.+agrees :: (Eq a, Show a, NFData a, MonadIO m, MonadTest m) => Maybe a -> a -> m ()+agrees total partial = do+  r :: Either SomeException a <- evalIO (try (evaluate (force partial)))+  either (const (label "partial throws" *> (total === Nothing))) (\p -> label "partial defined" *> (total === Just p)) r++-- | A total function that returns a plain value equals the partial one+-- wherever the partial one does not throw. Where it throws there is nothing+-- to compare. Each case is labelled, so that the coverage of both shows.+--+-- The partial result is forced in full.+agreesWhereDefined :: (Eq a, Show a, NFData a, MonadIO m, MonadTest m) => a -> a -> m ()+agreesWhereDefined total partial = do+  r :: Either SomeException a <- evalIO (try (evaluate (force partial)))+  either (const (label "partial throws")) (\p -> label "partial defined" *> (total === p)) r
+ test/Composes.hs view
@@ -0,0 +1,148 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+{- HLINT ignore "Evaluate" -}+{- HLINT ignore "Use max" -}+{- HLINT ignore "Use min" -}+{- HLINT ignore "Use ++" -}+{- HLINT ignore "Avoid lambda" -}+{- HLINT ignore "Read one value with the" -}+-- Reason: this module uses each name that has clashed, Papa's total maximum,+-- minimum, (!!) and head among them, so that the name must resolve; the+-- expressions are written to use the name, not to be simplified.++-- | "Papa" imports unqualified alongside every module that its+-- documentation says it does. This module compiles only if no name that+-- they export is ambiguous where it is used; every name that has clashed+-- before is used here.+module Composes (+  composes,+) where++import Control.Monad.Trans.Identity (IdentityT (runIdentityT))+import Papa+import Papa.Adjunctions (index)+import Papa.Associative.Renamed (SemigroupOp, op)+import Papa.Base.Control.Arrow (firstA, leftA, rightA, secondA)+import Papa.Base.Control.Monad.Cont ()+import Papa.Base.Control.Monad.Error ()+import Papa.Base.Control.Monad.Reader ()+import Papa.Base.Control.Monad.State ()+import Papa.Base.Control.Monad.Trans ()+import Papa.Base.Control.Monad.Writer ()+import Papa.Bifunctors.Data.Bifoldable ()+import qualified Papa.Comonad.Control.Comonad.Env as Env+import qualified Papa.Containers.Data.IntMap as IntMap+import qualified Papa.Containers.Data.IntSet as IntSet+import qualified Papa.Containers.Data.Map as Map+import qualified Papa.Containers.Data.Seq as Seq+import qualified Papa.Containers.Data.Set as Set+import Papa.Contravariant ()+import Papa.Distributive ()+import Papa.One.Renamed ()+import Papa.Polytree (Tree, levels)+import Papa.Profunctors.Renamed ()+import Papa.Selective (Over (Over), getOver, select)+import qualified Papa.Unsafe.Numeric as U+import Papa.Witherable.Renamed (wither)++-- | The names that have clashed, each used once, so that each must resolve.+composes :: [String]+composes =+  [ show (firstA (+ 1) (1 :: Int, 'x'))+  , show (secondA (+ 1) ('x', 1 :: Int))+  , show (first (+ 1) (1 :: Int, 'x'))+  , show (second (+ 1) ('x', 1 :: Int))+  , show ((show &&& show) (1 :: Int))+  , show (biconcat ("a", "b"))+  , show (concat [[1 :: Int], [2]])+  , show (concatMap show (1 :| [2 :: Int]))+  , show (concat (Just [1 :: Int]))+  , show (maximum (2 :| [1 :: Int]))+  , show (minimum (2 :| [1 :: Int]))+  , show (maximum (1 :| [2 :: Int]))+  , show (minimum (1 :| [2 :: Int]))+  , show (filter even [1, 2 :: Int])+  , show (mapMaybe (\x -> bool Nothing (Just x) (even x)) [1, 2 :: Int])+  , show (catMaybes [Just 'a', Nothing])+  , show (nonEmpty [1 :: Int])+  , show (null [()])+  , show (uncons [1 :: Int])+  , show (Env.ask (Env.env 'e' ()))+  , show (Map.fromList [('a', ())] Map.! 'a')+  , show (Set.findMin (Set.fromList "a"))+  , show (IntMap.findMin (IntMap.fromList [(1, 'a')]))+  , show (IntSet.findMax (IntSet.fromList [1]))+  , show (Seq.index (Seq.fromList "a") 0)+  , show (fmap (divideNonZero 1) (preview nonZero (2 :: Rational)))+  , show (toIntegralSized (1 :: Int) :: Maybe Word8)+  , show (fmap (divNonZero 7) (preview nonZero (2 :: Int)))+  , show (cycle ([] :: [Int]))+  , show (succ False)+  , show (Proxy :: Proxy Int)+  , show (getCompose (Compose (Just [()])))+  , show (reads "1 rest" :: [(Int, String)])+  , show ((show &&& negate) (1 :: Int))+  , show (runIdentityT (lift (Just 'a')))+  , show (chr 65)+  , show (stimes (2 :: Int) "ab")+  , show (fmap (ratioNonZero 7) (preview nonZero (2 :: Integer)))+  , show (readMaybe (pack "1") :: Maybe Int)+  , show ([1 :: Int] !? 0)+  , show ([1 :: Int] !! (0 :: Int))+  , show (singleton 'a')+  , show (unzip [(1 :: Int, 'a')])+  , show (partitionEithers [Left 'a', Right True])+  , show (the head ('a' :| "bc"))+  , show (getSum (Sum (1 :: Int) <> Sum 2))+  , show (getZipList (ZipList "a"))+  , show (lookup 'a' [('a', ())])+  , show (fst ('a', ()))+  , show ((ask :: Char -> Char) 'r')+  , show (runIdentity (wither (\x -> Identity (Just x)) "ab"))+  , show (getConst (contramap ord (Const "c" :: Const String Int)) :: String)+  , show (dimap ord show (+ 1) 'a')+  , show (runIdentity (select (Identity (Left 'a')) (Identity ord)))+  , show (index (Identity 'a') ())+  , show (const () (levels :: Tree [] Int Char -> [[Either Int Char]]))+  , show (getOver (Over "o" :: Over String Int))+  , show (const () (op (+) :: SemigroupOp Int Int))+  , show (userError "u")+  , show (U.div 7 (2 :: Int), (U./) 1 (2 :: Double), (U.%) 1 (2 :: Integer))+  , show (pow (2 :: Int) 3, maximumBy compare (1 :| [2 :: Int]), succ (1 :: Integer))+  , show (fromLeft 'z' (Left 'a' :: Either Char Int), preview right (Right 'b' :: Either Int Char))+  , show (leftA (+ 1) (Left 1 :: Either Int Char), rightA (+ 1) (Right 1 :: Either Char Int))+  , show (the _1 ('a', ()))+  , show (pack "t" :: Text, encodeUtf8 (pack "b") :: ByteString, (fromString "s" :: String))+  , show (Map.empty :: Map Int Char, Set.empty :: Set Int, IntMap.empty :: IntMap Char, IntSet.empty :: IntSet, Seq.empty :: Seq Int)+  , show (runState (modify (+ 1) *> gets (* 2)) (1 :: Int))+  , show (runReader (asks (+ 1)) (1 :: Int), runExcept (throwError 'e' :: Except Char Int))+  , show (swap ('a', ()), coerce (Sum (1 :: Int)) :: Int)+  , show (preview (nonZero . divisor) (3 :: Int))+  , show (nubOrd "abca", nubOrdOn ord "ab", nubInt [1, 1 :: Int], nubIntOn id [2, 2 :: Int], nub "aa")+  , show (has (errorType . _NoSuchThing) (userError "u"), the errorHandle (userError "u"), the description (userError "u"), the location (userError "u"), the fileName (userError "u"))+  , show (has _ArithException (toException Overflow), has (exception :: Prism' SomeException ArithException) (toException Overflow))+  , show (const () (catch :: IO () -> (IOException -> IO ()) -> IO ()), const () (handle :: (IOException -> IO ()) -> IO () -> IO ()), const () (try :: IO () -> IO (Either IOException ())))+  , show (const () (trying _IOException (pure ()) :: IO (Either IOException ())), const () (catching _IOException (pure ()) (const (pure ())) :: IO ()), const () (handling _IOException (const (pure ())) (pure ()) :: IO ()))+  , show (const () (bracket (pure ()) pure pure), const () (bracket_ (pure ()) (pure ()) (pure ())), const () (bracketOnError (pure ()) pure pure), const () (finally (pure ()) (pure ())), const () (onException (pure ()) (pure ())))+  , show (const () (mask_ (pure ())), const () (uninterruptibleMask_ (pure ())), const () getMaskingState, const () (forkFinally (pure ()) (const (pure ()))), const () (throwTo :: ThreadId -> ArithException -> IO ()))+  , show (const () (openFile "/dev/null" ReadMode), const () (withFile "/dev/null" ReadMode hClose), const () (hFlush stdout), const () (hIsEOF stderr), const () (hSetBuffering stdout NoBuffering), const () (exceptIO (pure ())))+  , show (const () (throwsIn :: IO ()), const () (triesIn :: IO (Either () ())), const () (masksIn :: IO ()))+  , show (const () (newIORef () >>= \r -> modifyIORef' r id *> atomicModifyIORef' r (\x -> (x, x)) *> atomicWriteIORef r ()))+  ]++-- | The class of lens's 'throwingM', in scope.+throwsIn :: (MonadThrow m) => m ()+throwsIn =+  throwingM _Overflow ()++-- | The class of lens's 'trying', in scope.+triesIn :: (MonadCatch m) => m (Either () ())+triesIn =+  trying _Overflow (pure ())++-- | The class of masking in the @exceptions@ package, in scope.+masksIn :: (MonadMask m) => m ()+masksIn =+  pure ()
+ test/ComposesUnsafe.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+{- HLINT ignore "Evaluate" -}+-- Reason: this module uses Papa.Unsafe's partial functions, without+-- evaluating them, and Papa's total+-- maximum, so that each name must resolve.++-- | "Papa.Unsafe" is "Papa" with every partial function, and imports on its+-- own: this module compiles only if no name it exports is ambiguous where it+-- is used.+module ComposesUnsafe (+  composesUnsafe,+) where++import Papa.Unsafe++-- | Partial functions and "Papa"'s names, each used once.+composesUnsafe :: [String]+composesUnsafe =+  [ show (7 `div` (2 :: Int), 7 `mod` (2 :: Int), divMod 7 (2 :: Int), quot 7 (2 :: Int), rem 7 (2 :: Int), quotRem 7 (2 :: Int))+  , show ((2 :: Int) ^ (3 :: Int), (1 :: Double) / 2, recip (2 :: Double), (2 :: Double) ^^ (-1 :: Int), 1 % (2 :: Integer))+  , show (fromIntegral (3 :: Int) :: Integer, intCast (3 :: Int) :: Integer)+  , printf "%d" (1 :: Int)+  , show (maximum (1 :| [2 :: Int]), fmap (divNonZero 7) (preview nonZero (2 :: Int)), the _1 ('a', ()))+  , show (const () (throw Overflow :: ()), const () (error "e" :: ()), const () (errorWithoutStackTrace "e" :: ()), const () (undefined :: ()), const () (throwing _ArithException Overflow :: ()), const () (throwing_ _Overflow :: Maybe ()))+  ]
+ test/Deny.hs view
@@ -0,0 +1,343 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: every restricted name here is this module's own binding of type (),+-- defined so that its use is ambiguous were Papa to export the name.++-- | The names that 'Papa' must not export: partial functions, functions that+-- return garbage or silently lose information, and lazy or throwing I/O.+--+-- This module defines each name itself and uses it unqualified. Were 'Papa' to+-- export one of them, the use would be ambiguous and this module, and so the+-- test suite, would not compile. That is the test.+--+-- Names that 'Papa' reuses for a total function (@head@, @succ@, @cycle@,+-- @readFile@, …) are not here: "Totals" pins their total types instead.+module Deny (+  denied,+  deniedTypes,+) where++import Papa++-- | Every denied name, used unqualified.+--+-- 'NonEmpty' and ':|' are 'Papa''s: a use of the import, without which it+-- would be unused (every other name here is this module's own).+denied :: NonEmpty ()+denied =+  error+    :| [ -- base: errors and partial functions+         errorWithoutStackTrace+       , undefined+       , throw+       , fromJust+       , read+       , toEnum+       , fromEnum+       , foldr1+       , foldl1+       , foldl1'+       , genericIndex+       , getEnv+       , -- base: numeric functions that throw, wrap or return garbage+         fromIntegral+       , fromInteger+       , approxRational+       , realToFrac+       , truncate+       , round+       , ceiling+       , floor+       , properFraction+       , toRational+       , div+       , mod+       , divMod+       , quot+       , rem+       , quotRem+       , (/)+       , recip+       , (^)+       , (^^)+       , (%)+       , -- base: unsafe, debugging and formatting+         unsafePerformIO+       , unsafeDupablePerformIO+       , unsafeInterleaveIO+       , unsafeCoerce+       , trace+       , traceShow+       , printf+       , hPrintf+       , fail+       , -- base: leaky+         modifyIORef+       , atomicModifyIORef+       , -- semigroupoids and base classes with partial instances+         zero+       , mfix+       , -- lens: partial combinators+         (^?!)+       , (^@?!)+       , foldr1Of+       , foldl1Of+       , foldr1Of'+       , foldl1Of'+       , singular+       , unsafeSingular+       , unsafePartsOf+       , unsafePartsOf'+       , iunsafePartsOf+       , iunsafePartsOf'+       , throwing+       , throwing_+       , -- base: String I/O that throws+         putChar+       , hGetChar+       , readLn+       , -- containers+         (!)+       , -- async: rethrow a thread's exception in another+         wait+       , waitAny+       , waitEither+       , waitBoth+       , link+       , link2+       , -- directory: deprecated, or with . and ..+         getDirectoryContents+       , isSymbolicLink+       ]++-- | Every denied type, used unqualified: a type of base whose arithmetic+-- throws ('Numeric.Natural.Natural') or wraps around at a bounded type+-- ('Data.Ratio.Ratio').+deniedTypes :: (Natural, Ratio Int)+deniedTypes =+  ((), ())++type Natural = ()++type Ratio a = ()++error :: ()+error = ()++errorWithoutStackTrace :: ()+errorWithoutStackTrace = ()++undefined :: ()+undefined = ()++throw :: ()+throw = ()++fromJust :: ()+fromJust = ()++read :: ()+read = ()++toEnum :: ()+toEnum = ()++fromEnum :: ()+fromEnum = ()++foldr1 :: ()+foldr1 = ()++foldl1 :: ()+foldl1 = ()++foldl1' :: ()+foldl1' = ()++genericIndex :: ()+genericIndex = ()++getEnv :: ()+getEnv = ()++fromIntegral :: ()+fromIntegral = ()++realToFrac :: ()+realToFrac = ()++fromInteger :: ()+fromInteger = ()++approxRational :: ()+approxRational = ()++truncate :: ()+truncate = ()++round :: ()+round = ()++ceiling :: ()+ceiling = ()++floor :: ()+floor = ()++properFraction :: ()+properFraction = ()++toRational :: ()+toRational = ()++div :: ()+div = ()++mod :: ()+mod = ()++divMod :: ()+divMod = ()++quot :: ()+quot = ()++rem :: ()+rem = ()++quotRem :: ()+quotRem = ()++(/) :: ()+(/) = ()++recip :: ()+recip = ()++(^) :: ()+(^) = ()++(^^) :: ()+(^^) = ()++(%) :: ()+(%) = ()++unsafePerformIO :: ()+unsafePerformIO = ()++unsafeDupablePerformIO :: ()+unsafeDupablePerformIO = ()++unsafeInterleaveIO :: ()+unsafeInterleaveIO = ()++unsafeCoerce :: ()+unsafeCoerce = ()++trace :: ()+trace = ()++traceShow :: ()+traceShow = ()++printf :: ()+printf = ()++hPrintf :: ()+hPrintf = ()++fail :: ()+fail = ()++modifyIORef :: ()+modifyIORef = ()++atomicModifyIORef :: ()+atomicModifyIORef = ()++zero :: ()+zero = ()++mfix :: ()+mfix = ()++(^?!) :: ()+(^?!) = ()++(^@?!) :: ()+(^@?!) = ()++foldr1Of :: ()+foldr1Of = ()++foldl1Of :: ()+foldl1Of = ()++foldr1Of' :: ()+foldr1Of' = ()++foldl1Of' :: ()+foldl1Of' = ()++singular :: ()+singular = ()++unsafeSingular :: ()+unsafeSingular = ()++unsafePartsOf :: ()+unsafePartsOf = ()++unsafePartsOf' :: ()+unsafePartsOf' = ()++iunsafePartsOf :: ()+iunsafePartsOf = ()++iunsafePartsOf' :: ()+iunsafePartsOf' = ()++throwing :: ()+throwing = ()++throwing_ :: ()+throwing_ = ()++putChar :: ()+putChar = ()++hGetChar :: ()+hGetChar = ()++readLn :: ()+readLn = ()++(!) :: ()+(!) = ()++wait :: ()+wait = ()++waitAny :: ()+waitAny = ()++waitEither :: ()+waitEither = ()++waitBoth :: ()+waitBoth = ()++link :: ()+link = ()++link2 :: ()+link2 = ()++getDirectoryContents :: ()+getDirectoryContents = ()++isSymbolicLink :: ()+isSymbolicLink = ()
test/Doctest.hs view
@@ -1,6 +1,10 @@-{-# OPTIONS_GHC -Wall -Werror -Wno-orphans #-}+{-# OPTIONS_GHC -Wall #-} -module Main (main) where+-- | Run the doctests of the library: the examples and the Hedgehog+-- properties in its Haddock comments.+module Main (+  main,+) where  import System.Exit (exitWith) import System.Process (rawSystem)@@ -12,6 +16,10 @@       "cabal"       [ "repl"       , "--with-compiler=doctest"+      , "--build-depends=hedgehog"+      , "--build-depends=hedgehog-fn"+      , "--build-depends=transformers"+      , "--build-depends=directory"       , "--repl-options=-w"       , "--repl-options=-Wdefault"       , "lib:papa"
+ test/Inspection.hs view
@@ -0,0 +1,200 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall -O -fplugin Test.Inspection.Plugin #-}++{- HLINT ignore "Eta reduce" -}+-- Reason: each function is applied to all its arguments, as at a call site,+-- so that GHC inlines the total function into it.++-- | The cost of totality, checked in the optimised Core of the total+-- functions. The module compiles only if every obligation holds, so the test+-- is its compilation. The functions are exported, so that GHC keeps them for+-- the inspection.+--+-- At 'Int' and 'Word', each 'NonZero' division function has no type class+-- dictionaries left (it is specialised) and mentions no 'Integer' (the test+-- of the divisor for @-1@ allocates nothing). The same holds for 'pow',+-- 'intCast', and the total conversions from 'Double'; and the 'NonZero'+-- functions at 'Double' and 'Rational' are specialised.+--+-- Equality of Core with the same function written by hand with+-- "Papa.Unsafe.Numeric" (@===@) is not checked: at 'Int' the two differ only+-- in where GHC places "Prelude"'s unreachable error branches+-- (@overflowError@, @divZeroError@), which differs between the library and+-- this module; at 'Double', 'divideNonZero' compiles to @GHC.Float.divideDouble@+-- under a coercion, which a hand-written version cannot state, since the+-- 'NonZero' constructor is not exported. The benchmarks measure the cost.+module Main (+  main,+  divInt,+  modInt,+  quotInt,+  remInt,+  divModInt,+  quotRemInt,+  divWord,+  modWord,+  quotWord,+  remWord,+  divModWord,+  quotRemWord,+  powInt,+  powWord,+  ratioInteger,+  divideDouble,+  recipDouble,+  powNonZeroDouble,+  truncateDoubleInt,+  roundDoubleInt,+  floorDoubleInt,+  ceilingDoubleInt,+  intCastInt32Int64,+) where++import Papa+import Test.Inspection (hasNoType, hasNoTypeClasses, inspect)++divInt :: Int -> NonZero Int -> Int+divInt x y =+  divNonZero x y++modInt :: Int -> NonZero Int -> Int+modInt x y =+  modNonZero x y++quotInt :: Int -> NonZero Int -> Int+quotInt x y =+  quotNonZero x y++remInt :: Int -> NonZero Int -> Int+remInt x y =+  remNonZero x y++divModInt :: Int -> NonZero Int -> (Int, Int)+divModInt x y =+  divModNonZero x y++quotRemInt :: Int -> NonZero Int -> (Int, Int)+quotRemInt x y =+  quotRemNonZero x y++divWord :: Word -> NonZero Word -> Word+divWord x y =+  divNonZero x y++modWord :: Word -> NonZero Word -> Word+modWord x y =+  modNonZero x y++quotWord :: Word -> NonZero Word -> Word+quotWord x y =+  quotNonZero x y++remWord :: Word -> NonZero Word -> Word+remWord x y =+  remNonZero x y++divModWord :: Word -> NonZero Word -> (Word, Word)+divModWord x y =+  divModNonZero x y++quotRemWord :: Word -> NonZero Word -> (Word, Word)+quotRemWord x y =+  quotRemNonZero x y++powInt :: Int -> Word -> Int+powInt x y =+  pow x y++powWord :: Word -> Word -> Word+powWord x y =+  pow x y++ratioInteger :: Integer -> NonZero Integer -> Rational+ratioInteger x y =+  ratioNonZero x y++divideDouble :: Double -> NonZero Double -> Double+divideDouble x y =+  divideNonZero x y++recipDouble :: NonZero Double -> Double+recipDouble x =+  recipNonZero x++powNonZeroDouble :: NonZero Double -> Int -> Double+powNonZeroDouble x y =+  powNonZero x y++truncateDoubleInt :: Double -> Maybe Int+truncateDoubleInt x =+  truncateMaybe x++roundDoubleInt :: Double -> Maybe Int+roundDoubleInt x =+  roundMaybe x++floorDoubleInt :: Double -> Maybe Int+floorDoubleInt x =+  floorMaybe x++ceilingDoubleInt :: Double -> Maybe Int+ceilingDoubleInt x =+  ceilingMaybe x++intCastInt32Int64 :: Int32 -> Int64+intCastInt32Int64 x =+  intCast x++-- Int: no dictionaries, no Integer.+$(inspect (hasNoTypeClasses 'divInt))+$(inspect ('divInt `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'modInt))+$(inspect ('modInt `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'quotInt))+$(inspect ('quotInt `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'remInt))+$(inspect ('remInt `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'divModInt))+$(inspect ('divModInt `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'quotRemInt))+$(inspect ('quotRemInt `hasNoType` ''Integer))++-- Word: no dictionaries, no Integer.+$(inspect (hasNoTypeClasses 'divWord))+$(inspect ('divWord `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'modWord))+$(inspect ('modWord `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'quotWord))+$(inspect ('quotWord `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'remWord))+$(inspect ('remWord `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'divModWord))+$(inspect ('divModWord `hasNoType` ''Integer))+$(inspect (hasNoTypeClasses 'quotRemWord))+$(inspect ('quotRemWord `hasNoType` ''Integer))++-- pow and ratioNonZero: specialised.+$(inspect (hasNoTypeClasses 'powInt))+$(inspect (hasNoTypeClasses 'powWord))+$(inspect (hasNoTypeClasses 'ratioInteger))++-- Double: specialised.+$(inspect (hasNoTypeClasses 'divideDouble))+$(inspect (hasNoTypeClasses 'recipDouble))+$(inspect (hasNoTypeClasses 'powNonZeroDouble))++-- The total conversions from Double: specialised.+$(inspect (hasNoTypeClasses 'truncateDoubleInt))+$(inspect (hasNoTypeClasses 'roundDoubleInt))+$(inspect (hasNoTypeClasses 'floorDoubleInt))+$(inspect (hasNoTypeClasses 'ceilingDoubleInt))++-- intCast: Prelude's fromIntegral, specialised, through no Integer.+$(inspect (hasNoTypeClasses 'intCastInt32Int64))+$(inspect ('intCastInt32Int64 `hasNoType` ''Integer))++-- | The obligations are checked when this module compiles.+main :: IO ()+main =+  pure ()
test/Main.hs view
@@ -1,50 +1,43 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -Wall #-} -{- HLINT ignore "Avoid restricted function" -}-{- HLINT ignore "Evaluate" -}--module Main where+-- | The Hedgehog properties of Papa, and the check that its modules import+-- together.+module Main (+  main,+) where +import Composes (composes)+import ComposesUnsafe (composesUnsafe)+import Deny (denied)+import Hedgehog (Group, checkParallel, checkSequential) import Papa-import System.Exit (exitFailure, exitSuccess)--assert :: Bool -> String -> IO ()-assert True _ = pure ()-assert False msg = putStrLn ("FAIL: " ++ msg) *> exitFailure+import Properties (properties)+import PropertiesAsync (propertiesAsync)+import PropertiesContainers (propertiesContainers)+import PropertiesFS (propertiesCurrentDirectory, propertiesFS)+import PropertiesIO (propertiesIO)+import PropertiesNumeric (propertiesNumeric)+import PropertiesText (propertiesText)+import PropertiesVector (propertiesVector)+import Totals (totals)  main :: IO () main = do-  -- Total (!!) using lens-based safe indexing-  assert (is _Nothing (([] :: [Int]) !! (1 :: Int))) "[] !! 1 == Nothing"-  assert ([10 :: Int, 20, 30] !! (1 :: Int) == Just 20) "[10,20,30] !! 1 == Just 20"--  -- Generalized map (Functor)-  assert (map (+ (1 :: Int)) [1, 2, 3] == [2, 3, 4]) "map (+1) [1,2,3] == [2,3,4]"--  -- Generalized (++) (Semigroup)-  assert ("abc" ++ "def" == "abcdef") "abc ++ def == abcdef"--  -- Generalized lookup (Foldable)-  assert (lookup 'b' [('a', 1 :: Int), ('b', 2)] == Just 2) "lookup 'b' == Just 2"-  assert (is _Nothing (lookup 'z' [('a', 1 :: Int)])) "lookup 'z' == Nothing"--  -- fst/snd via lens (Field1/Field2)-  assert (fst (1 :: Int, 'a') == 1) "fst (1, 'a') == 1"-  assert (snd (1 :: Int, 'a') == 'a') "snd (1, 'a') == 'a'"--  -- mconcat (Foldable Monoid)-  assert (mconcat ["a", "b", "c"] == "abc") "mconcat [a,b,c] == abc"--  -- maximum/minimum (Foldable1)-  assert (maximum (1 :| [2, 3 :: Int]) == 3) "maximum (1 :| [2,3]) == 3"-  assert (minimum (1 :| [2, 3 :: Int]) == 1) "minimum (1 :| [2,3]) == 1"--  -- const (Applicative pure)-  assert ((const 42 :: Maybe Int) == Just 42) "const 42 == Just 42"--  -- Const constructor accessible (issue 6)-  assert (getConst (Const "hello" :: Const String Int) == "hello") "Const constructor"+  printed <- runExceptT (for_ (composes <> composesUnsafe <> totals <> [show (length denied) <> " names are not exported by Papa"]) (putStrLn . pack))+  passed <- traverse checkParallel groups+  passedSequentially <- checkSequential propertiesCurrentDirectory+  bool exitFailure exitSuccess (isRight printed && and passed && passedSequentially) -  putStrLn "All tests passed."-  exitSuccess+-- | The property groups, one for each area of Papa.+groups :: [Group]+groups =+  [ properties+  , propertiesIO+  , propertiesVector+  , propertiesNumeric+  , propertiesContainers+  , propertiesText+  , propertiesFS+  , propertiesAsync+  ]
+ test/Properties.hs view
@@ -0,0 +1,531 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these are the properties of Papa's total head, last, init, tail,+-- maximum, minimum and (!!), and of Papa.Unsafe's partial functions compared+-- with them, whose names HLint restricts whatever module+-- they come from.++{- HLINT ignore "Evaluate" -}+{- HLINT ignore "Setter law: set twice" -}+{- HLINT ignore "Use lefts" -}+{- HLINT ignore "Use rights" -}+{- HLINT ignore "Use fromLeft" -}+{- HLINT ignore "Use fromRight" -}+{- HLINT ignore "Use mapM_" -}+{- HLINT ignore "Use traverse_" -}+{- HLINT ignore "Use fold" -}+{- HLINT ignore "Redundant map" -}+{- HLINT ignore "Use map once" -}+{- HLINT ignore "Redundant pair" -}+{- HLINT ignore "Redundant flip" -}+{- HLINT ignore "Use exitSuccess" -}+{- HLINT ignore "Use ix" -}+{- HLINT ignore "Use toList" -}+{- HLINT ignore "Lens law: read what you set" -}+{- HLINT ignore "Lens law: set what you read" -}+-- Reason: each property writes both sides of an equation that these hints+-- would rewrite one side into the other (CLAUDE.md, HLint Compliance: testing+-- laws).++{- HLINT ignore "Use maximumByOf" -}+{- HLINT ignore "Use minimumByOf" -}+-- Reason: Papa's maximumBy and minimumBy are Data.Foldable1's, which are+-- total; these hints are for Data.Foldable's, which throw for an empty+-- structure.++-- | Hedgehog properties of every function that Papa defines.+module Properties (+  properties,+) where++import Control.Monad.Trans.Writer.CPS (runWriter, tell)+import qualified Data.Bifunctor as B+import qualified Data.IntMap.Strict as IM+import qualified Data.IntSet as IS+import qualified Data.List as L+import qualified Data.Map.Strict as M+import qualified Data.Monoid as Mo+import qualified Data.Semigroup as S+import qualified Data.Sequence as Sq+import qualified Data.Set as St+import Data.Tagged (Tagged)+import Hedgehog (Gen, Group (Group), Property, PropertyName, evalIO, forAll, property, (===))+import Hedgehog.Function (Fn, Vary, apply, fn)+import qualified Hedgehog.Function as F+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import Papa.Base.Control.Arrow (firstA, leftA, rightA, secondA)+import qualified Papa.Containers.Data.IntMap as IntMap+import qualified Papa.Containers.Data.IntSet as IntSet+import qualified Papa.Containers.Data.Map as Map+import qualified Papa.Containers.Data.Seq as Seq+import qualified Papa.Containers.Data.Set as Set+import Papa.Unsafe.Numeric (Natural)+import qualified Papa.Unsafe.Numeric as U+import qualified Prelude as P++-- | Every property, in one group.+properties :: Group+properties =+  Group "papa" (integral <> intCasts <> nonZeros <> enums <> numeric <> semigroup <> list <> foldable <> traversable <> functions <> monad <> eithers <> maybes <> fractional <> exits <> containers <> nonEmptyLenses <> optics <> bifunctors)++-- Generators++genInt :: Gen Int+genInt =+  Gen.int (Range.linearFrom 0 (-1000) 1000)++genSmallInt :: Gen Int+genSmallInt =+  Gen.int (Range.linear (-5) 25)++genInteger :: Gen Integer+genInteger =+  Gen.integral (Range.linearFrom 0 (-1000) 1000)++genInts :: Gen [Int]+genInts =+  Gen.list (Range.linear 0 20) genInt++genString :: Gen String+genString =+  Gen.string (Range.linear 0 10) Gen.alpha++genNonEmpty :: Gen (NonEmpty Int)+genNonEmpty =+  Gen.nonEmpty (Range.linear 1 20) genInt++genEither :: Gen (Either Int Char)+genEither =+  Gen.either genInt Gen.alpha++genEithers :: Gen [Either Int Char]+genEithers =+  Gen.list (Range.linear 0 20) genEither++genFn :: (F.Arg a, Vary a, Show b) => Gen b -> Gen (Fn a b)+genFn =+  fn++prop :: PropertyName -> Property -> [(PropertyName, Property)]+prop name p =+  [(name, p)]++-- Papa.Base.Data.Integral++integral :: [(PropertyName, Property)]+integral =+  prop "divModNonZero: q * d + m == n" (property (do n <- forAll genInt; d <- forAll genNonZeroInt; (\(q, m) -> q * the divisor d + m) (divModNonZero n d) === n))+    <> prop "divModNonZero: Prelude's for d /= -1" (property (do n <- forAll genInt; d <- forAll genNonZeroInt; let { d' = the divisor d }; divModNonZero n d === bool (U.divMod n d') (P.negate n, 0) (d' == -1)))+    <> prop "divModNonZero: minBound / -1 does not throw" (property (fmap (divModNonZero (minBound :: Int)) (preview nonZero (-1 :: Int)) === Just (minBound, 0)))+    <> prop "divModNonZero: Prelude's at Word8" (property (do n <- forAll (Gen.word8 Range.linearBounded); d <- forAll (Gen.just (preview nonZero <$> Gen.word8 Range.linearBounded)); divModNonZero n d === U.divMod n (the divisor d)))+    <> prop "divModNonZero: Prelude's at Word" (property (do n <- forAll (Gen.word Range.linearBounded); d <- forAll (Gen.just (preview nonZero <$> Gen.frequency [(1, pure maxBound), (9, Gen.word Range.linearBounded)])); divModNonZero n d === U.divMod n (the divisor d)))+    <> prop "divModNonZero: Prelude's at Natural" (property (do n <- forAll genNatural; d <- forAll (Gen.just (preview nonZero <$> genNatural)); divModNonZero n d === U.divMod n (the divisor d)))+    <> prop "divNonZero, modNonZero: the components of divModNonZero" (property (do n <- forAll genInt; d <- forAll genNonZeroInt; (divNonZero n d, modNonZero n d) === divModNonZero n d))+    <> prop "quotRemNonZero: q * d + r == n" (property (do n <- forAll genInt; d <- forAll genNonZeroInt; (\(q, r) -> q * the divisor d + r) (quotRemNonZero n d) === n))+    <> prop "quotRemNonZero: Prelude's for d /= -1" (property (do n <- forAll genInt; d <- forAll genNonZeroInt; let { d' = the divisor d }; quotRemNonZero n d === bool (U.quotRem n d') (P.negate n, 0) (d' == -1)))+    <> prop "quotRemNonZero: Prelude's at Word8" (property (do n <- forAll (Gen.word8 Range.linearBounded); d <- forAll (Gen.just (preview nonZero <$> Gen.word8 Range.linearBounded)); quotRemNonZero n d === U.quotRem n (the divisor d)))+    <> prop "quotRemNonZero: Prelude's at Natural" (property (do n <- forAll genNatural; d <- forAll (Gen.just (preview nonZero <$> genNatural)); quotRemNonZero n d === U.quotRem n (the divisor d)))+    <> prop "quotNonZero, remNonZero: the components of quotRemNonZero" (property (do n <- forAll genInt; d <- forAll genNonZeroInt; (quotNonZero n d, remNonZero n d) === quotRemNonZero n d))+    <> prop "pow: x ^ (e + 1) == x ^ e * x" (property (do x <- forAll genInt; e <- forAll genSmallWord; pow x (e + 1) === pow x e * x))+    <> prop "pow: Prelude's" (property (do x <- forAll genInt; e <- forAll genSmallWord; pow x e === (U.^) x e))++-- | A generator that also gives 0 often, for the smart constructor.+withZero :: (Num a) => Gen a -> Gen a+withZero g =+  Gen.frequency [(1, pure 0), (4, g)]++genNatural :: Gen Natural+genNatural =+  Gen.integral (Range.linear 0 1000)++genSmallWord :: Gen Word+genSmallWord =+  Gen.integral (Range.linear 0 6)++-- Papa.Base.Data.NonZero: the classy optics laws (rule 13)++-- | Non-zero values, built through the smart constructor, with -1 often,+-- for the special case of division.+genNonZeroInt :: Gen (NonZero Int)+genNonZeroInt =+  Gen.just (preview nonZero <$> Gen.frequency [(1, pure (-1)), (9, genInt)])++genNonZeroRational :: Gen (NonZero Rational)+genNonZeroRational =+  Gen.just (preview nonZero <$> genRational)++-- | The prism laws of the smart constructor at a numeric type.+prismNonZero ::+  forall a.+  (Eq a, Num a, Show a, NonZeroLike (->) (Const (Mo.First (NonZero a))) a a a a, NonZeroLike (->) (Const Mo.Any) a a a a, NonZeroLike Tagged Identity a a a a) =>+  PropertyName ->+  Gen a ->+  [(PropertyName, Property)]+prismNonZero name genA =+  prop ("prism nonZero (" <> name <> "): preview (review x) == Just x") (property (do x <- forAll (Gen.just (preview nonZero <$> genA)); preview nonZero (review nonZero x :: a) === Just x))+    <> prop ("prism nonZero (" <> name <> "): preview s == Just x implies review x == s") (property (do s <- forAll genA; for_ (preview nonZero s) (\x -> review nonZero x === s)))+    <> prop ("prism nonZero (" <> name <> "): Just exactly where not zero") (property (do s <- forAll genA; has nonZero s === (s /= 0)))++nonZeros :: [(PropertyName, Property)]+nonZeros =+  prop "identity nonZero" (property (do s <- forAll genNonZeroInt; t <- forAll genNonZeroInt; (the nonZero s, set nonZero t s, review nonZero s) === (s, t, s)))+    <> prismNonZero "Int" (withZero genInt)+    <> prismNonZero "Int8" (withZero (Gen.int8 Range.linearBounded))+    <> prismNonZero "Int16" (withZero (Gen.int16 Range.linearBounded))+    <> prismNonZero "Int32" (withZero (Gen.int32 Range.linearBounded))+    <> prismNonZero "Int64" (withZero (Gen.int64 Range.linearBounded))+    <> prismNonZero "Integer" (withZero genInteger)+    <> prismNonZero "Word" (withZero (Gen.word Range.linearBounded))+    <> prismNonZero "Word8" (withZero (Gen.word8 Range.linearBounded))+    <> prismNonZero "Word16" (withZero (Gen.word16 Range.linearBounded))+    <> prismNonZero "Word32" (withZero (Gen.word32 Range.linearBounded))+    <> prismNonZero "Word64" (withZero (Gen.word64 Range.linearBounded))+    <> prismNonZero "Natural" (withZero genNatural)+    <> prismNonZero "Float" (withZero (Gen.float (Range.linearFracFrom 0 (-100) 100)))+    <> prismNonZero "Double" (withZero (Gen.double (Range.linearFracFrom 0 (-100) 100)))+    <> prismNonZero "Rational" (withZero genRational)+    <> prop "Eq1 NonZero: liftEq (==) == (==)" (property (do x <- forAll genNonZeroInt; y <- forAll genNonZeroInt; liftEq (==) x y === (x == y)))+    <> prop "Ord1 NonZero: liftCompare compare == compare" (property (do x <- forAll genNonZeroInt; y <- forAll genNonZeroInt; liftCompare compare x y === compare x y))+    <> prop "Show1 NonZero: liftShowsPrec showsPrec showList == showsPrec" (property (do x <- forAll genNonZeroInt; d <- forAll (Gen.int (Range.linear 0 11)); liftShowsPrec showsPrec showList d x "" === showsPrec d x ""))+    <> prop "Foldable NonZero: the one value" (property (do x <- forAll genNonZeroInt; (toList x, length x, null x, sum x, foldr (:) [] x) === ([the divisor x], 1, False, the divisor x, [the divisor x])))+    <> prop "Foldable NonZero: foldMap == foldr" (property (do x <- forAll genNonZeroInt; f <- forAll (genFn genString); foldMap (apply f) x === foldr ((<>) . apply f) mempty x))+    <> prop "Foldable1 NonZero: toNonEmpty, foldMap1 agree with Foldable" (property (do x <- forAll genNonZeroInt; f <- forAll (genFn genString); (toNonEmpty x, foldMap1 (apply f) x) === (the divisor x :| [], foldMap (apply f) x)))+    <> prop "getter divisor" (property (do s <- forAll genNonZeroInt; toListOf divisor s === [the divisor s]))+    <> prop "lawNamesNonZero == Just" (property (do s <- forAll genNonZeroInt; lawNamesNonZero s === Just s))+    <> prop "lawNamesNonZero == Just (Rational)" (property (do s <- forAll genNonZeroRational; lawNamesNonZero s === Just s))+    <> prop "validNonZero" (property (do n <- forAll genInt; validNonZero n === (n /= 0)))++-- Papa.Base.Data.IntCast: every lossless pair of the table, over the whole+-- range of its source type++intCasts :: [(PropertyName, Property)]+intCasts =+  prop "intCast Int8 -> Int16: the value is unchanged" (property (do x <- forAll (Gen.int8 Range.linearBounded); toInteger (intCast x :: Int16) === toInteger x))+    <> prop "intCast Int8 -> Int32: the value is unchanged" (property (do x <- forAll (Gen.int8 Range.linearBounded); toInteger (intCast x :: Int32) === toInteger x))+    <> prop "intCast Int8 -> Int: the value is unchanged" (property (do x <- forAll (Gen.int8 Range.linearBounded); toInteger (intCast x :: Int) === toInteger x))+    <> prop "intCast Int8 -> Int64: the value is unchanged" (property (do x <- forAll (Gen.int8 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))+    <> prop "intCast Int8 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.int8 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Int16 -> Int32: the value is unchanged" (property (do x <- forAll (Gen.int16 Range.linearBounded); toInteger (intCast x :: Int32) === toInteger x))+    <> prop "intCast Int16 -> Int: the value is unchanged" (property (do x <- forAll (Gen.int16 Range.linearBounded); toInteger (intCast x :: Int) === toInteger x))+    <> prop "intCast Int16 -> Int64: the value is unchanged" (property (do x <- forAll (Gen.int16 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))+    <> prop "intCast Int16 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.int16 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Int32 -> Int: the value is unchanged" (property (do x <- forAll (Gen.int32 Range.linearBounded); toInteger (intCast x :: Int) === toInteger x))+    <> prop "intCast Int32 -> Int64: the value is unchanged" (property (do x <- forAll (Gen.int32 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))+    <> prop "intCast Int32 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.int32 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Int -> Int64: the value is unchanged" (property (do x <- forAll (Gen.int Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))+    <> prop "intCast Int -> Integer: the value is unchanged" (property (do x <- forAll (Gen.int Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Int64 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.int64 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Word8 -> Word16: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Word16) === toInteger x))+    <> prop "intCast Word8 -> Word32: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Word32) === toInteger x))+    <> prop "intCast Word8 -> Word: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Word) === toInteger x))+    <> prop "intCast Word8 -> Word64: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Word64) === toInteger x))+    <> prop "intCast Word8 -> Natural: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Natural) === toInteger x))+    <> prop "intCast Word8 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Word16 -> Word32: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Word32) === toInteger x))+    <> prop "intCast Word16 -> Word: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Word) === toInteger x))+    <> prop "intCast Word16 -> Word64: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Word64) === toInteger x))+    <> prop "intCast Word16 -> Natural: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Natural) === toInteger x))+    <> prop "intCast Word16 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Word32 -> Word: the value is unchanged" (property (do x <- forAll (Gen.word32 Range.linearBounded); toInteger (intCast x :: Word) === toInteger x))+    <> prop "intCast Word32 -> Word64: the value is unchanged" (property (do x <- forAll (Gen.word32 Range.linearBounded); toInteger (intCast x :: Word64) === toInteger x))+    <> prop "intCast Word32 -> Natural: the value is unchanged" (property (do x <- forAll (Gen.word32 Range.linearBounded); toInteger (intCast x :: Natural) === toInteger x))+    <> prop "intCast Word32 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.word32 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Word -> Word64: the value is unchanged" (property (do x <- forAll (Gen.word Range.linearBounded); toInteger (intCast x :: Word64) === toInteger x))+    <> prop "intCast Word -> Natural: the value is unchanged" (property (do x <- forAll (Gen.word Range.linearBounded); toInteger (intCast x :: Natural) === toInteger x))+    <> prop "intCast Word -> Integer: the value is unchanged" (property (do x <- forAll (Gen.word Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Word64 -> Natural: the value is unchanged" (property (do x <- forAll (Gen.word64 Range.linearBounded); toInteger (intCast x :: Natural) === toInteger x))+    <> prop "intCast Word64 -> Integer: the value is unchanged" (property (do x <- forAll (Gen.word64 Range.linearBounded); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Natural -> Integer: the value is unchanged" (property (do x <- forAll ((Gen.integral (Range.linear 0 (pow 2 70)) :: Gen Natural)); toInteger (intCast x :: Integer) === toInteger x))+    <> prop "intCast Word8 -> Int16: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Int16) === toInteger x))+    <> prop "intCast Word8 -> Int32: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Int32) === toInteger x))+    <> prop "intCast Word8 -> Int: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Int) === toInteger x))+    <> prop "intCast Word8 -> Int64: the value is unchanged" (property (do x <- forAll (Gen.word8 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))+    <> prop "intCast Word16 -> Int32: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Int32) === toInteger x))+    <> prop "intCast Word16 -> Int: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Int) === toInteger x))+    <> prop "intCast Word16 -> Int64: the value is unchanged" (property (do x <- forAll (Gen.word16 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))+    <> prop "intCast Word32 -> Int64: the value is unchanged" (property (do x <- forAll (Gen.word32 Range.linearBounded); toInteger (intCast x :: Int64) === toInteger x))++-- Papa.Base.Data.Enum, Papa.Base.Data.Char++enums :: [(PropertyName, Property)]+enums =+  prop "succ: Integer, unbounded" (property (do n <- forAll genInteger; succ n === Just (n + 1)))+    <> prop "succ: Natural, unbounded" (property (do n <- forAll genNatural; succ n === Just (n + 1)))+    <> prop "succ: Nothing at maxBound, else Prelude's" (property (do n <- forAll (Gen.int Range.linearBounded); succ n === bool (Just (P.succ n)) Nothing (n == maxBound)))+    <> prop "pred: Nothing at minBound, else Prelude's" (property (do n <- forAll (Gen.int Range.linearBounded); pred n === bool (Just (P.pred n)) Nothing (n == minBound)))+    <> prop "succ >=> pred" (property (do n <- forAll (Gen.int Range.linearBounded); (succ >=> pred) n === bool (Just n) Nothing (n == maxBound)))+    <> prop "chr . ord == Just" (property (do c <- forAll Gen.unicodeAll; chr (ord c) === Just c))+    <> prop "chr: Nothing out of range" (property (do n <- forAll (Gen.choice [Gen.int (Range.linear (-1000) (-1)), Gen.int (Range.linear 0x110000 0x200000)]); chr n === Nothing))++-- Papa.Base.Data.Ratio, Papa.Base.Text.Read++numeric :: [(PropertyName, Property)]+numeric =+  prop "ratioNonZero: Data.Ratio's" (property (do n <- forAll genInteger; d <- forAll (Gen.just (preview nonZero <$> genInteger)); ratioNonZero n d === (U.%) n (the divisor d)))+    <> prop "readIO . show == pure . Just" (property (do n <- forAll genInt; r <- evalIO (readIO (display n)); r === Just n))+    <> prop "readIO: Nothing for a non-number" (property (do r <- evalIO (readIO "x" :: IO (Maybe Int)); r === Nothing))++-- Papa.Base.Data.Semigroup++semigroup :: [(PropertyName, Property)]+semigroup =+  prop "stimes: agrees with Data.Semigroup for n > 0" (property (do s <- forAll genString; n <- forAll (Gen.int (Range.linear 1 10)); stimes n s === Just (S.stimes n s)))+    <> prop "stimes: Nothing for n <= 0" (property (do s <- forAll genString; n <- forAll (Gen.int (Range.linear (-10) 0)); stimes n s === Nothing))+    <> prop "stimesMonoid: agrees for n >= 0, Nothing below" (property (do s <- forAll genString; n <- forAll (Gen.int (Range.linear (-10) 10)); stimesMonoid n s === bool (Just (S.stimesMonoid n s)) Nothing (n < 0)))+    <> prop "stimesIdempotent: the value for n > 0, Nothing otherwise" (property (do a <- forAll genInt; n <- forAll (Gen.int (Range.linear (-10) 10)); stimesIdempotent n (Max a) === bool (Just (Max a)) Nothing (n <= 0)))+    <> prop "stimesIdempotentMonoid: agrees for n >= 0, Nothing below" (property (do b <- forAll Gen.bool; n <- forAll (Gen.int (Range.linear (-10) 10)); stimesIdempotentMonoid n (Any b) === bool (Just (S.stimesIdempotentMonoid n (Any b))) Nothing (n < 0)))+    <> prop "mtimesDefault == stimesMonoid" (property (do s <- forAll genString; n <- forAll (Gen.int (Range.linear (-10) 10)); mtimesDefault n s === stimesMonoid n s))++-- Papa.Base.Data.List++list :: [(PropertyName, Property)]+list =+  prop "cycle: Nothing for [], else repeats" (property (do xs <- forAll genInts; k <- forAll (Gen.int (Range.linear 0 3)); fmap (take (k * length xs)) (cycle xs) === (P.concat (replicate k xs) <$ preview _head xs)))+    <> prop "maximum: Foldable1, the largest" (property (do xs <- forAll genNonEmpty; Just (maximum xs) === maximumOf folded xs; all (<= maximum xs) xs === True))+    <> prop "minimum: Foldable1, the smallest" (property (do xs <- forAll genNonEmpty; Just (minimum xs) === minimumOf folded xs; all (>= minimum xs) xs === True))+    <> prop "lookup: agrees with Data.List" (property (do k <- forAll (Gen.int (Range.linear 0 5)); kvs <- forAll (Gen.list (Range.linear 0 10) ((,) <$> Gen.int (Range.linear 0 5) <*> Gen.alpha)); lookup k kvs === L.lookup k kvs))+    <> prop "(!?): agrees with ix" (property (do xs <- forAll genInts; i <- forAll genSmallInt; (xs !? i) === preview (ix i) xs))+    <> prop "(++): associative" (property (do xs <- forAll genInts; ys <- forAll genInts; zs <- forAll genInts; (xs ++ ys) ++ zs === xs ++ (ys ++ zs)))+    <> prop "(++): Data.List's at lists" (property (do xs <- forAll genInts; ys <- forAll genInts; xs ++ ys === (L.++) xs ys))+    <> prop "(++): infixr 5" (property (do x <- forAll genInt; xs <- forAll genInts; ys <- forAll genInts; (x `elem` xs ++ ys) === elem x (xs <> ys)))+    <> prop "maximumBy: Foldable1, total" (property (do xs <- forAll genNonEmpty; Just (maximumBy (comparing negate) xs) === minimumOf folded xs))+    <> prop "minimumBy: Foldable1, total" (property (do xs <- forAll genNonEmpty; Just (minimumBy (comparing negate) xs) === maximumOf folded xs))++-- Papa.Base.Data.Foldable, Papa.Base.Data.Monoid++foldable :: [(PropertyName, Property)]+foldable =+  prop "mapM_ == traverse_" (property (do xs <- forAll genInts; f <- forAll (genFn genString); runWriter (mapM_ (tell . apply f) xs) === runWriter (traverse_ (tell . apply f) xs)))+    <> prop "forM_ == for_" (property (do xs <- forAll genInts; f <- forAll (genFn genString); runWriter (forM_ xs (tell . apply f)) === runWriter (for_ xs (tell . apply f))))+    <> prop "sequence_ == sequenceA_" (property (do ss <- forAll (Gen.list (Range.linear 0 10) genString); runWriter (sequence_ (fmap tell ss)) === runWriter (sequenceA_ (fmap tell ss))))+    <> prop "concat: Foldable of lists" (property (do xss <- forAll (Gen.list (Range.linear 0 5) genInts); concat xss === foldr (<>) [] xss; concat (Just (P.concat xss)) === P.concat xss))+    <> prop "concatMap: Foldable" (property (do xs <- forAll genNonEmpty; f <- forAll (genFn genInts); concatMap (apply f) xs === foldMap (apply f) xs))+    <> prop "mconcat == foldr (<>) mempty" (property (do ss <- forAll (Gen.list (Range.linear 0 10) genString); mconcat ss === foldr (<>) mempty ss))++-- Papa.Base.Data.Traversable++traversable :: [(PropertyName, Property)]+traversable =+  prop "mapM == traverse" (property (do xs <- forAll genInts; f <- forAll (genFn (Gen.maybe genInt)); mapM (apply f) xs === traverse (apply f) xs))+    <> prop "forM == for" (property (do xs <- forAll genInts; f <- forAll (genFn (Gen.maybe genInt)); forM xs (apply f) === for xs (apply f)))+    <> prop "sequence == sequenceA" (property (do xs <- forAll (Gen.list (Range.linear 0 10) (Gen.maybe genInt)); sequence xs === sequenceA xs))++-- Papa.Base.Data.Function, Papa.Base.Data.Functor, Papa.Base.Control.Applicative++functions :: [(PropertyName, Property)]+functions =+  prop "flip: Prelude's at functions" (property (do f <- forAll (genFn (genFn genInt)); a <- forAll genInt; b <- forAll genInt; flip (apply . apply f) a b === P.flip (apply . apply f) a b))+    <> prop "flip: fmap of application" (property (do fs <- forAll (Gen.list (Range.linear 0 5) (genFn genInt)); a <- forAll genInt; flip (fmap apply fs) a === fmap (`apply` a) fs))+    <> prop "map: Functor identity" (property (do xs <- forAll genInts; map id xs === xs))+    <> prop "map: Functor composition" (property (do xs <- forAll genInts; f <- forAll (genFn genInt); g <- forAll (genFn genInt); map (apply f . apply g) xs === map (apply f) (map (apply g) xs)))+    <> prop "const: Prelude's at functions" (property (do a <- forAll genInt; b <- forAll Gen.alpha; const a b === P.const a b))+    <> prop "const == pure" (property (do a <- forAll genInt; (const a :: Maybe Int) === pure a))+    <> prop "replicateA: replicate in Maybe" (property (do n <- forAll (Gen.int (Range.linear (-5) 10)); a <- forAll genInt; replicateA n (Just a) === Just (replicate n a)))+    <> prop "replicateA_: void of replicateA" (property (do n <- forAll (Gen.int (Range.linear (-5) 6)); replicateA_ n ("ab" :: String) === void (replicateA n ("ab" :: String))))++-- Papa.Base.Control.Monad++monad :: [(PropertyName, Property)]+monad =+  prop "anyM == any" (property (do xs <- forAll genInts; p <- forAll (genFn Gen.bool); anyM (Just . apply p) xs === Just (any (apply p) xs)))+    <> prop "allM == all" (property (do xs <- forAll genInts; p <- forAll (genFn Gen.bool); allM (Just . apply p) xs === Just (all (apply p) xs)))+    <> prop "findM == find" (property (do xs <- forAll genInts; p <- forAll (genFn Gen.bool); findM (Just . apply p) xs === Just (find (apply p) xs)))+    <> prop "anyM: stops at the first True" (property (do xs <- forAll genInts; p <- forAll (genFn Gen.bool); runWriter (anyM (\x -> apply p x <$ tell [x]) xs) === (any (apply p) xs, takeThrough (apply p) xs)))+    <> prop "allM: stops at the first False" (property (do xs <- forAll genInts; p <- forAll (genFn Gen.bool); runWriter (allM (\x -> apply p x <$ tell [x]) xs) === (all (apply p) xs, takeThrough (not . apply p) xs)))+    <> prop "findM: stops at the first True" (property (do xs <- forAll genInts; p <- forAll (genFn Gen.bool); runWriter (findM (\x -> apply p x <$ tell [x]) xs) === (find (apply p) xs, takeThrough (apply p) xs)))++-- | The elements up to and including the first that satisfies the+-- predicate.+takeThrough :: (a -> Bool) -> [a] -> [a]+takeThrough p xs =+  let (as, bs) = break p xs+   in as <> take 1 bs++-- Papa.Base.Data.Either++eithers :: [(PropertyName, Property)]+eithers =+  prop "lefts: the Left values" (property (do xs <- forAll genEithers; toListOf lefts xs === [a | Left a <- xs]))+    <> prop "rights: the Right values" (property (do xs <- forAll genEithers; toListOf rights xs === [b | Right b <- xs]))+    <> prop "prism left: preview (review x) == Just x" (property (do x <- forAll genInt; preview left (review left x :: Either Int Char) === Just x))+    <> prop "prism left: preview s == Just x implies review x == s" (property (do e <- forAll genEither; for_ (preview left e) (\x -> review left x === e)))+    <> prop "prism right: preview (review x) == Just x" (property (do x <- forAll Gen.alpha; preview right (review right x :: Either Int Char) === Just x))+    <> prop "prism right: preview s == Just x implies review x == s" (property (do e <- forAll genEither; for_ (preview right e) (\x -> review right x === e)))+    <> prop "fromLeft: Data.Either's" (property (do d <- forAll genInt; e <- forAll genEither; fromLeft d e === P.either id (P.const d) e))+    <> prop "fromRight: Data.Either's" (property (do d <- forAll Gen.alpha; e <- forAll genEither; fromRight d e === P.either (P.const d) id e))+    <> prop "partitionEithers: lefts and rights" (property (do xs <- forAll genEithers; partitionEithers xs === (toListOf lefts xs, toListOf rights xs)))++-- Papa.Base.Data.Fractional, toIntegralSized++genRational :: Gen Rational+genRational =+  Gen.realFrac_ (Range.linearFracFrom 0 (-100) 100)++fractional :: [(PropertyName, Property)]+fractional =+  prop "divideNonZero: Prelude's" (property (do x <- forAll genRational; y <- forAll genNonZeroRational; divideNonZero x y === (U./) x (the divisor y)))+    <> prop "divideNonZero: (x / y) * y == x" (property (do x <- forAll genRational; y <- forAll genNonZeroRational; divideNonZero x y * the divisor y === x))+    <> prop "recipNonZero == divideNonZero 1" (property (do x <- forAll genNonZeroRational; recipNonZero x === divideNonZero 1 x))+    <> prop "powNonZero: Prelude's" (property (do x <- forAll genNonZeroRational; e <- forAll (Gen.int (Range.linear (-5) 5)); powNonZero x e === (U.^^) (the divisor x) e))+    <> prop "toIntegralSized: Just in range, Nothing outside" (property (do n <- forAll (Gen.int (Range.linear (-300) 300)); (toIntegralSized n :: Maybe Word8) === bool Nothing (Just (P.fromIntegral n)) (0 <= n && n <= 255)))+    <> prop "toIntegralSized: to Natural" (property (do n <- forAll genInteger; (toIntegralSized n :: Maybe Natural) === bool Nothing (Just (P.fromInteger n)) (n >= 0)))++-- Papa.Base.System.Exit++exits :: [(PropertyName, Property)]+exits =+  prop "exitWith: Nothing exactly for ExitFailure 0" (property (do n <- forAll (Gen.int (Range.linearFrom 0 (-255) 255)); has _Just (exitWith (ExitFailure n) :: Maybe (IO ())) === (n /= 0)))+    <> prop "exitWith: Just for ExitSuccess" (property (has _Just (exitWith ExitSuccess :: Maybe (IO ())) === True))++-- Papa.Containers++genMap :: Gen (Map.Map Int Char)+genMap =+  Map.fromList <$> Gen.list (Range.linear 0 20) ((,) <$> Gen.int (Range.linear 0 30) <*> Gen.alpha)++genSet :: Gen (Set.Set Int)+genSet =+  Set.fromList <$> Gen.list (Range.linear 0 20) (Gen.int (Range.linear 0 30))++genIntMap :: Gen (IntMap.IntMap Char)+genIntMap =+  IntMap.fromList <$> Gen.list (Range.linear 0 20) ((,) <$> Gen.int (Range.linear (-30) 30) <*> Gen.alpha)++genIntSet :: Gen IntSet.IntSet+genIntSet =+  IntSet.fromList <$> Gen.list (Range.linear 0 20) (Gen.int (Range.linear (-30) 30))++genSeq :: Gen (Seq.Seq Int)+genSeq =+  Seq.fromList <$> genInts++-- | Lists of pairs in ascending, descending, strictly ascending and any+-- order of keys, with keys in a small range so that some are equal.+genKVs :: Gen [(Int, Char)]+genKVs =+  let kvs = Gen.list (Range.linear 0 10) ((,) <$> Gen.int (Range.linear 0 9) <*> Gen.alpha)+   in Gen.choice [L.sortOn fst <$> kvs, L.sortOn (Down . fst) <$> kvs, L.nubBy (\a b -> fst a == fst b) . L.sortOn fst <$> kvs, kvs]++-- | Lists in ascending, descending, strictly ascending and any order, in a+-- small range so that some are equal.+genXs :: Gen [Int]+genXs =+  let xs = Gen.list (Range.linear 0 10) (Gen.int (Range.linear 0 9))+   in Gen.choice [L.sort <$> xs, L.sortOn Down <$> xs, L.nub . L.sort <$> xs, xs]++-- | A list action with two results.+ab :: String+ab =+  "ab"++-- | Whether an index is in range of a structure of a size.+inRange :: Int -> Int -> Bool+inRange n i =+  0 <= i && i < n++containers :: [(PropertyName, Property)]+containers =+  prop "Map.!: lookup" (property (do m <- forAll genMap; k <- forAll (Gen.int (Range.linear 0 30)); (m Map.! k) === M.lookup k m))+    <> prop "Map.findMin, findMax: lookupMin, lookupMax" (property (do m <- forAll genMap; (Map.findMin m, Map.findMax m) === (M.lookupMin m, M.lookupMax m)))+    <> prop "Map.deleteFindMin, deleteFindMax: base's where non-empty" (property (do m <- forAll genMap; (Map.deleteFindMin m, Map.deleteFindMax m) === bool (Just (M.deleteFindMin m), Just (M.deleteFindMax m)) (Nothing, Nothing) (M.null m)))+    <> prop "Map.elemAt, deleteAt, updateAt: base's in range" (property (do m <- forAll genMap; i <- forAll genSmallInt; (Map.elemAt i m, Map.deleteAt i m, Map.updateAt (\_ _ -> Just 'z') i m) === bool (Nothing, Nothing, Nothing) (Just (M.elemAt i m), Just (M.deleteAt i m), Just (M.updateAt (\_ _ -> Just 'z') i m)) (inRange (M.size m) i)))+    <> prop "Map.findIndex: lookupIndex" (property (do m <- forAll genMap; k <- forAll (Gen.int (Range.linear 0 30)); Map.findIndex k m === M.lookupIndex k m))+    <> prop "Set.findMin, findMax: lookupMin, lookupMax" (property (do s <- forAll genSet; (Set.findMin s, Set.findMax s) === (St.lookupMin s, St.lookupMax s)))+    <> prop "Set.deleteFindMin, deleteFindMax: base's where non-empty" (property (do s <- forAll genSet; (Set.deleteFindMin s, Set.deleteFindMax s) === bool (Just (St.deleteFindMin s), Just (St.deleteFindMax s)) (Nothing, Nothing) (St.null s)))+    <> prop "Set.elemAt, deleteAt: base's in range" (property (do s <- forAll genSet; i <- forAll genSmallInt; (Set.elemAt i s, Set.deleteAt i s) === bool (Nothing, Nothing) (Just (St.elemAt i s), Just (St.deleteAt i s)) (inRange (St.size s) i)))+    <> prop "Set.findIndex: lookupIndex" (property (do s <- forAll genSet; a <- forAll (Gen.int (Range.linear 0 30)); Set.findIndex a s === St.lookupIndex a s))+    <> prop "IntMap.!, findMin, findMax: lookup, lookupMin, lookupMax" (property (do m <- forAll genIntMap; k <- forAll (Gen.int (Range.linear (-30) 30)); (m IntMap.! k, IntMap.findMin m, IntMap.findMax m) === (IM.lookup k m, IM.lookupMin m, IM.lookupMax m)))+    <> prop "IntMap.deleteFindMin, deleteFindMax: base's where non-empty" (property (do m <- forAll genIntMap; (IntMap.deleteFindMin m, IntMap.deleteFindMax m) === bool (Just (IM.deleteFindMin m), Just (IM.deleteFindMax m)) (Nothing, Nothing) (IM.null m)))+    <> prop "IntSet: base's where non-empty" (property (do s <- forAll genIntSet; (IntSet.findMin s, IntSet.findMax s, IntSet.deleteFindMin s, IntSet.deleteFindMax s) === bool (Just (IS.findMin s), Just (IS.findMax s), Just (IS.deleteFindMin s), Just (IS.deleteFindMax s)) (Nothing, Nothing, Nothing, Nothing) (IS.null s)))+    <> prop "Seq.index: lookup" (property (do s <- forAll genSeq; i <- forAll genSmallInt; Seq.index s i === Sq.lookup i s))+    <> prop "Seq.replicate, iterateN, fromFunction: base's for n >= 0" (property (do n <- forAll (Gen.int (Range.linear (-5) 20)); a <- forAll genInt; f <- forAll (genFn genInt); (Seq.replicate n a, Seq.iterateN n (apply f) a, Seq.fromFunction n (apply f)) === bool (Nothing, Nothing, Nothing) (Just (Sq.replicate n a), Just (Sq.iterateN n (apply f) a), Just (Sq.fromFunction n (apply f))) (n >= 0)))+    <> prop "Seq.replicateA, replicateM: base's for n >= 0" (property (do n <- forAll (Gen.int (Range.linear (-3) 4)); (Seq.replicateA n ab, Seq.replicateM n ab) === bool (Nothing, Nothing) (Just (Sq.replicateA n ab), Just (Sq.replicateM n ab)) (n >= 0)))+    <> prop "Seq.chunksOf: base's for n > 0 or empty" (property (do n <- forAll (Gen.int (Range.linear (-3) 6)); s <- forAll genSeq; Seq.chunksOf n s === bool Nothing (Just (Sq.chunksOf n s)) (n > 0 || Sq.null s)))+    <> prop "Seq.cycleTaking: base's for n <= 0 or non-empty" (property (do n <- forAll (Gen.int (Range.linear (-3) 30)); s <- forAll genSeq; Seq.cycleTaking n s === bool Nothing (Just (Sq.cycleTaking n s)) (n <= 0 || not (Sq.null s))))+    <> prop "Seq.scanl1, scanr1: base's where non-empty" (property (do s <- forAll genSeq; (Seq.scanl1 (+) s, Seq.scanr1 (+) s) === bool (Just (Sq.scanl1 (+) s), Just (Sq.scanr1 (+) s)) (Nothing, Nothing) (Sq.null s)))+    <> prop "Map.fromAscList: fromList where ascending, else Nothing" (property (do kvs <- forAll genKVs; Map.fromAscList kvs === bool Nothing (Just (Map.fromList kvs)) (L.sortOn fst kvs == kvs)))+    <> prop "Map.fromAscListWith: fromListWith where ascending, else Nothing" (property (do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs }; Map.fromAscListWith (<>) kss === bool Nothing (Just (Map.fromListWith (<>) kss)) (L.sortOn fst kvs == kvs)))+    <> prop "Map.fromAscListWithKey: fromListWithKey where ascending, else Nothing" (property (do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs; f k a b = show k <> a <> b }; Map.fromAscListWithKey f kss === bool Nothing (Just (Map.fromListWithKey f kss)) (L.sortOn fst kvs == kvs)))+    <> prop "Map.fromDistinctAscList: fromList where strictly ascending, else Nothing" (property (do kvs <- forAll genKVs; Map.fromDistinctAscList kvs === bool Nothing (Just (Map.fromList kvs)) (L.sortOn fst kvs == kvs && L.nub (fmap fst kvs) == fmap fst kvs)))+    <> prop "Map.fromDescList: fromList where descending, else Nothing" (property (do kvs <- forAll genKVs; Map.fromDescList kvs === bool Nothing (Just (Map.fromList kvs)) (L.sortOn (Down . fst) kvs == kvs)))+    <> prop "Map.mapKeysMonotonic: mapKeys where strictly increasing, else Nothing" (property (do m <- forAll (fmap Map.fromList genKVs); c <- forAll (Gen.int (Range.linear (-2) 2)); Map.mapKeysMonotonic (* c) m === bool Nothing (Just (Map.mapKeys (* c) m)) (c > 0 || Map.size m <= 1)))+    <> prop "IntMap.fromAscList: fromList where ascending, else Nothing" (property (do kvs <- forAll genKVs; IntMap.fromAscList kvs === bool Nothing (Just (IntMap.fromList kvs)) (L.sortOn fst kvs == kvs)))+    <> prop "IntMap.fromAscListWith: fromListWith where ascending, else Nothing" (property (do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs }; IntMap.fromAscListWith (<>) kss === bool Nothing (Just (IntMap.fromListWith (<>) kss)) (L.sortOn fst kvs == kvs)))+    <> prop "IntMap.fromAscListWithKey: fromListWithKey where ascending, else Nothing" (property (do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs; f k a b = show k <> a <> b }; IntMap.fromAscListWithKey f kss === bool Nothing (Just (IntMap.fromListWithKey f kss)) (L.sortOn fst kvs == kvs)))+    <> prop "IntMap.fromDistinctAscList: fromList where strictly ascending, else Nothing" (property (do kvs <- forAll genKVs; IntMap.fromDistinctAscList kvs === bool Nothing (Just (IntMap.fromList kvs)) (L.sortOn fst kvs == kvs && L.nub (fmap fst kvs) == fmap fst kvs)))+    <> prop "IntMap.fromDescList: fromList where descending, else Nothing" (property (do kvs <- forAll genKVs; IntMap.fromDescList kvs === bool Nothing (Just (IntMap.fromList kvs)) (L.sortOn (Down . fst) kvs == kvs)))+    <> prop "IntMap.mapKeysMonotonic: mapKeys where strictly increasing, else Nothing" (property (do m <- forAll (fmap IntMap.fromList genKVs); c <- forAll (Gen.int (Range.linear (-2) 2)); IntMap.mapKeysMonotonic (* c) m === bool Nothing (Just (IntMap.mapKeys (* c) m)) (c > 0 || IntMap.size m <= 1)))+    <> prop "Map.fromDescListWith: fromListWith where descending, else Nothing" (property (do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs }; Map.fromDescListWith (<>) kss === bool Nothing (Just (Map.fromListWith (<>) kss)) (L.sortOn (Down . fst) kvs == kvs)))+    <> prop "Map.fromDescListWithKey: fromListWithKey where descending, else Nothing" (property (do kvs <- forAll genKVs; let { kss = fmap (fmap (: [])) kvs; f k a b = show k <> a <> b }; Map.fromDescListWithKey f kss === bool Nothing (Just (Map.fromListWithKey f kss)) (L.sortOn (Down . fst) kvs == kvs)))+    <> prop "Map.fromDistinctDescList: fromList where strictly descending, else Nothing" (property (do kvs <- forAll genKVs; Map.fromDistinctDescList kvs === bool Nothing (Just (Map.fromList kvs)) (L.sortOn (Down . fst) kvs == kvs && L.nub (fmap fst kvs) == fmap fst kvs)))+    <> prop "Map: every built map is valid" (property (do kvs <- forAll genKVs; (all M.valid (Map.fromAscList kvs), all M.valid (Map.fromDescList kvs), all M.valid (Map.fromDistinctAscList kvs)) === (True, True, True)))+    <> prop "Set.fromAscList: fromList where ascending, else Nothing" (property (do xs <- forAll genXs; Set.fromAscList xs === bool Nothing (Just (Set.fromList xs)) (L.sort xs == xs)))+    <> prop "Set.fromDescList: fromList where descending, else Nothing" (property (do xs <- forAll genXs; Set.fromDescList xs === bool Nothing (Just (Set.fromList xs)) (L.sortOn Down xs == xs)))+    <> prop "Set.fromDistinctAscList: fromList where strictly ascending, else Nothing" (property (do xs <- forAll genXs; Set.fromDistinctAscList xs === bool Nothing (Just (Set.fromList xs)) (L.sort xs == xs && L.nub xs == xs)))+    <> prop "Set.mapMonotonic: map where strictly increasing, else Nothing" (property (do s <- forAll (fmap Set.fromList genXs); c <- forAll (Gen.int (Range.linear (-2) 2)); Set.mapMonotonic (* c) s === bool Nothing (Just (Set.map (* c) s)) (c > 0 || Set.size s <= 1)))+    <> prop "IntSet.fromAscList: fromList where ascending, else Nothing" (property (do xs <- forAll genXs; IntSet.fromAscList xs === bool Nothing (Just (IntSet.fromList xs)) (L.sort xs == xs)))+    <> prop "IntSet.fromDescList: fromList where descending, else Nothing" (property (do xs <- forAll genXs; IntSet.fromDescList xs === bool Nothing (Just (IntSet.fromList xs)) (L.sortOn Down xs == xs)))+    <> prop "IntSet.fromDistinctAscList: fromList where strictly ascending, else Nothing" (property (do xs <- forAll genXs; IntSet.fromDistinctAscList xs === bool Nothing (Just (IntSet.fromList xs)) (L.sort xs == xs && L.nub xs == xs)))+    <> prop "IntSet.mapMonotonic: map where strictly increasing, else Nothing" (property (do s <- forAll (fmap IntSet.fromList genXs); c <- forAll (Gen.int (Range.linear (-2) 2)); IntSet.mapMonotonic (* c) s === bool Nothing (Just (IntSet.map (* c) s)) (c > 0 || IntSet.size s <= 1)))+    <> prop "Set.fromDistinctDescList: fromList where strictly descending, else Nothing" (property (do xs <- forAll genXs; Set.fromDistinctDescList xs === bool Nothing (Just (Set.fromList xs)) (L.sortOn Down xs == xs && L.nub xs == xs)))+    <> prop "Set: every built set is valid" (property (do xs <- forAll genXs; (all St.valid (Set.fromAscList xs), all St.valid (Set.fromDescList xs)) === (True, True)))++-- Papa.Base.Data.Maybe++maybes :: [(PropertyName, Property)]+maybes =+  prop "whenJust: never applies is id" (property (do f <- forAll (genFn genInt :: Gen (Fn Int Int)); a <- forAll genInt; whenJust (P.const Nothing) (apply f) a === a))+    <> prop "whenJust: always applies is composition" (property (do f <- forAll (genFn genInt); g <- forAll (genFn genInt); a <- forAll genInt; whenJust (Just . apply g) (apply f) a === apply f (apply g a)))+    <> prop "whenJust: maybe a f (p a)" (property (do p <- forAll (genFn (Gen.maybe genInt)); f <- forAll (genFn genInt); a <- forAll genInt; whenJust (apply p) (apply f) a === maybe a (apply f) (apply p a)))+    <> prop "whenJustM: never applies is pure" (property (do f <- forAll (genFn (Gen.maybe genInt) :: Gen (Fn Int (Maybe Int))); a <- forAll genInt; whenJustM (\_ -> Just Nothing) (apply f) a === Just a))+    <> prop "whenJustM: always applies is Kleisli composition" (property (do f <- forAll (genFn (Gen.maybe genInt)); g <- forAll (genFn (Gen.maybe genInt)); a <- forAll genInt; whenJustM (fmap Just . apply g) (apply f) a === (apply g >=> apply f) a))+    <> prop "whenJustM: whenJust at Identity" (property (do p <- forAll (genFn (Gen.maybe genInt)); f <- forAll (genFn genInt); a <- forAll genInt; runIdentity (whenJustM (Identity . apply p) (Identity . apply f) a) === whenJust (apply p) (apply f) a))+    <> prop "whenJustM: effects of the step, then of f where it applies" (property (do p <- forAll (genFn (Gen.maybe genInt)); f <- forAll (genFn genInt); a <- forAll genInt; runWriter (whenJustM (\x -> apply p x <$ tell [x]) (\b -> apply f b <$ tell [b]) a) === (maybe a (apply f) (apply p a), a : toList (apply p a))))++-- Papa.Base.Data.List.NonEmpty: the lens laws of head, tail, last, init++nonEmptyLenses :: [(PropertyName, Property)]+nonEmptyLenses =+  lensLaws "head" head genInt+    <> lensLaws "tail" tail genInts+    <> lensLaws "last" last genInt+    <> lensLaws "init" init genInts+    <> prop "init <> [last] == toList" (property (do s <- forAll genNonEmpty; the init s <> [the last s] === toList s))+    <> prop "head : tail == toList" (property (do s <- forAll genNonEmpty; the head s : the tail s === toList s))++-- | The three lens laws, of a lens into a 'NonEmpty' 'Int'.+lensLaws :: (Eq a, Show a) => PropertyName -> Lens' (NonEmpty Int) a -> Gen a -> [(PropertyName, Property)]+lensLaws name l genA =+  prop (name <> ": the l (set l a s) == a") (property (do s <- forAll genNonEmpty; a <- forAll genA; the l (set l a s) === a))+    <> prop (name <> ": set l (the l s) s == s") (property (do s <- forAll genNonEmpty; set l (the l s) s === s))+    <> prop (name <> ": set l b (set l a s) == set l b s") (property (do s <- forAll genNonEmpty; a <- forAll genA; b <- forAll genA; set l b (set l a s) === set l b s))++-- Papa.Lens.Data.List, Papa.Lens.Data.Tuple++optics :: [(PropertyName, Property)]+optics =+  prop "(!!): agrees with (!?) at lists" (property (do xs <- forAll genInts; i <- forAll genSmallInt; (xs !! i) === (xs !? i)))+    <> prop "(!!): NonEmpty" (property (do xs <- forAll genNonEmpty; i <- forAll genSmallInt; (xs !! i) === (toList xs !? i)))+    <> prop "fst: Prelude's at pairs" (property (do a <- forAll genInt; b <- forAll Gen.alpha; fst (a, b) === P.fst (a, b)))+    <> prop "snd: Prelude's at pairs" (property (do a <- forAll genInt; b <- forAll Gen.alpha; snd (a, b) === P.snd (a, b)))+    <> prop "fst, snd: triples" (property (do a <- forAll genInt; b <- forAll Gen.alpha; c <- forAll Gen.bool; (fst (a, b, c), snd (a, b, c)) === (a, b)))++-- Papa.Bifunctors.Data.Bifoldable, Papa.Base.Control.Arrow++bifunctors :: [(PropertyName, Property)]+bifunctors =+  prop "biconcat: pairs" (property (do a <- forAll genString; b <- forAll genString; biconcat (a, b) === a <> b))+    <> prop "biconcat: Either" (property (do e <- forAll (Gen.either genString genString); biconcat e === P.either id id e))+    <> prop "biconcatMap == bifoldMap" (property (do f <- forAll (genFn genString); g <- forAll (genFn genString); e <- forAll (Gen.either genInt Gen.bool); biconcatMap (apply f) (apply g) e === bifoldMap (apply f) (apply g) e))+    <> prop "leftA: Bifunctor's first at Either" (property (do f <- forAll (genFn genInt); e <- forAll genEither; leftA (apply f) e === B.first (apply f) e))+    <> prop "rightA: Bifunctor's second at Either" (property (do f <- forAll (genFn genInt); e <- forAll (Gen.either Gen.alpha genInt); rightA (apply f) e === B.second (apply f) e))+    <> prop "firstA: Bifunctor's first at functions" (property (do f <- forAll (genFn genInt); a <- forAll genInt; c <- forAll Gen.alpha; firstA (apply f) (a, c) === B.first (apply f) (a, c)))+    <> prop "secondA: Bifunctor's second at functions" (property (do f <- forAll (genFn genInt); a <- forAll genInt; c <- forAll Gen.alpha; secondA (apply f) (c, a) === B.second (apply f) (c, a)))
+ test/PropertiesAsync.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TupleSections #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The properties of Papa's structured concurrency.+module PropertiesAsync (+  propertiesAsync,+) where++import qualified Control.Concurrent.Async as A+import qualified Control.Exception as E+import Hedgehog (Gen, Group (Group), Property, PropertyName, evalIO, forAll, property, withTests, (===))+import Hedgehog.Function (apply, fn)+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import System.IO.Error (ioeGetErrorString)++-- | The properties of Papa's structured concurrency.+propertiesAsync :: Group+propertiesAsync =+  Group "papa: structured concurrency" (waits <> combinators <> excepts)++prop :: PropertyName -> Property -> [(PropertyName, Property)]+prop name p =+  [(name, p)]++genInt :: Gen Int+genInt =+  Gen.int (Range.linear (-100) 100)++genInts :: Gen [Int]+genInts =+  Gen.list (Range.linear 0 20) genInt++-- | An action that returns the value or throws the string as a 'userError'.+returnsOrThrows :: Either String Int -> IO Int+returnsOrThrows =+  either (throwIO . userError) pure++-- | A long wait, which a test cancels.+long :: IO ()+long =+  threadDelay 10000000++-- | The message of a 'userError'.+message :: SomeException -> Maybe String+message e =+  ioeGetErrorString <$> E.fromException e++waits :: [(PropertyName, Property)]+waits =+  prop "waitExcept agrees with waitCatch" (property (do x <- forAll (Gen.either (Gen.string (Range.linear 0 5) Gen.alpha) genInt); r <- evalIO (withAsync (returnsOrThrows x) (\a -> (,) <$> runExceptT (waitExcept a) <*> A.waitCatch a)); bimap (over _Left message) (over _Left message) r === (over _Left Just x, over _Left Just x)))+    <> prop "waitExcept: Right the result, Left the exception" (property (do x <- forAll (Gen.either (Gen.string (Range.linear 0 5) Gen.alpha) genInt); r <- evalIO (withAsync (returnsOrThrows x) (runExceptT . waitExcept)); over _Left message r === over _Left Just x))+    <> prop "poll: Nothing while running, then the result" (withTests 20 (property (do x <- forAll genInt; r <- evalIO (do v <- newEmptyMVar; withAsync (takeMVar v $> x) (\a -> do p <- poll a; putMVar v (); w <- waitCatch a; q <- poll a; pure (fmap (preview _Right) p, preview _Right w, fmap (preview _Right) q))); r === (Nothing, Just x, Just (Just x)))))+    <> prop "waitAnyCatch: the thread that ends first" (property (do x <- forAll genInt; ys <- forAll (Gen.list (Range.linear 0 5) genInt); r <- evalIO (withAsync (pure x) (\a -> traverse (\y -> async (long $> y)) ys >>= \bs -> waitAnyCatch (a :| bs) <* traverse cancel bs)); preview _Right (snd r) === Just x))+    <> prop "waitAnyCatchSTM agrees with waitAnyCatch" (property (do xs <- forAll (Gen.nonEmpty (Range.linear 1 5) genInt); r <- evalIO (traverse (async . pure) xs >>= \as -> (,) <$> (traverse waitCatch as *> fmap (preview _Right . snd) (waitAnyCatch as)) <*> fmap (preview _Right . snd) (atomically (waitAnyCatchSTM as))); fmap (`elem` xs) (fst r) === Just True))+    <> prop "waitAnyCatchCancel: cancels the others" (withTests 20 (property (do x <- forAll genInt; r <- evalIO (do a <- async (pure x); b <- async (long $> x); _ <- waitAnyCatchCancel (a :| [b]); waitCatch b); either (has (filtered (\e -> isJust (E.fromException e :: Maybe AsyncCancelled)))) (const False) r === True)))+    <> prop "waitEitherCatch: the first to end" (property (do x <- forAll genInt; b <- forAll Gen.bool; r <- evalIO (withAsync (bool long (pure ()) b $> x) (withAsync (bool (pure ()) long b $> x) . waitEitherCatch)); either (\e -> (True, preview _Right e)) (\e -> (False, preview _Right e)) r === (b, Just x)))+    <> prop "waitEitherCatchSTM agrees with waitEitherCatch" (withTests 20 (property (do x <- forAll genInt; r <- evalIO (withAsync (pure x) (\l -> withAsync long (atomically . waitEitherCatchSTM l))); either (preview _Right) (const Nothing) r === Just x)))+    <> prop "waitEitherCatchCancel: cancels the other" (withTests 20 (property (do x <- forAll genInt; r <- evalIO (do l <- async (pure x); q <- async long; _ <- waitEitherCatchCancel l q; waitCatch q); isLeft r === True)))+    <> prop "cancel: the thread ends with AsyncCancelled" (withTests 20 (property (do r <- evalIO (do a <- async long; cancel a; waitCatch a); either (\e -> isJust (E.fromException e :: Maybe AsyncCancelled)) (const False) r === True)))+    <> prop "withAsync: cancels the thread when the scope ends" (withTests 20 (property (do r <- evalIO (withAsync long pure >>= waitCatch); isLeft r === True)))++combinators :: [(PropertyName, Property)]+combinators =+  prop "concurrently: both results" (property (do x <- forAll genInt; y <- forAll genInt; r <- evalIO (concurrently (pure x) (pure y)); r === (x, y)))+    <> prop "concurrently: the exception of either, which cancels the other" (property (do s <- forAll (Gen.string (Range.linear 0 5) Gen.alpha); b <- forAll Gen.bool; r <- evalIO (E.try (bool (concurrently (throwIO (userError s)) long $> ()) (concurrently long (throwIO (userError s)) $> ()) b)); over _Left ioeGetErrorString r === Left s))+    <> prop "concurrently_, race_: unit" (withTests 20 (property (do r <- evalIO ((,) <$> concurrently_ (pure ()) (pure ()) <*> race_ (pure ()) long); r === ((), ()))))+    <> prop "race: the first to end" (property (do x <- forAll genInt; b <- forAll Gen.bool; r <- evalIO (bool (race (long $> x) (pure x)) (race (pure x) (long $> x)) b); r === bool (Right x) (Left x) b))+    <> prop "mapConcurrently, forConcurrently agree with fmap" (property (do f <- forAll (fn genInt); xs <- forAll genInts; r <- evalIO ((,) <$> mapConcurrently (pure . apply f) xs <*> forConcurrently xs (pure . apply f)); r === (fmap (apply f) xs, fmap (apply f) xs)))+    <> prop "mapConcurrently_, forConcurrently_ run each action" (property (do xs <- forAll genInts; r <- evalIO (do v <- newIORef (0 :: Int); mapConcurrently_ (\x -> atomicModifyIORef' v (\n -> (n + x, ()))) xs; forConcurrently_ xs (\x -> atomicModifyIORef' v (\n -> (n + x, ()))); readIORef v); r === 2 * sum xs))+    <> prop "replicateConcurrently agrees with replicate, and is total at a negative count" (property (do n <- forAll (Gen.int (Range.linear (-5) 20)); x <- forAll genInt; r <- evalIO ((,) <$> replicateConcurrently n (pure x) <*> replicateConcurrently_ n (pure x)); r === (replicate n x, ())))+    <> prop "Concurrently: <*> runs both, <|> the first to end" (property (do f <- forAll (fn genInt); x <- forAll genInt; r <- evalIO ((,) <$> runConcurrently (apply f <$> Concurrently (pure x)) <*> runConcurrently (Concurrently (long $> x) <|> Concurrently (pure (apply f x)))); r === (apply f x, apply f x)))++excepts :: [(PropertyName, Property)]+excepts =+  prop "concurrentlyExcept: both results, or a failure (either, when both fail)" (property (do a <- forAll (Gen.either Gen.alpha genInt); b <- forAll (Gen.either Gen.alpha genInt); r <- evalIO (runExceptT (concurrentlyExcept (ExceptT (pure a)) (ExceptT (pure b)))); bool (r === ((,) <$> a <*> b)) ((r `elem` [over _Right (,0) a, over _Right (0,) b]) === True) (isLeft a && isLeft b)))+    <> prop "concurrentlyExcept: the first failure cancels the other" (withTests 20 (property (do e <- forAll Gen.alpha; r <- evalIO (runExceptT (concurrentlyExcept (ExceptT (pure (Left e))) (ExceptT (long $> Right ())))); r === (Left e :: Either Char ((), ())))))+    <> prop "concurrentlyE agrees with concurrentlyExcept, where at most one fails" (property (do a <- forAll (Gen.either Gen.alpha genInt); b <- forAll (bool (Gen.either Gen.alpha genInt) (Right <$> genInt) (isLeft a)); r <- evalIO ((,) <$> concurrentlyE (pure a) (pure b) <*> runExceptT (concurrentlyExcept (ExceptT (pure a)) (ExceptT (pure b)))); uncurry (===) r))+    <> prop "raceExcept: the result or failure of the first to end" (property (do a <- forAll (Gen.either Gen.alpha genInt); b <- forAll Gen.bool; r <- evalIO (runExceptT (bool (raceExcept (ExceptT (long $> Right ())) (ExceptT (pure a))) (raceExcept (ExceptT (pure a)) (ExceptT (long $> Right ())) <&> either Right Left) b)); r === fmap Right a))+    <> prop "IOExcept: failures in threads are values" (property (do n <- forAll (Gen.string (Range.linear 1 8) Gen.alphaNum); r <- evalIO (concurrently (runExceptT (removeFile ("/nonexistent/papa/" <> n))) (runExceptT (pure n :: IOExcept String))); first isLeft r === (True, Right n)))
+ test/PropertiesContainers.hs view
@@ -0,0 +1,180 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these properties compare Papa's total functions with the partial+-- ones of containers, whose names HLint restricts.++-- | The agreement of the total functions of "Papa.Containers" with the+-- partial ones of containers they replace: each is 'Nothing' exactly where+-- containers' throws, and containers' result everywhere else; each+-- order-checked builder is containers' result exactly where the input is in+-- order (where containers' result is a valid structure), and 'Nothing'+-- everywhere else.+module PropertiesContainers (+  propertiesContainers,+) where++import Agree (agrees)+import qualified Data.IntMap.Strict as IM+import qualified Data.IntSet as IS+import qualified Data.List as L+import qualified Data.Map.Strict as M+import qualified Data.Sequence as Sq+import qualified Data.Set as St+import Hedgehog (Gen, Group (Group), Property, PropertyName, forAll, forAllWith, property, (===))+import Hedgehog.Function (apply, fn)+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import qualified Papa.Containers.Data.IntMap as IntMap+import qualified Papa.Containers.Data.IntSet as IntSet+import qualified Papa.Containers.Data.Map as Map+import qualified Papa.Containers.Data.Seq as Seq+import qualified Papa.Containers.Data.Set as Set++-- | Every property of this module, in one group.+propertiesContainers :: Group+propertiesContainers =+  Group (fromString "papa: containers agreement") (partials <> builders)++-- | One named property.+prop :: String -> Property -> [(PropertyName, Property)]+prop name p =+  [(fromString name, p)]++-- Generators++genKey :: Gen Int+genKey =+  Gen.int (Range.linear (-20) 20)++genIndex :: Gen Int+genIndex =+  Gen.int (Range.linear (-3) 25)++-- | Lists of pairs, often in ascending or descending order of keys, with or+-- without duplicates.+genKVs :: Gen [(Int, Int)]+genKVs =+  Gen.choice+    [ raw+    , L.sortOn fst <$> raw+    , L.sortOn (Down . fst) <$> raw+    , L.nubBy (\a b -> fst a == fst b) . L.sortOn fst <$> raw+    , L.nubBy (\a b -> fst a == fst b) . L.sortOn (Down . fst) <$> raw+    ]+ where+  raw = Gen.list (Range.linear 0 20) ((,) <$> genKey <*> genKey)++genKeys :: Gen [Int]+genKeys =+  fmap (fmap fst) genKVs++genMap :: Gen (Map Int Int)+genMap =+  M.fromList <$> genKVs++genSet :: Gen (Set Int)+genSet =+  St.fromList <$> genKeys++genIntMap :: Gen (IntMap Int)+genIntMap =+  IM.fromList <$> genKVs++genIntSet :: Gen IntSet+genIntSet =+  IS.fromList <$> genKeys++genSeq :: Gen (Seq Int)+genSeq =+  Sq.fromList <$> genKeys++-- | A function, often strictly increasing.+genKeyFn :: Gen (String, Int -> Int)+genKeyFn =+  Gen.choice+    [ (\c -> ("(+ " <> show c <> ")", (+ c))) <$> genKey+    , (\c -> ("(* " <> show c <> ")", (* c))) <$> Gen.int (Range.linear (-3) 3)+    , (\f -> (show f, apply f)) <$> fn genKey+    ]++-- | Whether a list is in order by a relation of adjacent elements.+ordered :: (a -> a -> Bool) -> [a] -> Bool+ordered r xs =+  and (L.zipWith r xs (L.drop 1 xs))++-- Partial functions++-- | Each total function is containers' partial one, 'Nothing' exactly where+-- that throws.+partials :: [(PropertyName, Property)]+partials =+  prop "Map.!" (property (do m <- forAll genMap; k <- forAll genKey; agrees (m Map.! k) (m M.! k)))+    <> prop "Map.findMin" (property (do m <- forAll genMap; agrees (Map.findMin m) (M.findMin m)))+    <> prop "Map.findMax" (property (do m <- forAll genMap; agrees (Map.findMax m) (M.findMax m)))+    <> prop "Map.deleteFindMin" (property (do m <- forAll genMap; agrees (Map.deleteFindMin m) (M.deleteFindMin m)))+    <> prop "Map.deleteFindMax" (property (do m <- forAll genMap; agrees (Map.deleteFindMax m) (M.deleteFindMax m)))+    <> prop "Map.elemAt" (property (do m <- forAll genMap; i <- forAll genIndex; agrees (Map.elemAt i m) (M.elemAt i m)))+    <> prop "Map.findIndex" (property (do m <- forAll genMap; k <- forAll genKey; agrees (Map.findIndex k m) (M.findIndex k m)))+    <> prop "Map.deleteAt" (property (do m <- forAll genMap; i <- forAll genIndex; agrees (Map.deleteAt i m) (M.deleteAt i m)))+    <> prop "Map.updateAt" (property (do m <- forAll genMap; i <- forAll genIndex; f <- forAll (fn (Gen.maybe genKey)); agrees (Map.updateAt (\_ -> apply f) i m) (M.updateAt (\_ -> apply f) i m)))+    <> prop "Set.findMin" (property (do s <- forAll genSet; agrees (Set.findMin s) (St.findMin s)))+    <> prop "Set.findMax" (property (do s <- forAll genSet; agrees (Set.findMax s) (St.findMax s)))+    <> prop "Set.deleteFindMin" (property (do s <- forAll genSet; agrees (Set.deleteFindMin s) (St.deleteFindMin s)))+    <> prop "Set.deleteFindMax" (property (do s <- forAll genSet; agrees (Set.deleteFindMax s) (St.deleteFindMax s)))+    <> prop "Set.elemAt" (property (do s <- forAll genSet; i <- forAll genIndex; agrees (Set.elemAt i s) (St.elemAt i s)))+    <> prop "Set.findIndex" (property (do s <- forAll genSet; a <- forAll genKey; agrees (Set.findIndex a s) (St.findIndex a s)))+    <> prop "Set.deleteAt" (property (do s <- forAll genSet; i <- forAll genIndex; agrees (Set.deleteAt i s) (St.deleteAt i s)))+    <> prop "IntMap.!" (property (do m <- forAll genIntMap; k <- forAll genKey; agrees (m IntMap.! k) (m IM.! k)))+    <> prop "IntMap.findMin" (property (do m <- forAll genIntMap; agrees (IntMap.findMin m) (IM.findMin m)))+    <> prop "IntMap.findMax" (property (do m <- forAll genIntMap; agrees (IntMap.findMax m) (IM.findMax m)))+    <> prop "IntMap.deleteFindMin" (property (do m <- forAll genIntMap; agrees (IntMap.deleteFindMin m) (IM.deleteFindMin m)))+    <> prop "IntMap.deleteFindMax" (property (do m <- forAll genIntMap; agrees (IntMap.deleteFindMax m) (IM.deleteFindMax m)))+    <> prop "IntSet.findMin" (property (do s <- forAll genIntSet; agrees (IntSet.findMin s) (IS.findMin s)))+    <> prop "IntSet.findMax" (property (do s <- forAll genIntSet; agrees (IntSet.findMax s) (IS.findMax s)))+    <> prop "IntSet.deleteFindMin" (property (do s <- forAll genIntSet; agrees (IntSet.deleteFindMin s) (IS.deleteFindMin s)))+    <> prop "IntSet.deleteFindMax" (property (do s <- forAll genIntSet; agrees (IntSet.deleteFindMax s) (IS.deleteFindMax s)))+    <> prop "Seq.index" (property (do s <- forAll genSeq; i <- forAll genIndex; agrees (Seq.index s i) (Sq.index s i)))+    <> prop "Seq.replicate" (property (do n <- forAll genIndex; a <- forAll genKey; agrees (Seq.replicate n a) (Sq.replicate n a)))+    <> prop "Seq.replicateA" (property (do n <- forAll genIndex; a <- forAll (Gen.maybe genKey); agrees (Seq.replicateA n a) (Sq.replicateA n a)))+    <> prop "Seq.replicateM" (property (do n <- forAll genIndex; a <- forAll (Gen.maybe genKey); agrees (Seq.replicateM n a) (Sq.replicateM n a)))+    <> prop "Seq.iterateN" (property (do n <- forAll genIndex; f <- forAll (fn genKey); a <- forAll genKey; agrees (Seq.iterateN n (apply f) a) (Sq.iterateN n (apply f) a)))+    <> prop "Seq.fromFunction" (property (do n <- forAll genIndex; f <- forAll (fn genKey); agrees (Seq.fromFunction n (apply f)) (Sq.fromFunction n (apply f))))+    <> prop "Seq.chunksOf" (property (do n <- forAll (Gen.int (Range.linear (-3) 6)); s <- forAll genSeq; agrees (Seq.chunksOf n s) (Sq.chunksOf n s)))+    <> prop "Seq.cycleTaking" (property (do n <- forAll genIndex; s <- forAll genSeq; agrees (Seq.cycleTaking n s) (Sq.cycleTaking n s)))+    <> prop "Seq.scanl1" (property (do s <- forAll genSeq; agrees (Seq.scanl1 (+) s) (Sq.scanl1 (+) s)))+    <> prop "Seq.scanr1" (property (do s <- forAll genSeq; agrees (Seq.scanr1 (+) s) (Sq.scanr1 (+) s)))++-- Order-checked builders++-- | Each builder that checks the order of its input is containers' builder+-- exactly where the input is in order (where containers' result is valid),+-- and 'Nothing' everywhere else.+builders :: [(PropertyName, Property)]+builders =+  prop "Map.fromAscList" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<=) (fmap fst kvs); r = M.fromAscList kvs }; Map.fromAscList kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromAscListWith" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<=) (fmap fst kvs); r = M.fromAscListWith (-) kvs }; Map.fromAscListWith (-) kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromAscListWithKey" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<=) (fmap fst kvs); f k a b = k + a - b; r = M.fromAscListWithKey f kvs }; Map.fromAscListWithKey f kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromDistinctAscList" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<) (fmap fst kvs); r = M.fromDistinctAscList kvs }; Map.fromDistinctAscList kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromDescList" (property (do kvs <- forAll genKVs; let { inOrder = ordered (>=) (fmap fst kvs); r = M.fromDescList kvs }; Map.fromDescList kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromDescListWith" (property (do kvs <- forAll genKVs; let { inOrder = ordered (>=) (fmap fst kvs); r = M.fromDescListWith (-) kvs }; Map.fromDescListWith (-) kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromDescListWithKey" (property (do kvs <- forAll genKVs; let { inOrder = ordered (>=) (fmap fst kvs); f k a b = k + a - b; r = M.fromDescListWithKey f kvs }; Map.fromDescListWithKey f kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.fromDistinctDescList" (property (do kvs <- forAll genKVs; let { inOrder = ordered (>) (fmap fst kvs); r = M.fromDistinctDescList kvs }; Map.fromDistinctDescList kvs === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Map.mapKeysMonotonic" (property (do m <- forAll genMap; (_, f) <- forAllWith fst genKeyFn; let { inOrder = ordered (<) (fmap f (M.keys m)); r = M.mapKeysMonotonic f m }; Map.mapKeysMonotonic f m === bool Nothing (Just r) inOrder; when inOrder (M.valid r === True)))+    <> prop "Set.fromAscList" (property (do xs <- forAll genKeys; let { inOrder = ordered (<=) xs; r = St.fromAscList xs }; Set.fromAscList xs === bool Nothing (Just r) inOrder; when inOrder (St.valid r === True)))+    <> prop "Set.fromDescList" (property (do xs <- forAll genKeys; let { inOrder = ordered (>=) xs; r = St.fromDescList xs }; Set.fromDescList xs === bool Nothing (Just r) inOrder; when inOrder (St.valid r === True)))+    <> prop "Set.fromDistinctAscList" (property (do xs <- forAll genKeys; let { inOrder = ordered (<) xs; r = St.fromDistinctAscList xs }; Set.fromDistinctAscList xs === bool Nothing (Just r) inOrder; when inOrder (St.valid r === True)))+    <> prop "Set.fromDistinctDescList" (property (do xs <- forAll genKeys; let { inOrder = ordered (>) xs; r = St.fromDistinctDescList xs }; Set.fromDistinctDescList xs === bool Nothing (Just r) inOrder; when inOrder (St.valid r === True)))+    <> prop "Set.mapMonotonic" (property (do s <- forAll genSet; (_, f) <- forAllWith fst genKeyFn; let { inOrder = ordered (<) (fmap f (St.toAscList s)); r = St.mapMonotonic f s }; Set.mapMonotonic f s === bool Nothing (Just r) inOrder; when inOrder (St.valid r === True)))+    <> prop "IntMap.fromAscList" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<=) (fmap fst kvs); r = IM.fromAscList kvs }; IntMap.fromAscList kvs === bool Nothing (Just r) inOrder))+    <> prop "IntMap.fromAscListWith" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<=) (fmap fst kvs); r = IM.fromAscListWith (-) kvs }; IntMap.fromAscListWith (-) kvs === bool Nothing (Just r) inOrder))+    <> prop "IntMap.fromAscListWithKey" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<=) (fmap fst kvs); f k a b = k + a - b; r = IM.fromAscListWithKey f kvs }; IntMap.fromAscListWithKey f kvs === bool Nothing (Just r) inOrder))+    <> prop "IntMap.fromDistinctAscList" (property (do kvs <- forAll genKVs; let { inOrder = ordered (<) (fmap fst kvs); r = IM.fromDistinctAscList kvs }; IntMap.fromDistinctAscList kvs === bool Nothing (Just r) inOrder))+    <> prop "IntMap.fromDescList: fromList where descending" (property (do kvs <- forAll genKVs; let { inOrder = ordered (>=) (fmap fst kvs); r = IM.fromList kvs }; IntMap.fromDescList kvs === bool Nothing (Just r) inOrder))+    <> prop "IntMap.mapKeysMonotonic" (property (do m <- forAll genIntMap; (_, f) <- forAllWith fst genKeyFn; let { inOrder = ordered (<) (fmap f (IM.keys m)); r = IM.mapKeysMonotonic f m }; IntMap.mapKeysMonotonic f m === bool Nothing (Just r) inOrder))+    <> prop "IntSet.fromAscList" (property (do xs <- forAll genKeys; let { inOrder = ordered (<=) xs; r = IS.fromAscList xs }; IntSet.fromAscList xs === bool Nothing (Just r) inOrder))+    <> prop "IntSet.fromDescList: fromList where descending" (property (do xs <- forAll genKeys; let { inOrder = ordered (>=) xs; r = IS.fromList xs }; IntSet.fromDescList xs === bool Nothing (Just r) inOrder))+    <> prop "IntSet.fromDistinctAscList" (property (do xs <- forAll genKeys; let { inOrder = ordered (<) xs; r = IS.fromDistinctAscList xs }; IntSet.fromDistinctAscList xs === bool Nothing (Just r) inOrder))+    <> prop "IntSet.mapMonotonic" (property (do s <- forAll genIntSet; (_, f) <- forAllWith fst genKeyFn; let { inOrder = ordered (<) (fmap f (IS.toAscList s)); r = IS.mapMonotonic f s }; IntSet.mapMonotonic f s === bool Nothing (Just r) inOrder))
+ test/PropertiesFS.hs view
@@ -0,0 +1,118 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++-- | The properties of Papa's files, directories and paths.+module PropertiesFS (+  propertiesFS,+  propertiesCurrentDirectory,+) where++import qualified Control.Exception as E+import qualified Data.ByteString as SB+import qualified Data.Time as Time+import Hedgehog (Gen, Group (Group), Property, PropertyName, PropertyT, evalIO, forAll, property, withTests, (===))+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import qualified System.Directory as D+import qualified System.FilePath as F+import qualified System.IO as IO+import qualified Prelude as P++-- | The properties of Papa's files, directories and paths.+propertiesFS :: Group+propertiesFS =+  Group "papa: files, directories, paths" (directories <> files <> paths)++-- | The properties of the current directory, which is the process's: they+-- are checked one at a time, apart from all others, which they would+-- disturb.+propertiesCurrentDirectory :: Group+propertiesCurrentDirectory =+  Group "papa: the current directory" currentDirectory++prop :: PropertyName -> Property -> [(PropertyName, Property)]+prop name p =+  [(name, p)]++genName :: Gen String+genName =+  Gen.string (Range.linear 1 8) Gen.alphaNum++genNames :: Gen [String]+genNames =+  nubOrd <$> Gen.list (Range.linear 0 8) genName++-- | Any string, of the characters that matter to paths.+genPath :: Gen String+genPath =+  Gen.string (Range.linear 0 30) (Gen.frequency [(5, Gen.element ("/.\\:a b\0" :: String)), (1, Gen.unicode)])++-- | Run a property in a new, empty directory, removed afterwards.+withDir :: (FilePath -> PropertyT IO a) -> PropertyT IO a+withDir k = do+  d <- evalIO (D.getTemporaryDirectory >>= \t -> IO.openTempFile t "papa-fs" >>= \(p, h) -> IO.hClose h *> D.removeFile p *> D.createDirectory p $> p)+  a <- k d+  evalIO (D.removePathForcibly d)+  pure a++-- | Papa's action returns 'Right' what the action of "System.Directory"+-- returns, or 'Left' the 'IOException' it throws, as an 'IOFailed'.+agreesIO :: (Eq a, Show a) => IOExcept a -> IO a -> PropertyT IO ()+agreesIO papa directory = do+  p <- evalIO (runExceptT papa)+  d <- evalIO (tryIO directory)+  p === over _Left IOFailed d++tryIO :: IO a -> IO (Either IOException a)+tryIO =+  E.try++isNoSuchThing :: Either IOFailure a -> Bool+isNoSuchThing =+  either (anyOf _IOException (has _NoSuchThing . the errorType)) (const False)++directories :: [(PropertyName, Property)]+directories =+  prop "doesFileExist, doesDirectoryExist, doesPathExist agree with System.Directory" (property (do fs <- forAll genNames; ds <- forAll genNames; q <- forAll genName; withDir (\d -> do evalIO (for_ fs (\f -> D.createDirectoryIfMissing True (d </> "f") *> SB.writeFile (d </> "f" </> f) "")); evalIO (for_ ds (\x -> D.createDirectoryIfMissing True (d </> "d" </> x))); for_ ((d </> "f" </> q) : (d </> "d" </> q) : fmap ((d </> "f") </>) fs <> fmap ((d </> "d") </>) ds) (\p -> agreesIO (doesFileExist p) (D.doesFileExist p) *> agreesIO (doesDirectoryExist p) (D.doesDirectoryExist p) *> agreesIO (doesPathExist p) (D.doesPathExist p)))))+    <> prop "listDirectory: the names created, without . and .." (property (do fs <- forAll genNames; ds <- forAll genNames; withDir (\d -> do r <- evalIO (runExceptT (for_ fs (\f -> writeFile (d </> ("f" <> f)) (pack f)) *> for_ ds (\x -> createDirectory (d </> ("d" <> x))) *> listDirectory d)); fmap sort r === Right (sort (fmap ("f" <>) fs <> fmap ("d" <>) ds)))))+    <> prop "listDirectory agrees with System.Directory" (property (do n <- forAll genName; withDir (\d -> agreesIO (sort <$> listDirectory (d </> n)) (sort <$> D.listDirectory (d </> n)) *> agreesIO (sort <$> listDirectory d) (sort <$> D.listDirectory d))))+    <> prop "createDirectory: the directory, then AlreadyExists" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (createDirectory (d </> n) *> doesDirectoryExist (d </> n))); s <- evalIO (runExceptT (createDirectory (d </> n))); (r, either (anyOf _IOException (has _AlreadyExists . the errorType)) (const False) s) === (Right True, True))))+    <> prop "createDirectory: NoSuchThing without the parent" (property (do a <- forAll genName; b <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (createDirectory (d </> a </> b))); isNoSuchThing r === True)))+    <> prop "createDirectoryIfMissing True: every parent, and idempotent" (property (do ns <- forAll (Gen.list (Range.linear 1 5) genName); withDir (\d -> do let { p = F.joinPath (d : ns) }; r <- evalIO (runExceptT (createDirectoryIfMissing True p *> createDirectoryIfMissing True p *> doesDirectoryExist p)); r === Right True)))+    <> prop "removeDirectory: an empty directory, not a full one" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (createDirectory (d </> n) *> removeDirectory (d </> n) *> doesPathExist (d </> n))); s <- evalIO (runExceptT (writeFile (d </> n) (pack n) *> removeDirectory d)); (r, isLeft s) === (Right False, True))))+    <> prop "removeDirectoryRecursive: the whole tree" (property (do ns <- forAll (Gen.list (Range.linear 1 5) genName); fs <- forAll genNames; withDir (\d -> do let { p = F.joinPath (d : ns) }; let { top = F.joinPath (d : take 1 ns) }; r <- evalIO (runExceptT (createDirectoryIfMissing True p *> for_ fs (\f -> writeFile (p </> f) (pack f)) *> removeDirectoryRecursive top *> doesPathExist top)); s <- evalIO (runExceptT (removeDirectoryRecursive top)); (r, isNoSuchThing s) === (Right False, True))))+    <> prop "removePathForcibly: a missing path is not a failure" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (removePathForcibly (d </> n))); r === Right ())))+    <> prop "renameDirectory: moves the directory" (property (do a <- forAll genName; b <- forAll (Gen.filter (/= a) genName); withDir (\d -> do r <- evalIO (runExceptT (createDirectory (d </> a) *> renameDirectory (d </> a) (d </> b) *> traverse doesDirectoryExist [d </> a, d </> b])); r === Right [False, True])))+    <> prop "getXdgDirectory, getXdgDirectoryList, getAppUserDataDirectory agree with System.Directory" (property (do n <- forAll genName; x <- forAll (Gen.element [XdgData, XdgConfig, XdgCache, XdgState]); l <- forAll (Gen.element [XdgDataDirs, XdgConfigDirs]); agreesIO (getXdgDirectory x n) (D.getXdgDirectory x n) *> agreesIO (getXdgDirectoryList l) (D.getXdgDirectoryList l) *> agreesIO (getAppUserDataDirectory n) (D.getAppUserDataDirectory n)))+    <> prop "findExecutable, findExecutables, findFile, findFiles agree with System.Directory" (property (do n <- forAll (Gen.element ["sh", "ls", "papa-no-such-executable", ""]); fs <- forAll genNames; withDir (\d -> do evalIO (for_ fs (\f -> SB.writeFile (d </> f) "")); f <- forAll (Gen.element (n : fs)); agreesIO (findExecutable f) (D.findExecutable f) *> agreesIO (findExecutables f) (D.findExecutables f) *> agreesIO (findExecutablesInDirectories [d] f) (D.findExecutablesInDirectories [d] f) *> agreesIO (findFile [d, d] f) (D.findFile [d, d] f) *> agreesIO (findFiles [d, d] f) (D.findFiles [d, d] f))))++files :: [(PropertyName, Property)]+files =+  prop "writeFile, getFileSize: the size of the UTF-8 encoding" (property (do t <- forAll (Gen.text (Range.linear 0 50) Gen.unicode); withDir (\d -> do r <- evalIO (runExceptT (writeFile (d </> "f") t *> getFileSize (d </> "f"))); r === Right (P.toInteger (SB.length (encodeUtf8 t))))))+    <> prop "getFileSize agrees with System.Directory" (property (do n <- forAll genName; withDir (\d -> agreesIO (getFileSize (d </> n)) (D.getFileSize (d </> n)) *> agreesIO (getFileSize d) (D.getFileSize d))))+    <> prop "removeFile: the file, then NoSuchThing" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (writeFile (d </> n) (pack n) *> removeFile (d </> n) *> doesFileExist (d </> n))); s <- evalIO (runExceptT (removeFile (d </> n))); (r, isNoSuchThing s) === (Right False, True))))+    <> prop "renameFile, renamePath: move the contents" (property (do a <- forAll genName; b <- forAll (Gen.filter (/= a) genName); t <- forAll (Gen.text (Range.linear 0 20) Gen.unicode); withDir (\d -> do r <- evalIO (runExceptT (writeFile (d </> a) t *> renameFile (d </> a) (d </> b) *> renamePath (d </> b) (d </> a) *> ((,) <$> readFile (d </> a) <*> doesPathExist (d </> b)))); r === Right (t, False))))+    <> prop "copyFile, copyFileWithMetadata: the contents, and the source kept" (property (do t <- forAll (Gen.text (Range.linear 0 20) Gen.unicode); m <- forAll Gen.bool; withDir (\d -> do r <- evalIO (runExceptT (writeFile (d </> "a") t *> bool copyFile copyFileWithMetadata m (d </> "a") (d </> "b") *> ((,) <$> readFile (d </> "a") <*> readFile (d </> "b")))); r === Right (t, t))))+    <> prop "copyFile: NoSuchThing without the source" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (copyFile (d </> n) (d </> "b"))); isNoSuchThing r === True)))+    <> prop "setModificationTime, setAccessTime: read back" (property (do s <- forAll (Gen.integral (Range.linear 0 2000000000)); withDir (\d -> do let { t = Time.addUTCTime (P.fromInteger s) (Time.UTCTime (Time.fromGregorian 1970 1 1) 0) }; r <- evalIO (runExceptT (writeFile (d </> "f") (pack "") *> setModificationTime (d </> "f") t *> setAccessTime (d </> "f") t *> ((,) <$> getModificationTime (d </> "f") <*> getAccessTime (d </> "f")))); r === Right (t, t))))+    <> prop "getModificationTime, getAccessTime: NoSuchThing for a missing file" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (getModificationTime (d </> n))); s <- evalIO (runExceptT (getAccessTime (d </> n))); (isNoSuchThing r, isNoSuchThing s) === (True, True))))+    <> prop "setPermissions: System.Directory's, and executable read back (writable is always True for root)" (property (do w <- forAll Gen.bool; x <- forAll Gen.bool; withDir (\d -> do let { perms q = setOwnerReadable True (setOwnerWritable w (setOwnerExecutable x q)) }; r <- evalIO (runExceptT (writeFile (d </> "f") (pack "") *> getPermissions (d </> "f") >>= \p -> setPermissions (d </> "f") (perms p) *> getPermissions (d </> "f"))); s <- evalIO (IO.writeFile (d </> "g") "" *> D.getPermissions (d </> "g") >>= \p -> D.setPermissions (d </> "g") (perms p) *> D.getPermissions (d </> "g")); (r, fmap (\p -> (readable p, executable p)) r) === (Right s, Right (True, x)))))+    <> prop "copyPermissions: the permissions of the source" (property (do x <- forAll Gen.bool; withDir (\d -> do r <- evalIO (runExceptT (writeFile (d </> "a") (pack "") *> writeFile (d </> "b") (pack "") *> getPermissions (d </> "a") >>= \p -> setPermissions (d </> "a") (setOwnerExecutable x p) *> copyPermissions (d </> "a") (d </> "b") *> getPermissions (d </> "b"))); fmap executable r === Right x)))+    <> prop "createFileLink, createDirectoryLink, getSymbolicLinkTarget, pathIsSymbolicLink, removeDirectoryLink" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (writeFile (d </> "f") (pack n) *> createDirectory (d </> "d") *> createFileLink (d </> "f") (d </> "fl") *> createDirectoryLink (d </> "d") (d </> "dl") *> ((,,,) <$> traverse pathIsSymbolicLink [d </> "f", d </> "fl", d </> "dl"] <*> getSymbolicLinkTarget (d </> "fl") <*> readFile (d </> "fl") <*> (removeDirectoryLink (d </> "dl") *> traverse doesPathExist [d </> "dl", d </> "d"])))); r === Right ([False, True, True], d </> "f", pack n, [False, True]))))++paths :: [(PropertyName, Property)]+paths =+  prop "filepath: total at every string" (property (do p <- forAll genPath; q <- forAll genPath; r <- evalIO (E.try (E.evaluate (length (concat [show (splitPath p, splitDirectories p, splitFileName p, splitExtension p, splitExtensions p, splitDrive p), show (normalise p, makeValid p, isValid p, takeDirectory p, takeBaseName p, takeExtension p, dropExtension p), show (p </> q, p -<.> q, addExtension p q, replaceExtension p q, makeRelative p q, equalFilePath p q, stripExtension q p, isExtensionOf q p), show (splitSearchPath p, hasTrailingPathSeparator p, dropTrailingPathSeparator p, addTrailingPathSeparator p)])))); either (\(_ :: E.SomeException) -> False) (const True) r === True))+    <> prop "filepath: splitExtension, splitExtensions, splitDrive and splitPath rebuild the path" (property (do p <- forAll genPath; (uncurry (<>) (splitExtension p), uncurry (<>) (splitExtensions p), uncurry (<>) (splitDrive p), concat (splitPath p)) === (p, p, p, p)))+    <> prop "filepath: they are System.FilePath's" (property (do p <- forAll genPath; q <- forAll genPath; (p </> q, splitPath p, normalise p, p -<.> q) === (p F.</> q, F.splitPath p, F.normalise p, p F.-<.> q)))+    <> prop "getSearchPath agrees with System.FilePath" (withTests 10 (property (agreesIO getSearchPath F.getSearchPath)))++currentDirectory :: [(PropertyName, Property)]+currentDirectory =+  prop "withCurrentDirectory: runs in the directory, then returns, whether or not the action fails" (withTests 20 (property (do b <- forAll Gen.bool; withDir (\d -> do c <- evalIO D.getCurrentDirectory; r <- evalIO (runExceptT (withCurrentDirectory d (getCurrentDirectory >>= \x -> bool (pure x) (removeFile "papa-no-such-file" $> x) b))); c' <- evalIO D.getCurrentDirectory; d' <- evalIO (D.canonicalizePath d); (bool (preview _Right r) Nothing b, isLeft r, c') === (bool (Just d') Nothing b, b, c)))))+    <> prop "withCurrentDirectory: a missing directory is a failure" (property (do n <- forAll genName; withDir (\d -> do r <- evalIO (runExceptT (withCurrentDirectory (d </> n) (pure ()))); isNoSuchThing r === True)))+    <> prop "getCurrentDirectory, getHomeDirectory, getTemporaryDirectory, getUserDocumentsDirectory agree with System.Directory" (withTests 10 (property (agreesIO getCurrentDirectory D.getCurrentDirectory *> agreesIO getHomeDirectory D.getHomeDirectory *> agreesIO getTemporaryDirectory D.getTemporaryDirectory *> agreesIO getUserDocumentsDirectory D.getUserDocumentsDirectory)))+    <> prop "canonicalizePath, makeAbsolute, makeRelativeToCurrentDirectory agree with System.Directory" (property (do p <- forAll genPath; agreesIO (canonicalizePath p) (D.canonicalizePath p) *> agreesIO (makeAbsolute p) (D.makeAbsolute p) *> agreesIO (makeRelativeToCurrentDirectory p) (D.makeRelativeToCurrentDirectory p)))
+ test/PropertiesIO.hs view
@@ -0,0 +1,133 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Use nubOrd" -}+{- HLINT ignore "Lens law: read what you set" -}+{- HLINT ignore "Lens law: set what you read" -}+{- HLINT ignore "Setter law: set twice" -}+-- Reason: these properties compare nubOrd with nub, and test the lens laws of+-- errorHandle, writing both sides of equations that the hints would rewrite+-- one side into (CLAUDE.md, HLint Compliance: testing laws).++-- | The properties of Papa's exceptions, handles, references and+-- duplicate removal.+module PropertiesIO (+  propertiesIO,+) where++import qualified Control.Exception as E+import qualified Data.List as L+import Hedgehog (Gen, Group (Group), Property, PropertyName, evalIO, forAll, property, withTests, (===))+import Hedgehog.Function (apply, fn)+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import qualified Papa.Unsafe.IO as U++-- | The properties of Papa's exceptions, handles, references and duplicate+-- removal.+propertiesIO :: Group+propertiesIO =+  Group "papa: exceptions, handles, references" (exceptions <> handles <> references <> nubs)++prop :: PropertyName -> Property -> [(PropertyName, Property)]+prop name p =+  [(name, p)]++genString :: Gen String+genString =+  Gen.string (Range.linear 1 10) Gen.alphaNum++genInts :: Gen [Int]+genInts =+  Gen.list (Range.linear 0 50) (Gen.int (Range.linear (-10) 10))++genHandle :: Gen (Maybe Handle)+genHandle =+  Gen.element [Nothing, Just stdin, Just stdout, Just stderr]++-- | Fork a thread that runs the catcher around an action that signals it has+-- started and then waits; kill the thread once it has started; return how+-- the thread ended: "thread killed" if the kill was not caught.+killedWhileCaught :: ((IO String -> IO String)) -> IO String+killedWhileCaught catcher = do+  started <- newEmptyMVar+  ended <- newEmptyMVar+  t <- forkFinally (catcher ((putMVar started () *> threadDelay 10000000) $> "finished")) (putMVar ended . either show id)+  takeMVar started+  killThread t+  takeMVar ended++-- | The exception that an action throws, if any, caught by base's 'E.try'.+thrown :: IO a -> IO (Maybe String)+thrown a =+  either (Just . displaySome) (const Nothing) <$> E.try a++-- | The display of the exception inside a 'SomeException', without the+-- context (a backtrace) that GHC 9.10 and later add to 'SomeException''s own.+displaySome :: SomeException -> String+displaySome (E.SomeException e) =+  displayException e++-- Papa.Base.Control.Exception++exceptions :: [(PropertyName, Property)]+exceptions =+  prop "try: a killed thread is not caught at SomeException" (withTests 20 (property (do r <- evalIO (killedWhileCaught (fmap (either (\(_ :: SomeException) -> "caught") id) . try)); r === "thread killed")))+    <> prop "catch: a killed thread is not caught at SomeException" (withTests 20 (property (do r <- evalIO (killedWhileCaught (\a -> catch a (\(_ :: SomeException) -> pure "caught"))); r === "thread killed")))+    <> prop "handle: a killed thread is not caught at SomeException" (withTests 20 (property (do r <- evalIO (killedWhileCaught (handle (\(_ :: SomeException) -> pure "caught"))); r === "thread killed")))+    <> prop "base's try: a killed thread is caught at SomeException" (withTests 20 (property (do r <- evalIO (killedWhileCaught (fmap (either (\(_ :: SomeException) -> "caught") id) . E.try)); r === "caught")))+    <> prop "try: a synchronous exception is caught" (property (do s <- forAll genString; r <- evalIO (try @IOException (throwIO (userError s))); either displayException (const "") r === "user error (" <> s <> ")"))+    <> prop "try: a synchronous exception is caught at SomeException" (property (do s <- forAll genString; r <- evalIO (try @SomeException (throwIO (userError s))); either displaySome (const "") r === "user error (" <> s <> ")"))+    <> prop "try: an exception of another type passes through" (property (do s <- forAll genString; r <- evalIO (thrown (try @ArithException (throwIO (userError s)))); r === Just ("user error (" <> s <> ")")))+    <> prop "try: Right for an action that does not throw" (property (do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (try @SomeException (pure n)); r ^? _Right === Just n))+    <> prop "catch: the handler's result" (property (do s <- forAll genString; r <- evalIO (catch (throwIO (userError s)) (\(e :: IOException) -> pure (displayException e))); r === "user error (" <> s <> ")"))+    <> prop "bracket: releases and returns the use's result" (property (do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (do v <- newIORef ([] :: [String]); x <- bracket (modifyIORef' v ("acquire" :) $> n) (\_ -> modifyIORef' v ("release" :)) (\a -> modifyIORef' v ("use" :) $> a); (,) x <$> readIORef v); r === (n, ["release", "use", "acquire"])))+    <> prop "bracket: releases when the use throws, and rethrows" (property (do s <- forAll genString; r <- evalIO (do v <- newIORef ([] :: [String]); e <- thrown (bracket (pure ()) (\_ -> modifyIORef' v ("release" :)) (\_ -> throwIO (userError s))); (,) e <$> readIORef v); r === (Just ("user error (" <> s <> ")"), ["release"])))+    <> prop "bracket: the release's exception is discarded when the use throws" (property (do s <- forAll genString; r <- evalIO (thrown (bracket (pure ()) (\_ -> throwIO Overflow) (\_ -> throwIO (userError s)))); r === Just ("user error (" <> s <> ")")))+    <> prop "bracket: the release's exception is thrown when the use does not throw" (property (do s <- forAll genString; r <- evalIO (thrown (bracket (pure ()) (\_ -> throwIO (userError s)) pure)); r === Just ("user error (" <> s <> ")")))+    <> prop "bracket: the release cannot be interrupted" (withTests 10 (property (do r <- evalIO (do v <- newEmptyMVar; _ <- try @ArithException (bracket (pure ()) (\_ -> getMaskingState >>= putMVar v) (\_ -> throwIO Overflow)); w <- newEmptyMVar; bracket (pure ()) (\_ -> getMaskingState >>= putMVar w) pure; (,) <$> takeMVar v <*> takeMVar w); r === (MaskedUninterruptible, MaskedUninterruptible))))+    <> prop "bracket: the use can be interrupted" (withTests 10 (property (do r <- evalIO (bracket (pure ()) (\_ -> pure ()) (const getMaskingState)); r === Unmasked)))+    <> prop "bracket: a killed use is released" (withTests 20 (property (do r <- evalIO (do v <- newIORef False; e <- killedWhileCaught (bracket (pure ()) (\_ -> writeIORef v True) . const); (,) e <$> readIORef v); r === ("thread killed", True))))+    <> prop "bracket_: releases when the use throws" (property (do s <- forAll genString; r <- evalIO (do v <- newIORef False; _ <- thrown (bracket_ (pure ()) (writeIORef v True) (throwIO (userError s))); readIORef v); r === True))+    <> prop "bracketOnError: releases only when the use throws" (property (do b <- forAll Gen.bool; r <- evalIO (do v <- newIORef False; _ <- thrown (bracketOnError (pure ()) (\_ -> writeIORef v True) (\_ -> bool (pure ()) (throwIO Overflow) b)); readIORef v); r === b))+    <> prop "finally: runs whether or not the action throws" (property (do b <- forAll Gen.bool; r <- evalIO (do v <- newIORef False; e <- thrown (bool (pure ()) (throwIO Overflow) b `finally` writeIORef v True); (,) (isJust e) <$> readIORef v); r === (b, True)))+    <> prop "onException: runs only when the action throws, and rethrows" (property (do b <- forAll Gen.bool; r <- evalIO (do v <- newIORef False; e <- thrown (bool (pure ()) (throwIO Overflow) b `onException` writeIORef v True); (,) (isJust e) <$> readIORef v); r === (b, b)))+    <> prop "forkFinally: Right on success, Left on exception" (property (do b <- forAll Gen.bool; n <- forAll (Gen.int Range.linearBounded); r <- evalIO (do v <- newEmptyMVar; _ <- forkFinally (bool (pure n) (throwIO Overflow) b) (putMVar v . over _Left displaySome); takeMVar v); r === bool (Right n) (Left "arithmetic overflow") b))+    <> prop "trying _IOException: an IOException is caught" (property (do s <- forAll genString; r <- evalIO (trying _IOException (throwIO (userError s))); either displayException (const "") r === "user error (" <> s <> ")"))+    <> prop "trying _ArithException: an IOException passes through" (property (do s <- forAll genString; r <- evalIO (thrown (trying _ArithException (throwIO (userError s)))); r === Just ("user error (" <> s <> ")")))+    <> prop "catching (errorType . _UserError)" (property (do s <- forAll genString; r <- evalIO (catching (_IOException . errorType . _UserError) (throwIO (userError s)) (\() -> pure ("caught" :: String))); r === "caught"))++-- Papa.Base.System.IO, Papa.Lens.System.IO.Error++handles :: [(PropertyName, Property)]+handles =+  prop "openFile: NoSuchThing for a missing file" (property (do s <- forAll genString; r <- evalIO (runExceptT (openFile ("/nonexistent/papa/" <> s) ReadMode)); either (has (_IOException . errorType . _NoSuchThing)) (const False) r === True))+    <> prop "withFile: the use's result" (property (do n <- forAll (Gen.int Range.linearBounded); r <- evalIO (runExceptT (withFile "/dev/null" ReadMode (const (pure n)))); r ^? _Right === Just n))+    <> prop "withFile: the use's failure, and the handle closed" (property (do s <- forAll genString; r <- evalIO (do v <- newIORef Nothing; e <- runExceptT (withFile "/dev/null" ReadMode (\h -> exceptIO (writeIORef v (Just h)) *> openFile ("/nonexistent/papa/" <> s) ReadMode)); c <- readIORef v >>= traverse U.hIsClosed; pure (either (has (_IOException . errorType . _NoSuchThing)) (const False) e, c)); r === (True, Just True)))+    <> prop "withFile: the handle closed when the use throws a non-IO exception" (withTests 10 (property (do r <- evalIO (do v <- newIORef Nothing; _ <- thrown (runExceptT (withFile "/dev/null" ReadMode (\h -> exceptIO (writeIORef v (Just h) *> throwIO Overflow)))); readIORef v >>= traverse U.hIsClosed); r === Just True)))+    <> prop "hClose: twice is not a failure" (withTests 10 (property (do r <- evalIO (runExceptT (openFile "/dev/null" ReadMode >>= \h -> hClose h *> hClose h)); r === Right ())))+    <> prop "hIsEOF: IllegalOperation on a closed handle" (withTests 10 (property (do r <- evalIO (runExceptT (openFile "/dev/null" ReadMode >>= \h -> hClose h *> hIsEOF h)); either (has (_IOException . errorType . _IllegalOperation)) (const False) r === True)))+    <> prop "hFlush, hSetBuffering: IllegalOperation on a closed handle" (withTests 10 (property (do b <- forAll Gen.bool; r <- evalIO (runExceptT (openFile "/dev/null" WriteMode >>= \h -> hClose h *> bool (hFlush h) (hSetBuffering h NoBuffering) b)); either (has (_IOException . errorType . _IllegalOperation)) (const False) r === True)))+    <> prop "errorHandle: you get what you set" (property (do h <- forAll genHandle; the errorHandle (set errorHandle h (userError "u")) === h))+    <> prop "errorHandle: setting what you get changes nothing" (property (do h <- forAll genHandle; let { e = set errorHandle h (userError "u") }; the errorHandle (set errorHandle (the errorHandle e) e) === the errorHandle e))+    <> prop "errorHandle: setting twice is setting once" (property (do h <- forAll genHandle; i <- forAll genHandle; the errorHandle (set errorHandle i (set errorHandle h (userError "u"))) === i))++-- Papa.Base.Data.IORef++references :: [(PropertyName, Property)]+references =+  prop "modifyIORef': reads the function's result" (property (do n <- forAll (Gen.int Range.linearBounded); f <- forAll (fn (Gen.int Range.linearBounded)); r <- evalIO (do v <- newIORef n; modifyIORef' v (apply f); readIORef v); r === apply f n))+    <> prop "atomicModifyIORef': returns and stores the function's results" (property (do n <- forAll (Gen.int Range.linearBounded); f <- forAll (fn ((,) <$> Gen.int Range.linearBounded <*> Gen.alpha)); r <- evalIO (do v <- newIORef n; c <- atomicModifyIORef' v (apply f); (,) <$> readIORef v <*> pure c); r === apply f n))++-- Papa.Containers.Data.Containers.ListUtils++nubs :: [(PropertyName, Property)]+nubs =+  prop "nubOrd == nub" (property (do xs <- forAll genInts; nubOrd xs === L.nub xs))+    <> prop "nubOrdOn f == nubBy ((==) `on` f)" (property (do xs <- forAll genInts; f <- forAll (fn (Gen.int (Range.linear 0 5))); nubOrdOn (apply f) xs === L.nubBy ((==) `on` apply f) xs))+    <> prop "nubInt == nub" (property (do xs <- forAll genInts; nubInt xs === L.nub xs))+    <> prop "nubIntOn f == nubBy ((==) `on` f)" (property (do xs <- forAll genInts; f <- forAll (fn (Gen.int (Range.linear 0 5))); nubIntOn (apply f) xs === L.nubBy ((==) `on` apply f) xs))
+ test/PropertiesNumeric.hs view
@@ -0,0 +1,267 @@+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TupleSections #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these properties compare Papa's total functions with the partial+-- ones of Papa.Unsafe.Numeric and Prelude, whose names HLint restricts.++-- | The agreement of Papa's total numeric functions with the partial ones of+-- "Papa.Unsafe.Numeric" and "Prelude", at every numeric type of base.+module PropertiesNumeric (+  propertiesNumeric,+) where++import Agree (agrees, agreesWhereDefined)+import Data.Fixed (Centi, Fixed (MkFixed), mod')+import Hedgehog (Gen, Group (Group), Property, PropertyName, Range, assert, forAll, property, (===))+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import Papa.Unsafe.Numeric (Natural)+import qualified Papa.Unsafe.Numeric as U+import qualified Prelude as P++-- | Every property of this module, in one group.+propertiesNumeric :: Group+propertiesNumeric =+  Group (fromString "papa: numeric agreement") (integrals <> fractionals <> conversions)++-- | One named property.+prop :: String -> Property -> [(PropertyName, Property)]+prop name p =+  [(fromString name, p)]++-- Integral types++-- | The total integral functions at every integral type of base.+integrals :: [(PropertyName, Property)]+integrals =+  bounded "Int" (genBounded Gen.int) (preview nonZero)+    <> bounded "Int8" (genBounded Gen.int8) (preview nonZero)+    <> bounded "Int16" (genBounded Gen.int16) (preview nonZero)+    <> bounded "Int32" (genBounded Gen.int32) (preview nonZero)+    <> bounded "Int64" (genBounded Gen.int64) (preview nonZero)+    <> bounded "Word" (genBounded Gen.word) (preview nonZero)+    <> bounded "Word8" (genBounded Gen.word8) (preview nonZero)+    <> bounded "Word16" (genBounded Gen.word16) (preview nonZero)+    <> bounded "Word32" (genBounded Gen.word32) (preview nonZero)+    <> bounded "Word64" (genBounded Gen.word64) (preview nonZero)+    <> integral "Integer" genInteger (preview nonZero)+    <> integral "Natural" genNatural (preview nonZero)+    <> prop "ratioNonZero agrees with (%) at Integer" (property (do n <- forAll genInteger; d <- forAll genInteger; agrees (fmap (ratioNonZero n) (preview nonZero d)) (n U.% d)))++-- | A bounded integral type: its ends, the values next to them, and @-1@,+-- often.+genBounded :: (Integral a, Bounded a) => (Range a -> Gen a) -> Gen a+genBounded g =+  Gen.frequency+    [ (1, Gen.element [0, 1, 2, U.fromInteger (-1), U.fromInteger (-2), minBound, maxBound, minBound + 1, maxBound - 1])+    , (4, g Range.linearBounded)+    ]++genInteger :: Gen Integer+genInteger =+  Gen.frequency+    [ (1, Gen.element [0, 1, -1, 2, -2])+    , (4, Gen.integral (Range.exponentialFrom 0 (negate (pow 10 30)) (pow 10 30)))+    ]++genNatural :: Gen Natural+genNatural =+  Gen.frequency+    [ (1, Gen.element [0, 1, 2])+    , (4, Gen.integral (Range.exponential 0 (pow 10 30)))+    ]++-- | The properties of an integral type that is 'Bounded': those of every+-- integral type, and 'pred'.+bounded :: (Integral a, Bounded a, Show a, NFData a) => String -> Gen a -> (a -> Maybe (NonZero a)) -> [(PropertyName, Property)]+bounded t g mk =+  integral t g mk+    <> prop ("pred agrees with Prelude's at " <> t) (property (do x <- forAll g; agrees (pred x) (P.pred x)))++-- | The properties of every integral type: each total function agrees with+-- its partial counterpart wherever that is defined.+integral :: forall a. (Integral a, Show a, NFData a) => String -> Gen a -> (a -> Maybe (NonZero a)) -> [(PropertyName, Property)]+integral t g mk =+  prop ("nonZero is Nothing exactly at 0 at " <> t) (property (do d <- forAll g; isNothing (mk d) === (d == 0)))+    <> division "divNonZero" divNonZero U.div+    <> division "modNonZero" modNonZero U.mod+    <> division "divModNonZero" divModNonZero U.divMod+    <> division "quotNonZero" quotNonZero U.quot+    <> division "remNonZero" remNonZero U.rem+    <> division "quotRemNonZero" quotRemNonZero U.quotRem+    <> prop ("pow agrees with (^) at " <> t) (property (do x <- forAll g; e <- forAll (Gen.integral (Range.linear 0 20)); pow x e === x U.^ e))+    <> prop ("succ agrees with Prelude's at " <> t) (property (do x <- forAll g; agrees (succ x) (P.succ x)))+ where+  division :: (Eq r, Show r, NFData r) => String -> (a -> NonZero a -> r) -> (a -> a -> r) -> [(PropertyName, Property)]+  division name total partial =+    prop+      (name <> " agrees with Papa.Unsafe.Numeric at " <> t)+      (property (do n <- forAll g; d <- forAll g; for_ (mk d) (\nz -> agreesWhereDefined (total n nz) (partial n d))))++-- Fractional types++-- | The total fractional functions at 'Float', 'Double' and 'Rational'.+fractionals :: [(PropertyName, Property)]+fractionals =+  fractional "Float" genFloat (preview nonZero)+    <> fractional "Double" genDouble (preview nonZero)+    <> fractional "Rational" genRational (preview nonZero)+    <> floating "Double" genDouble cFloor cCeil cTrunc cRint+    <> floating "Float" genFloat cFloorf cCeilf cTruncf cRintf+    <> modulus++foreign import ccall unsafe "math.h floor" cFloor :: Double -> Double+foreign import ccall unsafe "math.h ceil" cCeil :: Double -> Double+foreign import ccall unsafe "math.h trunc" cTrunc :: Double -> Double+foreign import ccall unsafe "math.h rint" cRint :: Double -> Double+foreign import ccall unsafe "math.h floorf" cFloorf :: Float -> Float+foreign import ccall unsafe "math.h ceilf" cCeilf :: Float -> Float+foreign import ccall unsafe "math.h truncf" cTruncf :: Float -> Float+foreign import ccall unsafe "math.h rintf" cRintf :: Float -> Float++-- | The total floating-point functions at a floating type. The rounding+-- functions agree with C's (@rint@ rounds a half to even in the default+-- rounding mode), including at @NaN@, the infinities and @-0@: results are+-- compared as shown, so that @NaN@ equals @NaN@ and @-0@ differs from @0@.+floating :: (RealFloat a, Show a) => String -> Gen a -> (a -> a) -> (a -> a) -> (a -> a) -> (a -> a) -> [(PropertyName, Property)]+floating t g f c u r =+  prop ("divideFloating agrees with (/) at " <> t) (property (do x <- forAll g; d <- forAll g; show (divideFloating x d) === show (x U./ d)))+    <> prop ("recipFloating agrees with recip at " <> t) (property (do d <- forAll g; show (recipFloating d) === show (U.recip d)))+    <> prop ("floorFloating agrees with C's floor at " <> t) (property (do x <- forAll g; show (floorFloating x) === show (f x)))+    <> prop ("ceilingFloating agrees with C's ceil at " <> t) (property (do x <- forAll g; show (ceilingFloating x) === show (c x)))+    <> prop ("truncateFloating agrees with C's trunc at " <> t) (property (do x <- forAll g; show (truncateFloating x) === show (u x)))+    <> prop ("roundFloating agrees with C's rint at " <> t) (property (do x <- forAll g; show (roundFloating x) === show (r x)))++-- | 'modFloating' at 'Double': "Data.Fixed"'s @mod'@, exactly, then rounded,+-- for a finite dividend and a finite divisor that is not zero; in the closed+-- interval from zero to the divisor; @NaN@ elsewhere, except for an infinite+-- divisor.+modulus :: [(PropertyName, Property)]+modulus =+  prop "modFloating: Data.Fixed's mod' at Rational, rounded" (property (do x <- forAll genDouble; y <- forAll genDouble; when (finiteFloating x && finiteFloating y && y /= 0) (modFloating x y === P.fromRational (mod' (P.toRational x) (P.toRational y)))))+    <> prop "modFloating: from zero to the divisor, with its sign" (property (do x <- forAll genDouble; y <- forAll genDouble; when (finiteFloating x && finiteFloating y && y /= 0) (let m = modFloating x y in assert (bool (m <= 0 && m >= y) (m >= 0 && m <= y) (y > 0)))))+    <> prop "modFloating: NaN for a divisor of zero or NaN, or a dividend that is not finite" (property (do x <- forAll genDouble; y <- forAll genDouble; when (not (finiteFloating x) || isNaN y || y == 0) (assert (isNaN (modFloating x y)))))++-- | @NaN@, an infinity, and the largest finite and least positive 'Double'.+nan, infinity, maxFinite, minSubnormal :: Double+nan = 0 U./ 0+infinity = 1 U./ 0+maxFinite = 1.7976931348623157e308+minSubnormal = 5.0e-324++-- | Values at which rounding and conversion change: halves, the ends of+-- the integral types, and the values that are not finite.+specialDoubles :: [Double]+specialDoubles =+  [0, negate 0, 0.5, -0.5, 1.5, 2.5, -2.5, 127.5, 128, -128.5, -129, 255.5, 256, 9.223372036854775807e18, -9.223372036854775808e18, 1.8446744073709552e19, maxFinite, negate maxFinite, minSubnormal, nan, infinity, negate infinity]++genDouble :: Gen Double+genDouble =+  Gen.frequency+    [ (1, Gen.element specialDoubles)+    , (4, Gen.double (Range.exponentialFloatFrom 0 (-1.0e300) 1.0e300))+    ]++genFloat :: Gen Float+genFloat =+  Gen.frequency+    [ (1, Gen.element (fmap doubleToFloat specialDoubles))+    , (4, Gen.float (Range.exponentialFloatFrom 0 (-1.0e30) 1.0e30))+    ]++genRational :: Gen Rational+genRational =+  ratioNonZero <$> genInteger <*> Gen.just (preview nonZero <$> genInteger)++genCenti :: Gen Centi+genCenti =+  MkFixed <$> genInteger++-- | Whether a value of a floating type is finite.+finiteFloating :: (RealFloat a) => a -> Bool+finiteFloating x =+  not (isNaN x || isInfinite x)++-- | The properties of a fractional type: each total function agrees with+-- its partial counterpart wherever that is defined. Results are compared+-- as shown, so that @NaN@ equals @NaN@ and @-0@ differs from @0@.+fractional :: (Eq a, Fractional a, Show a) => String -> Gen a -> (a -> Maybe (NonZero a)) -> [(PropertyName, Property)]+fractional t g mk =+  prop ("nonZero is Nothing exactly at 0 at " <> t) (property (do d <- forAll g; isNothing (mk d) === (d == 0)))+    <> prop ("divideNonZero agrees with (/) at " <> t) (property (do x <- forAll g; d <- forAll g; for_ (mk d) (\nz -> agreesWhereDefined (show (divideNonZero x nz)) (show (x U./ d)))))+    <> prop ("recipNonZero agrees with recip at " <> t) (property (do d <- forAll g; for_ (mk d) (\nz -> agreesWhereDefined (show (recipNonZero nz)) (show (U.recip d)))))+    <> prop ("powNonZero agrees with (^^) at " <> t) (property (do d <- forAll g; e <- forAll (Gen.int (Range.linear (-20) 20)); for_ (mk d) (\nz -> agreesWhereDefined (show (powNonZero nz e)) (show (d U.^^ e)))))++-- Conversions++-- | The total conversions from fractional types, and between floating+-- types.+conversions :: [(PropertyName, Property)]+conversions =+  fromFractional "Float" genFloat finiteFloating+    <> fromFractional "Double" genDouble finiteFloating+    <> fromFractional "Rational" genRational (const True)+    <> fromFractional "Centi" genCenti (const True)+    <> prop "floatToDouble agrees with realToFrac at finite values, and keeps NaN, the infinities and -0" (property (do x <- forAll genFloat; when (finiteFloating x) (floatToDouble x === U.realToFrac x); (isNaN (floatToDouble x), isInfinite (floatToDouble x), isNegativeZero (floatToDouble x)) === (isNaN x, isInfinite x, isNegativeZero x)))+    <> prop "doubleToFloat agrees with realToFrac at finite values, and keeps NaN, the infinities and -0" (property (do x <- forAll genDouble; when (finiteFloating x) (doubleToFloat x === U.realToFrac x); when (isInfinite x) (floatToDouble (doubleToFloat x) === x); (isNaN (doubleToFloat x), isNegativeZero (doubleToFloat x)) === (isNaN x, isNegativeZero x)))+    <> prop "doubleToFloat . floatToDouble is the identity" (property (do x <- forAll genFloat; show (doubleToFloat (floatToDouble x)) === show x))+    <> toFloating "Int" (genBounded Gen.int)+    <> toFloating "Int8" (genBounded Gen.int8)+    <> toFloating "Int64" (genBounded Gen.int64)+    <> toFloating "Word" (genBounded Gen.word)+    <> toFloating "Word64" (genBounded Gen.word64)+    <> toFloating "Integer" genInteger+    <> toFloating "Natural" genNatural+    <> prop "integralToFloating rounds an Integer to the nearest Double" (property (do n <- forAll genInteger; integralToFloating n === (fromRational (U.fromInteger n) :: Double)))++-- | 'integralToFloating' agrees with @fromIntegral@ at 'Double' and 'Float'.+toFloating :: (Integral a, Show a) => String -> Gen a -> [(PropertyName, Property)]+toFloating t g =+  prop ("integralToFloating agrees with fromIntegral from " <> t) (property (do n <- forAll g; (integralToFloating n :: Double, integralToFloating n :: Float) === (U.fromIntegral n, U.fromIntegral n)))++-- | The total conversions from a fractional type, to each integral type.+fromFractional :: (RealFrac a, Show a) => String -> Gen a -> (a -> Bool) -> [(PropertyName, Property)]+fromFractional t g fin =+  rounding t g fin "Int" (Proxy :: Proxy Int)+    <> rounding t g fin "Int8" (Proxy :: Proxy Int8)+    <> rounding t g fin "Word" (Proxy :: Proxy Word)+    <> rounding t g fin "Word8" (Proxy :: Proxy Word8)+    <> rounding t g fin "Integer" (Proxy :: Proxy Integer)+    <> rounding t g fin "Natural" (Proxy :: Proxy Natural)+    <> prop ("toRationalMaybe: Prelude's toRational at finite values, else Nothing, at " <> t) (property (do x <- forAll g; toRationalMaybe x === bool Nothing (Just (U.toRational x)) (fin x)))++-- | Each total rounding function from a fractional type to an integral type+-- is 'Nothing' at values that are not finite and at results out of the+-- range of the target, and "Prelude"'s everywhere else.+rounding :: forall a b. (RealFrac a, Show a, Integral b, Bits b, Show b) => String -> Gen a -> (a -> Bool) -> String -> Proxy b -> [(PropertyName, Property)]+rounding t g fin u _ =+  method "truncateMaybe" truncateMaybe U.truncate+    <> method "roundMaybe" roundMaybe U.round+    <> method "ceilingMaybe" ceilingMaybe U.ceiling+    <> method "floorMaybe" floorMaybe U.floor+    <> prop+      ("properFractionMaybe: Prelude's where finite and in range, at " <> t <> " -> " <> u)+      ( property+          ( do+              x <- forAll g+              let (n, f) = U.properFraction x :: (Integer, a)+              (properFractionMaybe x :: Maybe (b, a)) === bool Nothing ((,f) <$> toIntegralSized n) (fin x)+          )+      )+ where+  method :: String -> (a -> Maybe b) -> (forall c. (Integral c) => a -> c) -> [(PropertyName, Property)]+  method name total partial =+    prop+      (name <> ": Prelude's where finite and in range, at " <> t <> " -> " <> u)+      ( property+          ( do+              x <- forAll g+              total x === bool Nothing (toIntegralSized (partial x :: Integer)) (fin x)+              for_ (total x) (\n -> n === partial x)+          )+      )
+ test/PropertiesText.hs view
@@ -0,0 +1,383 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these are the properties of the total head, last, init, tail,+-- maximum and minimum of the Text and ByteString modules, compared with the+-- partial functions of text and bytestring that they replace, whose names+-- HLint restricts whatever module they come from.++-- | Hedgehog properties of the Text and ByteString modules: each total+-- function agrees with the partial one it replaces wherever that one returns,+-- and is 'Nothing' (or an error) exactly where it throws; each checked+-- function agrees with the unchecked one wherever that one does not truncate;+-- and the I/O actions round-trip through a file.+module PropertiesText (+  propertiesText,+) where++import Agree (agrees)+import qualified Control.Exception as E+import qualified Data.ByteString as SB+import qualified Data.ByteString.Builder as SBB+import qualified Data.ByteString.Char8 as SC+import qualified Data.ByteString.Lazy as SL+import qualified Data.ByteString.Lazy.Char8 as SLC+import qualified Data.List as List+import qualified Data.Text as ST+import qualified Data.Text.Encoding as STE+import qualified Data.Text.Lazy as STL+import qualified Data.Text.Lazy.Builder as STB+import qualified Data.Text.Lazy.Builder.Int as STBI+import qualified Data.Text.Lazy.Encoding as STLE+import qualified Data.Text.Read as STR+import Hedgehog (Gen, Group (Group), Property, PropertyName, PropertyT, evalIO, forAll, property, withTests, (===))+import Hedgehog.Function (Fn, apply, fn)+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import qualified Papa.Bytestring.Data.ByteString as B+import qualified Papa.Bytestring.Data.ByteString.Builder as BB+import qualified Papa.Bytestring.Data.ByteString.Char8 as BC+import qualified Papa.Bytestring.Data.ByteString.Lazy as BL+import qualified Papa.Bytestring.Data.ByteString.Lazy.Char8 as BLC+import qualified Papa.Text.Data.Text as T+import qualified Papa.Text.Data.Text.Encoding as TE+import qualified Papa.Text.Data.Text.IO as TIO+import qualified Papa.Text.Data.Text.Lazy as TL+import qualified Papa.Text.Data.Text.Lazy.Builder as TB+import qualified Papa.Text.Data.Text.Lazy.Builder.Int as TBI+import qualified Papa.Text.Data.Text.Lazy.Encoding as TLE+import qualified Papa.Text.Data.Text.Lazy.Read as TLR+import qualified Papa.Text.Data.Text.Read as TR+import Papa.Unsafe.Numeric (Natural)+import qualified System.Directory as D+import qualified System.IO as IO+import System.IO.Error (isDoesNotExistError, isEOFError)+import qualified Prelude as P++-- | The properties of the Text and ByteString modules.+propertiesText :: Group+propertiesText =+  Group "text and bytestring" (text <> lazyText <> encoding <> textReads <> builders <> bytestring <> lazyBytestring <> char8 <> lazyChar8 <> bytestringBuilder <> io)++prop :: PropertyName -> Property -> [(PropertyName, Property)]+prop n p =+  [(n, p)]++-- Generators: short, over few letters, so that needles are found, with the+-- empty and singleton cases often.++genText :: Gen Text+genText =+  Gen.text (Range.linear 0 12) (Gen.element ("abc" :: [Char]))++genUnicode :: Gen Text+genUnicode =+  Gen.text (Range.linear 0 30) Gen.unicode++genNeedle :: Gen Text+genNeedle =+  Gen.text (Range.linear 0 3) (Gen.element ("abc" :: [Char]))++genLazyText :: Gen STL.Text+genLazyText =+  STL.fromChunks <$> Gen.list (Range.linear 0 4) genText++genLazyNeedle :: Gen STL.Text+genLazyNeedle =+  STL.fromStrict <$> genNeedle++genBytes :: Gen ByteString+genBytes =+  Gen.bytes (Range.linear 0 12)++-- | Lines of bytes, some of them not UTF-8: overlong forms, surrogates,+-- code points above U+10FFFF, truncated sequences, stray continuations.+genLineBytes :: Gen ByteString+genLineBytes =+  fmap SB.concat (Gen.list (Range.linear 0 30) (Gen.element (fmap SB.pack [[10], [13, 10], [97], [98, 99], [0xCE, 0xBB], [0xE2, 0x82, 0xAC], [0xF0, 0x9F, 0x98, 0x80], [0xC0, 0xAF], [0xE0, 0x80, 0xAF], [0xED, 0xA0, 0x80], [0xF4, 0x90, 0x80, 0x80], [0xFF], [0x80], [0xBF], [0xCE], [0xE2, 0x82], [0xF0, 0x9F]])))++-- | Every line of a file, read through a handle of the buffer size and+-- encoding, until the end of the file: the text, or which failure.+readLines :: FilePath -> Maybe Int -> IO.TextEncoding -> Int -> (IO.Handle -> IO (Either Text Text)) -> IO [Either Text Text]+readLines p n e size readLine =+  IO.withFile p IO.ReadMode (\h -> IO.hSetEncoding h e *> IO.hSetBuffering h (IO.BlockBuffering n) *> go h (size + 2))+ where+  go _ 0 = pure []+  go h k =+    readLine h >>= \r -> bool (fmap (r :) (go h (k - 1 :: Int))) (pure [r]) (r == Left (pack "eof"))++-- | A line by TextIO.hGetLine: the text, or which failure.+papaLine :: IO.Handle -> IO (Either Text Text)+papaLine h =+  fmap (over _Left (\f -> bool (bool (pack "other") (pack "eof") (anyOf _IOException isEOFError f)) (pack "decode") (has _DecodeFailed f))) (runExceptT (TIO.hGetLine h))++-- | A line by Data.ByteString.Char8's hGetLine, then decodeUtf8': the text,+-- or which failure.+referenceLine :: IO.Handle -> IO (Either Text Text)+referenceLine h =+  fmap (either (Left . bool (pack "other") (pack "eof") . isEOFError) (set _Left (pack "decode") . STE.decodeUtf8')) (E.try (SC.hGetLine h) :: IO (Either IOException ByteString))++genLazyBytes :: Gen SL.ByteString+genLazyBytes =+  SL.fromChunks <$> Gen.list (Range.linear 0 4) genBytes++genChar :: Gen Char+genChar =+  Gen.frequency [(9, Gen.latin1), (1, Gen.element ("\256\1000\1114111" :: [Char]))]++genString :: Gen [Char]+genString =+  Gen.string (Range.linear 0 12) genChar++genInteger :: Range.Range Integer -> Gen Integer+genInteger =+  Gen.integral++genIndex :: Gen Int+genIndex =+  Gen.int (Range.linear (-3) 15)++genWordFn :: Gen (Fn (Int, Int) Word8)+genWordFn =+  fn (Gen.word8 Range.linearBounded)++-- | A generated function of two bytes (hedgehog-fn has no Arg Word8).+wordFn :: Fn (Int, Int) Word8 -> Word8 -> Word8 -> Word8+wordFn f a b =+  apply f (intCast a, intCast b)++-- | The text, or bytes, of a total function that agrees with the partial+-- one: 'Nothing' where it throws.+agreesBy :: (Eq b, Show b, NFData b) => (a -> b) -> Maybe a -> a -> PropertyT IO ()+agreesBy f total partial =+  agrees (fmap f total) (f partial)++-- Papa.Text.Data.Text++text :: [(PropertyName, Property)]+text =+  prop "Text.head agrees with Data.Text" (property (do t <- forAll genText; agrees (T.head t) (ST.head t)))+    <> prop "Text.last agrees with Data.Text" (property (do t <- forAll genText; agrees (T.last t) (ST.last t)))+    <> prop "Text.tail agrees with Data.Text" (property (do t <- forAll genText; agrees (T.tail t) (ST.tail t)))+    <> prop "Text.init agrees with Data.Text" (property (do t <- forAll genText; agrees (T.init t) (ST.init t)))+    <> prop "Text.foldl1 agrees with Data.Text" (property (do t <- forAll genText; agrees (T.foldl1 max t) (ST.foldl1 max t)))+    <> prop "Text.foldl1' agrees with Data.Text" (property (do t <- forAll genText; agrees (T.foldl1' min t) (ST.foldl1' min t)))+    <> prop "Text.foldr1 agrees with Data.Text" (property (do t <- forAll genText; agrees (T.foldr1 const t) (ST.foldr1 const t)))+    <> prop "Text.maximum agrees with Data.Text" (property (do t <- forAll genText; agrees (T.maximum t) (ST.maximum t)))+    <> prop "Text.minimum agrees with Data.Text" (property (do t <- forAll genText; agrees (T.minimum t) (ST.minimum t)))+    <> prop "Text.index agrees with Data.Text" (property (do t <- forAll genText; i <- forAll genIndex; agrees (T.index t i) (ST.index t i)))+    <> prop "Text.splitOn agrees with Data.Text" (property (do p <- forAll genNeedle; t <- forAll genText; agrees (T.splitOn p t) (ST.splitOn p t)))+    <> prop "Text.breakOn agrees with Data.Text" (property (do p <- forAll genNeedle; t <- forAll genText; agrees (T.breakOn p t) (ST.breakOn p t)))+    <> prop "Text.breakOnEnd agrees with Data.Text" (property (do p <- forAll genNeedle; t <- forAll genText; agrees (T.breakOnEnd p t) (ST.breakOnEnd p t)))+    <> prop "Text.breakOnAll agrees with Data.Text" (property (do p <- forAll genNeedle; t <- forAll genText; agrees (T.breakOnAll p t) (ST.breakOnAll p t)))+    <> prop "Text.count agrees with Data.Text" (property (do p <- forAll genNeedle; t <- forAll genText; agrees (T.count p t) (ST.count p t)))+    <> prop "Text.replace agrees with Data.Text" (property (do p <- forAll genNeedle; r <- forAll genNeedle; t <- forAll genText; agrees (T.replace p r t) (ST.replace p r t)))+    <> prop "display is pack . show" (property (do n <- forAll (Gen.int Range.linearBounded); display n === ST.pack (P.show n)))++-- Papa.Text.Data.Text.Lazy++lazyText :: [(PropertyName, Property)]+lazyText =+  prop "LazyText.head agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.head t) (STL.head t)))+    <> prop "LazyText.last agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.last t) (STL.last t)))+    <> prop "LazyText.tail agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.tail t) (STL.tail t)))+    <> prop "LazyText.init agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.init t) (STL.init t)))+    <> prop "LazyText.foldl1 agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.foldl1 max t) (STL.foldl1 max t)))+    <> prop "LazyText.foldl1' agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.foldl1' min t) (STL.foldl1' min t)))+    <> prop "LazyText.foldr1 agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.foldr1 const t) (STL.foldr1 const t)))+    <> prop "LazyText.maximum agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.maximum t) (STL.maximum t)))+    <> prop "LazyText.minimum agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agrees (TL.minimum t) (STL.minimum t)))+    <> prop "LazyText.cycle agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; agreesBy (STL.take 20) (TL.cycle t) (STL.cycle t)))+    <> prop "LazyText.index agrees with Data.Text.Lazy" (property (do t <- forAll genLazyText; i <- forAll genIndex; agrees (TL.index t (intCast i)) (STL.index t (intCast i))))+    <> prop "LazyText.splitOn agrees with Data.Text.Lazy" (property (do p <- forAll genLazyNeedle; t <- forAll genLazyText; agrees (TL.splitOn p t) (STL.splitOn p t)))+    <> prop "LazyText.breakOn agrees with Data.Text.Lazy" (property (do p <- forAll genLazyNeedle; t <- forAll genLazyText; agrees (TL.breakOn p t) (STL.breakOn p t)))+    <> prop "LazyText.breakOnEnd agrees with Data.Text.Lazy" (property (do p <- forAll genLazyNeedle; t <- forAll genLazyText; agrees (TL.breakOnEnd p t) (STL.breakOnEnd p t)))+    <> prop "LazyText.breakOnAll agrees with Data.Text.Lazy" (property (do p <- forAll genLazyNeedle; t <- forAll genLazyText; agrees (TL.breakOnAll p t) (STL.breakOnAll p t)))+    <> prop "LazyText.count agrees with Data.Text.Lazy" (property (do p <- forAll genLazyNeedle; t <- forAll genLazyText; agrees (TL.count p t) (STL.count p t)))+    <> prop "LazyText.replace agrees with Data.Text.Lazy" (property (do p <- forAll genLazyNeedle; r <- forAll genLazyNeedle; t <- forAll genLazyText; agrees (TL.replace p r t) (STL.replace p r t)))++-- Papa.Text.Data.Text.Encoding and Papa.Text.Data.Text.Lazy.Encoding++encoding :: [(PropertyName, Property)]+encoding =+  prop "Encoding.decodeUtf8 agrees with Data.Text.Encoding" (property (do b <- forAll genEncoded; agreesBy id (preview _Right (TE.decodeUtf8 b)) (STE.decodeUtf8 b)))+    <> prop "Encoding.decodeASCII agrees with Data.Text.Encoding" (property (do b <- forAll genEncoded; agrees (TE.decodeASCII b) (STE.decodeASCII b)))+    <> prop "Encoding.decodeUtf16LE agrees with Data.Text.Encoding" (property (do b <- forAll genUtf16; agrees (preview _Right (TE.decodeUtf16LE b)) (STE.decodeUtf16LE b)))+    <> prop "Encoding.decodeUtf16BE agrees with Data.Text.Encoding" (property (do b <- forAll genUtf16; agrees (preview _Right (TE.decodeUtf16BE b)) (STE.decodeUtf16BE b)))+    <> prop "Encoding.decodeUtf32LE agrees with Data.Text.Encoding" (property (do b <- forAll genUtf32; agrees (preview _Right (TE.decodeUtf32LE b)) (STE.decodeUtf32LE b)))+    <> prop "Encoding.decodeUtf32BE agrees with Data.Text.Encoding" (property (do b <- forAll genUtf32; agrees (preview _Right (TE.decodeUtf32BE b)) (STE.decodeUtf32BE b)))+    <> prop "Encoding.decodeUtf16LE . encodeUtf16LE == Right" (property (do t <- forAll genUnicode; TE.decodeUtf16LE (TE.encodeUtf16LE t) === Right t))+    <> prop "Encoding.decodeUtf32BE . encodeUtf32BE == Right" (property (do t <- forAll genUnicode; TE.decodeUtf32BE (TE.encodeUtf32BE t) === Right t))+    <> prop "LazyEncoding.decodeUtf8 agrees with Data.Text.Lazy.Encoding" (property (do b <- forAll (SL.fromStrict <$> genEncoded); agrees (preview _Right (TLE.decodeUtf8 b)) (STLE.decodeUtf8 b)))+    <> prop "LazyEncoding.decodeASCII agrees with Data.Text.Lazy.Encoding" (property (do b <- forAll (SL.fromStrict <$> genEncoded); agrees (TLE.decodeASCII b) (STLE.decodeASCII b)))+    <> prop "LazyEncoding.decodeUtf16LE agrees with Data.Text.Lazy.Encoding" (property (do b <- forAll (SL.fromStrict <$> genUtf16); agrees (preview _Right (TLE.decodeUtf16LE b)) (STLE.decodeUtf16LE b)))+    <> prop "LazyEncoding.decodeUtf16BE agrees with Data.Text.Lazy.Encoding" (property (do b <- forAll (SL.fromStrict <$> genUtf16); agrees (preview _Right (TLE.decodeUtf16BE b)) (STLE.decodeUtf16BE b)))+    <> prop "LazyEncoding.decodeUtf32LE agrees with Data.Text.Lazy.Encoding" (property (do b <- forAll (SL.fromStrict <$> genUtf32); agrees (preview _Right (TLE.decodeUtf32LE b)) (STLE.decodeUtf32LE b)))+    <> prop "LazyEncoding.decodeUtf32BE agrees with Data.Text.Lazy.Encoding" (property (do b <- forAll (SL.fromStrict <$> genUtf32); agrees (preview _Right (TLE.decodeUtf32BE b)) (STLE.decodeUtf32BE b)))++-- | Bytes that are UTF-8 (and often ASCII), or are not.+genEncoded :: Gen ByteString+genEncoded =+  Gen.choice [STE.encodeUtf8 <$> genUnicode, STE.encodeUtf8 <$> genText, genBytes]++-- | Bytes that are UTF-16, or are not.+genUtf16 :: Gen ByteString+genUtf16 =+  Gen.choice [STE.encodeUtf16LE <$> genUnicode, STE.encodeUtf16BE <$> genUnicode, genBytes]++-- | Bytes that are UTF-32, or are not.+genUtf32 :: Gen ByteString+genUtf32 =+  Gen.choice [STE.encodeUtf32LE <$> genUnicode, STE.encodeUtf32BE <$> genUnicode, genBytes]++-- Papa.Text.Data.Text.Read and Papa.Text.Data.Text.Lazy.Read++textReads :: [(PropertyName, Property)]+textReads =+  prop "Read.decimal: Data.Text.Read's at Integer, where it fits a Word8" (property (do n <- forAll (genInteger (Range.linear 0 600)); s <- forAll genText; let { t = display n <> s }; (TR.decimal t :: Either [Char] (Word8, Text)) === fmap (first P.fromInteger) (bool (Left "number out of range") (STR.decimal t) (n <= 255))))+    <> prop "Read.hexadecimal: Data.Text.Read's at Integer" (property (do n <- forAll (genInteger (Range.linear 0 100000)); (TR.hexadecimal (display n) :: Either [Char] (Integer, Text)) === STR.hexadecimal (display n)))+    <> prop "Read.signed decimal: Data.Text.Read's at Int" (property (do n <- forAll (Gen.int (Range.linear (-1000) 1000)); (TR.signed TR.decimal (display n) :: Either [Char] (Int, Text)) === STR.signed STR.decimal (display n)))+    <> prop "Read.signed decimal: out of range at Word8 and Natural for a negative number" (property (do n <- forAll (genInteger (Range.linear (-1000) (-1))); (TR.signed TR.decimal (display n) :: Either [Char] (Word8, Text)) === Left "number out of range"; (TR.signed TR.decimal (display n) :: Either [Char] (Natural, Text)) === Left "number out of range"))+    <> prop "Read.decimal: every Int round-trips" (property (do n <- forAll (Gen.int Range.linearBounded); TR.signed TR.decimal (display n) === Right (n, "")))+    <> prop "Read.decimal: maxBound + 1 does not fit an Int" (property ((TR.decimal (display (toInteger (maxBound :: Int) + 1)) :: Either [Char] (Int, Text)) === Left "number out of range"))+    <> prop "LazyRead.decimal and hexadecimal: Data.Text.Read's on the strict text" (property (do t <- forAll (Gen.choice [genText, display <$> Gen.int Range.linearBounded, ("0x" <>) <$> genText, ("0x" <>) . display <$> Gen.int (Range.linear 0 1000)]); (TLR.decimal (STL.fromStrict t) :: Either [Char] (Int, STL.Text)) === fmap (second STL.fromStrict) (TR.decimal t); (TLR.hexadecimal (STL.fromStrict t) :: Either [Char] (Int, STL.Text)) === fmap (second STL.fromStrict) (TR.hexadecimal t)))+    <> prop "LazyRead.signed decimal: Data.Text.Lazy.Read's at Integer" (property (do n <- forAll (genInteger (Range.linear (-1000) 1000)); let { t = STL.fromStrict (display n) }; (TLR.signed TLR.decimal t :: Either [Char] (Integer, STL.Text)) === Right (n, "")))++-- Papa.Text.Data.Text.Lazy.Builder and .Int++builders :: [(PropertyName, Property)]+builders =+  prop "Builder.toLazyTextWith: the text, at any size" (property (do n <- forAll (Gen.int (Range.linear (-10) 10)); t <- forAll genUnicode; TB.toLazyTextWith n (STB.fromText t) === STL.fromStrict t))+    <> prop "BuilderInt.hexadecimal agrees with Data.Text.Lazy.Builder.Int" (property (do n <- forAll (Gen.int (Range.linear (-1000) 1000)); agreesBy STB.toLazyText (TBI.hexadecimal n) (STBI.hexadecimal n)))++-- Papa.Bytestring.Data.ByteString++bytestring :: [(PropertyName, Property)]+bytestring =+  prop "ByteString.head agrees with Data.ByteString" (property (do b <- forAll genBytes; agrees (B.head b) (SB.head b)))+    <> prop "ByteString.last agrees with Data.ByteString" (property (do b <- forAll genBytes; agrees (B.last b) (SB.last b)))+    <> prop "ByteString.tail agrees with Data.ByteString" (property (do b <- forAll genBytes; agrees (B.tail b) (SB.tail b)))+    <> prop "ByteString.init agrees with Data.ByteString" (property (do b <- forAll genBytes; agrees (B.init b) (SB.init b)))+    <> prop "ByteString.foldl1 agrees with Data.ByteString" (property (do b <- forAll genBytes; f <- forAll genWordFn; agrees (B.foldl1 (wordFn f) b) (SB.foldl1 (wordFn f) b)))+    <> prop "ByteString.foldl1' agrees with Data.ByteString" (property (do b <- forAll genBytes; f <- forAll genWordFn; agrees (B.foldl1' (wordFn f) b) (SB.foldl1' (wordFn f) b)))+    <> prop "ByteString.foldr1 agrees with Data.ByteString" (property (do b <- forAll genBytes; f <- forAll genWordFn; agrees (B.foldr1 (wordFn f) b) (SB.foldr1 (wordFn f) b)))+    <> prop "ByteString.foldr1' agrees with Data.ByteString" (property (do b <- forAll genBytes; f <- forAll genWordFn; agrees (B.foldr1' (wordFn f) b) (SB.foldr1' (wordFn f) b)))+    <> prop "ByteString.maximum agrees with Data.ByteString" (property (do b <- forAll genBytes; agrees (B.maximum b) (SB.maximum b)))+    <> prop "ByteString.minimum agrees with Data.ByteString" (property (do b <- forAll genBytes; agrees (B.minimum b) (SB.minimum b)))+    <> prop "ByteString.index agrees with Data.ByteString" (property (do b <- forAll genBytes; i <- forAll genIndex; agrees (B.index b i) (SB.index b i)))++-- Papa.Bytestring.Data.ByteString.Lazy++lazyBytestring :: [(PropertyName, Property)]+lazyBytestring =+  prop "LazyByteString.head agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agrees (BL.head b) (SL.head b)))+    <> prop "LazyByteString.last agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agrees (BL.last b) (SL.last b)))+    <> prop "LazyByteString.tail agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agrees (BL.tail b) (SL.tail b)))+    <> prop "LazyByteString.init agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agrees (BL.init b) (SL.init b)))+    <> prop "LazyByteString.foldl1 agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; f <- forAll genWordFn; agrees (BL.foldl1 (wordFn f) b) (SL.foldl1 (wordFn f) b)))+    <> prop "LazyByteString.foldl1' agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; f <- forAll genWordFn; agrees (BL.foldl1' (wordFn f) b) (SL.foldl1' (wordFn f) b)))+    <> prop "LazyByteString.foldr1 agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; f <- forAll genWordFn; agrees (BL.foldr1 (wordFn f) b) (SL.foldr1 (wordFn f) b)))+    <> prop "LazyByteString.foldr1' agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; f <- forAll genWordFn; agrees (BL.foldr1' (wordFn f) b) (SL.foldr1' (wordFn f) b)))+    <> prop "LazyByteString.maximum agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agrees (BL.maximum b) (SL.maximum b)))+    <> prop "LazyByteString.minimum agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agrees (BL.minimum b) (SL.minimum b)))+    <> prop "LazyByteString.cycle agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; agreesBy (SL.take 20) (BL.cycle b) (SL.cycle b)))+    <> prop "LazyByteString.index agrees with Data.ByteString.Lazy" (property (do b <- forAll genLazyBytes; i <- forAll genIndex; agrees (BL.index b (intCast i)) (SL.index b (intCast i))))++-- Papa.Bytestring.Data.ByteString.Char8++char8 :: [(PropertyName, Property)]+char8 =+  prop "Char8.head agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.head b) (SC.head b)))+    <> prop "Char8.last agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.last b) (SC.last b)))+    <> prop "Char8.tail agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.tail b) (SC.tail b)))+    <> prop "Char8.init agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.init b) (SC.init b)))+    <> prop "Char8.foldl1 agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.foldl1 max b) (SC.foldl1 max b)))+    <> prop "Char8.foldl1' agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.foldl1' min b) (SC.foldl1' min b)))+    <> prop "Char8.foldr1 agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.foldr1 const b) (SC.foldr1 const b)))+    <> prop "Char8.foldr1' agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.foldr1' max b) (SC.foldr1' max b)))+    <> prop "Char8.foldl1: an intermediate character above '\\255' is kept" (property (BC.foldl1 (\_ _ -> '\300') "ab" === Just '\300'))+    <> prop "Char8.maximum agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.maximum b) (SC.maximum b)))+    <> prop "Char8.minimum agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; agrees (BC.minimum b) (SC.minimum b)))+    <> prop "Char8.index agrees with Data.ByteString.Char8" (property (do b <- forAll genBytes; i <- forAll genIndex; agrees (BC.index b i) (SC.index b i)))+    <> prop "Char8.pack: Data.ByteString.Char8's where every character fits a byte" (property (do s <- forAll genString; BC.pack s === (SC.pack s <$ guard (all fits s))))+    <> prop "Char8.pack . unpack == Just" (property (do b <- forAll genBytes; BC.pack (BC.unpack b) === Just b))+    <> prop "Char8.singleton: Data.ByteString.Char8's where the character fits a byte" (property (do c <- forAll genChar; BC.singleton c === (SC.singleton c <$ guard (fits c))))+    <> prop "Char8.cons: Data.ByteString.Char8's where the character fits a byte" (property (do c <- forAll genChar; b <- forAll genBytes; BC.cons c b === (SC.cons c b <$ guard (fits c))))+    <> prop "Char8.snoc: Data.ByteString.Char8's where the character fits a byte" (property (do c <- forAll genChar; b <- forAll genBytes; BC.snoc b c === (SC.snoc b c <$ guard (fits c))))+    <> prop "Char8.intersperse: Data.ByteString.Char8's where the character fits a byte" (property (do c <- forAll genChar; b <- forAll genBytes; BC.intersperse c b === (SC.intersperse c b <$ guard (fits c))))+    <> prop "Char8.replicate: Data.ByteString.Char8's where the character fits a byte" (property (do n <- forAll genIndex; c <- forAll genChar; BC.replicate n c === (SC.replicate n c <$ guard (fits c))))+    <> prop "Char8.map: Data.ByteString.Char8's where every result fits a byte" (property (do c <- forAll genChar; b <- forAll genBytes; let { f x = bool x c (x == 'a') }; BC.map f b === (SC.map f b <$ guard (SC.all (fits . f) b))))+    <> prop "Char8.unfoldr: pack of the unfolded string" (property (do s <- forAll genString; BC.unfoldr uncons s === BC.pack s))+    <> prop "Char8.unzip: the packed firsts and seconds" (property (do s <- forAll genString; t <- forAll genString; BC.unzip (zip s t) === ((SC.pack (fmap fst (zip s t)), SC.pack (fmap snd (zip s t))) <$ guard (all (fits . fst) (zip s t) && all (fits . snd) (zip s t)))))+    <> prop "Char8.elem: the list's" (property (do c <- forAll genChar; b <- forAll genBytes; BC.elem c b === List.elem c (SC.unpack b)))+    <> prop "Char8.notElem: the list's" (property (do c <- forAll genChar; b <- forAll genBytes; BC.notElem c b === List.notElem c (SC.unpack b)))+    <> prop "Char8.elemIndex: the list's" (property (do c <- forAll genChar; b <- forAll genBytes; BC.elemIndex c b === List.elemIndex c (SC.unpack b)))+    <> prop "Char8.elemIndices: the list's" (property (do c <- forAll genChar; b <- forAll genBytes; BC.elemIndices c b === List.elemIndices c (SC.unpack b)))+    <> prop "Char8.elemIndexEnd: the list's last" (property (do c <- forAll genChar; b <- forAll genBytes; BC.elemIndexEnd c b === preview _last (List.elemIndices c (SC.unpack b))))+    <> prop "Char8.count: the list's" (property (do c <- forAll genChar; b <- forAll genBytes; BC.count c b === length (List.elemIndices c (SC.unpack b))))+    <> prop "Char8.split: splitWith (== c)" (property (do c <- forAll genChar; b <- forAll genBytes; BC.split c b === SC.splitWith (== c) b))+    <> prop "Char8.split: Data.ByteString.Char8's where the character fits a byte" (property (do c <- forAll Gen.latin1; b <- forAll genBytes; BC.split c b === SC.split c b))++-- | Whether a character fits a byte.+fits :: Char -> Bool+fits c =+  c <= '\255'++-- Papa.Bytestring.Data.ByteString.Lazy.Char8++lazyChar8 :: [(PropertyName, Property)]+lazyChar8 =+  prop "LazyChar8.head agrees with Data.ByteString.Lazy.Char8" (property (do b <- forAll genLazyBytes; agrees (BLC.head b) (SLC.head b)))+    <> prop "LazyChar8.foldr1 agrees with Data.ByteString.Lazy.Char8" (property (do b <- forAll genLazyBytes; agrees (BLC.foldr1 const b) (SLC.foldr1 const b)))+    <> prop "LazyChar8.maximum agrees with Data.ByteString.Lazy.Char8" (property (do b <- forAll genLazyBytes; agrees (BLC.maximum b) (SLC.maximum b)))+    <> prop "LazyChar8.index agrees with Data.ByteString.Lazy.Char8" (property (do b <- forAll genLazyBytes; i <- forAll genIndex; agrees (BLC.index b (intCast i)) (SLC.index b (intCast i))))+    <> prop "LazyChar8.cycle agrees with Data.ByteString.Lazy.Char8" (property (do b <- forAll genLazyBytes; agreesBy (SLC.take 20) (BLC.cycle b) (SLC.cycle b)))+    <> prop "LazyChar8.pack: Data.ByteString.Lazy.Char8's where every character fits a byte" (property (do s <- forAll genString; BLC.pack s === (SLC.pack s <$ guard (all fits s))))+    <> prop "LazyChar8.cons': Data.ByteString.Lazy.Char8's where the character fits a byte" (property (do c <- forAll genChar; b <- forAll genLazyBytes; BLC.cons' c b === (SLC.cons' c b <$ guard (fits c))))+    <> prop "LazyChar8.repeat: Data.ByteString.Lazy.Char8's where the character fits a byte" (property (do c <- forAll genChar; fmap (SLC.take 5) (BLC.repeat c) === (SLC.take 5 (SLC.repeat c) <$ guard (fits c))))+    <> prop "LazyChar8.replicate: Data.ByteString.Lazy.Char8's where the character fits a byte" (property (do n <- forAll genIndex; c <- forAll genChar; BLC.replicate (intCast n) c === (SLC.replicate (intCast n) c <$ guard (fits c))))+    <> prop "LazyChar8.elem: the list's" (property (do c <- forAll genChar; b <- forAll genLazyBytes; BLC.elem c b === List.elem c (SLC.unpack b)))+    <> prop "LazyChar8.count: the list's" (property (do c <- forAll genChar; b <- forAll genLazyBytes; BLC.count c b === intCast (length (List.elemIndices c (SLC.unpack b)))))+    <> prop "LazyChar8.split: splitWith (== c)" (property (do c <- forAll genChar; b <- forAll genLazyBytes; BLC.split c b === SLC.splitWith (== c) b))++-- Papa.Bytestring.Data.ByteString.Builder++bytestringBuilder :: [(PropertyName, Property)]+bytestringBuilder =+  prop "Builder.char7: Data.ByteString.Builder's where the character is ASCII" (property (do c <- forAll genChar; fmap SBB.toLazyByteString (BB.char7 c) === (SBB.toLazyByteString (SBB.char7 c) <$ guard (c <= '\127'))))+    <> prop "Builder.string7: Data.ByteString.Builder's where every character is ASCII" (property (do s <- forAll genString; fmap SBB.toLazyByteString (BB.string7 s) === (SBB.toLazyByteString (SBB.string7 s) <$ guard (all (<= '\127') s))))+    <> prop "Builder.char8: Data.ByteString.Builder's where the character fits a byte" (property (do c <- forAll genChar; fmap SBB.toLazyByteString (BB.char8 c) === (SBB.toLazyByteString (SBB.char8 c) <$ guard (fits c))))+    <> prop "Builder.string8: Data.ByteString.Builder's where every character fits a byte" (property (do s <- forAll genString; fmap SBB.toLazyByteString (BB.string8 s) === (SBB.toLazyByteString (SBB.string8 s) <$ guard (all fits s))))++-- I/O, through a temporary file.++-- | Run an action on the path of a new temporary file, and remove it.+withTemp :: (FilePath -> PropertyT IO a) -> PropertyT IO a+withTemp k = do+  path <- evalIO (D.getTemporaryDirectory >>= \d -> IO.openTempFile d "papa-test.txt" >>= \(p, h) -> p <$ IO.hClose h)+  a <- k path+  evalIO (D.removeFile path)+  pure a++io :: [(PropertyName, Property)]+io =+  prop "TextIO.readFile . TextIO.writeFile == Right" (property (do t <- forAll genUnicode; r <- withTemp (\p -> evalIO (runExceptT (TIO.writeFile p t >> TIO.readFile p))); r === Right t))+    <> prop "TextIO.writeFile writes UTF-8" (property (do t <- forAll genUnicode; r <- withTemp (\p -> evalIO (runExceptT (TIO.writeFile p t) >> SB.readFile p)); r === STE.encodeUtf8 t))+    <> prop "TextIO.appendFile appends" (property (do t <- forAll genUnicode; u <- forAll genUnicode; r <- withTemp (\p -> evalIO (runExceptT (TIO.writeFile p t >> TIO.appendFile p u >> TIO.readFile p))); r === Right (t <> u)))+    <> prop "TextIO.readFile: invalid UTF-8 is a DecodeFailed of the file" (property (do b <- forAll genBytes; (p, r) <- withTemp (\p -> (,) p <$> evalIO (SB.writeFile p b >> runExceptT (TIO.readFile p))); either (\e -> (preview (_DecodeFailed . _1) e, isLeft (STE.decodeUtf8' b)) === (Just (Right p), True)) (\t -> Right t === STE.decodeUtf8' b) r))+    <> prop "TextIO.readFile: a missing file is a does-not-exist error" (property (do r <- evalIO (runExceptT (TIO.readFile "/nonexistent/papa/file")); either (has (_IOException . filtered isDoesNotExistError)) (const False) r === True))+    <> prop "TextIO.hGetLine: Data.ByteString.Char8's hGetLine, then decodeUtf8', at any buffer size and encoding" (withTests 1000 (property (do b <- forAll genLineBytes; n <- forAll (Gen.element [Nothing, Just 1, Just 2, Just 3, Just 5, Just 8, Just 4096]); e <- forAll (Gen.element [IO.utf8, IO.latin1]); r <- withTemp (\p -> evalIO (SB.writeFile p b *> ((,) <$> readLines p n e (SB.length b) papaLine <*> readLines p n e (SB.length b) referenceLine))); uncurry (===) r)))+    <> prop "TextIO.hGetLine: the lines, then an end-of-file error" (property (do ls <- forAll (Gen.list (Range.linear 0 5) (Gen.text (Range.linear 0 8) (Gen.filter (/= '\n') Gen.unicode))); r <- withTemp (\p -> evalIO (runExceptT (TIO.writeFile p (ST.concat (fmap (<> "\n") ls))) >> IO.withFile p IO.ReadMode (\h -> traverse (const (runExceptT (TIO.hGetLine h))) (() : void ls)))); (fmap (preview _Right) r, fmap (either (has (_IOException . filtered isEOFError)) (const False)) (preview _last r)) === (fmap Just ls <> [Nothing], Just True)))+    <> prop "TextIO.hGetContents . TextIO.hPutStrLn == Right" (property (do t <- forAll genUnicode; r <- withTemp (\p -> evalIO (IO.withFile p IO.WriteMode (\h -> runExceptT (TIO.hPutStrLn h t)) >> IO.withFile p IO.ReadMode (runExceptT . TIO.hGetContents))); r === Right (t <> "\n")))+    <> prop "TextIO.hPrint writes display" (property (do n <- forAll (Gen.int Range.linearBounded); r <- withTemp (\p -> evalIO (IO.withFile p IO.WriteMode (\h -> runExceptT (TIO.hPrint h n)) >> SB.readFile p)); r === STE.encodeUtf8 (display n <> "\n")))+    <> prop "ByteString.readFile . ByteString.writeFile == Right" (property (do b <- forAll genBytes; r <- withTemp (\p -> evalIO (runExceptT (B.writeFile p b >> B.readFile p))); r === Right b))+    <> prop "ByteString.hGet: a negative size is an error" (property (do r <- withTemp (\p -> evalIO (IO.withFile p IO.ReadMode (\h -> runExceptT (B.hGet h (-1))))); isLeft r === True))+    <> prop "LazyByteString.writeFile writes" (property (do b <- forAll genLazyBytes; r <- withTemp (\p -> evalIO (runExceptT (BL.writeFile p b >> BL.appendFile p b) >> SB.readFile p)); r === SL.toStrict (b <> b)))+    <> prop "Char8.hPutStrLn writes a newline" (property (do b <- forAll genBytes; r <- withTemp (\p -> evalIO (IO.withFile p IO.WriteMode (\h -> runExceptT (BC.hPutStrLn h b)) >> SB.readFile p)); r === SB.snoc b 10))+    <> prop "LazyChar8.writeFile writes" (property (do b <- forAll genLazyBytes; r <- withTemp (\p -> evalIO (runExceptT (BLC.writeFile p b) >> SB.readFile p)); r === SL.toStrict b))+    <> prop "Builder.writeFile writes" (property (do b <- forAll genBytes; r <- withTemp (\p -> evalIO (runExceptT (BB.writeFile p (SBB.byteString b)) >> SB.readFile p)); r === b))+    <> prop "Builder.hPutBuilder: a closed handle is an error" (property (do r <- withTemp (\p -> evalIO (IO.openFile p IO.WriteMode >>= \h -> IO.hClose h >> runExceptT (BB.hPutBuilder h (SBB.word8 0)))); isLeft r === True))
+ test/PropertiesVector.hs view
@@ -0,0 +1,236 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these properties compare Papa's total head, last, init, tail,+-- maximum and minimum of vectors with vector's partial ones, whose names+-- HLint restricts whatever module they come from.++-- | The properties of the total vector, hash map and hash set modules: each+-- total function agrees with the partial one it replaces (it is 'Nothing'+-- exactly where the partial one throws), and lens's 'ix', 'at' and+-- 'contains' agree with the indexing functions.+--+-- The monadic folds are compared in 'Maybe', whose bind forces the fold: in+-- 'Identity', the originals' error for an empty vector is never forced.+module PropertiesVector (+  propertiesVector,+) where++import Agree (agrees)+import Control.Monad.ST (runST)+import qualified Data.HashMap.Strict as OHM+import qualified Data.HashSet as OHS+import qualified Data.Vector as OV+import qualified Data.Vector.Mutable as MV+import qualified Data.Vector.Storable as OS+import qualified Data.Vector.Storable.Mutable as MS+import qualified Data.Vector.Unboxed as OU+import qualified Data.Vector.Unboxed.Mutable as MU+import Hedgehog (Gen, Group (Group), Property, PropertyName, forAll, property, (===))+import Hedgehog.Function (Fn, apply, fn)+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range+import Papa+import qualified Papa.UnorderedContainers.Data.HashMap as HashMap+import qualified Papa.UnorderedContainers.Data.HashSet as HashSet+import qualified Papa.Vector.Data.Vector as PV+import qualified Papa.Vector.Data.Vector.Storable as PS+import qualified Papa.Vector.Data.Vector.Unboxed as PU++-- | The properties of the vector, hash map and hash set modules.+propertiesVector :: Group+propertiesVector =+  Group "papa: vector, unordered-containers" (vector <> unboxed <> storable <> hashMap <> hashSet)++prop :: PropertyName -> Property -> [(PropertyName, Property)]+prop name p =+  [(name, p)]++genInt :: Gen Int+genInt =+  Gen.int (Range.linear (-100) 100)++genIndex :: Gen Int+genIndex =+  Gen.int (Range.linear (-3) 12)++genList :: Gen [Int]+genList =+  Gen.list (Range.linear 0 10) genInt++genIndices :: Gen [Int]+genIndices =+  Gen.list (Range.linear 0 5) genIndex++genUpdates :: Gen [(Int, Int)]+genUpdates =+  Gen.list (Range.linear 0 5) ((,) <$> genIndex <*> genInt)++genFn1 :: Gen (Fn Int Int)+genFn1 =+  fn genInt++genFn2 :: Gen (Fn (Int, Int) Int)+genFn2 =+  fn genInt++genKey :: Gen Int+genKey =+  Gen.int (Range.linear 0 20)++genHashMap :: Gen (HashMap Int Int)+genHashMap =+  HashMap.fromList <$> Gen.list (Range.linear 0 10) ((,) <$> genKey <*> genInt)++genHashSet :: Gen (HashSet Int)+genHashSet =+  HashSet.fromList <$> Gen.list (Range.linear 0 10) genKey++genPV :: Gen (OV.Vector Int)+genPV =+  OV.fromList <$> genList++vector :: [(PropertyName, Property)]+vector =+  prop "Vector.head: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.head v) (OV.head v)))+    <> prop "Vector.last: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.last v) (OV.last v)))+    <> prop "Vector.indexM: agrees with Data.Vector" (property (do v <- forAll genPV; i <- forAll genIndex; agrees (runIdentity (PV.indexM v i)) (runIdentity (OV.indexM v i))))+    <> prop "Vector.headM: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (runIdentity (PV.headM v)) (runIdentity (OV.headM v))))+    <> prop "Vector.lastM: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (runIdentity (PV.lastM v)) (runIdentity (OV.lastM v))))+    <> prop "Vector.slice: agrees with Data.Vector" (property (do v <- forAll genPV; i <- forAll genIndex; n <- forAll genIndex; agrees (PV.slice i n v) (OV.slice i n v)))+    <> prop "Vector.init: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.init v) (OV.init v)))+    <> prop "Vector.tail: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.tail v) (OV.tail v)))+    <> prop "Vector.constructN: agrees with Data.Vector" (property (do n <- forAll genIndex; agrees (PV.constructN n (OV.sum :: OV.Vector Int -> Int)) (OV.constructN n OV.sum)))+    <> prop "Vector.constructrN: agrees with Data.Vector" (property (do n <- forAll genIndex; agrees (PV.constructrN n (OV.sum :: OV.Vector Int -> Int)) (OV.constructrN n OV.sum)))+    <> prop "Vector.//: agrees with Data.Vector" (property (do v <- forAll genPV; us <- forAll genUpdates; agrees (v PV.// us) (v OV.// us)))+    <> prop "Vector.update: agrees with Data.Vector" (property (do v <- forAll genPV; us <- forAll genUpdates; agrees (PV.update v (OV.fromList us)) (OV.update v (OV.fromList us))))+    <> prop "Vector.update_: agrees with Data.Vector" (property (do v <- forAll genPV; is <- forAll genIndices; xs <- forAll genPV; agrees (PV.update_ v (OV.fromList is) xs) (OV.update_ v (OV.fromList is) xs)))+    <> prop "Vector.accum: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; us <- forAll genUpdates; agrees (PV.accum f v us) (OV.accum f v us)))+    <> prop "Vector.accumulate: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; us <- forAll genUpdates; agrees (PV.accumulate f v (OV.fromList us)) (OV.accumulate f v (OV.fromList us))))+    <> prop "Vector.accumulate_: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; is <- forAll genIndices; xs <- forAll genPV; agrees (PV.accumulate_ f v (OV.fromList is) xs) (OV.accumulate_ f v (OV.fromList is) xs)))+    <> prop "Vector.backpermute: agrees with Data.Vector" (property (do v <- forAll genPV; is <- forAll genIndices; agrees (PV.backpermute v (OV.fromList is)) (OV.backpermute v (OV.fromList is))))+    <> prop "Vector.foldl1: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PV.foldl1 f v) (OV.foldl1 f v)))+    <> prop "Vector.foldl1': agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PV.foldl1' f v) (OV.foldl1' f v)))+    <> prop "Vector.foldr1: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PV.foldr1 f v) (OV.foldr1 f v)))+    <> prop "Vector.foldr1': agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PV.foldr1' f v) (OV.foldr1' f v)))+    <> prop "Vector.maximum: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.maximum v) (OV.maximum v)))+    <> prop "Vector.maximumBy: agrees with Data.Vector" (property (do v <- forAll genPV; h <- forAll genFn1; agrees (PV.maximumBy (comparing (apply h)) v) (OV.maximumBy (comparing (apply h)) v)))+    <> prop "Vector.maximumOn: agrees with Data.Vector" (property (do v <- forAll genPV; h <- forAll genFn1; agrees (PV.maximumOn (apply h) v) (OV.maximumOn (apply h) v)))+    <> prop "Vector.minimum: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.minimum v) (OV.minimum v)))+    <> prop "Vector.minimumBy: agrees with Data.Vector" (property (do v <- forAll genPV; h <- forAll genFn1; agrees (PV.minimumBy (comparing (apply h)) v) (OV.minimumBy (comparing (apply h)) v)))+    <> prop "Vector.minimumOn: agrees with Data.Vector" (property (do v <- forAll genPV; h <- forAll genFn1; agrees (PV.minimumOn (apply h) v) (OV.minimumOn (apply h) v)))+    <> prop "Vector.maxIndex: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.maxIndex v) (OV.maxIndex v)))+    <> prop "Vector.maxIndexBy: agrees with Data.Vector" (property (do v <- forAll genPV; h <- forAll genFn1; agrees (PV.maxIndexBy (comparing (apply h)) v) (OV.maxIndexBy (comparing (apply h)) v)))+    <> prop "Vector.minIndex: agrees with Data.Vector" (property (do v <- forAll genPV; agrees (PV.minIndex v) (OV.minIndex v)))+    <> prop "Vector.minIndexBy: agrees with Data.Vector" (property (do v <- forAll genPV; h <- forAll genFn1; agrees (PV.minIndexBy (comparing (apply h)) v) (OV.minIndexBy (comparing (apply h)) v)))+    <> prop "Vector.fold1M: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PV.fold1M f v)) (OV.fold1M f v)))+    <> prop "Vector.fold1M': agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PV.fold1M' f v)) (OV.fold1M' f v)))+    <> prop "Vector.fold1M_: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PV.fold1M_ f v)) (OV.fold1M_ f v)))+    <> prop "Vector.fold1M'_: agrees with Data.Vector" (property (do v <- forAll genPV; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PV.fold1M'_ f v)) (OV.fold1M'_ f v)))+    <> prop "Vector.copy: agrees with Data.Vector" (property (do v <- forAll genPV; n <- forAll genIndex; agrees (runST (do m <- MV.replicate (max 0 n) 0; r <- PV.copy m v; w <- OV.freeze m; pure (w <$ r))) (runST (do m <- MV.replicate (max 0 n) 0; OV.copy m v; OV.freeze m))))+    <> prop "Vector.ix: agrees with Data.Vector" (property (do v <- forAll genPV; i <- forAll genIndex; agrees (v ^? ix i) (v OV.! i)))+    <> prop "Vector.ix .~: agrees with Data.Vector" (property (do v <- forAll genPV; i <- forAll genIndex; a <- forAll genInt; (v & ix i .~ a) === fromMaybe v (v PV.// [(i, a)])))++genPU :: Gen (OU.Vector Int)+genPU =+  OU.fromList <$> genList++unboxed :: [(PropertyName, Property)]+unboxed =+  prop "Unboxed.head: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.head v) (OU.head v)))+    <> prop "Unboxed.last: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.last v) (OU.last v)))+    <> prop "Unboxed.indexM: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; i <- forAll genIndex; agrees (runIdentity (PU.indexM v i)) (runIdentity (OU.indexM v i))))+    <> prop "Unboxed.headM: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (runIdentity (PU.headM v)) (runIdentity (OU.headM v))))+    <> prop "Unboxed.lastM: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (runIdentity (PU.lastM v)) (runIdentity (OU.lastM v))))+    <> prop "Unboxed.slice: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; i <- forAll genIndex; n <- forAll genIndex; agrees (PU.slice i n v) (OU.slice i n v)))+    <> prop "Unboxed.init: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.init v) (OU.init v)))+    <> prop "Unboxed.tail: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.tail v) (OU.tail v)))+    <> prop "Unboxed.constructN: agrees with Data.Vector.Unboxed" (property (do n <- forAll genIndex; agrees (PU.constructN n (OU.sum :: OU.Vector Int -> Int)) (OU.constructN n OU.sum)))+    <> prop "Unboxed.constructrN: agrees with Data.Vector.Unboxed" (property (do n <- forAll genIndex; agrees (PU.constructrN n (OU.sum :: OU.Vector Int -> Int)) (OU.constructrN n OU.sum)))+    <> prop "Unboxed.//: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; us <- forAll genUpdates; agrees (v PU.// us) (v OU.// us)))+    <> prop "Unboxed.update: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; us <- forAll genUpdates; agrees (PU.update v (OU.fromList us)) (OU.update v (OU.fromList us))))+    <> prop "Unboxed.update_: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; is <- forAll genIndices; xs <- forAll genPU; agrees (PU.update_ v (OU.fromList is) xs) (OU.update_ v (OU.fromList is) xs)))+    <> prop "Unboxed.accum: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; us <- forAll genUpdates; agrees (PU.accum f v us) (OU.accum f v us)))+    <> prop "Unboxed.accumulate: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; us <- forAll genUpdates; agrees (PU.accumulate f v (OU.fromList us)) (OU.accumulate f v (OU.fromList us))))+    <> prop "Unboxed.accumulate_: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; is <- forAll genIndices; xs <- forAll genPU; agrees (PU.accumulate_ f v (OU.fromList is) xs) (OU.accumulate_ f v (OU.fromList is) xs)))+    <> prop "Unboxed.backpermute: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; is <- forAll genIndices; agrees (PU.backpermute v (OU.fromList is)) (OU.backpermute v (OU.fromList is))))+    <> prop "Unboxed.foldl1: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PU.foldl1 f v) (OU.foldl1 f v)))+    <> prop "Unboxed.foldl1': agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PU.foldl1' f v) (OU.foldl1' f v)))+    <> prop "Unboxed.foldr1: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PU.foldr1 f v) (OU.foldr1 f v)))+    <> prop "Unboxed.foldr1': agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PU.foldr1' f v) (OU.foldr1' f v)))+    <> prop "Unboxed.maximum: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.maximum v) (OU.maximum v)))+    <> prop "Unboxed.maximumBy: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; h <- forAll genFn1; agrees (PU.maximumBy (comparing (apply h)) v) (OU.maximumBy (comparing (apply h)) v)))+    <> prop "Unboxed.maximumOn: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; h <- forAll genFn1; agrees (PU.maximumOn (apply h) v) (OU.maximumOn (apply h) v)))+    <> prop "Unboxed.minimum: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.minimum v) (OU.minimum v)))+    <> prop "Unboxed.minimumBy: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; h <- forAll genFn1; agrees (PU.minimumBy (comparing (apply h)) v) (OU.minimumBy (comparing (apply h)) v)))+    <> prop "Unboxed.minimumOn: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; h <- forAll genFn1; agrees (PU.minimumOn (apply h) v) (OU.minimumOn (apply h) v)))+    <> prop "Unboxed.maxIndex: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.maxIndex v) (OU.maxIndex v)))+    <> prop "Unboxed.maxIndexBy: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; h <- forAll genFn1; agrees (PU.maxIndexBy (comparing (apply h)) v) (OU.maxIndexBy (comparing (apply h)) v)))+    <> prop "Unboxed.minIndex: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; agrees (PU.minIndex v) (OU.minIndex v)))+    <> prop "Unboxed.minIndexBy: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; h <- forAll genFn1; agrees (PU.minIndexBy (comparing (apply h)) v) (OU.minIndexBy (comparing (apply h)) v)))+    <> prop "Unboxed.fold1M: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PU.fold1M f v)) (OU.fold1M f v)))+    <> prop "Unboxed.fold1M': agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PU.fold1M' f v)) (OU.fold1M' f v)))+    <> prop "Unboxed.fold1M_: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PU.fold1M_ f v)) (OU.fold1M_ f v)))+    <> prop "Unboxed.fold1M'_: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PU.fold1M'_ f v)) (OU.fold1M'_ f v)))+    <> prop "Unboxed.copy: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; n <- forAll genIndex; agrees (runST (do m <- MU.replicate (max 0 n) 0; r <- PU.copy m v; w <- OU.freeze m; pure (w <$ r))) (runST (do m <- MU.replicate (max 0 n) 0; OU.copy m v; OU.freeze m))))+    <> prop "Unboxed.ix: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; i <- forAll genIndex; agrees (v ^? ix i) (v OU.! i)))+    <> prop "Unboxed.ix .~: agrees with Data.Vector.Unboxed" (property (do v <- forAll genPU; i <- forAll genIndex; a <- forAll genInt; (v & ix i .~ a) === fromMaybe v (v PU.// [(i, a)])))++genPS :: Gen (OS.Vector Int)+genPS =+  OS.fromList <$> genList++storable :: [(PropertyName, Property)]+storable =+  prop "Storable.head: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.head v) (OS.head v)))+    <> prop "Storable.last: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.last v) (OS.last v)))+    <> prop "Storable.indexM: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; i <- forAll genIndex; agrees (runIdentity (PS.indexM v i)) (runIdentity (OS.indexM v i))))+    <> prop "Storable.headM: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (runIdentity (PS.headM v)) (runIdentity (OS.headM v))))+    <> prop "Storable.lastM: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (runIdentity (PS.lastM v)) (runIdentity (OS.lastM v))))+    <> prop "Storable.slice: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; i <- forAll genIndex; n <- forAll genIndex; agrees (PS.slice i n v) (OS.slice i n v)))+    <> prop "Storable.init: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.init v) (OS.init v)))+    <> prop "Storable.tail: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.tail v) (OS.tail v)))+    <> prop "Storable.constructN: agrees with Data.Vector.Storable" (property (do n <- forAll genIndex; agrees (PS.constructN n (OS.sum :: OS.Vector Int -> Int)) (OS.constructN n OS.sum)))+    <> prop "Storable.constructrN: agrees with Data.Vector.Storable" (property (do n <- forAll genIndex; agrees (PS.constructrN n (OS.sum :: OS.Vector Int -> Int)) (OS.constructrN n OS.sum)))+    <> prop "Storable.//: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; us <- forAll genUpdates; agrees (v PS.// us) (v OS.// us)))+    <> prop "Storable.update_: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; is <- forAll genIndices; xs <- forAll genPS; agrees (PS.update_ v (OS.fromList is) xs) (OS.update_ v (OS.fromList is) xs)))+    <> prop "Storable.accum: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = apply g (a, b) }; us <- forAll genUpdates; agrees (PS.accum f v us) (OS.accum f v us)))+    <> prop "Storable.accumulate_: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = apply g (a, b) }; is <- forAll genIndices; xs <- forAll genPS; agrees (PS.accumulate_ f v (OS.fromList is) xs) (OS.accumulate_ f v (OS.fromList is) xs)))+    <> prop "Storable.backpermute: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; is <- forAll genIndices; agrees (PS.backpermute v (OS.fromList is)) (OS.backpermute v (OS.fromList is))))+    <> prop "Storable.foldl1: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PS.foldl1 f v) (OS.foldl1 f v)))+    <> prop "Storable.foldl1': agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PS.foldl1' f v) (OS.foldl1' f v)))+    <> prop "Storable.foldr1: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PS.foldr1 f v) (OS.foldr1 f v)))+    <> prop "Storable.foldr1': agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = apply g (a, b) }; agrees (PS.foldr1' f v) (OS.foldr1' f v)))+    <> prop "Storable.maximum: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.maximum v) (OS.maximum v)))+    <> prop "Storable.maximumBy: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; h <- forAll genFn1; agrees (PS.maximumBy (comparing (apply h)) v) (OS.maximumBy (comparing (apply h)) v)))+    <> prop "Storable.maximumOn: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; h <- forAll genFn1; agrees (PS.maximumOn (apply h) v) (OS.maximumOn (apply h) v)))+    <> prop "Storable.minimum: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.minimum v) (OS.minimum v)))+    <> prop "Storable.minimumBy: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; h <- forAll genFn1; agrees (PS.minimumBy (comparing (apply h)) v) (OS.minimumBy (comparing (apply h)) v)))+    <> prop "Storable.minimumOn: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; h <- forAll genFn1; agrees (PS.minimumOn (apply h) v) (OS.minimumOn (apply h) v)))+    <> prop "Storable.maxIndex: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.maxIndex v) (OS.maxIndex v)))+    <> prop "Storable.maxIndexBy: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; h <- forAll genFn1; agrees (PS.maxIndexBy (comparing (apply h)) v) (OS.maxIndexBy (comparing (apply h)) v)))+    <> prop "Storable.minIndex: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; agrees (PS.minIndex v) (OS.minIndex v)))+    <> prop "Storable.minIndexBy: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; h <- forAll genFn1; agrees (PS.minIndexBy (comparing (apply h)) v) (OS.minIndexBy (comparing (apply h)) v)))+    <> prop "Storable.fold1M: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PS.fold1M f v)) (OS.fold1M f v)))+    <> prop "Storable.fold1M': agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PS.fold1M' f v)) (OS.fold1M' f v)))+    <> prop "Storable.fold1M_: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PS.fold1M_ f v)) (OS.fold1M_ f v)))+    <> prop "Storable.fold1M'_: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; g <- forAll genFn2; let { f a b = Just (apply g (a, b)) }; agrees (sequenceA (PS.fold1M'_ f v)) (OS.fold1M'_ f v)))+    <> prop "Storable.copy: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; n <- forAll genIndex; agrees (runST (do m <- MS.replicate (max 0 n) 0; r <- PS.copy m v; w <- OS.freeze m; pure (w <$ r))) (runST (do m <- MS.replicate (max 0 n) 0; OS.copy m v; OS.freeze m))))+    <> prop "Storable.ix: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; i <- forAll genIndex; agrees (v ^? ix i) (v OS.! i)))+    <> prop "Storable.ix .~: agrees with Data.Vector.Storable" (property (do v <- forAll genPS; i <- forAll genIndex; a <- forAll genInt; (v & ix i .~ a) === fromMaybe v (v PS.// [(i, a)])))++hashMap :: [(PropertyName, Property)]+hashMap =+  prop "HashMap ix: agrees with Data.HashMap.Strict.!" (property (do m <- forAll genHashMap; k <- forAll genKey; agrees (m ^? ix k) (m OHM.! k)))+    <> prop "HashMap at: lookup" (property (do m <- forAll genHashMap; k <- forAll genKey; the (at k) m === OHM.lookup k m))+    <> prop "HashMap at ?~: insert" (property (do m <- forAll genHashMap; k <- forAll genKey; a <- forAll genInt; (m & at k ?~ a) === OHM.insert k a m))+    <> prop "HashMap sans (at .~ Nothing): delete" (property (do m <- forAll genHashMap; k <- forAll genKey; sans k m === OHM.delete k m))+    <> prop "HashMap ix %~: adjust" (property (do m <- forAll genHashMap; k <- forAll genKey; h <- forAll genFn1; (m & ix k %~ apply h) === OHM.adjust (apply h) k m))++hashSet :: [(PropertyName, Property)]+hashSet =+  prop "HashSet contains: member" (property (do s <- forAll genHashSet; a <- forAll genKey; the (contains a) s === OHS.member a s))+    <> prop "HashSet contains .~ True: insert" (property (do s <- forAll genHashSet; a <- forAll genKey; (s & contains a .~ True) === OHS.insert a s))+    <> prop "HashSet contains .~ False: delete" (property (do s <- forAll genHashSet; a <- forAll genKey; (s & contains a .~ False) === OHS.delete a s))
+ test/Totals.hs view
@@ -0,0 +1,310 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wall #-}++{- HLINT ignore "Avoid restricted function" -}+-- Reason: these are Papa's total head, last, init, tail, (!!), maximum and+-- minimum, whose names HLint restricts whatever module they come from.++-- | The total types of the names that 'Papa' reuses from "Prelude" and base+-- for a total function.+--+-- Each binding uses one such name at its total type. Were 'Papa' to export+-- the partial function of that name again (@head :: [a] -> a@,+-- @succ :: a -> a@, a lazy @readFile@, …), the binding would not type check,+-- and this module, and so the test suite, would not compile. That is the+-- test. "Deny" covers the names that 'Papa' must not export at all.+module Totals (+  totals,+  readFileOfPath,+  writeFileOfPath,+  appendFileOfPath,+  getContentsOfStdin,+  getLineOfStdin,+  interactOfStdin,+  putStrOfText,+  putStrLnOfText,+  printOfInt,+  hGetContentsOfHandle,+  hGetLineOfHandle,+  hPutStrOfHandle,+  hPutStrLnOfHandle,+  hPrintOfHandle,+  openFileOfPath,+  withFileOfPath,+  hCloseOfHandle,+  hFlushOfHandle,+  hIsEOFOfHandle,+  hSetBufferingOfHandle,+  exitWithOfCode,+  doesFileExistOfPath,+  listDirectoryOfPath,+  createDirectoryOfPath,+  removeFileOfPath,+  copyFileOfPaths,+  getCurrentDirectoryOfProcess,+  getTemporaryDirectoryOfProcess,+  withCurrentDirectoryOfPath,+  getSearchPathOfProcess,+  waitExceptOfAsync,+  waitAnyCatchOfNonEmpty,+  waitAnyCatchCancelOfNonEmpty,+  readIOOfText,+  dieOfText,+) where++import Papa++-- | One use of each reused name at its total type.+totals :: [String]+totals =+  [ show (headOfNonEmpty (1 :| [2]))+  , show (lastOfNonEmpty (1 :| [2]))+  , show (initOfNonEmpty (1 :| [2]))+  , show (tailOfNonEmpty (1 :| [2]))+  , show (indexOfList [1, 2] 5)+  , show (maximumOfNonEmpty (1 :| [2]))+  , show (minimumOfNonEmpty (1 :| [2]))+  , show (maximumByOfNonEmpty compare (1 :| [2]))+  , show (minimumByOfNonEmpty compare (1 :| [2]))+  , show (cycleOfList [])+  , show (chrOfInt (-1))+  , show (succOfInt maxBound)+  , show (predOfInt minBound)+  , show (stimesOfList (-1) [1])+  , show (cycleOfList [1])+  , show (lookupOfList 1 [(1, 'a')])+  , show (iterateOfInt (+ 1) 0 ^? ix 3)+  , show (repeatOfInt 1 ^? ix 3)+  , show (linesOfText (pack "a\nb"))+  , show (wordsOfText (pack "a b"))+  , show (readMaybeOfText (pack "1"))+  , show (readEitherOfText (pack "1"))+  ]++headOfNonEmpty :: NonEmpty Int -> Int+headOfNonEmpty =+  the head++lastOfNonEmpty :: NonEmpty Int -> Int+lastOfNonEmpty =+  the last++initOfNonEmpty :: NonEmpty Int -> [Int]+initOfNonEmpty =+  the init++tailOfNonEmpty :: NonEmpty Int -> [Int]+tailOfNonEmpty =+  the tail++indexOfList :: [Int] -> Int -> Maybe Int+indexOfList =+  (!!)++maximumOfNonEmpty :: NonEmpty Int -> Int+maximumOfNonEmpty =+  maximum++minimumOfNonEmpty :: NonEmpty Int -> Int+minimumOfNonEmpty =+  minimum++maximumByOfNonEmpty :: (Int -> Int -> Ordering) -> NonEmpty Int -> Int+maximumByOfNonEmpty =+  maximumBy++minimumByOfNonEmpty :: (Int -> Int -> Ordering) -> NonEmpty Int -> Int+minimumByOfNonEmpty =+  minimumBy++cycleOfList :: [Int] -> Maybe [Int]+cycleOfList =+  fmap (take 3) . cycle++chrOfInt :: Int -> Maybe Char+chrOfInt =+  chr++succOfInt :: Int -> Maybe Int+succOfInt =+  succ++predOfInt :: Int -> Maybe Int+predOfInt =+  pred++stimesOfList :: Int -> [Int] -> Maybe [Int]+stimesOfList =+  stimes++lookupOfList :: Int -> [(Int, Char)] -> Maybe Char+lookupOfList =+  lookup++iterateOfInt :: (Int -> Int) -> Int -> NonEmpty Int+iterateOfInt =+  iterate++repeatOfInt :: Int -> NonEmpty Int+repeatOfInt =+  repeat++linesOfText :: Text -> [Text]+linesOfText =+  lines++wordsOfText :: Text -> [Text]+wordsOfText =+  words++-- I/O: strict, UTF-8, and returning its errors.++readFileOfPath :: FilePath -> IOExcept Text+readFileOfPath =+  readFile++writeFileOfPath :: FilePath -> Text -> IOExcept ()+writeFileOfPath =+  writeFile++appendFileOfPath :: FilePath -> Text -> IOExcept ()+appendFileOfPath =+  appendFile++getContentsOfStdin :: IOExcept Text+getContentsOfStdin =+  getContents++getLineOfStdin :: IOExcept Text+getLineOfStdin =+  getLine++interactOfStdin :: (Text -> Text) -> IOExcept ()+interactOfStdin =+  interact++putStrOfText :: Text -> IOExcept ()+putStrOfText =+  putStr++putStrLnOfText :: Text -> IOExcept ()+putStrLnOfText =+  putStrLn++printOfInt :: Int -> IOExcept ()+printOfInt =+  print++hGetContentsOfHandle :: Handle -> IOExcept Text+hGetContentsOfHandle =+  hGetContents++hGetLineOfHandle :: Handle -> IOExcept Text+hGetLineOfHandle =+  hGetLine++hPutStrOfHandle :: Handle -> Text -> IOExcept ()+hPutStrOfHandle =+  hPutStr++hPutStrLnOfHandle :: Handle -> Text -> IOExcept ()+hPutStrLnOfHandle =+  hPutStrLn++hPrintOfHandle :: Handle -> Int -> IOExcept ()+hPrintOfHandle =+  hPrint++openFileOfPath :: FilePath -> IOMode -> IOExcept Handle+openFileOfPath =+  openFile++withFileOfPath :: FilePath -> IOMode -> (Handle -> IOExcept Text) -> IOExcept Text+withFileOfPath =+  withFile++hCloseOfHandle :: Handle -> IOExcept ()+hCloseOfHandle =+  hClose++hFlushOfHandle :: Handle -> IOExcept ()+hFlushOfHandle =+  hFlush++hIsEOFOfHandle :: Handle -> IOExcept Bool+hIsEOFOfHandle =+  hIsEOF++hSetBufferingOfHandle :: Handle -> BufferMode -> IOExcept ()+hSetBufferingOfHandle =+  hSetBuffering++exitWithOfCode :: ExitCode -> Maybe (IO ())+exitWithOfCode =+  exitWith++-- Files, directories and threads: failures as values, and non-empty lists.++doesFileExistOfPath :: FilePath -> IOExcept Bool+doesFileExistOfPath =+  doesFileExist++listDirectoryOfPath :: FilePath -> IOExcept [FilePath]+listDirectoryOfPath =+  listDirectory++createDirectoryOfPath :: FilePath -> IOExcept ()+createDirectoryOfPath =+  createDirectory++removeFileOfPath :: FilePath -> IOExcept ()+removeFileOfPath =+  removeFile++copyFileOfPaths :: FilePath -> FilePath -> IOExcept ()+copyFileOfPaths =+  copyFile++getCurrentDirectoryOfProcess :: IOExcept FilePath+getCurrentDirectoryOfProcess =+  getCurrentDirectory++getTemporaryDirectoryOfProcess :: IOExcept FilePath+getTemporaryDirectoryOfProcess =+  getTemporaryDirectory++withCurrentDirectoryOfPath :: FilePath -> IOExcept Text -> IOExcept Text+withCurrentDirectoryOfPath =+  withCurrentDirectory++getSearchPathOfProcess :: IOExcept [FilePath]+getSearchPathOfProcess =+  getSearchPath++waitExceptOfAsync :: Async Int -> ExceptT SomeException IO Int+waitExceptOfAsync =+  waitExcept++waitAnyCatchOfNonEmpty :: NonEmpty (Async Int) -> IO (Async Int, Either SomeException Int)+waitAnyCatchOfNonEmpty =+  waitAnyCatch++waitAnyCatchCancelOfNonEmpty :: NonEmpty (Async Int) -> IO (Async Int, Either SomeException Int)+waitAnyCatchCancelOfNonEmpty =+  waitAnyCatchCancel++readMaybeOfText :: Text -> Maybe Int+readMaybeOfText =+  readMaybe++readEitherOfText :: Text -> Either Text Int+readEitherOfText =+  readEither++readIOOfText :: Text -> IO (Maybe Int)+readIOOfText =+  readIO++dieOfText :: Text -> IO ()+dieOfText =+  die