-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Sized sequence data-types -- -- A wrapper to make length-parametrized data-type from functorial -- data-types. @package sized @version 1.0.0.2 module Data.Sized.Flipped -- | Wrapper for Sized which takes length as its last -- element, instead of the second. -- -- Since 0.2.0.0 newtype Flipped f a n Flipped :: Sized f n a -> Flipped f a n [runFlipped] :: Flipped f a n -> Sized f n a instance Data.MonoTraversable.MonoFunctor (f a) => Data.MonoTraversable.MonoFunctor (Data.Sized.Flipped.Flipped f a n) instance Data.MonoTraversable.MonoFoldable (f a) => Data.MonoTraversable.MonoFoldable (Data.Sized.Flipped.Flipped f a n) instance (Data.Sized.Flipped.Flipped f1 a1 n1 GHC.Types.~ t) => Control.Lens.Wrapped.Rewrapped (Data.Sized.Flipped.Flipped f2 a2 n2) t instance Control.Lens.Wrapped.Wrapped (Data.Sized.Flipped.Flipped f a n) instance Data.MonoTraversable.MonoTraversable (f a) => Data.MonoTraversable.MonoTraversable (Data.Sized.Flipped.Flipped f a n) instance (GHC.Real.Integral (Control.Lens.At.Index (f a)), Control.Lens.At.Ixed (f a)) => Control.Lens.At.Ixed (Data.Sized.Flipped.Flipped f a n) instance Data.Hashable.Class.Hashable (f a) => Data.Hashable.Class.Hashable (Data.Sized.Flipped.Flipped f a n) instance Control.DeepSeq.NFData (f a) => Control.DeepSeq.NFData (Data.Sized.Flipped.Flipped f a n) instance GHC.Classes.Ord (f a) => GHC.Classes.Ord (Data.Sized.Flipped.Flipped f a n) instance GHC.Classes.Eq (f a) => GHC.Classes.Eq (Data.Sized.Flipped.Flipped f a n) instance GHC.Show.Show (f a) => GHC.Show.Show (Data.Sized.Flipped.Flipped f a n) -- | This module provides the functionality to make length-parametrized -- types from existing CFreeMonoid sequential types. -- -- Most of the complexity of operations for Sized f n a are the -- same as original operations for f. For example, !! is -- O(1) for Sized Vector n a but O(i) for Sized [] n a. -- -- This module also provides powerful view types and pattern synonyms to -- inspect the sized sequence. See Views and Patterns for more -- detail. module Data.Sized -- | Sized wraps a sequential type f and makes -- length-parametrized version. -- -- Here, f must be the instance of CFreeMonoid (f a) -- a for all a@. -- -- Since 0.2.0.0 data Sized (f :: Type -> Type) (n :: Nat) a -- | Sized vector with the length is existentially quantified. This -- type is used mostly when the return type's length cannot be statically -- determined beforehand. -- -- SomeSized sn xs :: SomeSized f a stands for the Sized -- sequence xs of element type a and length -- sn. -- -- Since 0.7.0.0 data SomeSized f a [SomeSized] :: SNat n -> Sized f n a -> SomeSized f a class Dom f a => DomC f a -- | Returns the length of wrapped containers. If you use -- unsafeFromList or similar unsafe functions, this function may -- return different value from type-parameterized length. -- -- Since 0.8.0.0 (type changed) length :: forall f (n :: Nat) a. (Dom f a, KnownNat n) => Sized f n a -> Int -- | SNat version of length. -- -- Since 0.8.0.0 (type changed) sLength :: forall f (n :: Nat) a. (Dom f a, KnownNat n) => Sized f n a -> SNat n -- | Test if the sequence is empty or not. -- -- Since 0.7.0.0 null :: forall f (n :: Nat) a. (CFoldable f, Dom f a) => Sized f n a -> Bool -- | (Unsafe) indexing with Ints. If you want to check boundary -- statically, use %!! or sIndex. -- -- Since 0.7.0.0 (!!) :: forall f (m :: Nat) a. (CFoldable f, Dom f a, 1 <= m) => Sized f m a -> Int -> a -- | Safe indexing with Ordinals. -- -- Since 0.7.0.0 (%!!) :: forall f (n :: Nat) c. (CFoldable f, Dom f c) => Sized f n c -> Ordinal n -> c -- | Flipped version of !!. -- -- Since 0.7.0.0 index :: forall f (m :: Nat) a. (CFoldable f, Dom f a, 1 <= m) => Int -> Sized f m a -> a -- | Flipped version of %!!. -- -- Since 0.7.0.0 sIndex :: forall f (n :: Nat) c. (CFoldable f, Dom f c) => Ordinal n -> Sized f n c -> c -- | Take the first element of non-empty sequence. If you want to make -- case-analysis for general sequence, see Views and Patterns -- section. -- -- Since 0.7.0.0 head :: forall f (n :: Nat) a. (CFoldable f, Dom f a, 0 < n) => Sized f n a -> a -- | Take the last element of non-empty sequence. If you want to make -- case-analysis for general sequence, see Views and Patterns -- section. -- -- Since 0.7.0.0 last :: forall f (n :: Nat) a. (0 < n, CFoldable f, Dom f a) => Sized f n a -> a -- | Take the head and tail of non-empty sequence. If you -- want to make case-analysis for general sequence, see Views and -- Patterns section. -- -- Since 0.7.0.0 uncons :: forall f (n :: Nat) a. (KnownNat n, CFreeMonoid f, Dom f a, 1 <= n) => Sized f n a -> Uncons f n a -- | uncons with explicit specified length n -- -- Since 0.7.0.0 uncons' :: forall f (n :: Nat) a proxy. (KnownNat n, CFreeMonoid f, Dom f a) => proxy n -> Sized f (Succ n) a -> Uncons f (Succ n) a data Uncons f (n :: Nat) a [Uncons] :: forall f (n :: Nat) a. KnownNat n => a -> Sized f n a -> Uncons f (1 + n) a -- | Take the init and last of non-empty sequence. If you -- want to make case-analysis for general sequence, see Views and -- Patterns section. -- -- Since 0.7.0.0 unsnoc :: forall f (n :: Nat) a. (KnownNat n, CFreeMonoid f, Dom f a, 0 < n) => Sized f n a -> Unsnoc f n a -- | unsnoc' with explicit specified length n -- -- Since 0.7.0.0 unsnoc' :: forall f (n :: Nat) a proxy. (KnownNat n, CFreeMonoid f, Dom f a) => proxy n -> Sized f (Succ n) a -> Unsnoc f (Succ n) a data Unsnoc f n a [Unsnoc] :: forall f n a. Sized f (n :: Nat) a -> a -> Unsnoc f (Succ n) a -- | Take the tail of non-empty sequence. If you want to make case-analysis -- for general sequence, see Views and Patterns section. -- -- Since 0.7.0.0 tail :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => Sized f (1 + n) a -> Sized f n a -- | Take the initial segment of non-empty sequence. If you want to make -- case-analysis for general sequence, see Views and Patterns -- section. -- -- Since 0.7.0.0 init :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => Sized f (n + 1) a -> Sized f n a -- | take k xs takes first k element of xs where -- the length of xs should be larger than k. -- -- Since 0.7.0.0 take :: forall (n :: Nat) f (m :: Nat) a. (CFreeMonoid f, Dom f a, n <= m) => SNat n -> Sized f m a -> Sized f n a -- | takeAtMost k xs takes first at most k -- elements of xs. -- -- Since 0.7.0.0 takeAtMost :: forall (n :: Nat) f m a. (CFreeMonoid f, Dom f a) => SNat n -> Sized f m a -> Sized f (Min n m) a -- | drop k xs drops first k element of xs and -- returns the rest of sequence, where the length of xs should -- be larger than k. -- -- Since 0.7.0.0 drop :: forall (n :: Nat) f (m :: Nat) a. (CFreeMonoid f, Dom f a, n <= m) => SNat n -> Sized f m a -> Sized f (m - n) a -- | splitAt k xs split xs at k, where the -- length of xs should be less than or equal to k. -- -- Since 0.7.0.0 splitAt :: forall (n :: Nat) f m a. (CFreeMonoid f, Dom f a, n <= m) => SNat n -> Sized f m a -> (Sized f n a, Sized f (m -. n) a) -- | splitAtMost k xs split xs at k. If -- k exceeds the length of xs, then the second result -- value become empty. -- -- Since 0.7.0.0 splitAtMost :: forall (n :: Nat) f (m :: Nat) a. (CFreeMonoid f, Dom f a) => SNat n -> Sized f m a -> (Sized f (Min n m) a, Sized f (m -. n) a) -- | Empty sequence. -- -- Since 0.7.0.0 (type changed) empty :: forall f a. (Monoid (f a), Dom f a) => Sized f 0 a -- | Sequence with one element. -- -- Since 0.7.0.0 singleton :: forall f a. (CPointed f, Dom f a) => a -> Sized f 1 a -- | Consruct the Sized sequence from base type, but the length -- parameter is dynamically determined and existentially quantified; see -- also SomeSized. -- -- Since 0.7.0.0 toSomeSized :: forall f a. (Dom f a, CFoldable f) => f a -> SomeSized f a -- | Replicates the same value. -- -- Since 0.7.0.0 replicate :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => SNat n -> a -> Sized f n a -- | replicate with the length inferred. -- -- Since 0.7.0.0 replicate' :: forall f (n :: Nat) a. (KnownNat (n :: Nat), CFreeMonoid f, Dom f a) => a -> Sized f n a -- | Construct a sequence of the given length by applying the function to -- each index. -- -- Since 0.7.0.0 generate :: forall f (n :: Nat) (a :: Type). (CFreeMonoid f, Dom f a) => SNat n -> (Ordinal n -> a) -> Sized f n a -- | generate with length inferred. -- -- Since 0.8.0.0 generate' :: forall f (n :: Nat) (a :: Type). (KnownNat n, CFreeMonoid f, Dom f a) => (Ordinal n -> a) -> Sized f n a -- | Append an element to the head of sequence. -- -- Since 0.8.0.0 cons :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => a -> Sized f n a -> Sized f (1 + n) a -- | Infix version of cons. -- -- Since 0.8.0.0 (<|) :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => a -> Sized f n a -> Sized f (1 + n) a infixr 5 <| -- | Append an element to the tail of sequence. -- -- Since 0.7.0.0 snoc :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => Sized f n a -> a -> Sized f (n + 1) a -- | Infix version of snoc. -- -- Since 0.7.0.0 (|>) :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => Sized f n a -> a -> Sized f (n + 1) a infixl 5 |> -- | Append two lists. -- -- Since 0.7.0.0 append :: forall f (n :: Nat) (m :: Nat) a. (CFreeMonoid f, Dom f a) => Sized f n a -> Sized f m a -> Sized f (n + m) a -- | Infix version of append. -- -- Since 0.7.0.0 (++) :: forall f (n :: Nat) (m :: Nat) a. (CFreeMonoid f, Dom f a) => Sized f n a -> Sized f m a -> Sized f (n + m) a infixr 5 ++ -- | Concatenates multiple sequences into one. -- -- Since 0.7.0.0 concat :: forall f' (m :: Nat) f (n :: Nat) a. (CFreeMonoid f, CFunctor f', CFoldable f', Dom f a, Dom f' (f a), Dom f' (Sized f n a)) => Sized f' m (Sized f n a) -> Sized f (m * n) a -- | Zipping two sequences. Length is adjusted to shorter one. -- -- Since 0.7.0.0 zip :: forall f (n :: Nat) a (m :: Nat) b. (Dom f a, CZip f, Dom f b, Dom f (a, b)) => Sized f n a -> Sized f m b -> Sized f (Min n m) (a, b) -- | zip for the sequences of the same length. -- -- Since 0.7.0.0 zipSame :: forall f (n :: Nat) a b. (Dom f a, CZip f, Dom f b, Dom f (a, b)) => Sized f n a -> Sized f n b -> Sized f n (a, b) -- | Zipping two sequences with funtion. Length is adjusted to shorter one. -- -- Since 0.7.0.0 zipWith :: forall f (n :: Nat) a (m :: Nat) b c. (Dom f a, CZip f, Dom f b, CFreeMonoid f, Dom f c) => (a -> b -> c) -> Sized f n a -> Sized f m b -> Sized f (Min n m) c -- | zipWith for the sequences of the same length. -- -- Since 0.7.0.0 zipWithSame :: forall f (n :: Nat) a b c. (Dom f a, CZip f, Dom f b, CFreeMonoid f, Dom f c) => (a -> b -> c) -> Sized f n a -> Sized f n b -> Sized f n c -- | Unzipping the sequence of tuples. -- -- Since 0.7.0.0 unzip :: forall f (n :: Nat) a b. (CUnzip f, Dom f a, Dom f b, Dom f (a, b)) => Sized f n (a, b) -> (Sized f n a, Sized f n b) -- | Unzipping the sequence of tuples. -- -- Since 0.7.0.0 unzipWith :: forall f (n :: Nat) a b c. (CUnzip f, Dom f a, Dom f b, Dom f c) => (a -> (b, c)) -> Sized f n a -> (Sized f n b, Sized f n c) -- | Map function. -- -- Since 0.7.0.0 map :: forall f (n :: Nat) a b. (CFreeMonoid f, Dom f a, Dom f b) => (a -> b) -> Sized f n a -> Sized f n b -- | Reverse function. -- -- Since 0.7.0.0 reverse :: forall f (n :: Nat) a. (Dom f a, CFreeMonoid f) => Sized f n a -> Sized f n a -- | Intersperces. -- -- Since 0.7.0.0 intersperse :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => a -> Sized f n a -> Sized f ((2 * n) -. 1) a -- | Remove all duplicates. -- -- Since 0.7.0.0 nub :: forall f (n :: Nat) a. (Dom f a, Eq a, CFreeMonoid f) => Sized f n a -> SomeSized f a -- | Sorting sequence by ascending order. -- -- Since 0.7.0.0 sort :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a, Ord a) => Sized f n a -> Sized f n a -- | Generalized version of sort. -- -- Since 0.7.0.0 sortBy :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => (a -> a -> Ordering) -> Sized f n a -> Sized f n a -- | Insert new element into the presorted sequence. -- -- Since 0.7.0.0 insert :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a, Ord a) => a -> Sized f n a -> Sized f (Succ n) a -- | Generalized version of insert. -- -- Since 0.7.0.0 insertBy :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => (a -> a -> Ordering) -> a -> Sized f n a -> Sized f (Succ n) a -- | Convert to list. -- -- Since 0.7.0.0 toList :: forall f (n :: Nat) a. (CFoldable f, Dom f a) => Sized f n a -> [a] -- | If the given list is shorter than n, then returns -- Nothing Otherwise returns Sized f n a consisting of -- initial n element of given list. -- -- Since 0.7.0.0 (type changed) fromList :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => SNat n -> [a] -> Maybe (Sized f n a) -- | fromList with the result length inferred. -- -- Since 0.7.0.0 fromList' :: forall f (n :: Nat) a. (Dom f a, CFreeMonoid f, KnownNat n) => [a] -> Maybe (Sized f n a) -- | Unsafe version of fromList. If the length of the given list -- does not equal to n, then something unusual happens. -- -- Since 0.7.0.0 unsafeFromList :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => SNat n -> [a] -> Sized f n a -- | unsafeFromList with the result length inferred. -- -- Since 0.7.0.0 unsafeFromList' :: forall f (n :: Nat) a. (KnownNat n, CFreeMonoid f, Dom f a) => [a] -> Sized f n a -- | Construct a Sized f n a by padding default value if the given -- list is short. -- -- Since 0.5.0.0 (type changed) fromListWithDefault :: forall f (n :: Nat) a. (Dom f a, CFreeMonoid f) => SNat n -> a -> [a] -> Sized f n a -- | fromListWithDefault with the result length inferred. -- -- Since 0.7.0.0 fromListWithDefault' :: forall f (n :: Nat) a. (KnownNat n, CFreeMonoid f, Dom f a) => a -> [a] -> Sized f n a -- | Forget the length and obtain the wrapped base container. -- -- Since 0.7.0.0 unsized :: forall f (n :: Nat) a. Sized f n a -> f a -- | If the length of the input is shorter than n, then returns -- Nothing. Otherwise returns Sized f n a consisting of -- initial n element of the input. -- -- Since 0.7.0.0 toSized :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => SNat (n :: Nat) -> f a -> Maybe (Sized f n a) -- | toSized with the result length inferred. -- -- Since 0.7.0.0 toSized' :: forall f (n :: Nat) a. (Dom f a, CFreeMonoid f, KnownNat n) => f a -> Maybe (Sized f n a) -- | Unsafe version of toSized. If the length of the given list does -- not equal to n, then something unusual happens. -- -- Since 0.7.0.0 unsafeToSized :: forall f (n :: Nat) a. SNat n -> f a -> Sized f n a -- | unsafeToSized with the result length inferred. -- -- Since 0.7.0.0 unsafeToSized' :: forall f (n :: Nat) a. (KnownNat n, Dom f a) => f a -> Sized f n a -- | Construct a Sized f n a by padding default value if the given -- list is short. -- -- Since 0.7.0.0 toSizedWithDefault :: forall f (n :: Nat) a. (CFreeMonoid f, Dom f a) => SNat (n :: Nat) -> a -> f a -> Sized f n a -- | toSizedWithDefault with the result length inferred. -- -- Since 0.7.0.0 toSizedWithDefault' :: forall f (n :: Nat) a. (KnownNat n, CFreeMonoid f, Dom f a) => a -> f a -> Sized f n a -- | The type Partitioned f n a represents partitioned sequence of -- length n. Value Partitioned lenL ls lenR rs stands -- for: -- --
lenL + lenR = n